src/share/vm/prims/jvmtiEnvThreadState.hpp

Fri, 22 Oct 2010 15:59:34 -0400

author
acorn
date
Fri, 22 Oct 2010 15:59:34 -0400
changeset 2233
fa83ab460c54
parent 2036
126ea7725993
child 2314
f95d63e2154a
permissions
-rw-r--r--

6988353: refactor contended sync subsystem
Summary: reduce complexity by factoring synchronizer.cpp
Reviewed-by: dholmes, never, coleenp

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

mercurial