< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page




2671   AdapterFingerPrint* fingerprint = NULL;
2672   {
2673     MutexLocker mu(AdapterHandlerLibrary_lock);
2674     // make sure data structure is initialized
2675     initialize();
2676 
2677     if (method->is_abstract()) {
2678       return _abstract_method_handler;
2679     }
2680 
2681     // Fill in the signature array, for the calling-convention call.
2682     GrowableArray<SigEntry> sig_extended;
2683     {
2684       MutexUnlocker mul(AdapterHandlerLibrary_lock);
2685       Thread* THREAD = Thread::current();
2686       Klass* holder = method->method_holder();
2687       GrowableArray<BasicType> sig_bt_tmp;
2688 
2689       int i = 0;
2690       if (!method->is_static()) {  // Pass in receiver first
2691         if (ValueTypePassFieldsAsArgs && holder->is_value()) {
2692           ValueKlass* vk = ValueKlass::cast(holder);
2693           if (vk == SystemDictionary::___Value_klass()) {
2694             // If the holder of the method is __Value, we must pass a
2695             // reference.
2696             sig_extended.push(SigEntry(T_VALUETYPEPTR));
2697           } else {
2698             const Array<SigEntry>* sig_vk = vk->extended_sig();
2699             sig_extended.appendAll(sig_vk);
2700           }
2701         } else {
2702           sig_extended.push(SigEntry(T_OBJECT));
2703         }
2704       }
2705       for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2706         if (ValueTypePassFieldsAsArgs && ss.type() == T_VALUETYPE) {
2707           Symbol* name = ss.as_symbol_or_null();
2708           assert(name != NULL, "should not be null");
2709           if (name == vmSymbols::java_lang____Value()) {
2710             assert(method->is_compiled_lambda_form() || method->is_method_handle_intrinsic(),
2711                    "should not use __Value for a value type argument");
2712             sig_extended.push(SigEntry(T_VALUETYPEPTR));
2713           } else {
2714             // Method handle intrinsics with a __Value argument may be created during
2715             // compilation. Only do a full system dictionary lookup if the argument name
2716             // is not __Value, to avoid lookups from the compiler thread.
2717             Klass* k = ss.as_klass(Handle(THREAD, holder->class_loader()),
2718                                    Handle(THREAD, holder->protection_domain()),
2719                                    SignatureStream::ReturnNull, CHECK_NULL);
2720             const Array<SigEntry>* sig_vk = ValueKlass::cast(k)->extended_sig();
2721             sig_extended.appendAll(sig_vk);
2722           }
2723         } else {
2724           sig_extended.push(SigEntry(ss.type()));
2725           if (ss.type() == T_LONG || ss.type() == T_DOUBLE) {
2726             sig_extended.push(SigEntry(T_VOID));
2727           }
2728         }
2729       }
2730     }


2930     if (buf != NULL) {
2931       CodeBuffer buffer(buf);
2932       double locs_buf[20];
2933       buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2934       MacroAssembler _masm(&buffer);
2935 
2936       // Fill in the signature array, for the calling-convention call.
2937       const int total_args_passed = method->size_of_parameters();
2938 
2939       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2940       VMRegPair*   regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2941       int i=0;
2942       if (!method->is_static())  // Pass in receiver first
2943         sig_bt[i++] = T_OBJECT;
2944       SignatureStream ss(method->signature());
2945       for (; !ss.at_return_type(); ss.next()) {
2946         BasicType bt = ss.type();
2947         if  (bt == T_VALUETYPE) {
2948 #ifdef ASSERT
2949           Thread* THREAD = Thread::current();


2950           Handle class_loader(THREAD, method->method_holder()->class_loader());
2951           Handle protection_domain(THREAD, method->method_holder()->protection_domain());
2952           Klass* k = ss.as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, THREAD);
2953           assert(k != NULL && !HAS_PENDING_EXCEPTION, "can't resolve klass");
2954           assert(k == SystemDictionary::___Value_klass(), "other values not supported");

2955 #endif
2956           bt = T_VALUETYPEPTR;
2957         }
2958         sig_bt[i++] = bt;  // Collect remaining bits of signature
2959         if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2960           sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2961       }
2962       assert(i == total_args_passed, "");
2963       BasicType ret_type = ss.type();
2964 
2965       // Now get the compiled-Java layout as input (or output) arguments.
2966       // NOTE: Stubs for compiled entry points of method handle intrinsics
2967       // are just trampolines so the argument registers must be outgoing ones.
2968       const bool is_outgoing = method->is_method_handle_intrinsic();
2969       int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing);
2970 
2971       // Generate the compiled-to-native wrapper code
2972       nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type);
2973 
2974       if (nm != NULL) {




2671   AdapterFingerPrint* fingerprint = NULL;
2672   {
2673     MutexLocker mu(AdapterHandlerLibrary_lock);
2674     // make sure data structure is initialized
2675     initialize();
2676 
2677     if (method->is_abstract()) {
2678       return _abstract_method_handler;
2679     }
2680 
2681     // Fill in the signature array, for the calling-convention call.
2682     GrowableArray<SigEntry> sig_extended;
2683     {
2684       MutexUnlocker mul(AdapterHandlerLibrary_lock);
2685       Thread* THREAD = Thread::current();
2686       Klass* holder = method->method_holder();
2687       GrowableArray<BasicType> sig_bt_tmp;
2688 
2689       int i = 0;
2690       if (!method->is_static()) {  // Pass in receiver first
2691         if (holder->is_value()) {
2692           ValueKlass* vk = ValueKlass::cast(holder);
2693           if (!ValueTypePassFieldsAsArgs || (vk == SystemDictionary::___Value_klass())) {
2694             // If we don't pass value types as arguments or if the holder of
2695             // the method is __Value, we must pass a reference.
2696             sig_extended.push(SigEntry(T_VALUETYPEPTR));
2697           } else {
2698             const Array<SigEntry>* sig_vk = vk->extended_sig();
2699             sig_extended.appendAll(sig_vk);
2700           }
2701         } else {
2702           sig_extended.push(SigEntry(T_OBJECT));
2703         }
2704       }
2705       for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2706         if (ss.type() == T_VALUETYPE) {
2707           Symbol* name = ss.as_symbol_or_null();
2708           assert(name != NULL, "should not be null");
2709           if (!ValueTypePassFieldsAsArgs || (name == vmSymbols::java_lang____Value())) {
2710             assert(!ValueTypePassFieldsAsArgs || method->is_compiled_lambda_form() || method->is_method_handle_intrinsic(),
2711                    "should not use __Value for a value type argument");
2712             sig_extended.push(SigEntry(T_VALUETYPEPTR));
2713           } else {
2714             // Method handle intrinsics with a __Value argument may be created during
2715             // compilation. Only do a full system dictionary lookup if the argument name
2716             // is not __Value, to avoid lookups from the compiler thread.
2717             Klass* k = ss.as_klass(Handle(THREAD, holder->class_loader()),
2718                                    Handle(THREAD, holder->protection_domain()),
2719                                    SignatureStream::ReturnNull, CHECK_NULL);
2720             const Array<SigEntry>* sig_vk = ValueKlass::cast(k)->extended_sig();
2721             sig_extended.appendAll(sig_vk);
2722           }
2723         } else {
2724           sig_extended.push(SigEntry(ss.type()));
2725           if (ss.type() == T_LONG || ss.type() == T_DOUBLE) {
2726             sig_extended.push(SigEntry(T_VOID));
2727           }
2728         }
2729       }
2730     }


2930     if (buf != NULL) {
2931       CodeBuffer buffer(buf);
2932       double locs_buf[20];
2933       buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2934       MacroAssembler _masm(&buffer);
2935 
2936       // Fill in the signature array, for the calling-convention call.
2937       const int total_args_passed = method->size_of_parameters();
2938 
2939       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2940       VMRegPair*   regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2941       int i=0;
2942       if (!method->is_static())  // Pass in receiver first
2943         sig_bt[i++] = T_OBJECT;
2944       SignatureStream ss(method->signature());
2945       for (; !ss.at_return_type(); ss.next()) {
2946         BasicType bt = ss.type();
2947         if (bt == T_VALUETYPE) {
2948 #ifdef ASSERT
2949           Thread* THREAD = Thread::current();
2950           // Avoid class loading from compiler thread
2951           if (THREAD->can_call_java()) {
2952             Handle class_loader(THREAD, method->method_holder()->class_loader());
2953             Handle protection_domain(THREAD, method->method_holder()->protection_domain());
2954             Klass* k = ss.as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, THREAD);
2955             assert(k != NULL && !HAS_PENDING_EXCEPTION, "can't resolve klass");
2956             assert(k == SystemDictionary::___Value_klass(), "other values not supported");
2957           }
2958 #endif
2959           bt = T_VALUETYPEPTR;
2960         }
2961         sig_bt[i++] = bt;  // Collect remaining bits of signature
2962         if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2963           sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2964       }
2965       assert(i == total_args_passed, "");
2966       BasicType ret_type = ss.type();
2967 
2968       // Now get the compiled-Java layout as input (or output) arguments.
2969       // NOTE: Stubs for compiled entry points of method handle intrinsics
2970       // are just trampolines so the argument registers must be outgoing ones.
2971       const bool is_outgoing = method->is_method_handle_intrinsic();
2972       int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing);
2973 
2974       // Generate the compiled-to-native wrapper code
2975       nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type);
2976 
2977       if (nm != NULL) {


< prev index next >