< prev index next >

src/hotspot/share/oops/resolvedMethodEntry.cpp

Print this page

 52     set_resolved_references_index(saved_resolved_references_index);
 53   } else {
 54     *this = ResolvedMethodEntry(_cpool_index);
 55   }
 56 }
 57 
 58 #if INCLUDE_CDS
 59 void ResolvedMethodEntry::remove_unshareable_info() {
 60   reset_entry();
 61 }
 62 
 63 void ResolvedMethodEntry::mark_and_relocate(ConstantPool* src_cp) {
 64   if (_method == nullptr) {
 65     assert(bytecode2() == Bytecodes::_invokevirtual, "");
 66   } else {
 67     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_method);
 68   }
 69   if (bytecode1() == Bytecodes::_invokeinterface) {
 70     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_entry_specific._interface_klass);
 71   }











































































 72 }
 73 #endif
 74 
 75 void ResolvedMethodEntry::print_on(outputStream* st) const {
 76   st->print_cr("Method Entry:");
 77 
 78   if (method() != nullptr) {
 79     st->print_cr(" - Method: " INTPTR_FORMAT " %s", p2i(method()), method()->external_name());
 80   } else {
 81     st->print_cr("- Method: null");
 82   }
 83   // Some fields are mutually exclusive and are only used by certain invoke codes
 84   if (bytecode1() == Bytecodes::_invokeinterface && interface_klass() != nullptr) {
 85     st->print_cr(" - Klass: " INTPTR_FORMAT " %s", p2i(interface_klass()), interface_klass()->external_name());
 86   } else {
 87     st->print_cr("- Klass: null");
 88   }
 89   if (bytecode1() == Bytecodes::_invokehandle) {
 90     st->print_cr(" - Resolved References Index: %d", resolved_references_index());
 91   } else {

 52     set_resolved_references_index(saved_resolved_references_index);
 53   } else {
 54     *this = ResolvedMethodEntry(_cpool_index);
 55   }
 56 }
 57 
 58 #if INCLUDE_CDS
 59 void ResolvedMethodEntry::remove_unshareable_info() {
 60   reset_entry();
 61 }
 62 
 63 void ResolvedMethodEntry::mark_and_relocate(ConstantPool* src_cp) {
 64   if (_method == nullptr) {
 65     assert(bytecode2() == Bytecodes::_invokevirtual, "");
 66   } else {
 67     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_method);
 68   }
 69   if (bytecode1() == Bytecodes::_invokeinterface) {
 70     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_entry_specific._interface_klass);
 71   }
 72 #if 0
 73   // OLD CODE ... some of it may need to be salvaged.
 74   Bytecodes::Code invoke_code = bytecode_1();
 75   if (invoke_code != (Bytecodes::Code)0) {
 76     Metadata* f1 = f1_ord();
 77     if (f1 != nullptr) {
 78       ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_f1);
 79       switch (invoke_code) {
 80       case Bytecodes::_invokeinterface:
 81         assert(0, "not implemented");
 82         //assert(f1->is_klass(), "");
 83         //ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_f2); // f2 is interface method
 84         return false;
 85       case Bytecodes::_invokestatic:
 86         // For safety, we support invokestatic only for invoking methods in MethodHandle.
 87         // FIXME -- further restrict it to linkToStatic(), etc?
 88         assert(bytecode_2() == (Bytecodes::Code)0, "must be");
 89         assert(f1->is_method(), "");
 90         assert(f1_as_method()->method_holder()->name()->equals("java/lang/invoke/MethodHandle") ||
 91                f1_as_method()->method_holder()->name()->equals("java/lang/invoke/MethodHandleNatives"), "sanity");
 92         return true;
 93       case Bytecodes::_invokespecial:
 94         assert(f1->is_method(), "must be");
 95         // Also need to work on bytecode_2() below.
 96         break;
 97       case Bytecodes::_invokehandle:
 98         assert(bytecode_2() == (Bytecodes::Code)0, "must be");
 99         assert(f1->is_method(), "");
100         return true;
101       default:
102         ShouldNotReachHere();
103         break;
104       }
105     }
106   }
107 
108   // TODO test case: can invokespecial and invokevirtual share the same CP?
109   invoke_code = bytecode_2();
110   if (invoke_code != (Bytecodes::Code)0) {
111     assert(invoke_code == Bytecodes::_invokevirtual, "must be");
112     if (is_vfinal()) {
113       // f2 is vfinal method
114       ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_f2); // f2 is final method
115     } else {
116       // f2 is vtable index, no need to mark
117       if (DynamicDumpSharedSpaces) {
118         // InstanceKlass::methods() is has been resorted, so we need to
119         // update the vtable_index.
120         int holder_index = src_cp->uncached_klass_ref_index_at(constant_pool_index());
121         Klass* src_klass = src_cp->resolved_klass_at(holder_index);
122         Method* src_m = src_klass->method_at_vtable(f2_as_index());
123         if (!ArchiveBuilder::current()->is_in_mapped_static_archive(src_m->method_holder()) &&
124             !ArchiveBuilder::current()->is_in_mapped_static_archive(src_m)) {
125           Klass* buffered_klass = ArchiveBuilder::current()->get_buffered_addr(src_klass);
126           Method* buffered_m = ArchiveBuilder::current()->get_buffered_addr(src_m);
127           int vtable_index;
128           if (src_m->method_holder()->is_interface()) { // default or miranda method
129             assert(src_m->vtable_index() < 0, "must be");
130             assert(buffered_klass->is_instance_klass(), "must be");
131             vtable_index = InstanceKlass::cast(buffered_klass)->vtable_index_of_interface_method(buffered_m);
132             assert(vtable_index >= 0, "must be");
133           } else {
134             vtable_index = buffered_m->vtable_index();
135             assert(vtable_index >= 0, "must be");
136           }
137           if (_f2 != vtable_index) {
138             log_trace(cds, resolve)("vtable_index changed %d => %d", (int)_f2, vtable_index);
139             _f2 = vtable_index;
140           }
141         }
142       }
143     }
144   }
145 
146 #endif
147 }
148 #endif
149 
150 void ResolvedMethodEntry::print_on(outputStream* st) const {
151   st->print_cr("Method Entry:");
152 
153   if (method() != nullptr) {
154     st->print_cr(" - Method: " INTPTR_FORMAT " %s", p2i(method()), method()->external_name());
155   } else {
156     st->print_cr("- Method: null");
157   }
158   // Some fields are mutually exclusive and are only used by certain invoke codes
159   if (bytecode1() == Bytecodes::_invokeinterface && interface_klass() != nullptr) {
160     st->print_cr(" - Klass: " INTPTR_FORMAT " %s", p2i(interface_klass()), interface_klass()->external_name());
161   } else {
162     st->print_cr("- Klass: null");
163   }
164   if (bytecode1() == Bytecodes::_invokehandle) {
165     st->print_cr(" - Resolved References Index: %d", resolved_references_index());
166   } else {
< prev index next >