53 #include "runtime/interfaceSupport.inline.hpp"
54 #include "runtime/javaCalls.hpp"
55 #include "runtime/jniHandles.inline.hpp"
56 #include "runtime/os.hpp"
57 #include "runtime/safepointVerifiers.hpp"
58 #include "runtime/sharedRuntime.hpp"
59 #include "runtime/sweeper.hpp"
60 #include "runtime/timerTrace.hpp"
61 #include "runtime/vframe.inline.hpp"
62 #include "utilities/debug.hpp"
63 #include "utilities/dtrace.hpp"
64 #include "utilities/events.hpp"
65 #include "utilities/formatBuffer.hpp"
66 #include "utilities/macros.hpp"
67 #ifdef COMPILER1
68 #include "c1/c1_Compiler.hpp"
69 #endif
70 #if INCLUDE_JVMCI
71 #include "jvmci/jvmciEnv.hpp"
72 #include "jvmci/jvmciRuntime.hpp"
73 #include "runtime/vframe.hpp"
74 #endif
75 #ifdef COMPILER2
76 #include "opto/c2compiler.hpp"
77 #endif
78
79 #ifdef DTRACE_ENABLED
80
81 // Only bother with this argument setup if dtrace is available
82
83 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \
84 { \
85 Symbol* klass_name = (method)->klass_name(); \
86 Symbol* name = (method)->name(); \
87 Symbol* signature = (method)->signature(); \
88 HOTSPOT_METHOD_COMPILE_BEGIN( \
89 (char *) comp_name, strlen(comp_name), \
90 (char *) klass_name->bytes(), klass_name->utf8_length(), \
91 (char *) name->bytes(), name->utf8_length(), \
92 (char *) signature->bytes(), signature->utf8_length()); \
93 }
1046 return;
1047 }
1048
1049 // We need to check again to see if the compilation has
1050 // completed. A previous compilation may have registered
1051 // some result.
1052 if (compilation_is_complete(method, osr_bci, comp_level)) {
1053 return;
1054 }
1055
1056 // We now know that this compilation is not pending, complete,
1057 // or prohibited. Assign a compile_id to this compilation
1058 // and check to see if it is in our [Start..Stop) range.
1059 int compile_id = assign_compile_id(method, osr_bci);
1060 if (compile_id == 0) {
1061 // The compilation falls outside the allowed range.
1062 return;
1063 }
1064
1065 #if INCLUDE_JVMCI
1066 if (UseJVMCICompiler && blocking && !UseJVMCINativeLibrary) {
1067 // Don't allow blocking compiles for requests triggered by JVMCI.
1068 if (thread->is_Compiler_thread()) {
1069 blocking = false;
1070 }
1071
1072 // Don't allow blocking compiles if inside a class initializer or while performing class loading
1073 vframeStream vfst((JavaThread*) thread);
1074 for (; !vfst.at_end(); vfst.next()) {
1075 if (vfst.method()->is_static_initializer() ||
1076 (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
1077 vfst.method()->name() == vmSymbols::loadClass_name())) {
1078 blocking = false;
1079 break;
1080 }
1081 }
1082
1083 // Don't allow blocking compilation requests to JVMCI
1084 // if JVMCI itself is not yet initialized
1085 if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) {
1086 blocking = false;
1087 }
1088
1089 // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
1090 // to avoid deadlock between compiler thread(s) and threads run at shutdown
1091 // such as the DestroyJavaVM thread.
1092 if (JVMCI::shutdown_called()) {
1093 blocking = false;
1094 }
1095 }
1096 #endif // INCLUDE_JVMCI
1097
1098 // We will enter the compilation in the queue.
1099 // 14012000: Note that this sets the queued_for_compile bits in
1100 // the target method. We can now reason that a method cannot be
1101 // queued for compilation more than once, as follows:
2046 int system_dictionary_modification_counter;
2047 {
2048 MutexLocker locker(Compile_lock, thread);
2049 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2050 }
2051
2052 #if INCLUDE_JVMCI
2053 if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
2054 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2055
2056 TraceTime t1("compilation", &time);
2057 EventCompilation event;
2058
2059 // Skip redefined methods
2060 if (target_handle->is_old()) {
2061 failure_reason = "redefined method";
2062 retry_message = "not retryable";
2063 compilable = ciEnv::MethodCompilable_never;
2064 } else {
2065 JVMCICompileState compile_state(task, system_dictionary_modification_counter);
2066 JVMCIEnv env(&compile_state, __FILE__, __LINE__);
2067 methodHandle method(thread, target_handle);
2068 env.runtime()->compile_method(&env, jvmci, method, osr_bci);
2069
2070 failure_reason = compile_state.failure_reason();
2071 failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap();
2072 if (!compile_state.retryable()) {
2073 retry_message = "not retryable";
2074 compilable = ciEnv::MethodCompilable_not_at_tier;
2075 }
2076 if (task->code() == NULL) {
2077 assert(failure_reason != NULL, "must specify failure_reason");
2078 }
2079 }
2080 post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
2081 if (event.should_commit()) {
2082 post_compilation_event(&event, task);
2083 }
2084
2085 } else
2086 #endif // INCLUDE_JVMCI
|
53 #include "runtime/interfaceSupport.inline.hpp"
54 #include "runtime/javaCalls.hpp"
55 #include "runtime/jniHandles.inline.hpp"
56 #include "runtime/os.hpp"
57 #include "runtime/safepointVerifiers.hpp"
58 #include "runtime/sharedRuntime.hpp"
59 #include "runtime/sweeper.hpp"
60 #include "runtime/timerTrace.hpp"
61 #include "runtime/vframe.inline.hpp"
62 #include "utilities/debug.hpp"
63 #include "utilities/dtrace.hpp"
64 #include "utilities/events.hpp"
65 #include "utilities/formatBuffer.hpp"
66 #include "utilities/macros.hpp"
67 #ifdef COMPILER1
68 #include "c1/c1_Compiler.hpp"
69 #endif
70 #if INCLUDE_JVMCI
71 #include "jvmci/jvmciEnv.hpp"
72 #include "jvmci/jvmciRuntime.hpp"
73 #endif
74 #ifdef COMPILER2
75 #include "opto/c2compiler.hpp"
76 #endif
77
78 #ifdef DTRACE_ENABLED
79
80 // Only bother with this argument setup if dtrace is available
81
82 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \
83 { \
84 Symbol* klass_name = (method)->klass_name(); \
85 Symbol* name = (method)->name(); \
86 Symbol* signature = (method)->signature(); \
87 HOTSPOT_METHOD_COMPILE_BEGIN( \
88 (char *) comp_name, strlen(comp_name), \
89 (char *) klass_name->bytes(), klass_name->utf8_length(), \
90 (char *) name->bytes(), name->utf8_length(), \
91 (char *) signature->bytes(), signature->utf8_length()); \
92 }
1045 return;
1046 }
1047
1048 // We need to check again to see if the compilation has
1049 // completed. A previous compilation may have registered
1050 // some result.
1051 if (compilation_is_complete(method, osr_bci, comp_level)) {
1052 return;
1053 }
1054
1055 // We now know that this compilation is not pending, complete,
1056 // or prohibited. Assign a compile_id to this compilation
1057 // and check to see if it is in our [Start..Stop) range.
1058 int compile_id = assign_compile_id(method, osr_bci);
1059 if (compile_id == 0) {
1060 // The compilation falls outside the allowed range.
1061 return;
1062 }
1063
1064 #if INCLUDE_JVMCI
1065 if (UseJVMCICompiler && blocking) {
1066 // Don't allow blocking compiles for requests triggered by JVMCI.
1067 if (thread->is_Compiler_thread()) {
1068 blocking = false;
1069 }
1070
1071 if (!UseJVMCINativeLibrary) {
1072 // Don't allow blocking compiles if inside a class initializer or while performing class loading
1073 vframeStream vfst((JavaThread*) thread);
1074 for (; !vfst.at_end(); vfst.next()) {
1075 if (vfst.method()->is_static_initializer() ||
1076 (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) &&
1077 vfst.method()->name() == vmSymbols::loadClass_name())) {
1078 blocking = false;
1079 break;
1080 }
1081 }
1082 }
1083
1084 // Don't allow blocking compilation requests to JVMCI
1085 // if JVMCI itself is not yet initialized
1086 if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) {
1087 blocking = false;
1088 }
1089
1090 // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown
1091 // to avoid deadlock between compiler thread(s) and threads run at shutdown
1092 // such as the DestroyJavaVM thread.
1093 if (JVMCI::shutdown_called()) {
1094 blocking = false;
1095 }
1096 }
1097 #endif // INCLUDE_JVMCI
1098
1099 // We will enter the compilation in the queue.
1100 // 14012000: Note that this sets the queued_for_compile bits in
1101 // the target method. We can now reason that a method cannot be
1102 // queued for compilation more than once, as follows:
2047 int system_dictionary_modification_counter;
2048 {
2049 MutexLocker locker(Compile_lock, thread);
2050 system_dictionary_modification_counter = SystemDictionary::number_of_modifications();
2051 }
2052
2053 #if INCLUDE_JVMCI
2054 if (UseJVMCICompiler && comp != NULL && comp->is_jvmci()) {
2055 JVMCICompiler* jvmci = (JVMCICompiler*) comp;
2056
2057 TraceTime t1("compilation", &time);
2058 EventCompilation event;
2059
2060 // Skip redefined methods
2061 if (target_handle->is_old()) {
2062 failure_reason = "redefined method";
2063 retry_message = "not retryable";
2064 compilable = ciEnv::MethodCompilable_never;
2065 } else {
2066 JVMCICompileState compile_state(task, system_dictionary_modification_counter);
2067 JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__);
2068 methodHandle method(thread, target_handle);
2069 env.runtime()->compile_method(&env, jvmci, method, osr_bci);
2070
2071 failure_reason = compile_state.failure_reason();
2072 failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap();
2073 if (!compile_state.retryable()) {
2074 retry_message = "not retryable";
2075 compilable = ciEnv::MethodCompilable_not_at_tier;
2076 }
2077 if (task->code() == NULL) {
2078 assert(failure_reason != NULL, "must specify failure_reason");
2079 }
2080 }
2081 post_compile(thread, task, task->code() != NULL, NULL, compilable, failure_reason);
2082 if (event.should_commit()) {
2083 post_compilation_event(&event, task);
2084 }
2085
2086 } else
2087 #endif // INCLUDE_JVMCI
|