Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 2044:06f017f7daa7
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 07 Jan 2011 18:18:08 +0100 |
parents | 2d26b0046e0d 4de5f4101cfd |
children | 91fe28b03d6a |
comparison
equal
deleted
inserted
replaced
1942:00bc9eaf0e24 | 2044:06f017f7daa7 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 # include "incls/_precompiled.incl" | 25 #include "precompiled.hpp" |
26 # include "incls/_thread.cpp.incl" | 26 #include "classfile/classLoader.hpp" |
27 #include "classfile/javaClasses.hpp" | |
28 #include "classfile/systemDictionary.hpp" | |
29 #include "classfile/vmSymbols.hpp" | |
30 #include "code/scopeDesc.hpp" | |
31 #include "compiler/compileBroker.hpp" | |
32 #include "interpreter/interpreter.hpp" | |
33 #include "interpreter/linkResolver.hpp" | |
34 #include "memory/oopFactory.hpp" | |
35 #include "memory/universe.inline.hpp" | |
36 #include "oops/instanceKlass.hpp" | |
37 #include "oops/objArrayOop.hpp" | |
38 #include "oops/oop.inline.hpp" | |
39 #include "oops/symbolOop.hpp" | |
40 #include "prims/jvm_misc.hpp" | |
41 #include "prims/jvmtiExport.hpp" | |
42 #include "prims/jvmtiThreadState.hpp" | |
43 #include "prims/privilegedStack.hpp" | |
44 #include "runtime/aprofiler.hpp" | |
45 #include "runtime/arguments.hpp" | |
46 #include "runtime/biasedLocking.hpp" | |
47 #include "runtime/deoptimization.hpp" | |
48 #include "runtime/fprofiler.hpp" | |
49 #include "runtime/frame.inline.hpp" | |
50 #include "runtime/init.hpp" | |
51 #include "runtime/interfaceSupport.hpp" | |
52 #include "runtime/java.hpp" | |
53 #include "runtime/javaCalls.hpp" | |
54 #include "runtime/jniPeriodicChecker.hpp" | |
55 #include "runtime/memprofiler.hpp" | |
56 #include "runtime/mutexLocker.hpp" | |
57 #include "runtime/objectMonitor.hpp" | |
58 #include "runtime/osThread.hpp" | |
59 #include "runtime/safepoint.hpp" | |
60 #include "runtime/sharedRuntime.hpp" | |
61 #include "runtime/statSampler.hpp" | |
62 #include "runtime/stubRoutines.hpp" | |
63 #include "runtime/task.hpp" | |
64 #include "runtime/threadCritical.hpp" | |
65 #include "runtime/threadLocalStorage.hpp" | |
66 #include "runtime/vframe.hpp" | |
67 #include "runtime/vframeArray.hpp" | |
68 #include "runtime/vframe_hp.hpp" | |
69 #include "runtime/vmThread.hpp" | |
70 #include "runtime/vm_operations.hpp" | |
71 #include "services/attachListener.hpp" | |
72 #include "services/management.hpp" | |
73 #include "services/threadService.hpp" | |
74 #include "utilities/defaultStream.hpp" | |
75 #include "utilities/dtrace.hpp" | |
76 #include "utilities/events.hpp" | |
77 #include "utilities/preserveException.hpp" | |
78 #ifdef TARGET_OS_FAMILY_linux | |
79 # include "os_linux.inline.hpp" | |
80 # include "thread_linux.inline.hpp" | |
81 #endif | |
82 #ifdef TARGET_OS_FAMILY_solaris | |
83 # include "os_solaris.inline.hpp" | |
84 # include "thread_solaris.inline.hpp" | |
85 #endif | |
86 #ifdef TARGET_OS_FAMILY_windows | |
87 # include "os_windows.inline.hpp" | |
88 # include "thread_windows.inline.hpp" | |
89 #endif | |
90 #ifndef SERIALGC | |
91 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" | |
92 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" | |
93 #include "gc_implementation/parallelScavenge/pcTasks.hpp" | |
94 #endif | |
95 #ifdef COMPILER1 | |
96 #include "c1/c1_Compiler.hpp" | |
97 #endif | |
98 #ifdef COMPILER2 | |
99 #include "opto/c2compiler.hpp" | |
100 #include "opto/idealGraphPrinter.hpp" | |
101 #endif | |
27 | 102 |
28 #ifdef DTRACE_ENABLED | 103 #ifdef DTRACE_ENABLED |
29 | 104 |
30 // Only bother with this argument setup if dtrace is available | 105 // Only bother with this argument setup if dtrace is available |
31 | 106 |
3157 warning("java.lang.ClassCastException has not been initialized"); | 3232 warning("java.lang.ClassCastException has not been initialized"); |
3158 warning("java.lang.ArrayStoreException has not been initialized"); | 3233 warning("java.lang.ArrayStoreException has not been initialized"); |
3159 warning("java.lang.ArithmeticException has not been initialized"); | 3234 warning("java.lang.ArithmeticException has not been initialized"); |
3160 warning("java.lang.StackOverflowError has not been initialized"); | 3235 warning("java.lang.StackOverflowError has not been initialized"); |
3161 } | 3236 } |
3162 | |
3163 if (EnableInvokeDynamic) { | |
3164 // JSR 292: An intialized java.dyn.InvokeDynamic is required in | |
3165 // the compiler. | |
3166 initialize_class(vmSymbolHandles::java_dyn_InvokeDynamic(), CHECK_0); | |
3167 } | |
3168 } | 3237 } |
3169 | 3238 |
3170 // See : bugid 4211085. | 3239 // See : bugid 4211085. |
3171 // Background : the static initializer of java.lang.Compiler tries to read | 3240 // Background : the static initializer of java.lang.Compiler tries to read |
3172 // property"java.compiler" and read & write property "java.vm.info". | 3241 // property"java.compiler" and read & write property "java.vm.info". |
3311 char ebuf[1024]; | 3380 char ebuf[1024]; |
3312 const char *name = agent->name(); | 3381 const char *name = agent->name(); |
3313 const char *msg = "Could not find agent library "; | 3382 const char *msg = "Could not find agent library "; |
3314 | 3383 |
3315 if (agent->is_absolute_path()) { | 3384 if (agent->is_absolute_path()) { |
3316 library = hpi::dll_load(name, ebuf, sizeof ebuf); | 3385 library = os::dll_load(name, ebuf, sizeof ebuf); |
3317 if (library == NULL) { | 3386 if (library == NULL) { |
3318 const char *sub_msg = " in absolute path, with error: "; | 3387 const char *sub_msg = " in absolute path, with error: "; |
3319 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; | 3388 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; |
3320 char *buf = NEW_C_HEAP_ARRAY(char, len); | 3389 char *buf = NEW_C_HEAP_ARRAY(char, len); |
3321 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); | 3390 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); |
3323 vm_exit_during_initialization(buf, NULL); | 3392 vm_exit_during_initialization(buf, NULL); |
3324 FREE_C_HEAP_ARRAY(char, buf); | 3393 FREE_C_HEAP_ARRAY(char, buf); |
3325 } | 3394 } |
3326 } else { | 3395 } else { |
3327 // Try to load the agent from the standard dll directory | 3396 // Try to load the agent from the standard dll directory |
3328 hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); | 3397 os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); |
3329 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3398 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3330 #ifdef KERNEL | 3399 #ifdef KERNEL |
3331 // Download instrument dll | 3400 // Download instrument dll |
3332 if (library == NULL && strcmp(name, "instrument") == 0) { | 3401 if (library == NULL && strcmp(name, "instrument") == 0) { |
3333 char *props = Arguments::get_kernel_properties(); | 3402 char *props = Arguments::get_kernel_properties(); |
3334 char *home = Arguments::get_java_home(); | 3403 char *home = Arguments::get_java_home(); |
3344 vm_exit_during_initialization("fork_and_exec failed: %s", | 3413 vm_exit_during_initialization("fork_and_exec failed: %s", |
3345 strerror(errno)); | 3414 strerror(errno)); |
3346 } | 3415 } |
3347 FREE_C_HEAP_ARRAY(char, cmd); | 3416 FREE_C_HEAP_ARRAY(char, cmd); |
3348 // when this comes back the instrument.dll should be where it belongs. | 3417 // when this comes back the instrument.dll should be where it belongs. |
3349 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3418 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3350 } | 3419 } |
3351 #endif // KERNEL | 3420 #endif // KERNEL |
3352 if (library == NULL) { // Try the local directory | 3421 if (library == NULL) { // Try the local directory |
3353 char ns[1] = {0}; | 3422 char ns[1] = {0}; |
3354 hpi::dll_build_name(buffer, sizeof(buffer), ns, name); | 3423 os::dll_build_name(buffer, sizeof(buffer), ns, name); |
3355 library = hpi::dll_load(buffer, ebuf, sizeof ebuf); | 3424 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3356 if (library == NULL) { | 3425 if (library == NULL) { |
3357 const char *sub_msg = " on the library path, with error: "; | 3426 const char *sub_msg = " on the library path, with error: "; |
3358 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; | 3427 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; |
3359 char *buf = NEW_C_HEAP_ARRAY(char, len); | 3428 char *buf = NEW_C_HEAP_ARRAY(char, len); |
3360 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); | 3429 jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf); |
3367 agent->set_os_lib(library); | 3436 agent->set_os_lib(library); |
3368 } | 3437 } |
3369 | 3438 |
3370 // Find the OnLoad function. | 3439 // Find the OnLoad function. |
3371 for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) { | 3440 for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) { |
3372 on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, hpi::dll_lookup(library, on_load_symbols[symbol_index])); | 3441 on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, os::dll_lookup(library, on_load_symbols[symbol_index])); |
3373 if (on_load_entry != NULL) break; | 3442 if (on_load_entry != NULL) break; |
3374 } | 3443 } |
3375 return on_load_entry; | 3444 return on_load_entry; |
3376 } | 3445 } |
3377 | 3446 |
3449 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) { | 3518 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) { |
3450 | 3519 |
3451 // Find the Agent_OnUnload function. | 3520 // Find the Agent_OnUnload function. |
3452 for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) { | 3521 for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) { |
3453 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t, | 3522 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t, |
3454 hpi::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index])); | 3523 os::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index])); |
3455 | 3524 |
3456 // Invoke the Agent_OnUnload function | 3525 // Invoke the Agent_OnUnload function |
3457 if (unload_entry != NULL) { | 3526 if (unload_entry != NULL) { |
3458 JavaThread* thread = JavaThread::current(); | 3527 JavaThread* thread = JavaThread::current(); |
3459 ThreadToNativeFromVM ttn(thread); | 3528 ThreadToNativeFromVM ttn(thread); |
3618 // will be stopped at native=>Java/VM barriers. Note that we can't | 3687 // will be stopped at native=>Java/VM barriers. Note that we can't |
3619 // simply kill or suspend them, as it is inherently deadlock-prone. | 3688 // simply kill or suspend them, as it is inherently deadlock-prone. |
3620 | 3689 |
3621 #ifndef PRODUCT | 3690 #ifndef PRODUCT |
3622 // disable function tracing at JNI/JVM barriers | 3691 // disable function tracing at JNI/JVM barriers |
3623 TraceHPI = false; | |
3624 TraceJNICalls = false; | 3692 TraceJNICalls = false; |
3625 TraceJVMCalls = false; | 3693 TraceJVMCalls = false; |
3626 TraceRuntimeCalls = false; | 3694 TraceRuntimeCalls = false; |
3627 #endif | 3695 #endif |
3628 | 3696 |