1 /* 2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "code/codeCache.hpp" 26 #include "code/scopeDesc.hpp" 27 #include "interpreter/linkResolver.hpp" 28 #include "memory/oopFactory.hpp" 29 #include "oops/generateOopMap.hpp" 30 #include "oops/fieldStreams.hpp" 31 #include "oops/oop.inline.hpp" 32 #include "oops/objArrayOop.inline.hpp" 33 #include "runtime/fieldDescriptor.hpp" 34 #include "runtime/javaCalls.hpp" 35 #include "jvmci/jvmciRuntime.hpp" 36 #include "compiler/abstractCompiler.hpp" 37 #include "compiler/compileBroker.hpp" 38 #include "compiler/compilerOracle.hpp" 39 #include "compiler/disassembler.hpp" 40 #include "compiler/oopMap.hpp" 41 #include "jvmci/jvmciCompilerToVM.hpp" 42 #include "jvmci/jvmciCompiler.hpp" 43 #include "jvmci/jvmciEnv.hpp" 44 #include "jvmci/jvmciJavaClasses.hpp" 45 #include "jvmci/jvmciCodeInstaller.hpp" 46 #include "gc/g1/heapRegion.hpp" 47 #include "runtime/javaCalls.hpp" 48 #include "runtime/deoptimization.hpp" 49 #include "runtime/vframe.hpp" 50 #include "runtime/vframe_hp.hpp" 51 #include "runtime/vmStructs.hpp" 52 53 54 // Entry to native method implementation that transitions current thread to '_thread_in_vm'. 55 #define C2V_VMENTRY(result_type, name, signature) \ 56 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ 57 TRACE_jvmci_1("CompilerToVM::" #name); \ 58 TRACE_CALL(result_type, jvmci_ ## name signature) \ 59 JVMCI_VM_ENTRY_MARK; \ 60 61 #define C2V_END } 62 63 oop CompilerToVM::get_jvmci_method(const methodHandle& method, TRAPS) { 64 if (method() != NULL) { 65 JavaValue result(T_OBJECT); 66 JavaCallArguments args; 67 args.push_long((jlong) (address) method()); 68 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_NULL); 69 70 return (oop)result.get_jobject(); 71 } 72 return NULL; 73 } 74 75 oop CompilerToVM::get_jvmci_type(KlassHandle klass, TRAPS) { 76 if (klass() != NULL) { 77 JavaValue result(T_OBJECT); 78 JavaCallArguments args; 79 args.push_oop(klass->java_mirror()); 80 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL); 81 82 return (oop)result.get_jobject(); 83 } 84 return NULL; 85 } 86 87 void CompilerToVM::invalidate_installed_code(Handle installedCode, TRAPS) { 88 if (installedCode() == NULL) { 89 THROW(vmSymbols::java_lang_NullPointerException()); 90 } 91 jlong nativeMethod = InstalledCode::address(installedCode); 92 nmethod* nm = (nmethod*)nativeMethod; 93 assert(nm == NULL || nm->jvmci_installed_code() == installedCode(), "sanity check"); 94 if (nm != NULL && nm->is_alive()) { 95 // The nmethod state machinery maintains the link between the 96 // HotSpotInstalledCode and nmethod* so as long as the nmethod appears to be 97 // alive assume there is work to do and deoptimize the nmethod. 98 nm->mark_for_deoptimization(); 99 VM_Deoptimize op; 100 VMThread::execute(&op); 101 } 102 InstalledCode::set_address(installedCode, 0); 103 } 104 105 extern "C" { 106 extern VMStructEntry* gHotSpotVMStructs; 107 extern uint64_t gHotSpotVMStructEntryTypeNameOffset; 108 extern uint64_t gHotSpotVMStructEntryFieldNameOffset; 109 extern uint64_t gHotSpotVMStructEntryTypeStringOffset; 110 extern uint64_t gHotSpotVMStructEntryIsStaticOffset; 111 extern uint64_t gHotSpotVMStructEntryOffsetOffset; 112 extern uint64_t gHotSpotVMStructEntryAddressOffset; 113 extern uint64_t gHotSpotVMStructEntryArrayStride; 114 115 extern VMTypeEntry* gHotSpotVMTypes; 116 extern uint64_t gHotSpotVMTypeEntryTypeNameOffset; 117 extern uint64_t gHotSpotVMTypeEntrySuperclassNameOffset; 118 extern uint64_t gHotSpotVMTypeEntryIsOopTypeOffset; 119 extern uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset; 120 extern uint64_t gHotSpotVMTypeEntryIsUnsignedOffset; 121 extern uint64_t gHotSpotVMTypeEntrySizeOffset; 122 extern uint64_t gHotSpotVMTypeEntryArrayStride; 123 124 extern VMIntConstantEntry* gHotSpotVMIntConstants; 125 extern uint64_t gHotSpotVMIntConstantEntryNameOffset; 126 extern uint64_t gHotSpotVMIntConstantEntryValueOffset; 127 extern uint64_t gHotSpotVMIntConstantEntryArrayStride; 128 129 extern VMLongConstantEntry* gHotSpotVMLongConstants; 130 extern uint64_t gHotSpotVMLongConstantEntryNameOffset; 131 extern uint64_t gHotSpotVMLongConstantEntryValueOffset; 132 extern uint64_t gHotSpotVMLongConstantEntryArrayStride; 133 134 extern VMAddressEntry* gHotSpotVMAddresses; 135 extern uint64_t gHotSpotVMAddressEntryNameOffset; 136 extern uint64_t gHotSpotVMAddressEntryValueOffset; 137 extern uint64_t gHotSpotVMAddressEntryArrayStride; 138 } 139 140 // FIXME This is only temporary until the GC code is changed. 141 bool CompilerToVM::_supports_inline_contig_alloc; 142 HeapWord** CompilerToVM::_heap_end_addr; 143 HeapWord** CompilerToVM::_heap_top_addr; 144 145 /** 146 * We put all gHotSpotVM values in an array so we can read them easily from Java. 147 */ 148 static uintptr_t ciHotSpotVMData[28]; 149 150 C2V_VMENTRY(jlong, initializeConfiguration, (JNIEnv *env, jobject)) 151 ciHotSpotVMData[0] = (uintptr_t) gHotSpotVMStructs; 152 ciHotSpotVMData[1] = gHotSpotVMStructEntryTypeNameOffset; 153 ciHotSpotVMData[2] = gHotSpotVMStructEntryFieldNameOffset; 154 ciHotSpotVMData[3] = gHotSpotVMStructEntryTypeStringOffset; 155 ciHotSpotVMData[4] = gHotSpotVMStructEntryIsStaticOffset; 156 ciHotSpotVMData[5] = gHotSpotVMStructEntryOffsetOffset; 157 ciHotSpotVMData[6] = gHotSpotVMStructEntryAddressOffset; 158 ciHotSpotVMData[7] = gHotSpotVMStructEntryArrayStride; 159 160 ciHotSpotVMData[8] = (uintptr_t) gHotSpotVMTypes; 161 ciHotSpotVMData[9] = gHotSpotVMTypeEntryTypeNameOffset; 162 ciHotSpotVMData[10] = gHotSpotVMTypeEntrySuperclassNameOffset; 163 ciHotSpotVMData[11] = gHotSpotVMTypeEntryIsOopTypeOffset; 164 ciHotSpotVMData[12] = gHotSpotVMTypeEntryIsIntegerTypeOffset; 165 ciHotSpotVMData[13] = gHotSpotVMTypeEntryIsUnsignedOffset; 166 ciHotSpotVMData[14] = gHotSpotVMTypeEntrySizeOffset; 167 ciHotSpotVMData[15] = gHotSpotVMTypeEntryArrayStride; 168 169 ciHotSpotVMData[16] = (uintptr_t) gHotSpotVMIntConstants; 170 ciHotSpotVMData[17] = gHotSpotVMIntConstantEntryNameOffset; 171 ciHotSpotVMData[18] = gHotSpotVMIntConstantEntryValueOffset; 172 ciHotSpotVMData[19] = gHotSpotVMIntConstantEntryArrayStride; 173 174 ciHotSpotVMData[20] = (uintptr_t) gHotSpotVMLongConstants; 175 ciHotSpotVMData[21] = gHotSpotVMLongConstantEntryNameOffset; 176 ciHotSpotVMData[22] = gHotSpotVMLongConstantEntryValueOffset; 177 ciHotSpotVMData[23] = gHotSpotVMLongConstantEntryArrayStride; 178 179 ciHotSpotVMData[24] = (uintptr_t) gHotSpotVMAddresses; 180 ciHotSpotVMData[25] = gHotSpotVMAddressEntryNameOffset; 181 ciHotSpotVMData[26] = gHotSpotVMAddressEntryValueOffset; 182 ciHotSpotVMData[27] = gHotSpotVMAddressEntryArrayStride; 183 184 // FIXME This is only temporary until the GC code is changed. 185 CompilerToVM::_supports_inline_contig_alloc = Universe::heap()->supports_inline_contig_alloc(); 186 CompilerToVM::_heap_end_addr = CompilerToVM::_supports_inline_contig_alloc ? Universe::heap()->end_addr() : (HeapWord**) -1; 187 CompilerToVM::_heap_top_addr = CompilerToVM::_supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord**) -1; 188 189 return (jlong) (address) &ciHotSpotVMData; 190 C2V_END 191 192 C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jobject jvmci_method)) 193 methodHandle method = CompilerToVM::asMethod(jvmci_method); 194 ResourceMark rm; 195 196 int code_size = method->code_size(); 197 typeArrayOop reconstituted_code = oopFactory::new_byteArray(code_size, CHECK_NULL); 198 199 guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten"); 200 // iterate over all bytecodes and replace non-Java bytecodes 201 202 for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) { 203 Bytecodes::Code code = s.code(); 204 Bytecodes::Code raw_code = s.raw_code(); 205 int bci = s.bci(); 206 int len = s.instruction_size(); 207 208 // Restore original byte code. 209 reconstituted_code->byte_at_put(bci, (jbyte) (s.is_wide()? Bytecodes::_wide : code)); 210 if (len > 1) { 211 memcpy(reconstituted_code->byte_at_addr(bci + 1), s.bcp()+1, len-1); 212 } 213 214 if (len > 1) { 215 // Restore the big-endian constant pool indexes. 216 // Cf. Rewriter::scan_method 217 switch (code) { 218 case Bytecodes::_getstatic: 219 case Bytecodes::_putstatic: 220 case Bytecodes::_getfield: 221 case Bytecodes::_putfield: 222 case Bytecodes::_invokevirtual: 223 case Bytecodes::_invokespecial: 224 case Bytecodes::_invokestatic: 225 case Bytecodes::_invokeinterface: 226 case Bytecodes::_invokehandle: { 227 int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); 228 Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); 229 break; 230 } 231 232 case Bytecodes::_invokedynamic: 233 int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1)); 234 Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index); 235 break; 236 } 237 238 // Not all ldc byte code are rewritten. 239 switch (raw_code) { 240 case Bytecodes::_fast_aldc: { 241 int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff; 242 int cp_index = method->constants()->object_to_cp_index(cpc_index); 243 assert(cp_index < method->constants()->length(), "sanity check"); 244 reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index); 245 break; 246 } 247 248 case Bytecodes::_fast_aldc_w: { 249 int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); 250 int cp_index = method->constants()->object_to_cp_index(cpc_index); 251 assert(cp_index < method->constants()->length(), "sanity check"); 252 Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); 253 break; 254 } 255 } 256 } 257 } 258 259 return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code); 260 C2V_END 261 262 C2V_VMENTRY(jint, getExceptionTableLength, (JNIEnv *, jobject, jobject jvmci_method)) 263 ResourceMark rm; 264 methodHandle method = CompilerToVM::asMethod(jvmci_method); 265 return method->exception_table_length(); 266 C2V_END 267 268 C2V_VMENTRY(jlong, getExceptionTableStart, (JNIEnv *, jobject, jobject jvmci_method)) 269 ResourceMark rm; 270 methodHandle method = CompilerToVM::asMethod(jvmci_method); 271 if (method->exception_table_length() == 0) { 272 return 0L; 273 } 274 return (jlong) (address) method->exception_table_start(); 275 C2V_END 276 277 C2V_VMENTRY(jobject, getResolvedJavaMethodAtSlot, (JNIEnv *, jobject, jclass holder_handle, jint slot)) 278 oop java_class = JNIHandles::resolve(holder_handle); 279 Klass* holder = java_lang_Class::as_Klass(java_class); 280 methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot); 281 oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); 282 return JNIHandles::make_local(THREAD, result); 283 } 284 285 C2V_VMENTRY(jobject, getResolvedJavaMethod, (JNIEnv *, jobject, jobject base, jlong offset)) 286 methodHandle method; 287 oop base_object = JNIHandles::resolve(base); 288 if (base_object == NULL) { 289 method = *((Method**)(offset)); 290 } else if (base_object->is_a(SystemDictionary::MemberName_klass())) { 291 method = (Method*) (intptr_t) base_object->long_field(offset); 292 } else if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 293 method = *((Method**)(HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object) + offset)); 294 } else { 295 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 296 err_msg("Unexpected type: %s", base_object->klass()->external_name())); 297 } 298 assert (method.is_null() || method->is_method(), "invalid read"); 299 oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); 300 return JNIHandles::make_local(THREAD, result); 301 } 302 303 C2V_VMENTRY(jobject, getConstantPool, (JNIEnv *, jobject, jobject base, jlong offset)) 304 constantPoolHandle cp; 305 oop base_object = JNIHandles::resolve(base); 306 jlong base_address = 0; 307 if (base_object != NULL) { 308 if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 309 base_address = HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object); 310 } else if (base_object->is_a(SystemDictionary::HotSpotConstantPool_klass())) { 311 base_address = HotSpotConstantPool::metaspaceConstantPool(base_object); 312 } else if (base_object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 313 base_address = (jlong) CompilerToVM::asKlass(base_object); 314 } else { 315 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 316 err_msg("Unexpected type: %s", base_object->klass()->external_name())); 317 } 318 } 319 cp = *((ConstantPool**) (intptr_t) (base_address + offset)); 320 if (!cp.is_null()) { 321 JavaValue method_result(T_OBJECT); 322 JavaCallArguments args; 323 args.push_long((jlong) (address) cp()); 324 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL); 325 return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject()); 326 } 327 return NULL; 328 } 329 330 C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) 331 KlassHandle klass; 332 oop base_object = JNIHandles::resolve(base); 333 jlong base_address = 0; 334 if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { 335 klass = base_object->klass(); 336 } else if (!compressed) { 337 if (base_object != NULL) { 338 if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { 339 base_address = HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object); 340 } else if (base_object->is_a(SystemDictionary::HotSpotConstantPool_klass())) { 341 base_address = HotSpotConstantPool::metaspaceConstantPool(base_object); 342 } else if (base_object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { 343 base_address = (jlong) CompilerToVM::asKlass(base_object); 344 } else if (base_object->is_a(SystemDictionary::Class_klass())) { 345 base_address = (jlong) (address) base_object; 346 } else { 347 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 348 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 349 } 350 } 351 klass = *((Klass**) (intptr_t) (base_address + offset)); 352 } else { 353 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), 354 err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false")); 355 } 356 assert (klass.is_null() || klass->is_klass(), "invalid read"); 357 oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 358 return JNIHandles::make_local(THREAD, result); 359 } 360 361 C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 362 ResourceMark rm; 363 methodHandle method = CompilerToVM::asMethod(jvmci_method); 364 KlassHandle holder = CompilerToVM::asKlass(jvmci_type); 365 if (holder->is_interface()) { 366 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name())); 367 } 368 369 methodHandle ucm; 370 { 371 MutexLocker locker(Compile_lock); 372 ucm = Dependencies::find_unique_concrete_method(holder(), method()); 373 } 374 oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL); 375 return JNIHandles::make_local(THREAD, result); 376 C2V_END 377 378 C2V_VMENTRY(jobject, getImplementor, (JNIEnv *, jobject, jobject jvmci_type)) 379 InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type); 380 oop implementor = CompilerToVM::get_jvmci_type(klass->implementor(), CHECK_NULL); 381 return JNIHandles::make_local(THREAD, implementor); 382 C2V_END 383 384 C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method)) 385 methodHandle method = CompilerToVM::asMethod(jvmci_method); 386 return method->is_ignored_by_security_stack_walk(); 387 C2V_END 388 389 C2V_VMENTRY(jboolean, canInlineMethod,(JNIEnv *, jobject, jobject jvmci_method)) 390 methodHandle method = CompilerToVM::asMethod(jvmci_method); 391 return !method->is_not_compilable() && !CompilerOracle::should_not_inline(method) && !method->dont_inline(); 392 C2V_END 393 394 C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jobject jvmci_method)) 395 methodHandle method = CompilerToVM::asMethod(jvmci_method); 396 return CompilerOracle::should_inline(method) || method->force_inline(); 397 C2V_END 398 399 C2V_VMENTRY(jobject, lookupType, (JNIEnv*, jobject, jstring jname, jclass accessing_class, jboolean resolve)) 400 ResourceMark rm; 401 Handle name = JNIHandles::resolve(jname); 402 Symbol* class_name = java_lang_String::as_symbol(name, CHECK_0); 403 if (java_lang_String::length(name()) <= 1) { 404 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string())); 405 } 406 407 Klass* resolved_klass = NULL; 408 Handle class_loader; 409 Handle protection_domain; 410 if (JNIHandles::resolve(accessing_class) == NULL) { 411 THROW_0(vmSymbols::java_lang_NullPointerException()); 412 } 413 Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); 414 class_loader = accessing_klass->class_loader(); 415 protection_domain = accessing_klass->protection_domain(); 416 417 if (resolve) { 418 resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0); 419 } else { 420 if (class_name->byte_at(0) == 'L' && 421 class_name->byte_at(class_name->utf8_length()-1) == ';') { 422 // This is a name from a signature. Strip off the trimmings. 423 // Call recursive to keep scope of strippedsym. 424 TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1, 425 class_name->utf8_length()-2, 426 CHECK_0); 427 resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0); 428 } else if (FieldType::is_array(class_name)) { 429 FieldArrayInfo fd; 430 // dimension and object_key in FieldArrayInfo are assigned as a side-effect 431 // of this call 432 BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0); 433 if (t == T_OBJECT) { 434 TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(), 435 class_name->utf8_length()-2-fd.dimension(), 436 CHECK_0); 437 // naked oop "k" is OK here -- we assign back into it 438 resolved_klass = SystemDictionary::find(strippedsym, 439 class_loader, 440 protection_domain, 441 CHECK_0); 442 if (resolved_klass != NULL) { 443 resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0); 444 } 445 } else { 446 resolved_klass = Universe::typeArrayKlassObj(t); 447 resolved_klass = TypeArrayKlass::cast(resolved_klass)->array_klass(fd.dimension(), CHECK_0); 448 } 449 } 450 } 451 Handle result = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); 452 return JNIHandles::make_local(THREAD, result()); 453 C2V_END 454 455 C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 456 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 457 oop result = cp->resolve_constant_at(index, CHECK_NULL); 458 return JNIHandles::make_local(THREAD, result); 459 C2V_END 460 461 C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 462 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 463 oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); 464 return JNIHandles::make_local(THREAD, result); 465 C2V_END 466 467 C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 468 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 469 return cp->name_and_type_ref_index_at(index); 470 C2V_END 471 472 C2V_VMENTRY(jobject, lookupNameInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which)) 473 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 474 Handle sym = java_lang_String::create_from_symbol(cp->name_ref_at(which), CHECK_NULL); 475 return JNIHandles::make_local(THREAD, sym()); 476 C2V_END 477 478 C2V_VMENTRY(jobject, lookupSignatureInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which)) 479 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 480 Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(which), CHECK_NULL); 481 return JNIHandles::make_local(THREAD, sym()); 482 C2V_END 483 484 C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 485 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 486 return cp->klass_ref_index_at(index); 487 C2V_END 488 489 C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 490 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 491 Klass* resolved_klass = cp->klass_at(index, CHECK_NULL); 492 Handle klass = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); 493 return JNIHandles::make_local(THREAD, klass()); 494 C2V_END 495 496 C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 497 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 498 KlassHandle loading_klass(cp->pool_holder()); 499 bool is_accessible = false; 500 KlassHandle klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); 501 Symbol* symbol = NULL; 502 if (klass.is_null()) { 503 symbol = cp->klass_name_at(index); 504 } 505 Handle result; 506 if (!klass.is_null()) { 507 result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); 508 } else { 509 result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); 510 } 511 return JNIHandles::make_local(THREAD, result()); 512 C2V_END 513 514 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 515 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 516 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); 517 return JNIHandles::make_local(THREAD, appendix_oop); 518 C2V_END 519 520 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) 521 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 522 instanceKlassHandle pool_holder(cp->pool_holder()); 523 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); 524 methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); 525 oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL); 526 return JNIHandles::make_local(THREAD, result); 527 C2V_END 528 529 C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 530 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 531 return cp->remap_instruction_operand_from_cache(index); 532 C2V_END 533 534 C2V_VMENTRY(jobject, resolveFieldInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode, jlongArray info_handle)) 535 ResourceMark rm; 536 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 537 Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); 538 fieldDescriptor fd; 539 LinkInfo link_info(cp, index, CHECK_0); 540 LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0); 541 typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle); 542 assert(info != NULL && info->length() == 2, "must be"); 543 info->long_at_put(0, (jlong) fd.access_flags().as_int()); 544 info->long_at_put(1, (jlong) fd.offset()); 545 oop field_holder = CompilerToVM::get_jvmci_type(fd.field_holder(), CHECK_NULL); 546 return JNIHandles::make_local(THREAD, field_holder); 547 C2V_END 548 549 C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) 550 ResourceMark rm; 551 Klass* klass = CompilerToVM::asKlass(jvmci_type); 552 Method* method = CompilerToVM::asMethod(jvmci_method); 553 if (klass->is_interface()) { 554 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", klass->external_name())); 555 } 556 if (!method->method_holder()->is_interface()) { 557 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())); 558 } 559 if (!InstanceKlass::cast(klass)->is_linked()) { 560 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Class %s must be linked", klass->external_name())); 561 } 562 return LinkResolver::vtable_index_of_interface_method(klass, method); 563 C2V_END 564 565 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) 566 Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); 567 Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type); 568 Method* method = CompilerToVM::asMethod(jvmci_method); 569 570 if (recv_klass->is_array_klass() || (InstanceKlass::cast(recv_klass)->is_linked())) { 571 Klass* holder_klass = method->method_holder(); 572 Symbol* method_name = method->name(); 573 Symbol* method_signature = method->signature(); 574 575 if (holder_klass->is_interface()) { 576 // do link-time resolution to check all access rules. 577 LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true); 578 methodHandle resolved_method = LinkResolver::linktime_resolve_interface_method_or_null(link_info); 579 if (resolved_method.is_null() || resolved_method->is_private()) { 580 return NULL; 581 } 582 assert(recv_klass->is_subtype_of(holder_klass), ""); 583 // do actual lookup 584 methodHandle sel_method = LinkResolver::lookup_instance_method_in_klasses(recv_klass, resolved_method->name(), resolved_method->signature(), CHECK_AND_CLEAR_0); 585 oop result = CompilerToVM::get_jvmci_method(sel_method, CHECK_NULL); 586 return JNIHandles::make_local(THREAD, result); 587 } else { 588 // do link-time resolution to check all access rules. 589 LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true); 590 methodHandle resolved_method = LinkResolver::linktime_resolve_virtual_method_or_null(link_info); 591 if (resolved_method.is_null()) { 592 return NULL; 593 } 594 // do actual lookup (see LinkResolver::runtime_resolve_virtual_method) 595 int vtable_index = Method::invalid_vtable_index; 596 Method* selected_method; 597 598 if (resolved_method->method_holder()->is_interface()) { // miranda method 599 vtable_index = LinkResolver::vtable_index_of_interface_method(holder_klass, resolved_method); 600 assert(vtable_index >= 0 , "we should have valid vtable index at this point"); 601 602 InstanceKlass* inst = InstanceKlass::cast(recv_klass); 603 selected_method = inst->method_at_vtable(vtable_index); 604 } else { 605 // at this point we are sure that resolved_method is virtual and not 606 // a miranda method; therefore, it must have a valid vtable index. 607 assert(!resolved_method->has_itable_index(), ""); 608 vtable_index = resolved_method->vtable_index(); 609 // We could get a negative vtable_index for final methods, 610 // because as an optimization they are they are never put in the vtable, 611 // unless they override an existing method. 612 // If we do get a negative, it means the resolved method is the the selected 613 // method, and it can never be changed by an override. 614 if (vtable_index == Method::nonvirtual_vtable_index) { 615 assert(resolved_method->can_be_statically_bound(), "cannot override this method"); 616 selected_method = resolved_method(); 617 } else { 618 // recv_klass might be an arrayKlassOop but all vtables start at 619 // the same place. The cast is to avoid virtual call and assertion. 620 InstanceKlass* inst = (InstanceKlass*)recv_klass; 621 selected_method = inst->method_at_vtable(vtable_index); 622 } 623 } 624 oop result = CompilerToVM::get_jvmci_method(selected_method, CHECK_NULL); 625 return JNIHandles::make_local(THREAD, result); 626 } 627 } 628 return NULL; 629 C2V_END 630 631 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type)) 632 Klass* klass = CompilerToVM::asKlass(jvmci_type); 633 assert(klass != NULL, "method must not be called for primitive types"); 634 return Dependencies::find_finalizable_subclass(klass) != NULL; 635 C2V_END 636 637 C2V_VMENTRY(jobject, getClassInitializer, (JNIEnv *, jobject, jobject jvmci_type)) 638 InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type); 639 oop result = CompilerToVM::get_jvmci_method(klass->class_initializer(), CHECK_NULL); 640 return JNIHandles::make_local(THREAD, result); 641 C2V_END 642 643 C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv*, jobject, jlong addr)) 644 address target_addr = (address) addr; 645 if (target_addr != 0x0) { 646 int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); 647 int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); 648 return MAX2(ABS(off_low), ABS(off_high)); 649 } 650 return -1; 651 C2V_END 652 653 C2V_VMENTRY(void, doNotInlineOrCompile,(JNIEnv *, jobject, jobject jvmci_method)) 654 methodHandle method = CompilerToVM::asMethod(jvmci_method); 655 method->set_not_c1_compilable(); 656 method->set_not_c2_compilable(); 657 method->set_dont_inline(true); 658 C2V_END 659 660 C2V_VMENTRY(jint, installCode, (JNIEnv *jniEnv, jobject, jobject target, jobject compiled_code, jobject installed_code, jobject speculation_log)) 661 ResourceMark rm; 662 HandleMark hm; 663 Handle target_handle = JNIHandles::resolve(target); 664 Handle compiled_code_handle = JNIHandles::resolve(compiled_code); 665 CodeBlob* cb = NULL; 666 Handle installed_code_handle = JNIHandles::resolve(installed_code); 667 Handle speculation_log_handle = JNIHandles::resolve(speculation_log); 668 669 JVMCICompiler* compiler = JVMCICompiler::instance(CHECK_JNI_ERR); 670 671 TraceTime install_time("installCode", JVMCICompiler::codeInstallTimer()); 672 CodeInstaller installer; 673 JVMCIEnv::CodeInstallResult result = installer.install(compiler, target_handle, compiled_code_handle, cb, installed_code_handle, speculation_log_handle, CHECK_0); 674 675 if (PrintCodeCacheOnCompilation) { 676 stringStream s; 677 // Dump code cache into a buffer before locking the tty, 678 { 679 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 680 CodeCache::print_summary(&s, false); 681 } 682 ttyLocker ttyl; 683 tty->print_raw_cr(s.as_string()); 684 } 685 686 if (result != JVMCIEnv::ok) { 687 assert(cb == NULL, "should be"); 688 } else { 689 if (!installed_code_handle.is_null()) { 690 assert(installed_code_handle->is_a(InstalledCode::klass()), "wrong type"); 691 CompilerToVM::invalidate_installed_code(installed_code_handle, CHECK_0); 692 InstalledCode::set_address(installed_code_handle, (jlong) cb); 693 InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1); 694 if (cb->is_nmethod()) { 695 InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->as_nmethod_or_null()->verified_entry_point()); 696 } else { 697 InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->code_begin()); 698 } 699 if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { 700 HotSpotInstalledCode::set_size(installed_code_handle, cb->size()); 701 HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin()); 702 HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size()); 703 } 704 nmethod* nm = cb->as_nmethod_or_null(); 705 if (nm != NULL && installed_code_handle->is_scavengable()) { 706 assert(nm->detect_scavenge_root_oops(), "nm should be scavengable if installed_code is scavengable"); 707 if (!UseG1GC) { 708 assert(nm->on_scavenge_root_list(), "nm should be on scavengable list"); 709 } 710 } 711 } 712 } 713 return result; 714 C2V_END 715 716 C2V_VMENTRY(jint, getMetadata, (JNIEnv *jniEnv, jobject, jobject target, jobject compiled_code, jobject metadata)) 717 ResourceMark rm; 718 HandleMark hm; 719 720 Handle target_handle = JNIHandles::resolve(target); 721 Handle compiled_code_handle = JNIHandles::resolve(compiled_code); 722 Handle metadata_handle = JNIHandles::resolve(metadata); 723 724 HotSpotOopMap::klass()->initialize(thread); 725 726 CodeMetadata code_metadata; 727 CodeBlob *cb = NULL; 728 CodeInstaller installer; 729 730 JVMCIEnv::CodeInstallResult result = installer.gather_metadata(target_handle, compiled_code_handle, code_metadata, CHECK_0); //cb, pc_descs, nr_pc_descs, scopes_descs, scopes_size, reloc_buffer); 731 if (result != JVMCIEnv::ok) { 732 return result; 733 } 734 735 if (code_metadata.get_nr_pc_desc() > 0) { 736 typeArrayHandle pcArrayOop = oopFactory::new_byteArray(sizeof(PcDesc) * code_metadata.get_nr_pc_desc(), CHECK_(JVMCIEnv::cache_full)); 737 memcpy(pcArrayOop->byte_at_addr(0), code_metadata.get_pc_desc(), sizeof(PcDesc) * code_metadata.get_nr_pc_desc()); 738 HotSpotMetaData::set_pcDescBytes(metadata_handle, pcArrayOop()); 739 } 740 741 if (code_metadata.get_scopes_size() > 0) { 742 typeArrayHandle scopesArrayOop = oopFactory::new_byteArray(code_metadata.get_scopes_size(), CHECK_(JVMCIEnv::cache_full)); 743 memcpy(scopesArrayOop->byte_at_addr(0), code_metadata.get_scopes_desc(), code_metadata.get_scopes_size()); 744 HotSpotMetaData::set_scopesDescBytes(metadata_handle, scopesArrayOop()); 745 } 746 747 RelocBuffer* reloc_buffer = code_metadata.get_reloc_buffer(); 748 typeArrayHandle relocArrayOop = oopFactory::new_byteArray((int) reloc_buffer->size(), CHECK_(JVMCIEnv::cache_full)); 749 if (reloc_buffer->size() > 0) { 750 memcpy(relocArrayOop->byte_at_addr(0), reloc_buffer->begin(), reloc_buffer->size()); 751 } 752 HotSpotMetaData::set_relocBytes(metadata_handle, relocArrayOop()); 753 754 const OopMapSet* oopMapSet = installer.oopMapSet(); 755 { 756 ResourceMark mark; 757 ImmutableOopMapBuilder builder(oopMapSet); 758 int oopmap_size = builder.heap_size(); 759 typeArrayHandle oopMapArrayHandle = oopFactory::new_byteArray(oopmap_size, CHECK_(JVMCIEnv::cache_full)); 760 builder.generate_into((address) oopMapArrayHandle->byte_at_addr(0)); 761 HotSpotMetaData::set_oopMaps(metadata_handle, oopMapArrayHandle()); 762 } 763 764 HotSpotMetaData::set_metadata(metadata_handle, NULL); 765 766 ExceptionHandlerTable* handler = code_metadata.get_exception_table(); 767 int table_size = handler->size_in_bytes(); 768 typeArrayHandle exceptionArrayOop = oopFactory::new_byteArray(table_size, CHECK_(JVMCIEnv::cache_full)); 769 770 if (table_size > 0) { 771 handler->copy_bytes_to((address) exceptionArrayOop->byte_at_addr(0)); 772 } 773 HotSpotMetaData::set_exceptionBytes(metadata_handle, exceptionArrayOop()); 774 775 return result; 776 C2V_END 777 778 C2V_VMENTRY(void, notifyCompilationStatistics, (JNIEnv *jniEnv, jobject, jint id, jobject hotspot_method, jboolean osr, jint processedBytecodes, jlong time, jlong timeUnitsPerSecond, jobject installed_code)) 779 JVMCICompiler* compiler = JVMCICompiler::instance(CHECK); 780 CompilerStatistics* stats = compiler->stats(); 781 782 elapsedTimer timer = elapsedTimer(time, timeUnitsPerSecond); 783 if (osr) { 784 stats->_osr.update(timer, processedBytecodes); 785 } else { 786 stats->_standard.update(timer, processedBytecodes); 787 } 788 Handle installed_code_handle = JNIHandles::resolve(installed_code); 789 if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { 790 stats->_nmethods_size += HotSpotInstalledCode::size(installed_code_handle); 791 stats->_nmethods_code_size += HotSpotInstalledCode::codeSize(installed_code_handle); 792 } 793 794 if (CITimeEach) { 795 methodHandle method = CompilerToVM::asMethod(hotspot_method); 796 float bytes_per_sec = 1.0 * processedBytecodes / timer.seconds(); 797 tty->print_cr("%3d seconds: %f bytes/sec: %f (bytes %d)", 798 id, timer.seconds(), bytes_per_sec, processedBytecodes); 799 } 800 C2V_END 801 802 C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject)) 803 JVMCICompiler* compiler = JVMCICompiler::instance(CHECK); 804 CompilerStatistics* stats = compiler->stats(); 805 stats->_standard.reset(); 806 stats->_osr.reset(); 807 C2V_END 808 809 C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jobject installedCode)) 810 ResourceMark rm; 811 HandleMark hm; 812 813 if (installedCode == NULL) { 814 THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "installedCode is null"); 815 } 816 817 jlong codeBlob = InstalledCode::address(installedCode); 818 if (codeBlob == 0L) { 819 return NULL; 820 } 821 822 CodeBlob* cb = (CodeBlob*) (address) codeBlob; 823 if (cb == NULL) { 824 return NULL; 825 } 826 827 // We don't want the stringStream buffer to resize during disassembly as it 828 // uses scoped resource memory. If a nested function called during disassembly uses 829 // a ResourceMark and the buffer expands within the scope of the mark, 830 // the buffer becomes garbage when that scope is exited. Experience shows that 831 // the disassembled code is typically about 10x the code size so a fixed buffer 832 // sized to 20x code size plus a fixed amount for header info should be sufficient. 833 int bufferSize = cb->code_size() * 20 + 1024; 834 char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize); 835 stringStream st(buffer, bufferSize); 836 if (cb->is_nmethod()) { 837 nmethod* nm = (nmethod*) cb; 838 if (!nm->is_alive()) { 839 return NULL; 840 } 841 Disassembler::decode(nm, &st); 842 } else { 843 Disassembler::decode(cb, &st); 844 } 845 if (st.size() <= 0) { 846 return NULL; 847 } 848 849 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); 850 return JNIHandles::make_local(THREAD, result()); 851 C2V_END 852 853 C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv*, jobject, jobject jvmci_method, int bci)) 854 ResourceMark rm; 855 HandleMark hm; 856 857 methodHandle method = CompilerToVM::asMethod(jvmci_method); 858 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); 859 return JNIHandles::make_local(THREAD, element); 860 C2V_END 861 862 C2V_VMENTRY(jobject, executeInstalledCode, (JNIEnv*, jobject, jobject args, jobject hotspotInstalledCode)) 863 ResourceMark rm; 864 HandleMark hm; 865 866 jlong nmethodValue = InstalledCode::address(hotspotInstalledCode); 867 if (nmethodValue == 0L) { 868 THROW_NULL(vmSymbols::jdk_vm_ci_code_InvalidInstalledCodeException()); 869 } 870 nmethod* nm = (nmethod*) (address) nmethodValue; 871 methodHandle mh = nm->method(); 872 Symbol* signature = mh->signature(); 873 JavaCallArguments jca(mh->size_of_parameters()); 874 875 JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); 876 JavaValue result(jap.get_ret_type()); 877 jca.set_alternative_target(nm); 878 JavaCalls::call(&result, mh, &jca, CHECK_NULL); 879 880 if (jap.get_ret_type() == T_VOID) { 881 return NULL; 882 } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) { 883 return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); 884 } else { 885 jvalue *value = (jvalue *) result.get_value_addr(); 886 // Narrow the value down if required (Important on big endian machines) 887 switch (jap.get_ret_type()) { 888 case T_BOOLEAN: 889 value->z = (jboolean) value->i; 890 break; 891 case T_BYTE: 892 value->b = (jbyte) value->i; 893 break; 894 case T_CHAR: 895 value->c = (jchar) value->i; 896 break; 897 case T_SHORT: 898 value->s = (jshort) value->i; 899 break; 900 } 901 oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL); 902 return JNIHandles::make_local(THREAD, o); 903 } 904 C2V_END 905 906 C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jobject jvmci_method)) 907 Method* method = CompilerToVM::asMethod(jvmci_method); 908 if (!method->has_linenumber_table()) { 909 return NULL; 910 } 911 u2 num_entries = 0; 912 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); 913 while (streamForSize.read_pair()) { 914 num_entries++; 915 } 916 917 CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); 918 typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL); 919 920 int i = 0; 921 jlong value; 922 while (stream.read_pair()) { 923 value = ((long) stream.bci()); 924 result->long_at_put(i, value); 925 value = ((long) stream.line()); 926 result->long_at_put(i + 1, value); 927 i += 2; 928 } 929 930 return (jlongArray) JNIHandles::make_local(THREAD, result); 931 C2V_END 932 933 C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jobject jvmci_method)) 934 ResourceMark rm; 935 Method* method = CompilerToVM::asMethod(jvmci_method); 936 if (!method->has_localvariable_table()) { 937 return 0; 938 } 939 return (jlong) (address) method->localvariable_table_start(); 940 C2V_END 941 942 C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jobject jvmci_method)) 943 ResourceMark rm; 944 Method* method = CompilerToVM::asMethod(jvmci_method); 945 return method->localvariable_table_length(); 946 C2V_END 947 948 C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jobject jvmci_method)) 949 Method* method = CompilerToVM::asMethod(jvmci_method); 950 MethodCounters* mcs = method->method_counters(); 951 if (mcs != NULL) { 952 mcs->clear_counters(); 953 } 954 NOT_PRODUCT(method->set_compiled_invocation_count(0)); 955 956 nmethod* code = method->code(); 957 if (code != NULL) { 958 code->make_not_entrant(); 959 } 960 961 MethodData* method_data = method->method_data(); 962 if (method_data == NULL) { 963 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); 964 method_data = MethodData::allocate(loader_data, method, CHECK); 965 method->set_method_data(method_data); 966 } else { 967 method_data->initialize(); 968 } 969 C2V_END 970 971 972 C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject installed_code)) 973 Handle installed_code_handle = JNIHandles::resolve(installed_code); 974 CompilerToVM::invalidate_installed_code(installed_code_handle, CHECK); 975 C2V_END 976 977 C2V_VMENTRY(jobject, readUncompressedOop, (JNIEnv*, jobject, jlong addr)) 978 oop ret = oopDesc::load_decode_heap_oop((oop*)(address)addr); 979 return JNIHandles::make_local(THREAD, ret); 980 C2V_END 981 982 C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv*, jobject)) 983 typeArrayOop arrayOop = oopFactory::new_longArray(JVMCICounterSize, CHECK_NULL); 984 JavaThread::collect_counters(arrayOop); 985 return (jlongArray) JNIHandles::make_local(THREAD, arrayOop); 986 C2V_END 987 988 C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jobject jvmci_method, int entry_bci)) 989 HandleMark hm; 990 ResourceMark rm; 991 if (JNIHandles::resolve(jvmci_method) == NULL) { 992 THROW_0(vmSymbols::java_lang_NullPointerException()); 993 } 994 Method* method = CompilerToVM::asMethod(jvmci_method); 995 if (entry_bci >= method->code_size() || entry_bci < -1) { 996 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Unexpected bci %d", entry_bci)); 997 } 998 return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); 999 C2V_END 1000 1001 1002 C2V_VMENTRY(jboolean, isMature, (JNIEnv*, jobject, jlong metaspace_method_data)) 1003 MethodData* mdo = CompilerToVM::asMethodData(metaspace_method_data); 1004 return mdo != NULL && mdo->is_mature(); 1005 C2V_END 1006 1007 C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv*, jobject, jobject jvmci_method, int entry_bci, int comp_level)) 1008 Method* method = CompilerToVM::asMethod(jvmci_method); 1009 return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL; 1010 C2V_END 1011 1012 C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong symbol)) 1013 Handle sym = java_lang_String::create_from_symbol((Symbol*)(address)symbol, CHECK_NULL); 1014 return JNIHandles::make_local(THREAD, sym()); 1015 C2V_END 1016 1017 bool matches(jobjectArray methods, Method* method) { 1018 objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods); 1019 1020 for (int i = 0; i < methods_oop->length(); i++) { 1021 oop resolved = methods_oop->obj_at(i); 1022 if (resolved->is_a(HotSpotResolvedJavaMethodImpl::klass()) && CompilerToVM::asMethod(resolved) == method) { 1023 return true; 1024 } 1025 } 1026 return false; 1027 } 1028 1029 C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv*, jobject compilerToVM, jobject hs_frame, jobjectArray methods, jint initialSkip)) 1030 ResourceMark rm; 1031 1032 if (!thread->has_last_Java_frame()) return NULL; 1033 Handle result = HotSpotStackFrameReference::klass()->allocate_instance(thread); 1034 HotSpotStackFrameReference::klass()->initialize(thread); 1035 1036 StackFrameStream fst(thread); 1037 if (hs_frame != NULL) { 1038 // look for the correct stack frame if one is given 1039 intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); 1040 while (fst.current()->sp() != stack_pointer && !fst.is_done()) { 1041 fst.next(); 1042 } 1043 if (fst.current()->sp() != stack_pointer) { 1044 THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") 1045 } 1046 } 1047 1048 int frame_number = 0; 1049 vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); 1050 if (hs_frame != NULL) { 1051 // look for the correct vframe within the stack frame if one is given 1052 int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); 1053 while (frame_number < last_frame_number) { 1054 if (vf->is_top()) { 1055 THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") 1056 } 1057 vf = vf->sender(); 1058 frame_number ++; 1059 } 1060 // move one frame forward 1061 if (vf->is_top()) { 1062 if (fst.is_done()) { 1063 return NULL; 1064 } 1065 fst.next(); 1066 vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); 1067 frame_number = 0; 1068 } else { 1069 vf = vf->sender(); 1070 frame_number++; 1071 } 1072 } 1073 1074 while (true) { 1075 // look for the given method 1076 while (true) { 1077 StackValueCollection* locals = NULL; 1078 if (vf->is_compiled_frame()) { 1079 // compiled method frame 1080 compiledVFrame* cvf = compiledVFrame::cast(vf); 1081 if (methods == NULL || matches(methods, cvf->method())) { 1082 if (initialSkip > 0) { 1083 initialSkip --; 1084 } else { 1085 ScopeDesc* scope = cvf->scope(); 1086 // native wrapper do not have a scope 1087 if (scope != NULL && scope->objects() != NULL) { 1088 bool realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), scope->objects(), THREAD); 1089 Deoptimization::reassign_fields(fst.current(), fst.register_map(), scope->objects(), realloc_failures, false); 1090 1091 GrowableArray<ScopeValue*>* local_values = scope->locals(); 1092 typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread); 1093 for (int i = 0; i < local_values->length(); i++) { 1094 ScopeValue* value = local_values->at(i); 1095 if (value->is_object()) { 1096 array->bool_at_put(i, true); 1097 } 1098 } 1099 HotSpotStackFrameReference::set_localIsVirtual(result, array()); 1100 } else { 1101 HotSpotStackFrameReference::set_localIsVirtual(result, NULL); 1102 } 1103 1104 locals = cvf->locals(); 1105 HotSpotStackFrameReference::set_bci(result, cvf->bci()); 1106 oop method = CompilerToVM::get_jvmci_method(cvf->method(), CHECK_NULL); 1107 HotSpotStackFrameReference::set_method(result, method); 1108 } 1109 } 1110 } else if (vf->is_interpreted_frame()) { 1111 // interpreted method frame 1112 interpretedVFrame* ivf = interpretedVFrame::cast(vf); 1113 if (methods == NULL || matches(methods, ivf->method())) { 1114 if (initialSkip > 0) { 1115 initialSkip --; 1116 } else { 1117 locals = ivf->locals(); 1118 HotSpotStackFrameReference::set_bci(result, ivf->bci()); 1119 oop method = CompilerToVM::get_jvmci_method(ivf->method(), CHECK_NULL); 1120 HotSpotStackFrameReference::set_method(result, method); 1121 HotSpotStackFrameReference::set_localIsVirtual(result, NULL); 1122 } 1123 } 1124 } 1125 1126 // locals != NULL means that we found a matching frame and result is already partially initialized 1127 if (locals != NULL) { 1128 HotSpotStackFrameReference::set_compilerToVM(result, JNIHandles::resolve(compilerToVM)); 1129 HotSpotStackFrameReference::set_stackPointer(result, (jlong) fst.current()->sp()); 1130 HotSpotStackFrameReference::set_frameNumber(result, frame_number); 1131 1132 // initialize the locals array 1133 objArrayHandle array = oopFactory::new_objectArray(locals->size(), thread); 1134 for (int i = 0; i < locals->size(); i++) { 1135 StackValue* var = locals->at(i); 1136 if (var->type() == T_OBJECT) { 1137 array->obj_at_put(i, locals->at(i)->get_obj()()); 1138 } 1139 } 1140 HotSpotStackFrameReference::set_locals(result, array()); 1141 1142 return JNIHandles::make_local(thread, result()); 1143 } 1144 1145 if (vf->is_top()) { 1146 break; 1147 } 1148 frame_number++; 1149 vf = vf->sender(); 1150 } // end of vframe loop 1151 1152 if (fst.is_done()) { 1153 break; 1154 } 1155 fst.next(); 1156 vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); 1157 frame_number = 0; 1158 } // end of frame loop 1159 1160 // the end was reached without finding a matching method 1161 return NULL; 1162 C2V_END 1163 1164 C2V_VMENTRY(void, resolveInvokeDynamicInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1165 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1166 CallInfo callInfo; 1167 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokedynamic, CHECK); 1168 ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); 1169 cp_cache_entry->set_dynamic_call(cp, callInfo); 1170 C2V_END 1171 1172 C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) 1173 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); 1174 CallInfo callInfo; 1175 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); 1176 ConstantPoolCacheEntry* cp_cache_entry = cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index)); 1177 cp_cache_entry->set_method_handle(cp, callInfo); 1178 C2V_END 1179 1180 C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject)) 1181 //see compute_recording_non_safepoints in debugInfroRec.cpp 1182 if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { 1183 return true; 1184 } 1185 return DebugNonSafepoints; 1186 C2V_END 1187 1188 // public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); 1189 C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv*, jobject, jobject hs_frame, bool invalidate)) 1190 ResourceMark rm; 1191 1192 if (hs_frame == NULL) { 1193 THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null") 1194 } 1195 1196 HotSpotStackFrameReference::klass()->initialize(thread); 1197 1198 // look for the given stack frame 1199 StackFrameStream fst(thread); 1200 intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); 1201 while (fst.current()->sp() != stack_pointer && !fst.is_done()) { 1202 fst.next(); 1203 } 1204 if (fst.current()->sp() != stack_pointer) { 1205 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") 1206 } 1207 1208 if (invalidate) { 1209 if (!fst.current()->is_compiled_frame()) { 1210 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected") 1211 } 1212 assert(fst.current()->cb()->is_nmethod(), "nmethod expected"); 1213 ((nmethod*) fst.current()->cb())->make_not_entrant(); 1214 } 1215 Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none); 1216 // look for the frame again as it has been updated by deopt (pc, deopt state...) 1217 StackFrameStream fstAfterDeopt(thread); 1218 while (fstAfterDeopt.current()->sp() != stack_pointer && !fstAfterDeopt.is_done()) { 1219 fstAfterDeopt.next(); 1220 } 1221 if (fstAfterDeopt.current()->sp() != stack_pointer) { 1222 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found after deopt") 1223 } 1224 1225 vframe* vf = vframe::new_vframe(fstAfterDeopt.current(), fstAfterDeopt.register_map(), thread); 1226 if (!vf->is_compiled_frame()) { 1227 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected") 1228 } 1229 1230 GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10); 1231 while (true) { 1232 assert(vf->is_compiled_frame(), "Wrong frame type"); 1233 virtualFrames->push(compiledVFrame::cast(vf)); 1234 if (vf->is_top()) { 1235 break; 1236 } 1237 vf = vf->sender(); 1238 } 1239 1240 int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); 1241 if (last_frame_number >= virtualFrames->length()) { 1242 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") 1243 } 1244 1245 // Reallocate the non-escaping objects and restore their fields. 1246 assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope"); 1247 GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects(); 1248 1249 if (objects == NULL) { 1250 // no objects to materialize 1251 return; 1252 } 1253 1254 bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, THREAD); 1255 Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false); 1256 1257 for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) { 1258 compiledVFrame* cvf = virtualFrames->at(frame_index); 1259 1260 GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals(); 1261 StackValueCollection* locals = cvf->locals(); 1262 1263 if (locals != NULL) { 1264 for (int i2 = 0; i2 < locals->size(); i2++) { 1265 StackValue* var = locals->at(i2); 1266 if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) { 1267 jvalue val; 1268 val.l = (jobject) locals->at(i2)->get_obj()(); 1269 cvf->update_local(T_OBJECT, i2, val); 1270 } 1271 } 1272 } 1273 } 1274 1275 // all locals are materialized by now 1276 HotSpotStackFrameReference::set_localIsVirtual(hs_frame, NULL); 1277 1278 // update the locals array 1279 objArrayHandle array = HotSpotStackFrameReference::locals(hs_frame); 1280 StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals(); 1281 for (int i = 0; i < locals->size(); i++) { 1282 StackValue* var = locals->at(i); 1283 if (var->type() == T_OBJECT) { 1284 array->obj_at_put(i, locals->at(i)->get_obj()()); 1285 } 1286 } 1287 C2V_END 1288 1289 C2V_VMENTRY(void, writeDebugOutput, (JNIEnv*, jobject, jbyteArray bytes, jint offset, jint length)) 1290 if (bytes == NULL) { 1291 THROW(vmSymbols::java_lang_NullPointerException()); 1292 } 1293 typeArrayOop array = (typeArrayOop) JNIHandles::resolve(bytes); 1294 1295 // Check if offset and length are non negative. 1296 if (offset < 0 || length < 0) { 1297 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); 1298 } 1299 // Check if the range is valid. 1300 if ((((unsigned int) length + (unsigned int) offset) > (unsigned int) array->length())) { 1301 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); 1302 } 1303 while (length > 0) { 1304 jbyte* start = array->byte_at_addr(offset); 1305 tty->write((char*) start, MIN2(length, O_BUFLEN)); 1306 length -= O_BUFLEN; 1307 offset += O_BUFLEN; 1308 } 1309 C2V_END 1310 1311 C2V_VMENTRY(void, flushDebugOutput, (JNIEnv*, jobject)) 1312 tty->flush(); 1313 C2V_END 1314 1315 C2V_VMENTRY(int, methodDataProfileDataSize, (JNIEnv*, jobject, jlong metaspace_method_data, jint position)) 1316 ResourceMark rm; 1317 MethodData* mdo = CompilerToVM::asMethodData(metaspace_method_data); 1318 ProfileData* profile_data = mdo->data_at(position); 1319 if (mdo->is_valid(profile_data)) { 1320 return profile_data->size_in_bytes(); 1321 } 1322 DataLayout* data = mdo->extra_data_base(); 1323 DataLayout* end = mdo->extra_data_limit(); 1324 for (;; data = mdo->next_extra(data)) { 1325 assert(data < end, "moved past end of extra data"); 1326 profile_data = data->data_in(); 1327 if (mdo->dp_to_di(profile_data->dp()) == position) { 1328 return profile_data->size_in_bytes(); 1329 } 1330 } 1331 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Invalid profile data position %d", position)); 1332 C2V_END 1333 1334 1335 #define CC (char*) /*cast a literal from (const char*)*/ 1336 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) 1337 1338 #define STRING "Ljava/lang/String;" 1339 #define OBJECT "Ljava/lang/Object;" 1340 #define CLASS "Ljava/lang/Class;" 1341 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" 1342 #define INSTALLED_CODE "Ljdk/vm/ci/code/InstalledCode;" 1343 #define TARGET_DESCRIPTION "Ljdk/vm/ci/code/TargetDescription;" 1344 #define RESOLVED_METHOD "Ljdk/vm/ci/meta/ResolvedJavaMethod;" 1345 #define HS_RESOLVED_METHOD "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;" 1346 #define HS_RESOLVED_KLASS "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;" 1347 #define HS_CONSTANT_POOL "Ljdk/vm/ci/hotspot/HotSpotConstantPool;" 1348 #define HS_COMPILED_CODE "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;" 1349 #define HS_CONFIG "Ljdk/vm/ci/hotspot/HotSpotVMConfig;" 1350 #define HS_METADATA "Ljdk/vm/ci/hotspot/HotSpotMetaData;" 1351 #define HS_STACK_FRAME_REF "Ljdk/vm/ci/hotspot/HotSpotStackFrameReference;" 1352 #define HS_SPECULATION_LOG "Ljdk/vm/ci/hotspot/HotSpotSpeculationLog;" 1353 #define METASPACE_METHOD_DATA "J" 1354 1355 JNINativeMethod CompilerToVM::methods[] = { 1356 {CC"getBytecode", CC"("HS_RESOLVED_METHOD")[B", FN_PTR(getBytecode)}, 1357 {CC"getExceptionTableStart", CC"("HS_RESOLVED_METHOD")J", FN_PTR(getExceptionTableStart)}, 1358 {CC"getExceptionTableLength", CC"("HS_RESOLVED_METHOD")I", FN_PTR(getExceptionTableLength)}, 1359 {CC"findUniqueConcreteMethod", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD")"HS_RESOLVED_METHOD, FN_PTR(findUniqueConcreteMethod)}, 1360 {CC"getImplementor", CC"("HS_RESOLVED_KLASS")"HS_RESOLVED_KLASS, FN_PTR(getImplementor)}, 1361 {CC"getStackTraceElement", CC"("HS_RESOLVED_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, 1362 {CC"methodIsIgnoredBySecurityStackWalk", CC"("HS_RESOLVED_METHOD")Z", FN_PTR(methodIsIgnoredBySecurityStackWalk)}, 1363 {CC"doNotInlineOrCompile", CC"("HS_RESOLVED_METHOD")V", FN_PTR(doNotInlineOrCompile)}, 1364 {CC"canInlineMethod", CC"("HS_RESOLVED_METHOD")Z", FN_PTR(canInlineMethod)}, 1365 {CC"shouldInlineMethod", CC"("HS_RESOLVED_METHOD")Z", FN_PTR(shouldInlineMethod)}, 1366 {CC"lookupType", CC"("STRING CLASS"Z)"HS_RESOLVED_KLASS, FN_PTR(lookupType)}, 1367 {CC"lookupNameInPool", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameInPool)}, 1368 {CC"lookupNameAndTypeRefIndexInPool", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, 1369 {CC"lookupSignatureInPool", CC"("HS_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureInPool)}, 1370 {CC"lookupKlassRefIndexInPool", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, 1371 {CC"lookupKlassInPool", CC"("HS_CONSTANT_POOL"I)Ljava/lang/Object;", FN_PTR(lookupKlassInPool)}, 1372 {CC"lookupAppendixInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, 1373 {CC"lookupMethodInPool", CC"("HS_CONSTANT_POOL"IB)"HS_RESOLVED_METHOD, FN_PTR(lookupMethodInPool)}, 1374 {CC"constantPoolRemapInstructionOperandFromCache", CC"("HS_CONSTANT_POOL"I)I", FN_PTR(constantPoolRemapInstructionOperandFromCache)}, 1375 {CC"resolveConstantInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolveConstantInPool)}, 1376 {CC"resolvePossiblyCachedConstantInPool", CC"("HS_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, 1377 {CC"resolveTypeInPool", CC"("HS_CONSTANT_POOL"I)"HS_RESOLVED_KLASS, FN_PTR(resolveTypeInPool)}, 1378 {CC"resolveFieldInPool", CC"("HS_CONSTANT_POOL"IB[J)"HS_RESOLVED_KLASS, FN_PTR(resolveFieldInPool)}, 1379 {CC"resolveInvokeDynamicInPool", CC"("HS_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeDynamicInPool)}, 1380 {CC"resolveInvokeHandleInPool", CC"("HS_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeHandleInPool)}, 1381 {CC"resolveMethod", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD HS_RESOLVED_KLASS")"HS_RESOLVED_METHOD, FN_PTR(resolveMethod)}, 1382 {CC"getVtableIndexForInterfaceMethod", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD")I", FN_PTR(getVtableIndexForInterfaceMethod)}, 1383 {CC"getClassInitializer", CC"("HS_RESOLVED_KLASS")"HS_RESOLVED_METHOD, FN_PTR(getClassInitializer)}, 1384 {CC"hasFinalizableSubclass", CC"("HS_RESOLVED_KLASS")Z", FN_PTR(hasFinalizableSubclass)}, 1385 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, 1386 {CC"getResolvedJavaMethodAtSlot", CC"("CLASS"I)"HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethodAtSlot)}, 1387 {CC"getResolvedJavaMethod", CC"(Ljava/lang/Object;J)"HS_RESOLVED_METHOD, FN_PTR(getResolvedJavaMethod)}, 1388 {CC"getConstantPool", CC"(Ljava/lang/Object;J)"HS_CONSTANT_POOL, FN_PTR(getConstantPool)}, 1389 {CC"getResolvedJavaType", CC"(Ljava/lang/Object;JZ)"HS_RESOLVED_KLASS, FN_PTR(getResolvedJavaType)}, 1390 {CC"initializeConfiguration", CC"("HS_CONFIG")J", FN_PTR(initializeConfiguration)}, 1391 {CC"installCode", CC"("TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG")I", FN_PTR(installCode)}, 1392 {CC"getMetadata", CC"("TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA")I", FN_PTR(getMetadata)}, 1393 {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)}, 1394 {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)}, 1395 {CC"disassembleCodeBlob", CC"("INSTALLED_CODE")"STRING, FN_PTR(disassembleCodeBlob)}, 1396 {CC"executeInstalledCode", CC"(["OBJECT INSTALLED_CODE")"OBJECT, FN_PTR(executeInstalledCode)}, 1397 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, 1398 {CC"getLocalVariableTableStart", CC"("HS_RESOLVED_METHOD")J", FN_PTR(getLocalVariableTableStart)}, 1399 {CC"getLocalVariableTableLength", CC"("HS_RESOLVED_METHOD")I", FN_PTR(getLocalVariableTableLength)}, 1400 {CC"reprofile", CC"("HS_RESOLVED_METHOD")V", FN_PTR(reprofile)}, 1401 {CC"invalidateInstalledCode", CC"("INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, 1402 {CC"readUncompressedOop", CC"(J)"OBJECT, FN_PTR(readUncompressedOop)}, 1403 {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, 1404 {CC"allocateCompileId", CC"("HS_RESOLVED_METHOD"I)I", FN_PTR(allocateCompileId)}, 1405 {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, 1406 {CC"hasCompiledCodeForOSR", CC"("HS_RESOLVED_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, 1407 {CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)}, 1408 {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "["RESOLVED_METHOD"I)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, 1409 {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)}, 1410 {CC"shouldDebugNonSafepoints", CC"()Z", FN_PTR(shouldDebugNonSafepoints)}, 1411 {CC"writeDebugOutput", CC"([BII)V", FN_PTR(writeDebugOutput)}, 1412 {CC"flushDebugOutput", CC"()V", FN_PTR(flushDebugOutput)}, 1413 {CC"methodDataProfileDataSize", CC"(JI)I", FN_PTR(methodDataProfileDataSize)}, 1414 }; 1415 1416 int CompilerToVM::methods_count() { 1417 return sizeof(methods) / sizeof(JNINativeMethod); 1418 } 1419