annotate src/share/vm/prims/jvmtiEnvThreadState.hpp @ 12355:cefad50507d8

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