Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 15806:240cc9a901fb
don't use JNI natives to interact with VM metadata
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 20 May 2014 21:35:32 -0700 |
parents | dffc37fa7157 |
children | 747bc4099ad8 |
comparison
equal
deleted
inserted
replaced
15805:dffc37fa7157 | 15806:240cc9a901fb |
---|---|
51 #define C2V_VMENTRY(result_type, name, signature) \ | 51 #define C2V_VMENTRY(result_type, name, signature) \ |
52 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ | 52 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ |
53 TRACE_graal_3("CompilerToVM::" #name); \ | 53 TRACE_graal_3("CompilerToVM::" #name); \ |
54 GRAAL_VM_ENTRY_MARK; \ | 54 GRAAL_VM_ENTRY_MARK; \ |
55 | 55 |
56 // Entry to native method implementation that calls a JNI function | |
57 // and hence cannot transition current thread to '_thread_in_vm'. | |
58 #define C2V_ENTRY(result_type, name, signature) \ | |
59 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ | |
60 TRACE_graal_3("CompilerToVM::" #name); \ | |
61 | |
62 #define C2V_END } | 56 #define C2V_END } |
63 | 57 |
64 extern "C" { | 58 extern "C" { |
65 extern VMStructEntry* gHotSpotVMStructs; | 59 extern VMStructEntry* gHotSpotVMStructs; |
66 extern uint64_t gHotSpotVMStructEntryTypeNameOffset; | 60 extern uint64_t gHotSpotVMStructEntryTypeNameOffset; |
89 extern uint64_t gHotSpotVMLongConstantEntryNameOffset; | 83 extern uint64_t gHotSpotVMLongConstantEntryNameOffset; |
90 extern uint64_t gHotSpotVMLongConstantEntryValueOffset; | 84 extern uint64_t gHotSpotVMLongConstantEntryValueOffset; |
91 extern uint64_t gHotSpotVMLongConstantEntryArrayStride; | 85 extern uint64_t gHotSpotVMLongConstantEntryArrayStride; |
92 } | 86 } |
93 | 87 |
94 C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config)) | 88 C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *, jobject, jobject config)) |
95 VMStructs::initHotSpotVMConfig(env, config); | 89 VMStructs::initHotSpotVMConfig(JNIHandles::resolve(config)); |
96 C2V_END | 90 C2V_END |
97 | 91 |
98 C2V_ENTRY(jbyteArray, initializeBytecode, (JNIEnv *env, jobject, jlong metaspace_method, jbyteArray result)) | 92 C2V_VMENTRY(jbyteArray, initializeBytecode, (JNIEnv *, jobject, jlong metaspace_method)) |
99 methodHandle method = asMethod(metaspace_method); | 93 methodHandle method = asMethod(metaspace_method); |
100 ResourceMark rm; | 94 ResourceMark rm; |
101 | 95 |
102 int code_size = method->code_size(); | 96 int code_size = method->code_size(); |
103 jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size); | 97 jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size); |
160 } | 154 } |
161 } | 155 } |
162 } | 156 } |
163 } | 157 } |
164 | 158 |
165 env->SetByteArrayRegion(result, 0, code_size, reconstituted_code); | 159 typeArrayOop result_array = oopFactory::new_byteArray(code_size, CHECK_NULL); |
166 | 160 memcpy(result_array->byte_at_addr(0), reconstituted_code, code_size); |
167 return result; | 161 return (jbyteArray) JNIHandles::make_local(result_array); |
168 C2V_END | 162 C2V_END |
169 | 163 |
170 C2V_VMENTRY(jint, exceptionTableLength, (JNIEnv *, jobject, jlong metaspace_method)) | 164 C2V_VMENTRY(jint, exceptionTableLength, (JNIEnv *, jobject, jlong metaspace_method)) |
171 ResourceMark rm; | 165 ResourceMark rm; |
172 methodHandle method = asMethod(metaspace_method); | 166 methodHandle method = asMethod(metaspace_method); |
231 C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) | 225 C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) |
232 methodHandle method = asMethod(metaspace_method); | 226 methodHandle method = asMethod(metaspace_method); |
233 return CompilerOracle::should_inline(method) || method->force_inline(); | 227 return CompilerOracle::should_inline(method) || method->force_inline(); |
234 C2V_END | 228 C2V_END |
235 | 229 |
236 C2V_VMENTRY(jlong, lookupType, (JNIEnv *env, jobject, jstring jname, jclass accessing_class, jboolean resolve)) | 230 C2V_VMENTRY(jlong, lookupType, (JNIEnv*, jobject, jstring jname, jclass accessing_class, jboolean resolve)) |
237 ResourceMark rm; | 231 ResourceMark rm; |
238 Handle name = JNIHandles::resolve(jname); | 232 Handle name = JNIHandles::resolve(jname); |
239 Symbol* class_name = java_lang_String::as_symbol(name, THREAD); | 233 Symbol* class_name = java_lang_String::as_symbol(name, THREAD); |
240 assert(class_name != NULL, "name to symbol creation failed"); | 234 assert(class_name != NULL, "name to symbol creation failed"); |
241 assert(class_name->size() > 1, "primitive types should be handled in Java code"); | 235 assert(class_name->size() > 1, "primitive types should be handled in Java code"); |
256 } | 250 } |
257 | 251 |
258 return (jlong) (address) resolved_klass; | 252 return (jlong) (address) resolved_klass; |
259 C2V_END | 253 C2V_END |
260 | 254 |
261 C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 255 C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
262 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; | 256 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
263 oop result = cp->resolve_constant_at(index, CHECK_NULL); | 257 oop result = cp->resolve_constant_at(index, CHECK_NULL); |
264 return JNIHandles::make_local(THREAD, result); | 258 return JNIHandles::make_local(THREAD, result); |
265 C2V_END | 259 C2V_END |
266 | 260 |
267 C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 261 C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
268 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; | 262 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
269 oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); | 263 oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); |
270 return JNIHandles::make_local(THREAD, result); | 264 return JNIHandles::make_local(THREAD, result); |
271 C2V_END | 265 C2V_END |
272 | 266 |
273 C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 267 C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
274 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 268 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
275 return cp->name_and_type_ref_index_at(index); | 269 return cp->name_and_type_ref_index_at(index); |
276 C2V_END | 270 C2V_END |
277 | 271 |
278 C2V_VMENTRY(jlong, lookupNameRefInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 272 C2V_VMENTRY(jlong, lookupNameRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
279 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 273 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
280 return (jlong) (address) cp->name_ref_at(index); | 274 return (jlong) (address) cp->name_ref_at(index); |
281 C2V_END | 275 C2V_END |
282 | 276 |
283 C2V_VMENTRY(jlong, lookupSignatureRefInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 277 C2V_VMENTRY(jlong, lookupSignatureRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
284 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 278 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
285 return (jlong) (address) cp->signature_ref_at(index); | 279 return (jlong) (address) cp->signature_ref_at(index); |
286 C2V_END | 280 C2V_END |
287 | 281 |
288 C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 282 C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
289 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 283 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
290 return cp->klass_ref_index_at(index); | 284 return cp->klass_ref_index_at(index); |
291 C2V_END | 285 C2V_END |
292 | 286 |
293 C2V_VMENTRY(jlong, constantPoolKlassAt, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 287 C2V_VMENTRY(jlong, constantPoolKlassAt, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
294 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; | 288 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
295 return (jlong) (address) cp->klass_at(index, THREAD); | 289 return (jlong) (address) cp->klass_at(index, THREAD); |
296 C2V_END | 290 C2V_END |
297 | 291 |
298 C2V_VMENTRY(jlong, lookupKlassInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) | 292 C2V_VMENTRY(jlong, lookupKlassInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) |
299 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 293 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
300 KlassHandle loading_klass(cp->pool_holder()); | 294 KlassHandle loading_klass(cp->pool_holder()); |
301 bool is_accessible = false; | 295 bool is_accessible = false; |
302 KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); | 296 KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); |
303 if (klass.is_null()) { | 297 if (klass.is_null()) { |
317 } | 311 } |
318 } | 312 } |
319 return (jlong) CompilerToVM::tag_pointer(klass()); | 313 return (jlong) CompilerToVM::tag_pointer(klass()); |
320 C2V_END | 314 C2V_END |
321 | 315 |
322 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 316 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
323 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 317 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
324 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); | 318 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); |
325 return JNIHandles::make_local(THREAD, appendix_oop); | 319 return JNIHandles::make_local(THREAD, appendix_oop); |
326 C2V_END | 320 C2V_END |
327 | 321 |
328 C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) | 322 C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) |
329 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 323 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
330 instanceKlassHandle pool_holder(cp->pool_holder()); | 324 instanceKlassHandle pool_holder(cp->pool_holder()); |
331 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); | 325 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); |
332 methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder); | 326 methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder); |
333 return (jlong) (address) method(); | 327 return (jlong) (address) method(); |
334 C2V_END | 328 C2V_END |
335 | 329 |
336 C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 330 C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
337 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; | 331 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
338 return cp->remap_instruction_operand_from_cache(index); | 332 return cp->remap_instruction_operand_from_cache(index); |
339 C2V_END | 333 C2V_END |
340 | 334 |
341 C2V_VMENTRY(jlong, resolveField, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle)) | 335 C2V_VMENTRY(jlong, resolveField, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle)) |
342 ResourceMark rm; | 336 ResourceMark rm; |
343 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; | 337 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
344 Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); | 338 Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); |
345 fieldDescriptor result; | 339 fieldDescriptor result; |
346 LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, CHECK_0); | 340 LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, CHECK_0); |
432 C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jlong metaspace_klass)) | 426 C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jlong metaspace_klass)) |
433 InstanceKlass* klass = (InstanceKlass*) metaspace_klass; | 427 InstanceKlass* klass = (InstanceKlass*) metaspace_klass; |
434 return (jlong) (address) klass->class_initializer(); | 428 return (jlong) (address) klass->class_initializer(); |
435 C2V_END | 429 C2V_END |
436 | 430 |
437 C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv *env, jobject, jlong addr)) | 431 C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv*, jobject, jlong addr)) |
438 address target_addr = (address) addr; | 432 address target_addr = (address) addr; |
439 if (target_addr != 0x0) { | 433 if (target_addr != 0x0) { |
440 int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); | 434 int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); |
441 int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); | 435 int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); |
442 return MAX2(ABS(off_low), ABS(off_high)); | 436 return MAX2(ABS(off_low), ABS(off_high)); |
568 | 562 |
569 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); | 563 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); |
570 return JNIHandles::make_local(result()); | 564 return JNIHandles::make_local(result()); |
571 C2V_END | 565 C2V_END |
572 | 566 |
573 C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv *env, jobject, jlong metaspace_method, int bci)) | 567 C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv*, jobject, jlong metaspace_method, int bci)) |
574 ResourceMark rm; | 568 ResourceMark rm; |
575 HandleMark hm; | 569 HandleMark hm; |
576 | 570 |
577 methodHandle method = asMethod(metaspace_method); | 571 methodHandle method = asMethod(metaspace_method); |
578 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); | 572 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); |
579 return JNIHandles::make_local(element); | 573 return JNIHandles::make_local(element); |
580 C2V_END | 574 C2V_END |
581 | 575 |
582 C2V_VMENTRY(jobject, executeCompiledMethodVarargs, (JNIEnv *env, jobject, jobject args, jobject hotspotInstalledCode)) | 576 C2V_VMENTRY(jobject, executeCompiledMethodVarargs, (JNIEnv*, jobject, jobject args, jobject hotspotInstalledCode)) |
583 ResourceMark rm; | 577 ResourceMark rm; |
584 HandleMark hm; | 578 HandleMark hm; |
585 | 579 |
586 jlong nmethodValue = InstalledCode::address(hotspotInstalledCode); | 580 jlong nmethodValue = InstalledCode::address(hotspotInstalledCode); |
587 if (nmethodValue == 0L) { | 581 if (nmethodValue == 0L) { |
605 oop o = java_lang_boxing_object::create(jap.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL); | 599 oop o = java_lang_boxing_object::create(jap.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL); |
606 return JNIHandles::make_local(o); | 600 return JNIHandles::make_local(o); |
607 } | 601 } |
608 C2V_END | 602 C2V_END |
609 | 603 |
610 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jlong metaspace_method)) | 604 C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jlong metaspace_method)) |
611 Method* method = (Method*) metaspace_method; | 605 Method* method = (Method*) metaspace_method; |
612 if (!method->has_linenumber_table()) { | 606 if (!method->has_linenumber_table()) { |
613 return NULL; | 607 return NULL; |
614 } | 608 } |
615 u2 num_entries = 0; | 609 u2 num_entries = 0; |
617 while (streamForSize.read_pair()) { | 611 while (streamForSize.read_pair()) { |
618 num_entries++; | 612 num_entries++; |
619 } | 613 } |
620 | 614 |
621 CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); | 615 CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); |
622 jlongArray result = env->NewLongArray(2 * num_entries); | 616 typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL); |
623 | 617 |
624 int i = 0; | 618 int i = 0; |
625 jlong value; | 619 jlong value; |
626 while (stream.read_pair()) { | 620 while (stream.read_pair()) { |
627 value = ((long) stream.bci()); | 621 value = ((long) stream.bci()); |
628 env->SetLongArrayRegion(result,i,1,&value); | 622 result->long_at_put(i, value); |
629 value = ((long) stream.line()); | 623 value = ((long) stream.line()); |
630 env->SetLongArrayRegion(result,i + 1,1,&value); | 624 result->long_at_put(i + 1, value); |
631 i += 2; | 625 i += 2; |
632 } | 626 } |
633 | 627 |
634 return result; | 628 return (jlongArray) JNIHandles::make_local(result); |
635 C2V_END | 629 C2V_END |
636 | 630 |
637 C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jlong metaspace_method)) | 631 C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jlong metaspace_method)) |
638 ResourceMark rm; | 632 ResourceMark rm; |
639 Method* method = (Method*) metaspace_method; | 633 Method* method = (Method*) metaspace_method; |
647 ResourceMark rm; | 641 ResourceMark rm; |
648 Method* method = (Method*) metaspace_method; | 642 Method* method = (Method*) metaspace_method; |
649 return method->localvariable_table_length(); | 643 return method->localvariable_table_length(); |
650 C2V_END | 644 C2V_END |
651 | 645 |
652 C2V_VMENTRY(void, reprofile, (JNIEnv *env, jobject, jlong metaspace_method)) | 646 C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jlong metaspace_method)) |
653 Method* method = asMethod(metaspace_method); | 647 Method* method = asMethod(metaspace_method); |
654 MethodCounters* mcs = method->method_counters(); | 648 MethodCounters* mcs = method->method_counters(); |
655 if (mcs != NULL) { | 649 if (mcs != NULL) { |
656 mcs->clear_counters(); | 650 mcs->clear_counters(); |
657 } | 651 } |
671 method_data->initialize(true); | 665 method_data->initialize(true); |
672 } | 666 } |
673 C2V_END | 667 C2V_END |
674 | 668 |
675 | 669 |
676 C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv *env, jobject, jobject hotspotInstalledCode)) | 670 C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject hotspotInstalledCode)) |
677 jlong nativeMethod = InstalledCode::address(hotspotInstalledCode); | 671 jlong nativeMethod = InstalledCode::address(hotspotInstalledCode); |
678 nmethod* m = (nmethod*)nativeMethod; | 672 nmethod* m = (nmethod*)nativeMethod; |
679 if (m != NULL && !m->is_not_entrant()) { | 673 if (m != NULL && !m->is_not_entrant()) { |
680 m->mark_for_deoptimization(); | 674 m->mark_for_deoptimization(); |
681 VM_Deoptimize op; | 675 VM_Deoptimize op; |
682 VMThread::execute(&op); | 676 VMThread::execute(&op); |
683 } | 677 } |
684 InstalledCode::set_address(hotspotInstalledCode, 0); | 678 InstalledCode::set_address(hotspotInstalledCode, 0); |
685 C2V_END | 679 C2V_END |
686 | 680 |
687 C2V_VMENTRY(jobject, getJavaMirror, (JNIEnv *env, jobject, jlong metaspace_klass)) | 681 C2V_VMENTRY(jobject, getJavaMirror, (JNIEnv*, jobject, jlong metaspace_klass)) |
688 Klass* klass = asKlass(metaspace_klass); | 682 Klass* klass = asKlass(metaspace_klass); |
689 return JNIHandles::make_local(klass->java_mirror()); | 683 return JNIHandles::make_local(klass->java_mirror()); |
690 C2V_END | 684 C2V_END |
691 | 685 |
692 C2V_VMENTRY(jlong, readUnsafeKlassPointer, (JNIEnv *env, jobject, jobject o)) | 686 C2V_VMENTRY(jlong, readUnsafeKlassPointer, (JNIEnv*, jobject, jobject o)) |
693 oop resolved_o = JNIHandles::resolve(o); | 687 oop resolved_o = JNIHandles::resolve(o); |
694 jlong klass = (jlong)(address)resolved_o->klass(); | 688 jlong klass = (jlong)(address)resolved_o->klass(); |
695 return klass; | 689 return klass; |
696 C2V_END | 690 C2V_END |
697 | 691 |
698 C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv *env, jobject)) | 692 C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv*, jobject)) |
699 typeArrayOop arrayOop = oopFactory::new_longArray(GraalCounterSize, CHECK_NULL); | 693 typeArrayOop arrayOop = oopFactory::new_longArray(GraalCounterSize, CHECK_NULL); |
700 JavaThread::collect_counters(arrayOop); | 694 JavaThread::collect_counters(arrayOop); |
701 return (jlongArray) JNIHandles::make_local(arrayOop); | 695 return (jlongArray) JNIHandles::make_local(arrayOop); |
702 C2V_END | 696 C2V_END |
703 | 697 |
704 C2V_ENTRY(jobject, getGPUs, (JNIEnv *env, jobject)) | 698 // In general we should avoid using regular JNI methods to interact with the JVM but this |
699 // particular case is just about registering JNI methods so it should be a regular native | |
700 // method. | |
701 JNIEXPORT jobject JNICALL c2v_getGPUs (JNIEnv* env, jobject) { | |
702 TRACE_graal_3("CompilerToVM::getGPUs" ); | |
705 #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_windows) | 703 #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_windows) |
706 return Gpu::probe_gpus(env); | 704 return Gpu::probe_gpus(env); |
707 #else | 705 #else |
708 return env->NewStringUTF(""); | 706 return env->NewStringUTF(""); |
709 #endif | 707 #endif |
710 C2V_END | 708 } |
711 | 709 |
712 C2V_VMENTRY(int, allocateCompileId, (JNIEnv *env, jobject, jlong metaspace_method, int entry_bci)) | 710 C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci)) |
713 HandleMark hm; | 711 HandleMark hm; |
714 ResourceMark rm; | 712 ResourceMark rm; |
715 Method* method = (Method*) metaspace_method; | 713 Method* method = (Method*) metaspace_method; |
716 return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); | 714 return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); |
717 C2V_END | 715 C2V_END |
718 | 716 |
719 | 717 |
720 C2V_VMENTRY(jboolean, isMature, (JNIEnv *env, jobject, jlong metaspace_method_data)) | 718 C2V_VMENTRY(jboolean, isMature, (JNIEnv*, jobject, jlong metaspace_method_data)) |
721 MethodData* mdo = asMethodData(metaspace_method_data); | 719 MethodData* mdo = asMethodData(metaspace_method_data); |
722 return mdo != NULL && mdo->is_mature(); | 720 return mdo != NULL && mdo->is_mature(); |
723 C2V_END | 721 C2V_END |
724 | 722 |
725 C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv *env, jobject, jlong metaspace_method, int entry_bci, int comp_level)) | 723 C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci, int comp_level)) |
726 Method* method = asMethod(metaspace_method); | 724 Method* method = asMethod(metaspace_method); |
727 return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL; | 725 return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL; |
728 C2V_END | 726 C2V_END |
729 | 727 |
730 C2V_VMENTRY(jlong, getTimeStamp, (JNIEnv *env, jobject)) | 728 C2V_VMENTRY(jlong, getTimeStamp, (JNIEnv*, jobject)) |
731 // tty->time_stamp is the time since VM start which should be used | 729 // tty->time_stamp is the time since VM start which should be used |
732 // for all HotSpot log output when a timestamp is required. | 730 // for all HotSpot log output when a timestamp is required. |
733 return tty->time_stamp().milliseconds(); | 731 return tty->time_stamp().milliseconds(); |
734 C2V_END | 732 C2V_END |
735 | 733 |
742 } | 740 } |
743 } | 741 } |
744 return false; | 742 return false; |
745 } | 743 } |
746 | 744 |
747 C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv *env, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip)) | 745 C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv*, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip)) |
748 ResourceMark rm; | 746 ResourceMark rm; |
749 | 747 |
750 if (!thread->has_last_Java_frame()) return NULL; | 748 if (!thread->has_last_Java_frame()) return NULL; |
751 Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread); | 749 Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread); |
752 HotSpotStackFrameReference::klass()->initialize(thread); | 750 HotSpotStackFrameReference::klass()->initialize(thread); |
877 | 875 |
878 // the end was reached without finding a matching method | 876 // the end was reached without finding a matching method |
879 return NULL; | 877 return NULL; |
880 C2V_END | 878 C2V_END |
881 | 879 |
882 C2V_VMENTRY(void, resolveInvokeDynamic, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) | 880 C2V_VMENTRY(void, resolveInvokeDynamic, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) |
883 ConstantPool* cp = (ConstantPool*)metaspace_constant_pool; | 881 ConstantPool* cp = (ConstantPool*)metaspace_constant_pool; |
884 CallInfo callInfo; | 882 CallInfo callInfo; |
885 LinkResolver::resolve_invokedynamic(callInfo, cp, index, CHECK); | 883 LinkResolver::resolve_invokedynamic(callInfo, cp, index, CHECK); |
886 ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); | 884 ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); |
887 cp_cache_entry->set_dynamic_call(cp, callInfo); | 885 cp_cache_entry->set_dynamic_call(cp, callInfo); |
888 C2V_END | 886 C2V_END |
889 | 887 |
890 // public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); | 888 // public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); |
891 C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv *env, jobject, jobject hs_frame, bool invalidate)) | 889 C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv*, jobject, jobject hs_frame, bool invalidate)) |
892 ResourceMark rm; | 890 ResourceMark rm; |
893 | 891 |
894 if (hs_frame == NULL) { | 892 if (hs_frame == NULL) { |
895 THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null") | 893 THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null") |
896 } | 894 } |
1004 #define METASPACE_METHOD_DATA "J" | 1002 #define METASPACE_METHOD_DATA "J" |
1005 #define METASPACE_CONSTANT_POOL "J" | 1003 #define METASPACE_CONSTANT_POOL "J" |
1006 #define METASPACE_SYMBOL "J" | 1004 #define METASPACE_SYMBOL "J" |
1007 | 1005 |
1008 JNINativeMethod CompilerToVM_methods[] = { | 1006 JNINativeMethod CompilerToVM_methods[] = { |
1009 {CC"initializeBytecode", CC"("METASPACE_METHOD"[B)[B", FN_PTR(initializeBytecode)}, | 1007 {CC"initializeBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(initializeBytecode)}, |
1010 {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, | 1008 {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, |
1011 {CC"exceptionTableLength", CC"("METASPACE_METHOD")I", FN_PTR(exceptionTableLength)}, | 1009 {CC"exceptionTableLength", CC"("METASPACE_METHOD")I", FN_PTR(exceptionTableLength)}, |
1012 {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, | 1010 {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, |
1013 {CC"findUniqueConcreteMethod", CC"("METASPACE_METHOD")"METASPACE_METHOD, FN_PTR(findUniqueConcreteMethod)}, | 1011 {CC"findUniqueConcreteMethod", CC"("METASPACE_METHOD")"METASPACE_METHOD, FN_PTR(findUniqueConcreteMethod)}, |
1014 {CC"getKlassImplementor", CC"("METASPACE_KLASS")"METASPACE_KLASS, FN_PTR(getKlassImplementor)}, | 1012 {CC"getKlassImplementor", CC"("METASPACE_KLASS")"METASPACE_KLASS, FN_PTR(getKlassImplementor)}, |