# HG changeset patch # User Lukas Stadler # Date 1321613579 -3600 # Node ID 6c04a4f268e5cd6e5ac0c0a5f7eca459ac5c05b9 # Parent 753443a8c4fff4f8f857517bc36aa1c44a2ad5d3 implement generic callback mechanism (CiGenericCallback) diff -r 753443a8c4ff -r 6c04a4f268e5 src/cpu/x86/vm/c1_Runtime1_x86.cpp --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp Tue Nov 15 11:24:26 2011 +0100 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp Fri Nov 18 11:52:59 2011 +0100 @@ -1058,6 +1058,39 @@ thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)()); JRT_END +JRT_ENTRY(void, graal_generic_callback(JavaThread* thread, oop _callback, oop _argument)) + HandleMark hm; + Handle callback(_callback); + Handle argument(_argument); + + KlassHandle klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_cri_ci_CiGenericCallback(), SystemDictionary::java_system_loader(), NULL, thread); + if (klass.is_null()) { + tty->print_cr("couldn't resolve com_sun_cri_ci_CiGenericCallback"); + } + + JavaValue result(T_OBJECT); + JavaCallArguments args; + args.push_oop(Handle(callback)); + args.push_oop(Handle(argument)); + JavaCalls::call_interface(&result, klass, vmSymbols::callback_name(), vmSymbols::callback_signature(), &args, thread); + + if (thread->has_pending_exception()) { + Handle exception = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; + + assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected"); + JavaValue result(T_VOID); + JavaCalls::call_virtual(&result, + exception, + KlassHandle(THREAD, + SystemDictionary::Throwable_klass()), + vmSymbols::printStackTrace_name(), + vmSymbols::void_method_signature(), + THREAD); + } + thread->set_vm_result((oop) result.get_jobject()); +JRT_END + @@ -1949,6 +1982,17 @@ break; } + case graal_generic_callback_id: { + __ enter(); + oop_maps = new OopMapSet(); + OopMap* oop_map = save_live_registers(sasm, 0); + int call_offset = __ call_RT(rax, noreg, (address)graal_generic_callback, j_rarg0, j_rarg1); + oop_maps->add_gc_map(call_offset, oop_map); + __ leave(); + __ ret(0); + break; + } + case graal_handle_exception_id: { StubFrame f(sasm, "graal_handle_exception", dont_gc_arguments); oop_maps = new OopMapSet(); diff -r 753443a8c4ff -r 6c04a4f268e5 src/share/vm/c1/c1_Runtime1.hpp --- a/src/share/vm/c1/c1_Runtime1.hpp Tue Nov 15 11:24:26 2011 +0100 +++ b/src/share/vm/c1/c1_Runtime1.hpp Fri Nov 18 11:52:59 2011 +0100 @@ -81,6 +81,7 @@ stub(graal_set_deopt_info) \ stub(graal_create_null_pointer_exception) \ stub(graal_create_out_of_bounds_exception) \ + stub(graal_generic_callback) \ last_entry(number_of_ids) #define DECLARE_STUB_ID(x) x ## _id , diff -r 753443a8c4ff -r 6c04a4f268e5 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue Nov 15 11:24:26 2011 +0100 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri Nov 18 11:52:59 2011 +0100 @@ -281,6 +281,7 @@ template(com_sun_cri_ci_CiAssumptions, "com/sun/cri/ci/CiAssumptions") \ template(com_sun_cri_ci_CiAssumptions_ConcreteSubtype, "com/sun/cri/ci/CiAssumptions$ConcreteSubtype") \ template(com_sun_cri_ci_CiAssumptions_ConcreteMethod, "com/sun/cri/ci/CiAssumptions$ConcreteMethod") \ + template(com_sun_cri_ci_CiGenericCallback, "com/sun/cri/ci/CiGenericCallback") \ template(com_sun_cri_ci_CiTargetMethod, "com/sun/cri/ci/CiTargetMethod") \ template(com_sun_cri_ci_CiTargetMethod_Site, "com/sun/cri/ci/CiTargetMethod$Site") \ template(com_sun_cri_ci_CiTargetMethod_Call, "com/sun/cri/ci/CiTargetMethod$Call") \ @@ -337,6 +338,8 @@ template(initialize_name, "initialize") \ template(getInstance_signature, "()Lcom/oracle/max/graal/hotspot/Compiler;") \ template(forObject_name, "forObject") \ + template(callback_name, "callback") \ + template(callback_signature, "(Ljava/lang/Object;)Ljava/lang/Object;") \ \ /* common method and field names */ \ template(object_initializer_name, "") \ diff -r 753443a8c4ff -r 6c04a4f268e5 src/share/vm/graal/graalCodeInstaller.cpp --- a/src/share/vm/graal/graalCodeInstaller.cpp Tue Nov 15 11:24:26 2011 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Fri Nov 18 11:52:59 2011 +0100 @@ -608,8 +608,13 @@ TRACE_graal_3("CiRuntimeCall::ArithmeticTan()"); } else if (runtime_call == CiRuntimeCall::RegisterFinalizer()) { target_addr = Runtime1::entry_for(Runtime1::register_finalizer_id); + TRACE_graal_3("CiRuntimeCall::RegisterFinalizer()"); } else if (runtime_call == CiRuntimeCall::Deoptimize()) { target_addr = SharedRuntime::deopt_blob()->uncommon_trap(); + TRACE_graal_3("CiRuntimeCall::Deoptimize()"); + } else if (runtime_call == CiRuntimeCall::GenericCallback()) { + target_addr = Runtime1::entry_for(Runtime1::graal_generic_callback_id); + TRACE_graal_3("CiRuntimeCall::GenericCallback()"); } else { runtime_call->print(); fatal("runtime_call not implemented"); diff -r 753443a8c4ff -r 6c04a4f268e5 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Tue Nov 15 11:24:26 2011 +0100 +++ b/src/share/vm/graal/graalJavaAccess.hpp Fri Nov 18 11:52:59 2011 +0100 @@ -78,6 +78,7 @@ end_class \ start_class(HotSpotCompiledMethod) \ long_field(HotSpotCompiledMethod, nmethod) \ + oop_field(HotSpotCompiledMethod, method, "Lcom/sun/cri/ri/RiResolvedMethod;") \ end_class \ start_class(HotSpotProxy) \ static_oop_field(HotSpotProxy, DUMMY_CONSTANT_OBJ, "Ljava/lang/Long;") \ @@ -195,6 +196,7 @@ static_oop_field(CiRuntimeCall, ArithmeticLog10, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ static_oop_field(CiRuntimeCall, ArithmeticSin, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ static_oop_field(CiRuntimeCall, Deoptimize, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ + static_oop_field(CiRuntimeCall, GenericCallback, "Lcom/sun/cri/ci/CiRuntimeCall;"); \ end_class \ start_class(RiMethod) \ end_class \