Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiImpl.cpp @ 1878:fa83ab460c54
6988353: refactor contended sync subsystem
Summary: reduce complexity by factoring synchronizer.cpp
Reviewed-by: dholmes, never, coleenp
author | acorn |
---|---|
date | Fri, 22 Oct 2010 15:59:34 -0400 |
parents | c18cbe5936b8 |
children | 5caa30ea147b |
comparison
equal
deleted
inserted
replaced
1874:75ab0162aa84 | 1878:fa83ab460c54 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 # include "incls/_precompiled.incl" | 25 # include "incls/_precompiled.incl" |
26 # include "incls/_jvmtiImpl.cpp.incl" | 26 # include "incls/_jvmtiImpl.cpp.incl" |
27 | 27 |
28 GrowableArray<JvmtiRawMonitor*> *JvmtiPendingMonitors::_monitors = new (ResourceObj::C_HEAP) GrowableArray<JvmtiRawMonitor*>(1,true); | |
29 | |
30 void JvmtiPendingMonitors::transition_raw_monitors() { | |
31 assert((Threads::number_of_threads()==1), | |
32 "Java thread has not created yet or more than one java thread \ | |
33 is running. Raw monitor transition will not work"); | |
34 JavaThread *current_java_thread = JavaThread::current(); | |
35 assert(current_java_thread->thread_state() == _thread_in_vm, "Must be in vm"); | |
36 { | |
37 ThreadBlockInVM __tbivm(current_java_thread); | |
38 for(int i=0; i< count(); i++) { | |
39 JvmtiRawMonitor *rmonitor = monitors()->at(i); | |
40 int r = rmonitor->raw_enter(current_java_thread); | |
41 assert(r == ObjectMonitor::OM_OK, "raw_enter should have worked"); | |
42 } | |
43 } | |
44 // pending monitors are converted to real monitor so delete them all. | |
45 dispose(); | |
46 } | |
47 | |
48 // | 28 // |
49 // class JvmtiAgentThread | 29 // class JvmtiAgentThread |
50 // | 30 // |
51 // JavaThread used to wrap a thread started by an agent | 31 // JavaThread used to wrap a thread started by an agent |
52 // using the JVMTI method RunAgentThread. | 32 // using the JVMTI method RunAgentThread. |
213 // recompute the new cache value after GC | 193 // recompute the new cache value after GC |
214 for (int i=0; i<len; i++) { | 194 for (int i=0; i<len; i++) { |
215 _cache[i] = _elements->at(i)->getCacheValue(); | 195 _cache[i] = _elements->at(i)->getCacheValue(); |
216 } | 196 } |
217 } | 197 } |
218 | |
219 | |
220 // | |
221 // class JvmtiRawMonitor | |
222 // | |
223 | |
224 JvmtiRawMonitor::JvmtiRawMonitor(const char *name) { | |
225 #ifdef ASSERT | |
226 _name = strcpy(NEW_C_HEAP_ARRAY(char, strlen(name) + 1), name); | |
227 #else | |
228 _name = NULL; | |
229 #endif | |
230 _magic = JVMTI_RM_MAGIC; | |
231 } | |
232 | |
233 JvmtiRawMonitor::~JvmtiRawMonitor() { | |
234 #ifdef ASSERT | |
235 FreeHeap(_name); | |
236 #endif | |
237 _magic = 0; | |
238 } | |
239 | |
240 | |
241 bool | |
242 JvmtiRawMonitor::is_valid() { | |
243 int value = 0; | |
244 | |
245 // This object might not be a JvmtiRawMonitor so we can't assume | |
246 // the _magic field is properly aligned. Get the value in a safe | |
247 // way and then check against JVMTI_RM_MAGIC. | |
248 | |
249 switch (sizeof(_magic)) { | |
250 case 2: | |
251 value = Bytes::get_native_u2((address)&_magic); | |
252 break; | |
253 | |
254 case 4: | |
255 value = Bytes::get_native_u4((address)&_magic); | |
256 break; | |
257 | |
258 case 8: | |
259 value = Bytes::get_native_u8((address)&_magic); | |
260 break; | |
261 | |
262 default: | |
263 guarantee(false, "_magic field is an unexpected size"); | |
264 } | |
265 | |
266 return value == JVMTI_RM_MAGIC; | |
267 } | |
268 | |
269 | 198 |
270 // | 199 // |
271 // class JvmtiBreakpoint | 200 // class JvmtiBreakpoint |
272 // | 201 // |
273 | 202 |