42 #include "runtime/interfaceSupport.inline.hpp" |
42 #include "runtime/interfaceSupport.inline.hpp" |
43 #include "runtime/jniHandles.inline.hpp" |
43 #include "runtime/jniHandles.inline.hpp" |
44 #include "runtime/timerTrace.hpp" |
44 #include "runtime/timerTrace.hpp" |
45 #include "runtime/vframe_hp.hpp" |
45 #include "runtime/vframe_hp.hpp" |
46 |
46 |
|
47 JVMCIKlassHandle::JVMCIKlassHandle(Thread* thread, Klass* klass) { |
|
48 _thread = thread; |
|
49 _klass = klass; |
|
50 if (klass != NULL) { |
|
51 _holder = Handle(_thread, klass->holder_phantom()); |
|
52 } |
|
53 } |
|
54 |
|
55 JVMCIKlassHandle& JVMCIKlassHandle::operator=(Klass* klass) { |
|
56 _klass = klass; |
|
57 if (klass != NULL) { |
|
58 _holder = Handle(_thread, klass->holder_phantom()); |
|
59 } |
|
60 return *this; |
|
61 } |
47 |
62 |
48 void JNIHandleMark::push_jni_handle_block() { |
63 void JNIHandleMark::push_jni_handle_block() { |
49 JavaThread* thread = JavaThread::current(); |
64 JavaThread* thread = JavaThread::current(); |
50 if (thread != NULL) { |
65 if (thread != NULL) { |
51 // Allocate a new block for JNI handles. |
66 // Allocate a new block for JNI handles. |
89 return (oop)result.get_jobject(); |
104 return (oop)result.get_jobject(); |
90 } |
105 } |
91 return NULL; |
106 return NULL; |
92 } |
107 } |
93 |
108 |
94 oop CompilerToVM::get_jvmci_type(Klass* klass, TRAPS) { |
109 oop CompilerToVM::get_jvmci_type(JVMCIKlassHandle& klass, TRAPS) { |
95 if (klass != NULL) { |
110 if (!klass.is_null()) { |
96 JavaValue result(T_OBJECT); |
111 JavaValue result(T_OBJECT); |
97 JavaCallArguments args; |
112 JavaCallArguments args; |
98 args.push_oop(Handle(THREAD, klass->java_mirror())); |
113 args.push_oop(Handle(THREAD, klass->java_mirror())); |
99 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL); |
114 JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL); |
100 |
115 |
309 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL); |
324 JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL); |
310 return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject()); |
325 return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject()); |
311 } |
326 } |
312 |
327 |
313 C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) |
328 C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed)) |
314 Klass* klass = NULL; |
329 JVMCIKlassHandle klass(THREAD); |
315 oop base_object = JNIHandles::resolve(base); |
330 oop base_object = JNIHandles::resolve(base); |
316 jlong base_address = 0; |
331 jlong base_address = 0; |
317 if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { |
332 if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) { |
318 klass = base_object->klass(); |
333 klass = base_object->klass(); |
319 } else if (!compressed) { |
334 } else if (!compressed) { |
363 if (!klass->is_interface()) { |
378 if (!klass->is_interface()) { |
364 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), |
379 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), |
365 err_msg("Expected interface type, got %s", klass->external_name())); |
380 err_msg("Expected interface type, got %s", klass->external_name())); |
366 } |
381 } |
367 InstanceKlass* iklass = InstanceKlass::cast(klass); |
382 InstanceKlass* iklass = InstanceKlass::cast(klass); |
368 oop implementor = CompilerToVM::get_jvmci_type(iklass->implementor(), CHECK_NULL); |
383 JVMCIKlassHandle handle(THREAD, iklass->implementor()); |
|
384 oop implementor = CompilerToVM::get_jvmci_type(handle, CHECK_NULL); |
369 return JNIHandles::make_local(THREAD, implementor); |
385 return JNIHandles::make_local(THREAD, implementor); |
370 C2V_END |
386 C2V_END |
371 |
387 |
372 C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method)) |
388 C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method)) |
373 methodHandle method = CompilerToVM::asMethod(jvmci_method); |
389 methodHandle method = CompilerToVM::asMethod(jvmci_method); |
398 Symbol* class_name = java_lang_String::as_symbol(name(), CHECK_0); |
414 Symbol* class_name = java_lang_String::as_symbol(name(), CHECK_0); |
399 if (java_lang_String::length(name()) <= 1) { |
415 if (java_lang_String::length(name()) <= 1) { |
400 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string())); |
416 THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string())); |
401 } |
417 } |
402 |
418 |
403 Klass* resolved_klass = NULL; |
419 JVMCIKlassHandle resolved_klass(THREAD); |
404 if (JNIHandles::resolve(accessing_class) == NULL) { |
420 if (JNIHandles::resolve(accessing_class) == NULL) { |
405 THROW_0(vmSymbols::java_lang_NullPointerException()); |
421 THROW_0(vmSymbols::java_lang_NullPointerException()); |
406 } |
422 } |
407 Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); |
423 Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); |
408 Handle class_loader(THREAD, accessing_klass->class_loader()); |
424 Handle class_loader(THREAD, accessing_klass->class_loader()); |
431 // naked oop "k" is OK here -- we assign back into it |
447 // naked oop "k" is OK here -- we assign back into it |
432 resolved_klass = SystemDictionary::find(strippedsym, |
448 resolved_klass = SystemDictionary::find(strippedsym, |
433 class_loader, |
449 class_loader, |
434 protection_domain, |
450 protection_domain, |
435 CHECK_0); |
451 CHECK_0); |
436 if (resolved_klass != NULL) { |
452 if (!resolved_klass.is_null()) { |
437 resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0); |
453 resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0); |
438 } |
454 } |
439 } else { |
455 } else { |
440 resolved_klass = Universe::typeArrayKlassObj(t); |
456 resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(t))->array_klass(fd.dimension(), CHECK_0); |
441 resolved_klass = TypeArrayKlass::cast(resolved_klass)->array_klass(fd.dimension(), CHECK_0); |
|
442 } |
457 } |
443 } |
458 } |
444 } |
459 } |
445 oop result = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); |
460 oop result = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); |
446 return JNIHandles::make_local(THREAD, result); |
461 return JNIHandles::make_local(THREAD, result); |
480 return cp->klass_ref_index_at(index); |
495 return cp->klass_ref_index_at(index); |
481 C2V_END |
496 C2V_END |
482 |
497 |
483 C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) |
498 C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index)) |
484 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); |
499 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); |
485 Klass* resolved_klass = cp->klass_at(index, CHECK_NULL); |
500 Klass* klass = cp->klass_at(index, CHECK_NULL); |
|
501 JVMCIKlassHandle resolved_klass(THREAD, klass); |
486 if (resolved_klass->is_instance_klass()) { |
502 if (resolved_klass->is_instance_klass()) { |
487 InstanceKlass::cast(resolved_klass)->link_class_or_fail(THREAD); |
503 InstanceKlass::cast(resolved_klass())->link_class_or_fail(THREAD); |
488 } |
504 } |
489 oop klass = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); |
505 oop jvmci_type = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL); |
490 return JNIHandles::make_local(THREAD, klass); |
506 return JNIHandles::make_local(THREAD, jvmci_type); |
491 C2V_END |
507 C2V_END |
492 |
508 |
493 C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) |
509 C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode)) |
494 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); |
510 constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool); |
495 Klass* loading_klass = cp->pool_holder(); |
511 Klass* loading_klass = cp->pool_holder(); |
496 bool is_accessible = false; |
512 bool is_accessible = false; |
497 Klass* klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); |
513 JVMCIKlassHandle klass(THREAD, JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass)); |
498 Symbol* symbol = NULL; |
514 Symbol* symbol = NULL; |
499 if (klass == NULL) { |
515 if (klass == NULL) { |
500 symbol = cp->klass_name_at(index); |
516 symbol = cp->klass_name_at(index); |
501 } |
517 } |
502 oop result_oop; |
518 oop result_oop; |
503 if (klass != NULL) { |
519 if (!klass.is_null()) { |
504 result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); |
520 result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL); |
505 } else { |
521 } else { |
506 Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); |
522 Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL); |
507 result_oop = result(); |
523 result_oop = result(); |
508 } |
524 } |
541 JVMCI_ERROR_NULL("info must not be null and have a length of 3"); |
557 JVMCI_ERROR_NULL("info must not be null and have a length of 3"); |
542 } |
558 } |
543 info->int_at_put(0, fd.access_flags().as_int()); |
559 info->int_at_put(0, fd.access_flags().as_int()); |
544 info->int_at_put(1, fd.offset()); |
560 info->int_at_put(1, fd.offset()); |
545 info->int_at_put(2, fd.index()); |
561 info->int_at_put(2, fd.index()); |
546 oop field_holder = CompilerToVM::get_jvmci_type(fd.field_holder(), CHECK_NULL); |
562 JVMCIKlassHandle handle(THREAD, fd.field_holder()); |
|
563 oop field_holder = CompilerToVM::get_jvmci_type(handle, CHECK_NULL); |
547 return JNIHandles::make_local(THREAD, field_holder); |
564 return JNIHandles::make_local(THREAD, field_holder); |
548 C2V_END |
565 C2V_END |
549 |
566 |
550 C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) |
567 C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) |
551 ResourceMark rm; |
568 ResourceMark rm; |
1411 C2V_END |
1428 C2V_END |
1412 |
1429 |
1413 C2V_VMENTRY(jobject, getHostClass, (JNIEnv*, jobject, jobject jvmci_type)) |
1430 C2V_VMENTRY(jobject, getHostClass, (JNIEnv*, jobject, jobject jvmci_type)) |
1414 InstanceKlass* k = InstanceKlass::cast(CompilerToVM::asKlass(jvmci_type)); |
1431 InstanceKlass* k = InstanceKlass::cast(CompilerToVM::asKlass(jvmci_type)); |
1415 InstanceKlass* host = k->host_klass(); |
1432 InstanceKlass* host = k->host_klass(); |
1416 oop result = CompilerToVM::get_jvmci_type(host, CHECK_NULL); |
1433 JVMCIKlassHandle handle(THREAD, host); |
|
1434 oop result = CompilerToVM::get_jvmci_type(handle, CHECK_NULL); |
1417 return JNIHandles::make_local(THREAD, result); |
1435 return JNIHandles::make_local(THREAD, result); |
1418 C2V_END |
1436 C2V_END |
1419 |
1437 |
1420 C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle)) |
1438 C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle)) |
1421 if (bytecode_frame_handle == NULL) { |
1439 if (bytecode_frame_handle == NULL) { |