hotspot/src/share/vm/runtime/thread.cpp
changeset 7405 e6fc8d3926f8
parent 7397 5b173b4ca846
child 7439 572e3f624901
equal deleted inserted replaced
7397:5b173b4ca846 7405:e6fc8d3926f8
    45 #include "runtime/arguments.hpp"
    45 #include "runtime/arguments.hpp"
    46 #include "runtime/biasedLocking.hpp"
    46 #include "runtime/biasedLocking.hpp"
    47 #include "runtime/deoptimization.hpp"
    47 #include "runtime/deoptimization.hpp"
    48 #include "runtime/fprofiler.hpp"
    48 #include "runtime/fprofiler.hpp"
    49 #include "runtime/frame.inline.hpp"
    49 #include "runtime/frame.inline.hpp"
    50 #include "runtime/hpi.hpp"
       
    51 #include "runtime/init.hpp"
    50 #include "runtime/init.hpp"
    52 #include "runtime/interfaceSupport.hpp"
    51 #include "runtime/interfaceSupport.hpp"
    53 #include "runtime/java.hpp"
    52 #include "runtime/java.hpp"
    54 #include "runtime/javaCalls.hpp"
    53 #include "runtime/javaCalls.hpp"
    55 #include "runtime/jniPeriodicChecker.hpp"
    54 #include "runtime/jniPeriodicChecker.hpp"
  3384     char ebuf[1024];
  3383     char ebuf[1024];
  3385     const char *name = agent->name();
  3384     const char *name = agent->name();
  3386     const char *msg = "Could not find agent library ";
  3385     const char *msg = "Could not find agent library ";
  3387 
  3386 
  3388     if (agent->is_absolute_path()) {
  3387     if (agent->is_absolute_path()) {
  3389       library = hpi::dll_load(name, ebuf, sizeof ebuf);
  3388       library = os::dll_load(name, ebuf, sizeof ebuf);
  3390       if (library == NULL) {
  3389       if (library == NULL) {
  3391         const char *sub_msg = " in absolute path, with error: ";
  3390         const char *sub_msg = " in absolute path, with error: ";
  3392         size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
  3391         size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
  3393         char *buf = NEW_C_HEAP_ARRAY(char, len);
  3392         char *buf = NEW_C_HEAP_ARRAY(char, len);
  3394         jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
  3393         jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
  3396         vm_exit_during_initialization(buf, NULL);
  3395         vm_exit_during_initialization(buf, NULL);
  3397         FREE_C_HEAP_ARRAY(char, buf);
  3396         FREE_C_HEAP_ARRAY(char, buf);
  3398       }
  3397       }
  3399     } else {
  3398     } else {
  3400       // Try to load the agent from the standard dll directory
  3399       // Try to load the agent from the standard dll directory
  3401       hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name);
  3400       os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name);
  3402       library = hpi::dll_load(buffer, ebuf, sizeof ebuf);
  3401       library = os::dll_load(buffer, ebuf, sizeof ebuf);
  3403 #ifdef KERNEL
  3402 #ifdef KERNEL
  3404       // Download instrument dll
  3403       // Download instrument dll
  3405       if (library == NULL && strcmp(name, "instrument") == 0) {
  3404       if (library == NULL && strcmp(name, "instrument") == 0) {
  3406         char *props = Arguments::get_kernel_properties();
  3405         char *props = Arguments::get_kernel_properties();
  3407         char *home  = Arguments::get_java_home();
  3406         char *home  = Arguments::get_java_home();
  3417           vm_exit_during_initialization("fork_and_exec failed: %s",
  3416           vm_exit_during_initialization("fork_and_exec failed: %s",
  3418                                          strerror(errno));
  3417                                          strerror(errno));
  3419         }
  3418         }
  3420         FREE_C_HEAP_ARRAY(char, cmd);
  3419         FREE_C_HEAP_ARRAY(char, cmd);
  3421         // when this comes back the instrument.dll should be where it belongs.
  3420         // when this comes back the instrument.dll should be where it belongs.
  3422         library = hpi::dll_load(buffer, ebuf, sizeof ebuf);
  3421         library = os::dll_load(buffer, ebuf, sizeof ebuf);
  3423       }
  3422       }
  3424 #endif // KERNEL
  3423 #endif // KERNEL
  3425       if (library == NULL) { // Try the local directory
  3424       if (library == NULL) { // Try the local directory
  3426         char ns[1] = {0};
  3425         char ns[1] = {0};
  3427         hpi::dll_build_name(buffer, sizeof(buffer), ns, name);
  3426         os::dll_build_name(buffer, sizeof(buffer), ns, name);
  3428         library = hpi::dll_load(buffer, ebuf, sizeof ebuf);
  3427         library = os::dll_load(buffer, ebuf, sizeof ebuf);
  3429         if (library == NULL) {
  3428         if (library == NULL) {
  3430           const char *sub_msg = " on the library path, with error: ";
  3429           const char *sub_msg = " on the library path, with error: ";
  3431           size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
  3430           size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
  3432           char *buf = NEW_C_HEAP_ARRAY(char, len);
  3431           char *buf = NEW_C_HEAP_ARRAY(char, len);
  3433           jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
  3432           jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
  3440     agent->set_os_lib(library);
  3439     agent->set_os_lib(library);
  3441   }
  3440   }
  3442 
  3441 
  3443   // Find the OnLoad function.
  3442   // Find the OnLoad function.
  3444   for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) {
  3443   for (size_t symbol_index = 0; symbol_index < num_symbol_entries; symbol_index++) {
  3445     on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, hpi::dll_lookup(library, on_load_symbols[symbol_index]));
  3444     on_load_entry = CAST_TO_FN_PTR(OnLoadEntry_t, os::dll_lookup(library, on_load_symbols[symbol_index]));
  3446     if (on_load_entry != NULL) break;
  3445     if (on_load_entry != NULL) break;
  3447   }
  3446   }
  3448   return on_load_entry;
  3447   return on_load_entry;
  3449 }
  3448 }
  3450 
  3449 
  3522   for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) {
  3521   for (AgentLibrary* agent = Arguments::agents(); agent != NULL; agent = agent->next()) {
  3523 
  3522 
  3524     // Find the Agent_OnUnload function.
  3523     // Find the Agent_OnUnload function.
  3525     for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) {
  3524     for (uint symbol_index = 0; symbol_index < ARRAY_SIZE(on_unload_symbols); symbol_index++) {
  3526       Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t,
  3525       Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR(Agent_OnUnload_t,
  3527                hpi::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index]));
  3526                os::dll_lookup(agent->os_lib(), on_unload_symbols[symbol_index]));
  3528 
  3527 
  3529       // Invoke the Agent_OnUnload function
  3528       // Invoke the Agent_OnUnload function
  3530       if (unload_entry != NULL) {
  3529       if (unload_entry != NULL) {
  3531         JavaThread* thread = JavaThread::current();
  3530         JavaThread* thread = JavaThread::current();
  3532         ThreadToNativeFromVM ttn(thread);
  3531         ThreadToNativeFromVM ttn(thread);
  3691   // will be stopped at native=>Java/VM barriers. Note that we can't
  3690   // will be stopped at native=>Java/VM barriers. Note that we can't
  3692   // simply kill or suspend them, as it is inherently deadlock-prone.
  3691   // simply kill or suspend them, as it is inherently deadlock-prone.
  3693 
  3692 
  3694 #ifndef PRODUCT
  3693 #ifndef PRODUCT
  3695   // disable function tracing at JNI/JVM barriers
  3694   // disable function tracing at JNI/JVM barriers
  3696   TraceHPI = false;
       
  3697   TraceJNICalls = false;
  3695   TraceJNICalls = false;
  3698   TraceJVMCalls = false;
  3696   TraceJVMCalls = false;
  3699   TraceRuntimeCalls = false;
  3697   TraceRuntimeCalls = false;
  3700 #endif
  3698 #endif
  3701 
  3699