117 char buf[256]; \
118 jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
119 JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
120 return; \
121 } \
122 (void)(0
123
124 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
125 JVMCI_EXCEPTION_CONTEXT
126
127 bool is_osr = entry_bci != InvocationEntryBci;
128 if (_bootstrapping && is_osr) {
129 // no OSR compilations during bootstrap - the compiler is just too slow at this point,
130 // and we know that there are no endless loops
131 return;
132 }
133
134 JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
135
136 HandleMark hm;
137 ResourceMark rm;
138 Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
139
140 JavaValue method_result(T_OBJECT);
141 JavaCallArguments args;
142 args.push_long((jlong) (address) method());
143 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
144 vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
145
146 if (!HAS_PENDING_EXCEPTION) {
147 JavaValue result(T_VOID);
148 JavaCallArguments args;
149 args.push_oop(receiver);
150 args.push_oop((oop)method_result.get_jobject());
151 args.push_int(entry_bci);
152 args.push_long((jlong) (address) env);
153 args.push_int(env->task()->compile_id());
154 JavaCalls::call_special(&result, receiver->klass(),
155 vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
156 }
157
158 // An uncaught exception was thrown during compilation. Generally these
159 // should be handled by the Java code in some useful way but if they leak
160 // through to here report them instead of dying or silently ignoring them.
161 if (HAS_PENDING_EXCEPTION) {
162 Handle exception(THREAD, PENDING_EXCEPTION);
163 CLEAR_PENDING_EXCEPTION;
164
165 java_lang_Throwable::java_printStackTrace(exception, THREAD);
166
167 // Something went wrong so disable compilation at this level
168 method->set_not_compilable(CompLevel_full_optimization);
169 } else {
170 _methodsCompiled++;
171 }
172 }
173
174 /**
175 * Aborts the VM due to an unexpected exception.
176 */
177 void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
178 Thread* THREAD = Thread::current();
179 CLEAR_PENDING_EXCEPTION;
180
181 java_lang_Throwable::java_printStackTrace(exception, THREAD);
182
183 // Give other aborting threads to also print their stack traces.
184 // This can be very useful when debugging class initialization
185 // failures.
186 assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
187 const bool interruptible = true;
188 os::sleep(THREAD, 200, interruptible);
189
190 vm_abort(dump_core);
191 }
|
117 char buf[256]; \
118 jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
119 JVMCICompiler::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
120 return; \
121 } \
122 (void)(0
123
124 void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
125 JVMCI_EXCEPTION_CONTEXT
126
127 bool is_osr = entry_bci != InvocationEntryBci;
128 if (_bootstrapping && is_osr) {
129 // no OSR compilations during bootstrap - the compiler is just too slow at this point,
130 // and we know that there are no endless loops
131 return;
132 }
133
134 JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);
135
136 HandleMark hm;
137 Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);
138
139 JavaValue method_result(T_OBJECT);
140 JavaCallArguments args;
141 args.push_long((jlong) (address) method());
142 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
143 vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);
144
145 JavaValue result(T_OBJECT);
146 if (!HAS_PENDING_EXCEPTION) {
147 JavaCallArguments args;
148 args.push_oop(receiver);
149 args.push_oop((oop)method_result.get_jobject());
150 args.push_int(entry_bci);
151 args.push_long((jlong) (address) env);
152 args.push_int(env->task()->compile_id());
153 JavaCalls::call_special(&result, receiver->klass(),
154 vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
155 }
156
157 // An uncaught exception was thrown during compilation. Generally these
158 // should be handled by the Java code in some useful way but if they leak
159 // through to here report them instead of dying or silently ignoring them.
160 if (HAS_PENDING_EXCEPTION) {
161 Handle exception(THREAD, PENDING_EXCEPTION);
162 CLEAR_PENDING_EXCEPTION;
163
164 java_lang_Throwable::java_printStackTrace(exception, THREAD);
165
166 env->set_failure("exception throw", false);
167 } else {
168 oop result_object = (oop) result.get_jobject();
169 if (result_object != NULL) {
170 oop failure_message = CompilationRequestResult::failureMessage(result_object);
171 if (failure_message != NULL) {
172 const char* failure_reason = failure_message != NULL ? java_lang_String::as_utf8_string(failure_message) : "unknown reason";
173 env->set_failure(failure_reason, CompilationRequestResult::retry(result_object));
174 } else {
175 if (env->task()->code() == NULL) {
176 env->set_failure("no nmethod produced", true);
177 } else {
178 env->task()->set_num_inlined_bytecodes(CompilationRequestResult::inlinedBytecodes(result_object));
179 _methodsCompiled++;
180 }
181 }
182 }
183 }
184 }
185
186 /**
187 * Aborts the VM due to an unexpected exception.
188 */
189 void JVMCICompiler::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
190 Thread* THREAD = Thread::current();
191 CLEAR_PENDING_EXCEPTION;
192
193 java_lang_Throwable::java_printStackTrace(exception, THREAD);
194
195 // Give other aborting threads to also print their stack traces.
196 // This can be very useful when debugging class initialization
197 // failures.
198 assert(THREAD->is_Java_thread(), "compiler threads should be Java threads");
199 const bool interruptible = true;
200 os::sleep(THREAD, 200, interruptible);
201
202 vm_abort(dump_core);
203 }
|