void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) { GRAAL_EXCEPTION_CONTEXT bool is_osr = entry_bci != InvocationEntryBci; if (_bootstrapping && is_osr) { // no OSR compilations during bootstrap - the compiler is just too slow at this point, // and we know that there are no endless loops return; } HandleMark hm; ResourceMark rm; JavaValue result(T_VOID); JavaCallArguments args; args.push_long((jlong) (address) method()); args.push_int(entry_bci); args.push_long((jlong) (address) task); args.push_int(task->compile_id()); JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, CHECK_ABORT); _methodsCompiled++; }
oop LiveFrameStream::create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) { Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL); instanceKlassHandle ik (THREAD, k); JavaValue result(T_OBJECT); JavaCallArguments args; Symbol* signature = NULL; // ## TODO: type is only available in LocalVariable table, if present. // ## StackValue type is T_INT or T_OBJECT. switch (values->at(i)->type()) { case T_INT: args.push_int(values->int_at(i)); signature = vmSymbols::asPrimitive_int_signature(); break; case T_LONG: args.push_long(values->long_at(i)); signature = vmSymbols::asPrimitive_long_signature(); break; case T_FLOAT: args.push_float(values->float_at(i)); signature = vmSymbols::asPrimitive_float_signature(); break; case T_DOUBLE: args.push_double(values->double_at(i)); signature = vmSymbols::asPrimitive_double_signature(); break; case T_BYTE: args.push_int(values->int_at(i)); signature = vmSymbols::asPrimitive_byte_signature(); break; case T_SHORT: args.push_int(values->int_at(i)); signature = vmSymbols::asPrimitive_short_signature(); break; case T_CHAR: args.push_int(values->int_at(i)); signature = vmSymbols::asPrimitive_char_signature(); break; case T_BOOLEAN: args.push_int(values->int_at(i)); signature = vmSymbols::asPrimitive_boolean_signature(); break; case T_OBJECT: return values->obj_at(i)(); case T_CONFLICT: // put a non-null slot args.push_int(0); signature = vmSymbols::asPrimitive_int_signature(); break; default: ShouldNotReachHere(); } JavaCalls::call_static(&result, ik, vmSymbols::asPrimitive_name(), signature, &args, CHECK_NULL); return (instanceOop) result.get_jobject(); }
inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); }
// Returns an instanceHandle of a MemoryPool object. // It creates a MemoryPool instance when the first time // this function is called. instanceOop MemoryPool::get_memory_pool_instance(TRAPS) { // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_pool_obj points to or implies. instanceOop pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj); if (pool_obj == NULL) { // It's ok for more than one thread to execute the code up to the locked region. // Extra pool instances will just be gc'ed. klassOop k = Management::sun_management_ManagementFactory_klass(CHECK_NULL); instanceKlassHandle ik(THREAD, k); Handle pool_name = java_lang_String::create_from_str(_name, CHECK_NULL); jlong usage_threshold_value = (_usage_threshold->is_high_threshold_supported() ? 0 : -1L); jlong gc_usage_threshold_value = (_gc_usage_threshold->is_high_threshold_supported() ? 0 : -1L); JavaValue result(T_OBJECT); JavaCallArguments args; args.push_oop(pool_name); // Argument 1 args.push_int((int) is_heap()); // Argument 2 symbolHandle method_name = vmSymbolHandles::createMemoryPool_name(); symbolHandle signature = vmSymbolHandles::createMemoryPool_signature(); args.push_long(usage_threshold_value); // Argument 3 args.push_long(gc_usage_threshold_value); // Argument 4 JavaCalls::call_static(&result, ik, method_name, signature, &args, CHECK_NULL); instanceOop p = (instanceOop) result.get_jobject(); instanceHandle pool(THREAD, p); { // Get lock since another thread may have create the instance MutexLocker ml(Management_lock); // Check if another thread has created the pool. We reload // _memory_pool_obj here because some other thread may have // initialized it while we were executing the code before the lock. // // The lock has done an acquire, so the load can't float above it, // but we need to do a load_acquire as above. pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj); if (pool_obj != NULL) { return pool_obj; } // Get the address of the object we created via call_special. pool_obj = pool(); // Use store barrier to make sure the memory accesses associated // with creating the pool are visible before publishing its address. // The unlock will publish the store to _memory_pool_obj because // it does a release first. OrderAccess::release_store_ptr(&_memory_pool_obj, pool_obj); } } return pool_obj; }
void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) { JVMCI_EXCEPTION_CONTEXT bool is_osr = entry_bci != InvocationEntryBci; if (_bootstrapping && is_osr) { // no OSR compilations during bootstrap - the compiler is just too slow at this point, // and we know that there are no endless loops return; } JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT); HandleMark hm; Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT); JavaValue method_result(T_OBJECT); JavaCallArguments args; args.push_long((jlong) (address) method()); JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD); JavaValue result(T_OBJECT); if (!HAS_PENDING_EXCEPTION) { JavaCallArguments args; args.push_oop(receiver); args.push_oop((oop)method_result.get_jobject()); args.push_int(entry_bci); args.push_long((jlong) (address) env); args.push_int(env->task()->compile_id()); JavaCalls::call_special(&result, receiver->klass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD); } // An uncaught exception was thrown during compilation. Generally these // should be handled by the Java code in some useful way but if they leak // through to here report them instead of dying or silently ignoring them. if (HAS_PENDING_EXCEPTION) { Handle exception(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; java_lang_Throwable::java_printStackTrace(exception, THREAD); env->set_failure("exception throw", false); } else { oop result_object = (oop) result.get_jobject(); if (result_object != NULL) { oop failure_message = CompilationRequestResult::failureMessage(result_object); if (failure_message != NULL) { const char* failure_reason = java_lang_String::as_utf8_string(failure_message); env->set_failure(failure_reason, CompilationRequestResult::retry(result_object) != 0); } else { if (env->task()->code() == NULL) { env->set_failure("no nmethod produced", true); } else { env->task()->set_num_inlined_bytecodes(CompilationRequestResult::inlinedBytecodes(result_object)); Atomic::inc(&_methods_compiled); } } } else { assert(false, "JVMCICompiler.compileMethod should always return non-null"); } } }
virtual void pushLong(jlong j) { _javaArgs->push_long(j); }