src/share/vm/prims/jvmtiEnvThreadState.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 4037
da91efe96a93
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP
aoqi@0 26 #define SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP
aoqi@0 27
aoqi@0 28 #include "jvmtifiles/jvmti.h"
aoqi@0 29 #include "memory/allocation.hpp"
aoqi@0 30 #include "memory/allocation.inline.hpp"
aoqi@0 31 #include "oops/instanceKlass.hpp"
aoqi@0 32 #include "prims/jvmtiEventController.hpp"
aoqi@0 33 #include "utilities/globalDefinitions.hpp"
aoqi@0 34 #include "utilities/growableArray.hpp"
aoqi@0 35
aoqi@0 36 class JvmtiEnv;
aoqi@0 37
aoqi@0 38 ///////////////////////////////////////////////////////////////
aoqi@0 39 //
aoqi@0 40 // class JvmtiFramePop
aoqi@0 41 // Used by : JvmtiFramePops
aoqi@0 42 // Used by JVMTI methods: none directly.
aoqi@0 43 //
aoqi@0 44 // Wrapper class for FramePop, used in the JvmtiFramePops class.
aoqi@0 45 //
aoqi@0 46 // Two problems: 1) this isn't being used as a ValueObj class, in
aoqi@0 47 // several places there are constructors for it. 2) It seems like
aoqi@0 48 // overkill as a means to get an assert and name the geater than
aoqi@0 49 // operator. I'm trying to to rewrite everything.
aoqi@0 50
aoqi@0 51 class JvmtiFramePop VALUE_OBJ_CLASS_SPEC {
aoqi@0 52 private:
aoqi@0 53 // Frame number counting from BOTTOM (oldest) frame;
aoqi@0 54 // bottom frame == #0
aoqi@0 55 int _frame_number;
aoqi@0 56 public:
aoqi@0 57 JvmtiFramePop() {}
aoqi@0 58 JvmtiFramePop(int frame_number) {
aoqi@0 59 assert(frame_number >= 0, "invalid frame number");
aoqi@0 60 _frame_number = frame_number;
aoqi@0 61 }
aoqi@0 62
aoqi@0 63 int frame_number() { return _frame_number; }
aoqi@0 64 int above_on_stack(JvmtiFramePop& other) { return _frame_number > other._frame_number; }
aoqi@0 65 void print() PRODUCT_RETURN;
aoqi@0 66 };
aoqi@0 67
aoqi@0 68
aoqi@0 69 ///////////////////////////////////////////////////////////////
aoqi@0 70 //
aoqi@0 71 // class JvmtiFramePops
aoqi@0 72 // Used by : JvmtiThreadState
aoqi@0 73 // Used by JVMTI methods: none directly.
aoqi@0 74 //
aoqi@0 75 // A collection of JvmtiFramePop.
aoqi@0 76 // It records what frames on a threads stack should post frame_pop events when they're exited.
aoqi@0 77 //
aoqi@0 78
aoqi@0 79 class JvmtiFramePops : public CHeapObj<mtInternal> {
aoqi@0 80 private:
aoqi@0 81 GrowableArray<int>* _pops;
aoqi@0 82
aoqi@0 83 // should only be used by JvmtiEventControllerPrivate
aoqi@0 84 // to insure they only occur at safepoints.
aoqi@0 85 // Todo: add checks for safepoint
aoqi@0 86 friend class JvmtiEventControllerPrivate;
aoqi@0 87 void set(JvmtiFramePop& fp);
aoqi@0 88 void clear(JvmtiFramePop& fp);
aoqi@0 89 int clear_to(JvmtiFramePop& fp);
aoqi@0 90
aoqi@0 91 public:
aoqi@0 92 JvmtiFramePops();
aoqi@0 93 ~JvmtiFramePops();
aoqi@0 94
aoqi@0 95 bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
aoqi@0 96 int length() { return _pops->length(); }
aoqi@0 97 void print() PRODUCT_RETURN;
aoqi@0 98 };
aoqi@0 99
aoqi@0 100
aoqi@0 101 ///////////////////////////////////////////////////////////////
aoqi@0 102 //
aoqi@0 103 // class JvmtiEnvThreadState
aoqi@0 104 //
aoqi@0 105 // 2. Cache of pending frame_pop_events, created by NotifyFramePop
aoqi@0 106 // and lazily initialized.
aoqi@0 107 // 3: Location of last executed instruction, used to filter out duplicate
aoqi@0 108 // events due to instruction rewriting.
aoqi@0 109
aoqi@0 110 class JvmtiEnvThreadState : public CHeapObj<mtInternal> {
aoqi@0 111 private:
aoqi@0 112 friend class JvmtiEnv;
aoqi@0 113 JavaThread *_thread;
aoqi@0 114 JvmtiEnv *_env;
aoqi@0 115 JvmtiEnvThreadState *_next;
aoqi@0 116 jmethodID _current_method_id;
aoqi@0 117 int _current_bci;
aoqi@0 118 bool _breakpoint_posted;
aoqi@0 119 bool _single_stepping_posted;
aoqi@0 120 JvmtiEnvThreadEventEnable _event_enable;
aoqi@0 121 void *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
aoqi@0 122
aoqi@0 123 // Class used to store pending framepops.
aoqi@0 124 // lazily initialized by get_frame_pops();
aoqi@0 125 JvmtiFramePops *_frame_pops;
aoqi@0 126
aoqi@0 127 inline void set_current_location(jmethodID method_id, int bci) {
aoqi@0 128 _current_method_id = method_id;
aoqi@0 129 _current_bci = bci;
aoqi@0 130 }
aoqi@0 131
aoqi@0 132 friend class JvmtiEnvThreadStateIterator;
aoqi@0 133 JvmtiEnvThreadState* next() { return _next; }
aoqi@0 134
aoqi@0 135 friend class JvmtiThreadState;
aoqi@0 136 void set_next(JvmtiEnvThreadState* link) { _next = link; }
aoqi@0 137
aoqi@0 138 public:
aoqi@0 139 JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);
aoqi@0 140 ~JvmtiEnvThreadState();
aoqi@0 141
aoqi@0 142 bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
aoqi@0 143
aoqi@0 144 JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }
aoqi@0 145 void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }
aoqi@0 146 void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }
aoqi@0 147
aoqi@0 148
aoqi@0 149 // If the thread is in the given method at the given
aoqi@0 150 // location just return. Otherwise, reset the current location
aoqi@0 151 // and reset _breakpoint_posted and _single_stepping_posted.
aoqi@0 152 // _breakpoint_posted and _single_stepping_posted are only cleared
aoqi@0 153 // here.
aoqi@0 154 void compare_and_set_current_location(Method* method, address location, jvmtiEvent event);
aoqi@0 155
aoqi@0 156 void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
aoqi@0 157
aoqi@0 158 void reset_current_location(jvmtiEvent event, bool enabled);
aoqi@0 159
aoqi@0 160 inline void set_breakpoint_posted() { _breakpoint_posted = true; }
aoqi@0 161 inline void set_single_stepping_posted() {
aoqi@0 162 _single_stepping_posted = true;
aoqi@0 163 }
aoqi@0 164 inline bool breakpoint_posted() { return _breakpoint_posted; }
aoqi@0 165 inline bool single_stepping_posted() {
aoqi@0 166 return _single_stepping_posted;
aoqi@0 167 }
aoqi@0 168
aoqi@0 169 inline JavaThread *get_thread() { return _thread; }
aoqi@0 170 inline JvmtiEnv *get_env() { return _env; }
aoqi@0 171
aoqi@0 172 // lazily initialize _frame_pops
aoqi@0 173 JvmtiFramePops* get_frame_pops();
aoqi@0 174
aoqi@0 175 bool has_frame_pops();
aoqi@0 176
aoqi@0 177 // quickly test whether we should deliver a frame pop event on return from sp
aoqi@0 178 bool is_frame_pop(int cur_stack_depth);
aoqi@0 179
aoqi@0 180 void set_frame_pop(int frame_number);
aoqi@0 181 void clear_frame_pop(int frame_number);
aoqi@0 182 void clear_to_frame_pop(int frame_number);
aoqi@0 183
aoqi@0 184 };
aoqi@0 185
aoqi@0 186 #endif // SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP

mercurial