comparison src/share/vm/runtime/thread.cpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents ec267141f753 190899198332
children 096c224171c4
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
335 335
336 Thread::~Thread() { 336 Thread::~Thread() {
337 // Reclaim the objectmonitors from the omFreeList of the moribund thread. 337 // Reclaim the objectmonitors from the omFreeList of the moribund thread.
338 ObjectSynchronizer::omFlush (this) ; 338 ObjectSynchronizer::omFlush (this) ;
339 339
340 EVENT_THREAD_DESTRUCT(this);
341
340 // stack_base can be NULL if the thread is never started or exited before 342 // stack_base can be NULL if the thread is never started or exited before
341 // record_stack_base_and_size called. Although, we would like to ensure 343 // record_stack_base_and_size called. Although, we would like to ensure
342 // that all started threads do call record_stack_base_and_size(), there is 344 // that all started threads do call record_stack_base_and_size(), there is
343 // not proper way to enforce that. 345 // not proper way to enforce that.
344 #if INCLUDE_NMT 346 #if INCLUDE_NMT
1483 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) { 1485 for (int i = 0; i < GRAAL_COUNTERS_SIZE; i++) {
1484 _graal_counters[i] = 0; 1486 _graal_counters[i] = 0;
1485 } 1487 }
1486 #endif // GRAAL_COUNTER_SIZE > 0 1488 #endif // GRAAL_COUNTER_SIZE > 0
1487 #endif // GRAAL 1489 #endif // GRAAL
1488 _exception_oop = NULL; 1490 (void)const_cast<oop&>(_exception_oop = NULL);
1489 _exception_pc = 0; 1491 _exception_pc = 0;
1490 _exception_handler_pc = 0; 1492 _exception_handler_pc = 0;
1491 _is_method_handle_return = 0; 1493 _is_method_handle_return = 0;
1492 _jvmti_thread_state= NULL; 1494 _jvmti_thread_state= NULL;
1493 _should_post_on_exceptions_flag = JNI_FALSE; 1495 _should_post_on_exceptions_flag = JNI_FALSE;
3378 3380
3379 // Parse arguments 3381 // Parse arguments
3380 jint parse_result = Arguments::parse(args); 3382 jint parse_result = Arguments::parse(args);
3381 if (parse_result != JNI_OK) return parse_result; 3383 if (parse_result != JNI_OK) return parse_result;
3382 3384
3385 os::init_before_ergo();
3386
3387 jint ergo_result = Arguments::apply_ergo();
3388 if (ergo_result != JNI_OK) return ergo_result;
3389
3383 if (PauseAtStartup) { 3390 if (PauseAtStartup) {
3384 os::pause(); 3391 os::pause();
3385 } 3392 }
3386 3393
3387 #ifndef USDT2 3394 #ifndef USDT2
3685 // initialize compiler(s) 3692 // initialize compiler(s)
3686 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(GRAALVM) 3693 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(GRAALVM)
3687 CompileBroker::compilation_init(); 3694 CompileBroker::compilation_init();
3688 #endif 3695 #endif
3689 3696
3697 if (EnableInvokeDynamic) {
3698 // Pre-initialize some JSR292 core classes to avoid deadlock during class loading.
3699 // It is done after compilers are initialized, because otherwise compilations of
3700 // signature polymorphic MH intrinsics can be missed
3701 // (see SystemDictionary::find_method_handle_intrinsic).
3702 initialize_class(vmSymbols::java_lang_invoke_MethodHandle(), CHECK_0);
3703 initialize_class(vmSymbols::java_lang_invoke_MemberName(), CHECK_0);
3704 initialize_class(vmSymbols::java_lang_invoke_MethodHandleNatives(), CHECK_0);
3705 }
3706
3690 #if INCLUDE_MANAGEMENT 3707 #if INCLUDE_MANAGEMENT
3691 Management::initialize(THREAD); 3708 Management::initialize(THREAD);
3692 #endif // INCLUDE_MANAGEMENT 3709 #endif // INCLUDE_MANAGEMENT
3693 3710
3694 if (HAS_PENDING_EXCEPTION) { 3711 if (HAS_PENDING_EXCEPTION) {
3745 // Find a command line agent library and return its entry point for 3762 // Find a command line agent library and return its entry point for
3746 // -agentlib: -agentpath: -Xrun 3763 // -agentlib: -agentpath: -Xrun
3747 // num_symbol_entries must be passed-in since only the caller knows the number of symbols in the array. 3764 // num_symbol_entries must be passed-in since only the caller knows the number of symbols in the array.
3748 static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_symbols[], size_t num_symbol_entries) { 3765 static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_symbols[], size_t num_symbol_entries) {
3749 OnLoadEntry_t on_load_entry = NULL; 3766 OnLoadEntry_t on_load_entry = NULL;
3750 void *library = agent->os_lib(); // check if we have looked it up before 3767 void *library = NULL;
3751 3768
3752 if (library == NULL) { 3769 if (!agent->valid()) {
3753 char buffer[JVM_MAXPATHLEN]; 3770 char buffer[JVM_MAXPATHLEN];
3754 char ebuf[1024]; 3771 char ebuf[1024];
3755 const char *name = agent->name(); 3772 const char *name = agent->name();
3756 const char *msg = "Could not find agent library "; 3773 const char *msg = "Could not find agent library ";
3757 3774
3758 if (agent->is_absolute_path()) { 3775 // First check to see if agent is statically linked into executable
3776 if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) {
3777 library = agent->os_lib();
3778 } else if (agent->is_absolute_path()) {
3759 library = os::dll_load(name, ebuf, sizeof ebuf); 3779 library = os::dll_load(name, ebuf, sizeof ebuf);
3760 if (library == NULL) { 3780 if (library == NULL) {
3761 const char *sub_msg = " in absolute path, with error: "; 3781 const char *sub_msg = " in absolute path, with error: ";
3762 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; 3782 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
3763 char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread); 3783 char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread);
3787 FREE_C_HEAP_ARRAY(char, buf, mtThread); 3807 FREE_C_HEAP_ARRAY(char, buf, mtThread);
3788 } 3808 }
3789 } 3809 }
3790 } 3810 }
3791 agent->set_os_lib(library); 3811 agent->set_os_lib(library);
3812 agent->set_valid();
3792 } 3813 }
3793 3814
3794 // Find the OnLoad function. 3815 // Find the OnLoad function.
3795 for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) { 3816 on_load_entry =
3796 on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, os::dll_lookup(library, on_load_symbols[symbol_index])); 3817 CAST_TO_FN_PTR(OnLoadEntry_t, os::find_agent_function(agent,
3797 if (on_load_entry != NULL) break; 3818 false,
3798 } 3819 on_load_symbols,
3820 num_symbol_entries));
3799 return on_load_entry; 3821 return on_load_entry;
3800 } 3822 }
3801 3823
3802 // Find the JVM_OnLoad entry point 3824 // Find the JVM_OnLoad entry point
3803 static OnLoadEntry_t lookup_jvm_on_load(AgentLibrary* agent) { 3825 static OnLoadEntry_t lookup_jvm_on_load(AgentLibrary* agent) {
3868 } 3890 }
3869 3891
3870 void Threads::shutdown_vm_agents() { 3892 void Threads::shutdown_vm_agents() {
3871 // Send any Agent_OnUnload notifications 3893 // Send any Agent_OnUnload notifications
3872 const char *on_unload_symbols[] = AGENT_ONUNLOAD_SYMBOLS; 3894 const char *on_unload_symbols[] = AGENT_ONUNLOAD_SYMBOLS;
3895 size_t num_symbol_entries = ARRAY_SIZE(on_unload_symbols);
3873 extern struct JavaVM_ main_vm; 3896 extern struct JavaVM_ main_vm;
3874 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) { 3897 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) {
3875 3898
3876 // Find the Agent_OnUnload function. 3899 // Find the Agent_OnUnload function.
3877 for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) { 3900 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t,
3878 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t, 3901 os::find_agent_function(agent,
3879 os::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index])); 3902 false,
3880 3903 on_unload_symbols,
3881 // Invoke the Agent_OnUnload function 3904 num_symbol_entries));
3882 if (unload_entry != NULL) { 3905
3883 JavaThread* thread = JavaThread::current(); 3906 // Invoke the Agent_OnUnload function
3884 ThreadToNativeFromVM ttn(thread); 3907 if (unload_entry != NULL) {
3885 HandleMark hm(thread); 3908 JavaThread* thread = JavaThread::current();
3886 (*unload_entry)(&main_vm); 3909 ThreadToNativeFromVM ttn(thread);
3887 break; 3910 HandleMark hm(thread);
3888 } 3911 (*unload_entry)(&main_vm);
3889 } 3912 }
3890 } 3913 }
3891 } 3914 }
3892 3915
3893 // Called for after the VM is initialized for -Xrun libraries which have not been converted to agent libraries 3916 // Called for after the VM is initialized for -Xrun libraries which have not been converted to agent libraries