src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
changeset 47668 fc4cfca10556
parent 47580 96392e113a0a
child 47765 b7c7428eaab9
equal deleted inserted replaced
47667:390896759aa2 47668:fc4cfca10556
  1116     HotSpotMetaData::set_oopMaps(metadata_handle, oopMapArrayHandle());
  1116     HotSpotMetaData::set_oopMaps(metadata_handle, oopMapArrayHandle());
  1117   }
  1117   }
  1118 
  1118 
  1119   AOTOopRecorder* recorder = code_metadata.get_oop_recorder();
  1119   AOTOopRecorder* recorder = code_metadata.get_oop_recorder();
  1120 
  1120 
  1121   int nr_meta_strings = recorder->nr_meta_strings();
  1121   int nr_meta_refs = recorder->nr_meta_refs();
  1122   objArrayOop metadataArray = oopFactory::new_objectArray(nr_meta_strings, CHECK_(JVMCIEnv::cache_full));
  1122   objArrayOop metadataArray = oopFactory::new_objectArray(nr_meta_refs, CHECK_(JVMCIEnv::cache_full));
  1123   objArrayHandle metadataArrayHandle(THREAD, metadataArray);
  1123   objArrayHandle metadataArrayHandle(THREAD, metadataArray);
  1124   for (int i = 0; i < nr_meta_strings; ++i) {
  1124   for (int i = 0; i < nr_meta_refs; ++i) {
  1125     const char* element = recorder->meta_element(i);
  1125     jobject element = recorder->meta_element(i);
  1126     Handle java_string = java_lang_String::create_from_str(element, CHECK_(JVMCIEnv::cache_full));
  1126     if (element == NULL) {
  1127     metadataArrayHandle->obj_at_put(i, java_string());
  1127       return JVMCIEnv::cache_full;
       
  1128     }
       
  1129     metadataArrayHandle->obj_at_put(i, JNIHandles::resolve(element));
  1128   }
  1130   }
  1129   HotSpotMetaData::set_metadata(metadata_handle, metadataArrayHandle());
  1131   HotSpotMetaData::set_metadata(metadata_handle, metadataArrayHandle());
  1130 
  1132 
  1131   ExceptionHandlerTable* handler = code_metadata.get_exception_table();
  1133   ExceptionHandlerTable* handler = code_metadata.get_exception_table();
  1132   int table_size = handler->size_in_bytes();
  1134   int table_size = handler->size_in_bytes();
  1516     LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK);
  1518     LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK);
  1517     ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
  1519     ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
  1518     cp_cache_entry->set_method_handle(cp, callInfo);
  1520     cp_cache_entry->set_method_handle(cp, callInfo);
  1519   }
  1521   }
  1520 C2V_END
  1522 C2V_END
       
  1523 
       
  1524 C2V_VMENTRY(jint, isResolvedInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
       
  1525   constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
       
  1526   ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
       
  1527   if (cp_cache_entry->is_resolved(Bytecodes::_invokehandle)) {
       
  1528     // MethodHandle.invoke* --> LambdaForm?
       
  1529     ResourceMark rm;
       
  1530 
       
  1531     LinkInfo link_info(cp, index, CATCH);
       
  1532 
       
  1533     Klass* resolved_klass = link_info.resolved_klass();
       
  1534 
       
  1535     Symbol* name_sym = cp->name_ref_at(index);
       
  1536 
       
  1537     vmassert(MethodHandles::is_method_handle_invoke_name(resolved_klass, name_sym), "!");
       
  1538     vmassert(MethodHandles::is_signature_polymorphic_name(resolved_klass, name_sym), "!");
       
  1539 
       
  1540     methodHandle adapter_method(cp_cache_entry->f1_as_method());
       
  1541 
       
  1542     methodHandle resolved_method(adapter_method);
       
  1543 
       
  1544     // Can we treat it as a regular invokevirtual?
       
  1545     if (resolved_method->method_holder() == resolved_klass && resolved_method->name() == name_sym) {
       
  1546       vmassert(!resolved_method->is_static(),"!");
       
  1547       vmassert(MethodHandles::is_signature_polymorphic_method(resolved_method()),"!");
       
  1548       vmassert(!MethodHandles::is_signature_polymorphic_static(resolved_method->intrinsic_id()), "!");
       
  1549       vmassert(cp_cache_entry->appendix_if_resolved(cp) == NULL, "!");
       
  1550       vmassert(cp_cache_entry->method_type_if_resolved(cp) == NULL, "!");
       
  1551 
       
  1552       methodHandle m(LinkResolver::linktime_resolve_virtual_method_or_null(link_info));
       
  1553       vmassert(m == resolved_method, "!!");
       
  1554       return -1;
       
  1555     }
       
  1556 
       
  1557     return Bytecodes::_invokevirtual;
       
  1558   }
       
  1559   if (cp_cache_entry->is_resolved(Bytecodes::_invokedynamic)) {
       
  1560     return Bytecodes::_invokedynamic;
       
  1561   }
       
  1562   return -1;
       
  1563 C2V_END
       
  1564 
  1521 
  1565 
  1522 C2V_VMENTRY(jobject, getSignaturePolymorphicHolders, (JNIEnv*, jobject))
  1566 C2V_VMENTRY(jobject, getSignaturePolymorphicHolders, (JNIEnv*, jobject))
  1523   objArrayHandle holders = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), 2, CHECK_NULL);
  1567   objArrayHandle holders = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), 2, CHECK_NULL);
  1524   Handle mh = java_lang_String::create_from_str("Ljava/lang/invoke/MethodHandle;", CHECK_NULL);
  1568   Handle mh = java_lang_String::create_from_str("Ljava/lang/invoke/MethodHandle;", CHECK_NULL);
  1525   Handle vh = java_lang_String::create_from_str("Ljava/lang/invoke/VarHandle;", CHECK_NULL);
  1569   Handle vh = java_lang_String::create_from_str("Ljava/lang/invoke/VarHandle;", CHECK_NULL);
  1793   {CC "resolvePossiblyCachedConstantInPool",          CC "(" HS_CONSTANT_POOL "I)" OBJECT,                                                  FN_PTR(resolvePossiblyCachedConstantInPool)},
  1837   {CC "resolvePossiblyCachedConstantInPool",          CC "(" HS_CONSTANT_POOL "I)" OBJECT,                                                  FN_PTR(resolvePossiblyCachedConstantInPool)},
  1794   {CC "resolveTypeInPool",                            CC "(" HS_CONSTANT_POOL "I)" HS_RESOLVED_KLASS,                                       FN_PTR(resolveTypeInPool)},
  1838   {CC "resolveTypeInPool",                            CC "(" HS_CONSTANT_POOL "I)" HS_RESOLVED_KLASS,                                       FN_PTR(resolveTypeInPool)},
  1795   {CC "resolveFieldInPool",                           CC "(" HS_CONSTANT_POOL "I" HS_RESOLVED_METHOD "B[I)" HS_RESOLVED_KLASS,              FN_PTR(resolveFieldInPool)},
  1839   {CC "resolveFieldInPool",                           CC "(" HS_CONSTANT_POOL "I" HS_RESOLVED_METHOD "B[I)" HS_RESOLVED_KLASS,              FN_PTR(resolveFieldInPool)},
  1796   {CC "resolveInvokeDynamicInPool",                   CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeDynamicInPool)},
  1840   {CC "resolveInvokeDynamicInPool",                   CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeDynamicInPool)},
  1797   {CC "resolveInvokeHandleInPool",                    CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeHandleInPool)},
  1841   {CC "resolveInvokeHandleInPool",                    CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeHandleInPool)},
       
  1842   {CC "isResolvedInvokeHandleInPool",                 CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(isResolvedInvokeHandleInPool)},
  1798   {CC "resolveMethod",                                CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD, FN_PTR(resolveMethod)},
  1843   {CC "resolveMethod",                                CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD, FN_PTR(resolveMethod)},
  1799   {CC "getSignaturePolymorphicHolders",               CC "()[" STRING,                                                                      FN_PTR(getSignaturePolymorphicHolders)},
  1844   {CC "getSignaturePolymorphicHolders",               CC "()[" STRING,                                                                      FN_PTR(getSignaturePolymorphicHolders)},
  1800   {CC "getVtableIndexForInterfaceMethod",             CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD ")I",                                     FN_PTR(getVtableIndexForInterfaceMethod)},
  1845   {CC "getVtableIndexForInterfaceMethod",             CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD ")I",                                     FN_PTR(getVtableIndexForInterfaceMethod)},
  1801   {CC "getClassInitializer",                          CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD,                                      FN_PTR(getClassInitializer)},
  1846   {CC "getClassInitializer",                          CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD,                                      FN_PTR(getClassInitializer)},
  1802   {CC "hasFinalizableSubclass",                       CC "(" HS_RESOLVED_KLASS ")Z",                                                        FN_PTR(hasFinalizableSubclass)},
  1847   {CC "hasFinalizableSubclass",                       CC "(" HS_RESOLVED_KLASS ")Z",                                                        FN_PTR(hasFinalizableSubclass)},