Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/methodHandles.cpp @ 3938:e6b1331a51d2
7086585: make Java field injection more flexible
Reviewed-by: jrose, twisti, kvn, coleenp
author | never |
---|---|
date | Sat, 10 Sep 2011 17:29:02 -0700 |
parents | b0efc7ee3b31 |
children | 12d38ffcba2a |
comparison
equal
deleted
inserted
replaced
3937:c565834fb592 | 3938:e6b1331a51d2 |
---|---|
518 if (target_oop->klass() == SystemDictionary::reflect_Field_klass()) { | 518 if (target_oop->klass() == SystemDictionary::reflect_Field_klass()) { |
519 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() | 519 oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() |
520 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() | 520 int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() |
521 int mods = java_lang_reflect_Field::modifiers(target_oop); | 521 int mods = java_lang_reflect_Field::modifiers(target_oop); |
522 klassOop k = java_lang_Class::as_klassOop(clazz); | 522 klassOop k = java_lang_Class::as_klassOop(clazz); |
523 int offset = instanceKlass::cast(k)->offset_from_fields(slot); | 523 int offset = instanceKlass::cast(k)->field_offset(slot); |
524 init_MemberName(mname_oop, k, accessFlags_from(mods), offset); | 524 init_MemberName(mname_oop, k, accessFlags_from(mods), offset); |
525 } else { | 525 } else { |
526 KlassHandle receiver_limit; int decode_flags = 0; | 526 KlassHandle receiver_limit; int decode_flags = 0; |
527 methodHandle m = MethodHandles::decode_method(target_oop, receiver_limit, decode_flags); | 527 methodHandle m = MethodHandles::decode_method(target_oop, receiver_limit, decode_flags); |
528 bool do_dispatch = ((decode_flags & MethodHandles::_dmf_does_dispatch) != 0); | 528 bool do_dispatch = ((decode_flags & MethodHandles::_dmf_does_dispatch) != 0); |
1630 if (mh.is_null() || m.is_null() || | 1630 if (mh.is_null() || m.is_null() || |
1631 (!do_dispatch && m->is_abstract())) { | 1631 (!do_dispatch && m->is_abstract())) { |
1632 THROW(vmSymbols::java_lang_InternalError()); | 1632 THROW(vmSymbols::java_lang_InternalError()); |
1633 } | 1633 } |
1634 | 1634 |
1635 java_lang_invoke_MethodHandle::init_vmslots(mh()); | |
1636 | |
1637 if (VerifyMethodHandles) { | 1635 if (VerifyMethodHandles) { |
1638 // The privileged code which invokes this routine should not make | 1636 // The privileged code which invokes this routine should not make |
1639 // a mistake about types, but it's better to verify. | 1637 // a mistake about types, but it's better to verify. |
1640 verify_DirectMethodHandle(mh, m, CHECK); | 1638 verify_DirectMethodHandle(mh, m, CHECK); |
1641 } | 1639 } |
1754 receiver_klass, | 1752 receiver_klass, |
1755 CHECK); | 1753 CHECK); |
1756 if (m.is_null()) { THROW(vmSymbols::java_lang_InternalError()); } | 1754 if (m.is_null()) { THROW(vmSymbols::java_lang_InternalError()); } |
1757 if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); } | 1755 if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); } |
1758 | 1756 |
1759 java_lang_invoke_MethodHandle::init_vmslots(mh()); | |
1760 int vmargslot = m->size_of_parameters() - 1; | 1757 int vmargslot = m->size_of_parameters() - 1; |
1761 assert(java_lang_invoke_BoundMethodHandle::vmargslot(mh()) == vmargslot, ""); | 1758 assert(java_lang_invoke_BoundMethodHandle::vmargslot(mh()) == vmargslot, ""); |
1762 | 1759 |
1763 if (VerifyMethodHandles) { | 1760 if (VerifyMethodHandles) { |
1764 verify_BoundMethodHandle_with_receiver(mh, m, CHECK); | 1761 verify_BoundMethodHandle_with_receiver(mh, m, CHECK); |
1860 // Check arguments. | 1857 // Check arguments. |
1861 if (mh.is_null() || target.is_null() || !java_lang_invoke_MethodHandle::is_instance(target())) { | 1858 if (mh.is_null() || target.is_null() || !java_lang_invoke_MethodHandle::is_instance(target())) { |
1862 THROW(vmSymbols::java_lang_InternalError()); | 1859 THROW(vmSymbols::java_lang_InternalError()); |
1863 } | 1860 } |
1864 | 1861 |
1865 java_lang_invoke_MethodHandle::init_vmslots(mh()); | |
1866 int argslot = java_lang_invoke_BoundMethodHandle::vmargslot(mh()); | 1862 int argslot = java_lang_invoke_BoundMethodHandle::vmargslot(mh()); |
1867 | 1863 |
1868 if (VerifyMethodHandles) { | 1864 if (VerifyMethodHandles) { |
1869 int insert_after = argnum - 1; | 1865 int insert_after = argnum - 1; |
1870 verify_vmargslot(mh, insert_after, argslot, CHECK); | 1866 verify_vmargslot(mh, insert_after, argslot, CHECK); |
2684 SystemDictionaryHandles::Object_klass(), | 2680 SystemDictionaryHandles::Object_klass(), |
2685 THREAD); | 2681 THREAD); |
2686 java_lang_invoke_MethodTypeForm::init_vmlayout(mtform(), cookie); | 2682 java_lang_invoke_MethodTypeForm::init_vmlayout(mtform(), cookie); |
2687 } | 2683 } |
2688 } | 2684 } |
2685 assert(java_lang_invoke_MethodTypeForm::vmslots(mtform()) == argument_slot_count(mtype()), "must agree"); | |
2689 } | 2686 } |
2690 | 2687 |
2691 #ifdef ASSERT | 2688 #ifdef ASSERT |
2692 | 2689 |
2693 extern "C" | 2690 extern "C" |