Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 14412:e2722a66aba7
Merge
author | kvn |
---|---|
date | Thu, 05 Sep 2013 11:04:39 -0700 |
parents | 94c202aa2646 f92b82d454fa |
children | 2b8e28fdf503 |
comparison
equal
deleted
inserted
replaced
14411:bdd155477289 | 14412:e2722a66aba7 |
---|---|
3697 // Find a command line agent library and return its entry point for | 3697 // Find a command line agent library and return its entry point for |
3698 // -agentlib: -agentpath: -Xrun | 3698 // -agentlib: -agentpath: -Xrun |
3699 // num_symbol_entries must be passed-in since only the caller knows the number of symbols in the array. | 3699 // num_symbol_entries must be passed-in since only the caller knows the number of symbols in the array. |
3700 static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_symbols[], size_t num_symbol_entries) { | 3700 static OnLoadEntry_t lookup_on_load(AgentLibrary* agent, const char *on_load_symbols[], size_t num_symbol_entries) { |
3701 OnLoadEntry_t on_load_entry = NULL; | 3701 OnLoadEntry_t on_load_entry = NULL; |
3702 void *library = agent->os_lib(); // check if we have looked it up before | 3702 void *library = NULL; |
3703 | 3703 |
3704 if (library == NULL) { | 3704 if (!agent->valid()) { |
3705 char buffer[JVM_MAXPATHLEN]; | 3705 char buffer[JVM_MAXPATHLEN]; |
3706 char ebuf[1024]; | 3706 char ebuf[1024]; |
3707 const char *name = agent->name(); | 3707 const char *name = agent->name(); |
3708 const char *msg = "Could not find agent library "; | 3708 const char *msg = "Could not find agent library "; |
3709 | 3709 |
3710 if (agent->is_absolute_path()) { | 3710 // First check to see if agent is statcally linked into executable |
3711 if (os::find_builtin_agent(agent, on_load_symbols, num_symbol_entries)) { | |
3712 library = agent->os_lib(); | |
3713 } else if (agent->is_absolute_path()) { | |
3711 library = os::dll_load(name, ebuf, sizeof ebuf); | 3714 library = os::dll_load(name, ebuf, sizeof ebuf); |
3712 if (library == NULL) { | 3715 if (library == NULL) { |
3713 const char *sub_msg = " in absolute path, with error: "; | 3716 const char *sub_msg = " in absolute path, with error: "; |
3714 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; | 3717 size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; |
3715 char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread); | 3718 char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread); |
3739 FREE_C_HEAP_ARRAY(char, buf, mtThread); | 3742 FREE_C_HEAP_ARRAY(char, buf, mtThread); |
3740 } | 3743 } |
3741 } | 3744 } |
3742 } | 3745 } |
3743 agent->set_os_lib(library); | 3746 agent->set_os_lib(library); |
3747 agent->set_valid(); | |
3744 } | 3748 } |
3745 | 3749 |
3746 // Find the OnLoad function. | 3750 // Find the OnLoad function. |
3747 for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) { | 3751 on_load_entry = |
3748 on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, os::dll_lookup(library, on_load_symbols[symbol_index])); | 3752 CAST_TO_FN_PTR(OnLoadEntry_t, os::find_agent_function(agent, |
3749 if (on_load_entry != NULL) break; | 3753 false, |
3750 } | 3754 on_load_symbols, |
3755 num_symbol_entries)); | |
3751 return on_load_entry; | 3756 return on_load_entry; |
3752 } | 3757 } |
3753 | 3758 |
3754 // Find the JVM_OnLoad entry point | 3759 // Find the JVM_OnLoad entry point |
3755 static OnLoadEntry_t lookup_jvm_on_load(AgentLibrary* agent) { | 3760 static OnLoadEntry_t lookup_jvm_on_load(AgentLibrary* agent) { |
3820 } | 3825 } |
3821 | 3826 |
3822 void Threads::shutdown_vm_agents() { | 3827 void Threads::shutdown_vm_agents() { |
3823 // Send any Agent_OnUnload notifications | 3828 // Send any Agent_OnUnload notifications |
3824 const char *on_unload_symbols[] = AGENT_ONUNLOAD_SYMBOLS; | 3829 const char *on_unload_symbols[] = AGENT_ONUNLOAD_SYMBOLS; |
3830 size_t num_symbol_entries = ARRAY_SIZE(on_unload_symbols); | |
3825 extern struct JavaVM_ main_vm; | 3831 extern struct JavaVM_ main_vm; |
3826 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) { | 3832 for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) { |
3827 | 3833 |
3828 // Find the Agent_OnUnload function. | 3834 // Find the Agent_OnUnload function. |
3829 for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) { | 3835 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t, |
3830 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t, | 3836 os::find_agent_function(agent, |
3831 os::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index])); | 3837 false, |
3832 | 3838 on_unload_symbols, |
3833 // Invoke the Agent_OnUnload function | 3839 num_symbol_entries)); |
3834 if (unload_entry != NULL) { | 3840 |
3835 JavaThread* thread = JavaThread::current(); | 3841 // Invoke the Agent_OnUnload function |
3836 ThreadToNativeFromVM ttn(thread); | 3842 if (unload_entry != NULL) { |
3837 HandleMark hm(thread); | 3843 JavaThread* thread = JavaThread::current(); |
3838 (*unload_entry)(&main_vm); | 3844 ThreadToNativeFromVM ttn(thread); |
3839 break; | 3845 HandleMark hm(thread); |
3840 } | 3846 (*unload_entry)(&main_vm); |
3841 } | 3847 } |
3842 } | 3848 } |
3843 } | 3849 } |
3844 | 3850 |
3845 // Called for after the VM is initialized for -Xrun libraries which have not been converted to agent libraries | 3851 // Called for after the VM is initialized for -Xrun libraries which have not been converted to agent libraries |