Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/prims/jvmtiEnvThreadState.hpp
32285 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP25#define SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP2627#include "jvmtifiles/jvmti.h"28#include "memory/allocation.hpp"29#include "memory/allocation.inline.hpp"30#include "oops/instanceKlass.hpp"31#include "prims/jvmtiEventController.hpp"32#include "utilities/globalDefinitions.hpp"33#include "utilities/growableArray.hpp"3435class JvmtiEnv;3637///////////////////////////////////////////////////////////////38//39// class JvmtiFramePop40// Used by : JvmtiFramePops41// Used by JVMTI methods: none directly.42//43// Wrapper class for FramePop, used in the JvmtiFramePops class.44//45// Two problems: 1) this isn't being used as a ValueObj class, in46// several places there are constructors for it. 2) It seems like47// overkill as a means to get an assert and name the geater than48// operator. I'm trying to to rewrite everything.4950class JvmtiFramePop VALUE_OBJ_CLASS_SPEC {51private:52// Frame number counting from BOTTOM (oldest) frame;53// bottom frame == #054int _frame_number;55public:56JvmtiFramePop() {}57JvmtiFramePop(int frame_number) {58assert(frame_number >= 0, "invalid frame number");59_frame_number = frame_number;60}6162int frame_number() { return _frame_number; }63int above_on_stack(JvmtiFramePop& other) { return _frame_number > other._frame_number; }64void print() PRODUCT_RETURN;65};666768///////////////////////////////////////////////////////////////69//70// class JvmtiFramePops71// Used by : JvmtiThreadState72// Used by JVMTI methods: none directly.73//74// A collection of JvmtiFramePop.75// It records what frames on a threads stack should post frame_pop events when they're exited.76//7778class JvmtiFramePops : public CHeapObj<mtInternal> {79private:80GrowableArray<int>* _pops;8182// should only be used by JvmtiEventControllerPrivate83// to insure they only occur at safepoints.84// Todo: add checks for safepoint85friend class JvmtiEventControllerPrivate;86void set(JvmtiFramePop& fp);87void clear(JvmtiFramePop& fp);88int clear_to(JvmtiFramePop& fp);8990public:91JvmtiFramePops();92~JvmtiFramePops();9394bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }95int length() { return _pops->length(); }96void print() PRODUCT_RETURN;97};9899100///////////////////////////////////////////////////////////////101//102// class JvmtiEnvThreadState103//104// 2. Cache of pending frame_pop_events, created by NotifyFramePop105// and lazily initialized.106// 3: Location of last executed instruction, used to filter out duplicate107// events due to instruction rewriting.108109class JvmtiEnvThreadState : public CHeapObj<mtInternal> {110private:111friend class JvmtiEnv;112JavaThread *_thread;113JvmtiEnv *_env;114JvmtiEnvThreadState *_next;115jmethodID _current_method_id;116int _current_bci;117bool _breakpoint_posted;118bool _single_stepping_posted;119JvmtiEnvThreadEventEnable _event_enable;120void *_agent_thread_local_storage_data; // per env and per thread agent allocated data.121122// Class used to store pending framepops.123// lazily initialized by get_frame_pops();124JvmtiFramePops *_frame_pops;125126inline void set_current_location(jmethodID method_id, int bci) {127_current_method_id = method_id;128_current_bci = bci;129}130131friend class JvmtiEnvThreadStateIterator;132JvmtiEnvThreadState* next() { return _next; }133134friend class JvmtiThreadState;135void set_next(JvmtiEnvThreadState* link) { _next = link; }136137public:138JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);139~JvmtiEnvThreadState();140141bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }142143JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }144void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }145void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }146147148// If the thread is in the given method at the given149// location just return. Otherwise, reset the current location150// and reset _breakpoint_posted and _single_stepping_posted.151// _breakpoint_posted and _single_stepping_posted are only cleared152// here.153void compare_and_set_current_location(Method* method, address location, jvmtiEvent event);154155void clear_current_location() { set_current_location((jmethodID)NULL, 0); }156157void reset_current_location(jvmtiEvent event, bool enabled);158159inline void set_breakpoint_posted() { _breakpoint_posted = true; }160inline void set_single_stepping_posted() {161_single_stepping_posted = true;162}163inline bool breakpoint_posted() { return _breakpoint_posted; }164inline bool single_stepping_posted() {165return _single_stepping_posted;166}167168inline JavaThread *get_thread() { return _thread; }169inline JvmtiEnv *get_env() { return _env; }170171// lazily initialize _frame_pops172JvmtiFramePops* get_frame_pops();173174bool has_frame_pops();175176// quickly test whether we should deliver a frame pop event on return from sp177bool is_frame_pop(int cur_stack_depth);178179void set_frame_pop(int frame_number);180void clear_frame_pop(int frame_number);181void clear_to_frame_pop(int frame_number);182183};184185#endif // SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP186187188