< prev index next >

src/hotspot/share/oops/resolvedMethodEntry.cpp

Print this page

 48     u2 saved_cpool_index = _cpool_index;
 49     memset(this, 0, sizeof(*this));
 50     _cpool_index = saved_cpool_index;
 51   }
 52 }
 53 
 54 #if INCLUDE_CDS
 55 void ResolvedMethodEntry::remove_unshareable_info() {
 56   reset_entry();
 57 }
 58 
 59 void ResolvedMethodEntry::mark_and_relocate(ConstantPool* src_cp) {
 60   if (_method == nullptr) {
 61     assert(bytecode2() == Bytecodes::_invokevirtual, "");
 62   } else {
 63     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_method);
 64   }
 65   if (bytecode1() == Bytecodes::_invokeinterface) {
 66     ArchiveBuilder::current()->mark_and_relocate_to_buffered_addr(&_entry_specific._interface_klass);
 67   }











































































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

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