59 #define C2V_VMENTRY(result_type, name, signature) \ 60 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ 61 TRACE_jvmci_1("CompilerToVM::" #name); \ 62 TRACE_CALL(result_type, jvmci_ ## name signature) \ 63 JVMCI_VM_ENTRY_MARK; \ 64 65 #define C2V_END } 66 67 oop CompilerToVM::get_jvmci_method(const methodHandle& method, TRAPS) { 68 if (method() != NULL) { 69 JavaValue result(T_OBJECT); 70 JavaCallArguments args; 71 args.push_long((jlong) (address) method()); 72 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_NULL); 73 74 return (oop)result.get_jobject(); 75 } 76 return NULL; 77 } 78 79 oop CompilerToVM::get_jvmci_type(KlassHandle klass, TRAPS) { 80 if (klass() != NULL) { 81 JavaValue result(T_OBJECT); 82 JavaCallArguments args; 83 args.push_oop(Handle(THREAD, klass->java_mirror())); 84 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL); 85 86 return (oop)result.get_jobject(); 87 } 88 return NULL; 89 } 90 91 int CompilerToVM::Data::Klass_vtable_start_offset; 92 int CompilerToVM::Data::Klass_vtable_length_offset; 93 94 int CompilerToVM::Data::Method_extra_stack_entries; 95 96 address CompilerToVM::Data::SharedRuntime_ic_miss_stub; 97 address CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub; 98 address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack; 99 address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap; 100 522 if (object == NULL) { 523 THROW_0(vmSymbols::java_lang_NullPointerException()); 524 } 525 if (object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 526 cp = CompilerToVM::asMethod(object)->constMethod()->constants(); 527 } else if (object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 528 cp = InstanceKlass::cast(CompilerToVM::asKlass(object))->constants(); 529 } else { 530 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 531 err_msg("Unexpected type: %s", object->klass()->external_name())); 532 } 533 assert(!cp.is_null(), "npe"); 534 JavaValue method_result(T_OBJECT); 535 JavaCallArguments args; 536 args.push_long((jlong) (address) cp()); 537 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL); 538 return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject()); 539 } 540 541 C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) 542 KlassHandle klass; 543 oop base_object = JNIHandles::resolve(base); 544 jlong base_address = 0; 545 if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { 546 klass = base_object->klass(); 547 } else if (!compressed) { 548 if (base_object != NULL) { 549 if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 550 base_address = HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object); 551 } else if (base_object->is_a(SystemDictionary::HotSpotConstantPool_klass())) { 552 base_address = HotSpotConstantPool::metaspaceConstantPool(base_object); 553 } else if (base_object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 554 base_address = (jlong) CompilerToVM::asKlass(base_object); 555 } else if (base_object->is_a(SystemDictionary::Class_klass())) { 556 base_address = (jlong) (address) base_object; 557 } else { 558 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 559 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 560 } 561 } 562 klass = *((Klass**) (intptr_t) (base_address + offset)); 563 } else { 564 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 565 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 566 } 567 assert (klass.is_null() || klass->is_klass(), "invalid read"); 568 oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 569 return JNIHandles::make_local(THREAD, result); 570 } 571 572 C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 573 ResourceMark rm; 574 methodHandle method = CompilerToVM::asMethod(jvmci_method); 575 KlassHandle holder = CompilerToVM::asKlass(jvmci_type); 576 if (holder->is_interface()) { 577 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name())); 578 } 579 580 methodHandle ucm; 581 { 582 MutexLocker locker(Compile_lock); 583 ucm = Dependencies::find_unique_concrete_method(holder(), method()); 584 } 585 oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL); 586 return JNIHandles::make_local(THREAD, result); 587 C2V_END 588 589 C2V_VMENTRY(jobject, getImplementor, (JNIEnv *, jobject, jobject jvmci_type)) 590 InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type); 591 oop implementor = CompilerToVM::get_jvmci_type(klass->implementor(), CHECK_NULL); 592 return JNIHandles::make_local(THREAD, implementor); 593 C2V_END 594 595 C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method)) 596 methodHandle method = CompilerToVM::asMethod(jvmci_method); 597 return method->is_ignored_by_security_stack_walk(); 598 C2V_END 599 600 C2V_VMENTRY(jboolean, isCompilable,(JNIEnv *, jobject, jobject jvmci_method)) 601 methodHandle method = CompilerToVM::asMethod(jvmci_method); 602 // Ignore the not_compilable flags in hosted mode since they are never set by 603 // the JVMCI compiler. 694 C2V_VMENTRY(jobject, lookupSignatureInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which)) 695 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 696 Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(which), CHECK_NULL); 697 return JNIHandles::make_local(THREAD, sym()); 698 C2V_END 699 700 C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 701 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 702 return cp->klass_ref_index_at(index); 703 C2V_END 704 705 C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 706 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 707 Klass* resolved_klass = cp->klass_at(index, CHECK_NULL); 708 oop klass = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); 709 return JNIHandles::make_local(THREAD, klass); 710 C2V_END 711 712 C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 713 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 714 KlassHandle loading_klass(cp->pool_holder()); 715 bool is_accessible = false; 716 KlassHandle klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); 717 Symbol* symbol = NULL; 718 if (klass.is_null()) { 719 symbol = cp->klass_name_at(index); 720 } 721 oop result_oop; 722 if (!klass.is_null()) { 723 result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 724 } else { 725 Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); 726 result_oop = result(); 727 } 728 return JNIHandles::make_local(THREAD, result_oop); 729 C2V_END 730 731 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 732 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 733 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); 734 return JNIHandles::make_local(THREAD, appendix_oop); 735 C2V_END 736 737 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 738 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 739 instanceKlassHandle pool_holder(cp->pool_holder()); 740 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); 741 methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); 742 oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); 743 return JNIHandles::make_local(THREAD, result); 744 C2V_END 745 746 C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 747 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 748 return cp->remap_instruction_operand_from_cache(index); 749 C2V_END 750 751 C2V_VMENTRY(jobject, resolveFieldInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jobject jvmci_method, jbyte opcode, jlongArray info_handle)) 752 ResourceMark rm; 753 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 754 Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); 755 fieldDescriptor fd; 756 LinkInfo link_info(cp, index, (jvmci_method != NULL) ? CompilerToVM::asMethod(jvmci_method) : NULL, CHECK_0); 757 LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0); 758 typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle); 759 assert(info != NULL && info->length() == 2, "must be"); 763 return JNIHandles::make_local(THREAD, field_holder); 764 C2V_END 765 766 C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 767 ResourceMark rm; 768 Klass* klass = CompilerToVM::asKlass(jvmci_type); 769 Method* method = CompilerToVM::asMethod(jvmci_method); 770 if (klass->is_interface()) { 771 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", klass->external_name())); 772 } 773 if (!method->method_holder()->is_interface()) { 774 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string())); 775 } 776 if (!InstanceKlass::cast(klass)->is_linked()) { 777 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Class %s must be linked", klass->external_name())); 778 } 779 return LinkResolver::vtable_index_of_interface_method(klass, method); 780 C2V_END 781 782 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) 783 KlassHandle recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); 784 KlassHandle caller_klass = CompilerToVM::asKlass(caller_jvmci_type); 785 methodHandle method = CompilerToVM::asMethod(jvmci_method); 786 787 KlassHandle h_resolved (THREAD, method->method_holder()); 788 Symbol* h_name = method->name(); 789 Symbol* h_signature = method->signature(); 790 791 if (MethodHandles::is_signature_polymorphic_method(method())) { 792 // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case. 793 return NULL; 794 } 795 796 LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass); 797 methodHandle m; 798 // Only do exact lookup if receiver klass has been linked. Otherwise, 799 // the vtable has not been setup, and the LinkResolver will fail. 800 if (recv_klass->is_array_klass() || 801 InstanceKlass::cast(recv_klass())->is_linked() && !recv_klass->is_interface()) { 802 if (h_resolved->is_interface()) { 803 m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); 804 } else { 805 m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); 806 } 807 } 808 809 if (m.is_null()) { 810 // Return NULL if there was a problem with lookup (uninitialized class, etc.) 811 return NULL; 812 } 813 814 oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL); 815 return JNIHandles::make_local(THREAD, result); 816 C2V_END 817 818 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type)) 819 Klass* klass = CompilerToVM::asKlass(jvmci_type); 820 assert(klass != NULL, "method must not be called for primitive types"); 821 return Dependencies::find_finalizable_subclass(klass) != NULL; 822 C2V_END 1325 } 1326 fst.next(); 1327 vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); 1328 frame_number = 0; 1329 } // end of frame loop 1330 1331 // the end was reached without finding a matching method 1332 return NULL; 1333 C2V_END 1334 1335 C2V_VMENTRY(void, resolveInvokeDynamicInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1336 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1337 CallInfo callInfo; 1338 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokedynamic, CHECK); 1339 ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); 1340 cp_cache_entry->set_dynamic_call(cp, callInfo); 1341 C2V_END 1342 1343 C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1344 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1345 KlassHandle holder = cp->klass_ref_at(index, CHECK); 1346 Symbol* name = cp->name_ref_at(index); 1347 if (MethodHandles::is_signature_polymorphic_name(holder(), name)) { 1348 CallInfo callInfo; 1349 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); 1350 ConstantPoolCacheEntry* cp_cache_entry = cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index)); 1351 cp_cache_entry->set_method_handle(cp, callInfo); 1352 } 1353 C2V_END 1354 1355 C2V_VMENTRY(jobject, getSignaturePolymorphicHolders, (JNIEnv*, jobject)) 1356 objArrayHandle holders = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), 2, CHECK_NULL); 1357 Handle mh = java_lang_String::create_from_str("Ljava/lang/invoke/MethodHandle;", CHECK_NULL); 1358 Handle vh = java_lang_String::create_from_str("Ljava/lang/invoke/VarHandle;", CHECK_NULL); 1359 holders->obj_at_put(0, mh()); 1360 holders->obj_at_put(1, vh()); 1361 return JNIHandles::make_local(THREAD, holders()); 1362 C2V_END 1363 1364 C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject)) 1365 //see compute_recording_non_safepoints in debugInfroRec.cpp 1366 if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { 1367 return true; 1368 } 1369 return DebugNonSafepoints; 1370 C2V_END | 59 #define C2V_VMENTRY(result_type, name, signature) \ 60 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ 61 TRACE_jvmci_1("CompilerToVM::" #name); \ 62 TRACE_CALL(result_type, jvmci_ ## name signature) \ 63 JVMCI_VM_ENTRY_MARK; \ 64 65 #define C2V_END } 66 67 oop CompilerToVM::get_jvmci_method(const methodHandle& method, TRAPS) { 68 if (method() != NULL) { 69 JavaValue result(T_OBJECT); 70 JavaCallArguments args; 71 args.push_long((jlong) (address) method()); 72 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_NULL); 73 74 return (oop)result.get_jobject(); 75 } 76 return NULL; 77 } 78 79 oop CompilerToVM::get_jvmci_type(Klass* klass, TRAPS) { 80 if (klass != NULL) { 81 JavaValue result(T_OBJECT); 82 JavaCallArguments args; 83 args.push_oop(Handle(THREAD, klass->java_mirror())); 84 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL); 85 86 return (oop)result.get_jobject(); 87 } 88 return NULL; 89 } 90 91 int CompilerToVM::Data::Klass_vtable_start_offset; 92 int CompilerToVM::Data::Klass_vtable_length_offset; 93 94 int CompilerToVM::Data::Method_extra_stack_entries; 95 96 address CompilerToVM::Data::SharedRuntime_ic_miss_stub; 97 address CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub; 98 address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack; 99 address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap; 100 522 if (object == NULL) { 523 THROW_0(vmSymbols::java_lang_NullPointerException()); 524 } 525 if (object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 526 cp = CompilerToVM::asMethod(object)->constMethod()->constants(); 527 } else if (object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 528 cp = InstanceKlass::cast(CompilerToVM::asKlass(object))->constants(); 529 } else { 530 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 531 err_msg("Unexpected type: %s", object->klass()->external_name())); 532 } 533 assert(!cp.is_null(), "npe"); 534 JavaValue method_result(T_OBJECT); 535 JavaCallArguments args; 536 args.push_long((jlong) (address) cp()); 537 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL); 538 return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject()); 539 } 540 541 C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) 542 Klass* klass = NULL; 543 oop base_object = JNIHandles::resolve(base); 544 jlong base_address = 0; 545 if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { 546 klass = base_object->klass(); 547 } else if (!compressed) { 548 if (base_object != NULL) { 549 if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 550 base_address = HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object); 551 } else if (base_object->is_a(SystemDictionary::HotSpotConstantPool_klass())) { 552 base_address = HotSpotConstantPool::metaspaceConstantPool(base_object); 553 } else if (base_object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 554 base_address = (jlong) CompilerToVM::asKlass(base_object); 555 } else if (base_object->is_a(SystemDictionary::Class_klass())) { 556 base_address = (jlong) (address) base_object; 557 } else { 558 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 559 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 560 } 561 } 562 klass = *((Klass**) (intptr_t) (base_address + offset)); 563 } else { 564 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 565 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 566 } 567 assert (klass == NULL || klass->is_klass(), "invalid read"); 568 oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 569 return JNIHandles::make_local(THREAD, result); 570 } 571 572 C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 573 ResourceMark rm; 574 methodHandle method = CompilerToVM::asMethod(jvmci_method); 575 Klass* holder = CompilerToVM::asKlass(jvmci_type); 576 if (holder->is_interface()) { 577 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name())); 578 } 579 580 methodHandle ucm; 581 { 582 MutexLocker locker(Compile_lock); 583 ucm = Dependencies::find_unique_concrete_method(holder, method()); 584 } 585 oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL); 586 return JNIHandles::make_local(THREAD, result); 587 C2V_END 588 589 C2V_VMENTRY(jobject, getImplementor, (JNIEnv *, jobject, jobject jvmci_type)) 590 InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type); 591 oop implementor = CompilerToVM::get_jvmci_type(klass->implementor(), CHECK_NULL); 592 return JNIHandles::make_local(THREAD, implementor); 593 C2V_END 594 595 C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method)) 596 methodHandle method = CompilerToVM::asMethod(jvmci_method); 597 return method->is_ignored_by_security_stack_walk(); 598 C2V_END 599 600 C2V_VMENTRY(jboolean, isCompilable,(JNIEnv *, jobject, jobject jvmci_method)) 601 methodHandle method = CompilerToVM::asMethod(jvmci_method); 602 // Ignore the not_compilable flags in hosted mode since they are never set by 603 // the JVMCI compiler. 694 C2V_VMENTRY(jobject, lookupSignatureInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which)) 695 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 696 Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(which), CHECK_NULL); 697 return JNIHandles::make_local(THREAD, sym()); 698 C2V_END 699 700 C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 701 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 702 return cp->klass_ref_index_at(index); 703 C2V_END 704 705 C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 706 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 707 Klass* resolved_klass = cp->klass_at(index, CHECK_NULL); 708 oop klass = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); 709 return JNIHandles::make_local(THREAD, klass); 710 C2V_END 711 712 C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 713 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 714 Klass* loading_klass = cp->pool_holder(); 715 bool is_accessible = false; 716 Klass* klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); 717 Symbol* symbol = NULL; 718 if (klass == NULL) { 719 symbol = cp->klass_name_at(index); 720 } 721 oop result_oop; 722 if (klass != NULL) { 723 result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 724 } else { 725 Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); 726 result_oop = result(); 727 } 728 return JNIHandles::make_local(THREAD, result_oop); 729 C2V_END 730 731 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 732 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 733 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); 734 return JNIHandles::make_local(THREAD, appendix_oop); 735 C2V_END 736 737 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 738 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 739 InstanceKlass* pool_holder = cp->pool_holder(); 740 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); 741 methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); 742 oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); 743 return JNIHandles::make_local(THREAD, result); 744 C2V_END 745 746 C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 747 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 748 return cp->remap_instruction_operand_from_cache(index); 749 C2V_END 750 751 C2V_VMENTRY(jobject, resolveFieldInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jobject jvmci_method, jbyte opcode, jlongArray info_handle)) 752 ResourceMark rm; 753 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 754 Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); 755 fieldDescriptor fd; 756 LinkInfo link_info(cp, index, (jvmci_method != NULL) ? CompilerToVM::asMethod(jvmci_method) : NULL, CHECK_0); 757 LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0); 758 typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle); 759 assert(info != NULL && info->length() == 2, "must be"); 763 return JNIHandles::make_local(THREAD, field_holder); 764 C2V_END 765 766 C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 767 ResourceMark rm; 768 Klass* klass = CompilerToVM::asKlass(jvmci_type); 769 Method* method = CompilerToVM::asMethod(jvmci_method); 770 if (klass->is_interface()) { 771 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", klass->external_name())); 772 } 773 if (!method->method_holder()->is_interface()) { 774 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string())); 775 } 776 if (!InstanceKlass::cast(klass)->is_linked()) { 777 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Class %s must be linked", klass->external_name())); 778 } 779 return LinkResolver::vtable_index_of_interface_method(klass, method); 780 C2V_END 781 782 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) 783 Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); 784 Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type); 785 methodHandle method = CompilerToVM::asMethod(jvmci_method); 786 787 Klass* resolved = method->method_holder(); 788 Symbol* h_name = method->name(); 789 Symbol* h_signature = method->signature(); 790 791 if (MethodHandles::is_signature_polymorphic_method(method())) { 792 // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case. 793 return NULL; 794 } 795 796 LinkInfo link_info(resolved, h_name, h_signature, caller_klass); 797 methodHandle m; 798 // Only do exact lookup if receiver klass has been linked. Otherwise, 799 // the vtable has not been setup, and the LinkResolver will fail. 800 if (recv_klass->is_array_klass() || 801 InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface()) { 802 if (resolved->is_interface()) { 803 m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); 804 } else { 805 m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); 806 } 807 } 808 809 if (m.is_null()) { 810 // Return NULL if there was a problem with lookup (uninitialized class, etc.) 811 return NULL; 812 } 813 814 oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL); 815 return JNIHandles::make_local(THREAD, result); 816 C2V_END 817 818 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type)) 819 Klass* klass = CompilerToVM::asKlass(jvmci_type); 820 assert(klass != NULL, "method must not be called for primitive types"); 821 return Dependencies::find_finalizable_subclass(klass) != NULL; 822 C2V_END 1325 } 1326 fst.next(); 1327 vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); 1328 frame_number = 0; 1329 } // end of frame loop 1330 1331 // the end was reached without finding a matching method 1332 return NULL; 1333 C2V_END 1334 1335 C2V_VMENTRY(void, resolveInvokeDynamicInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1336 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1337 CallInfo callInfo; 1338 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokedynamic, CHECK); 1339 ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); 1340 cp_cache_entry->set_dynamic_call(cp, callInfo); 1341 C2V_END 1342 1343 C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1344 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1345 Klass* holder = cp->klass_ref_at(index, CHECK); 1346 Symbol* name = cp->name_ref_at(index); 1347 if (MethodHandles::is_signature_polymorphic_name(holder, name)) { 1348 CallInfo callInfo; 1349 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); 1350 ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index)); 1351 cp_cache_entry->set_method_handle(cp, callInfo); 1352 } 1353 C2V_END 1354 1355 C2V_VMENTRY(jobject, getSignaturePolymorphicHolders, (JNIEnv*, jobject)) 1356 objArrayHandle holders = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), 2, CHECK_NULL); 1357 Handle mh = java_lang_String::create_from_str("Ljava/lang/invoke/MethodHandle;", CHECK_NULL); 1358 Handle vh = java_lang_String::create_from_str("Ljava/lang/invoke/VarHandle;", CHECK_NULL); 1359 holders->obj_at_put(0, mh()); 1360 holders->obj_at_put(1, vh()); 1361 return JNIHandles::make_local(THREAD, holders()); 1362 C2V_END 1363 1364 C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject)) 1365 //see compute_recording_non_safepoints in debugInfroRec.cpp 1366 if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { 1367 return true; 1368 } 1369 return DebugNonSafepoints; 1370 C2V_END |