Fri, 03 Sep 2010 17:51:07 -0700
6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #include "incls/_precompiled.incl"
26 #include "incls/_linkResolver.cpp.incl"
28 //------------------------------------------------------------------------------------------------------------------------
29 // Implementation of FieldAccessInfo
31 void FieldAccessInfo::set(KlassHandle klass, symbolHandle name, int field_index, int field_offset,
32 BasicType field_type, AccessFlags access_flags) {
33 _klass = klass;
34 _name = name;
35 _field_index = field_index;
36 _field_offset = field_offset;
37 _field_type = field_type;
38 _access_flags = access_flags;
39 }
42 //------------------------------------------------------------------------------------------------------------------------
43 // Implementation of CallInfo
46 void CallInfo::set_static(KlassHandle resolved_klass, methodHandle resolved_method, TRAPS) {
47 int vtable_index = methodOopDesc::nonvirtual_vtable_index;
48 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, vtable_index, CHECK);
49 }
52 void CallInfo::set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, TRAPS) {
53 // This is only called for interface methods. If the resolved_method
54 // comes from java/lang/Object, it can be the subject of a virtual call, so
55 // we should pick the vtable index from the resolved method.
56 // Other than that case, there is no valid vtable index to specify.
57 int vtable_index = methodOopDesc::invalid_vtable_index;
58 if (resolved_method->method_holder() == SystemDictionary::Object_klass()) {
59 assert(resolved_method->vtable_index() == selected_method->vtable_index(), "sanity check");
60 vtable_index = resolved_method->vtable_index();
61 }
62 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
63 }
65 void CallInfo::set_virtual(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
66 assert(vtable_index >= 0 || vtable_index == methodOopDesc::nonvirtual_vtable_index, "valid index");
67 set_common(resolved_klass, selected_klass, resolved_method, selected_method, vtable_index, CHECK);
68 }
70 void CallInfo::set_dynamic(methodHandle resolved_method, TRAPS) {
71 assert(resolved_method->is_method_handle_invoke(), "");
72 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
73 assert(resolved_klass == resolved_method->method_holder(), "");
74 int vtable_index = methodOopDesc::nonvirtual_vtable_index;
75 assert(resolved_method->vtable_index() == vtable_index, "");
76 set_common(resolved_klass, KlassHandle(), resolved_method, resolved_method, vtable_index, CHECK);
77 }
79 void CallInfo::set_common(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS) {
80 assert(resolved_method->signature() == selected_method->signature(), "signatures must correspond");
81 _resolved_klass = resolved_klass;
82 _selected_klass = selected_klass;
83 _resolved_method = resolved_method;
84 _selected_method = selected_method;
85 _vtable_index = vtable_index;
86 if (CompilationPolicy::must_be_compiled(selected_method)) {
87 // This path is unusual, mostly used by the '-Xcomp' stress test mode.
89 // Note: with several active threads, the must_be_compiled may be true
90 // while can_be_compiled is false; remove assert
91 // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile");
92 if (THREAD->is_Compiler_thread()) {
93 // don't force compilation, resolve was on behalf of compiler
94 return;
95 }
96 if (instanceKlass::cast(selected_method->method_holder())->is_not_initialized()) {
97 // 'is_not_initialized' means not only '!is_initialized', but also that
98 // initialization has not been started yet ('!being_initialized')
99 // Do not force compilation of methods in uninitialized classes.
100 // Note that doing this would throw an assert later,
101 // in CompileBroker::compile_method.
102 // We sometimes use the link resolver to do reflective lookups
103 // even before classes are initialized.
104 return;
105 }
106 CompileBroker::compile_method(selected_method, InvocationEntryBci,
107 CompLevel_initial_compile,
108 methodHandle(), 0, "must_be_compiled", CHECK);
109 }
110 }
113 //------------------------------------------------------------------------------------------------------------------------
114 // Klass resolution
116 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
117 if (!Reflection::verify_class_access(ref_klass->as_klassOop(),
118 sel_klass->as_klassOop(),
119 true)) {
120 ResourceMark rm(THREAD);
121 Exceptions::fthrow(
122 THREAD_AND_LOCATION,
123 vmSymbolHandles::java_lang_IllegalAccessError(),
124 "tried to access class %s from class %s",
125 sel_klass->external_name(),
126 ref_klass->external_name()
127 );
128 return;
129 }
130 }
132 void LinkResolver::resolve_klass(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
133 klassOop result_oop = pool->klass_ref_at(index, CHECK);
134 result = KlassHandle(THREAD, result_oop);
135 }
137 void LinkResolver::resolve_klass_no_update(KlassHandle& result, constantPoolHandle pool, int index, TRAPS) {
138 klassOop result_oop =
139 constantPoolOopDesc::klass_ref_at_if_loaded_check(pool, index, CHECK);
140 result = KlassHandle(THREAD, result_oop);
141 }
144 //------------------------------------------------------------------------------------------------------------------------
145 // Method resolution
146 //
147 // According to JVM spec. $5.4.3c & $5.4.3d
149 void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
150 methodOop result_oop = klass->uncached_lookup_method(name(), signature());
151 if (EnableMethodHandles && result_oop != NULL) {
152 switch (result_oop->intrinsic_id()) {
153 case vmIntrinsics::_invokeExact:
154 case vmIntrinsics::_invokeGeneric:
155 case vmIntrinsics::_invokeDynamic:
156 // Do not link directly to these. The VM must produce a synthetic one using lookup_implicit_method.
157 return;
158 }
159 }
160 result = methodHandle(THREAD, result_oop);
161 }
163 // returns first instance method
164 void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
165 methodOop result_oop = klass->uncached_lookup_method(name(), signature());
166 result = methodHandle(THREAD, result_oop);
167 while (!result.is_null() && result->is_static()) {
168 klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super());
169 result = methodHandle(THREAD, klass->uncached_lookup_method(name(), signature()));
170 }
171 }
174 int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
175 ResourceMark rm(THREAD);
176 klassVtable *vt = instanceKlass::cast(klass())->vtable();
177 return vt->index_of_miranda(name(), signature());
178 }
180 void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
181 instanceKlass *ik = instanceKlass::cast(klass());
182 result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature()));
183 }
185 void LinkResolver::lookup_implicit_method(methodHandle& result,
186 KlassHandle klass, symbolHandle name, symbolHandle signature,
187 KlassHandle current_klass,
188 TRAPS) {
189 if (EnableMethodHandles &&
190 klass() == SystemDictionary::MethodHandle_klass() &&
191 methodOopDesc::is_method_handle_invoke_name(name())) {
192 if (!MethodHandles::enabled()) {
193 // Make sure the Java part of the runtime has been booted up.
194 klassOop natives = SystemDictionary::MethodHandleNatives_klass();
195 if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) {
196 SystemDictionary::resolve_or_fail(vmSymbolHandles::sun_dyn_MethodHandleNatives(),
197 Handle(),
198 Handle(),
199 true,
200 CHECK);
201 }
202 }
203 methodOop result_oop = SystemDictionary::find_method_handle_invoke(name,
204 signature,
205 current_klass,
206 CHECK);
207 if (result_oop != NULL) {
208 assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent");
209 result = methodHandle(THREAD, result_oop);
210 }
211 }
212 }
214 void LinkResolver::check_method_accessability(KlassHandle ref_klass,
215 KlassHandle resolved_klass,
216 KlassHandle sel_klass,
217 methodHandle sel_method,
218 TRAPS) {
220 AccessFlags flags = sel_method->access_flags();
222 // Special case: arrays always override "clone". JVMS 2.15.
223 // If the resolved klass is an array class, and the declaring class
224 // is java.lang.Object and the method is "clone", set the flags
225 // to public.
226 //
227 // We'll check for the method name first, as that's most likely
228 // to be false (so we'll short-circuit out of these tests).
229 if (sel_method->name() == vmSymbols::clone_name() &&
230 sel_klass() == SystemDictionary::Object_klass() &&
231 resolved_klass->oop_is_array()) {
232 // We need to change "protected" to "public".
233 assert(flags.is_protected(), "clone not protected?");
234 jint new_flags = flags.as_int();
235 new_flags = new_flags & (~JVM_ACC_PROTECTED);
236 new_flags = new_flags | JVM_ACC_PUBLIC;
237 flags.set_flags(new_flags);
238 }
240 if (!Reflection::verify_field_access(ref_klass->as_klassOop(),
241 resolved_klass->as_klassOop(),
242 sel_klass->as_klassOop(),
243 flags,
244 true)) {
245 ResourceMark rm(THREAD);
246 Exceptions::fthrow(
247 THREAD_AND_LOCATION,
248 vmSymbolHandles::java_lang_IllegalAccessError(),
249 "tried to access method %s.%s%s from class %s",
250 sel_klass->external_name(),
251 sel_method->name()->as_C_string(),
252 sel_method->signature()->as_C_string(),
253 ref_klass->external_name()
254 );
255 return;
256 }
257 }
259 void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle& resolved_klass,
260 constantPoolHandle pool, int index, TRAPS) {
262 // resolve klass
263 resolve_klass(resolved_klass, pool, index, CHECK);
265 symbolHandle method_name (THREAD, pool->name_ref_at(index));
266 symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
267 KlassHandle current_klass(THREAD, pool->pool_holder());
269 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
270 }
272 void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) {
273 // The class is java.dyn.MethodHandle
274 resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
276 symbolHandle method_name = vmSymbolHandles::invokeExact_name();
278 symbolHandle method_signature(THREAD, pool->signature_ref_at(index));
279 KlassHandle current_klass (THREAD, pool->pool_holder());
281 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
282 }
284 void LinkResolver::resolve_interface_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) {
286 // resolve klass
287 resolve_klass(resolved_klass, pool, index, CHECK);
288 symbolHandle method_name (THREAD, pool->name_ref_at(index));
289 symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
290 KlassHandle current_klass(THREAD, pool->pool_holder());
292 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
293 }
296 void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass,
297 symbolHandle method_name, symbolHandle method_signature,
298 KlassHandle current_klass, bool check_access, TRAPS) {
300 // 1. check if klass is not interface
301 if (resolved_klass->is_interface()) {
302 char buf[200];
303 jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected", Klass::cast(resolved_klass())->external_name());
304 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
305 }
307 // 2. lookup method in resolved klass and its super klasses
308 lookup_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK);
310 if (resolved_method.is_null()) { // not found in the class hierarchy
311 // 3. lookup method in all the interfaces implemented by the resolved klass
312 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
314 if (resolved_method.is_null()) {
315 // JSR 292: see if this is an implicitly generated method MethodHandle.invoke(*...)
316 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, CHECK);
317 }
319 if (resolved_method.is_null()) {
320 // 4. method lookup failed
321 ResourceMark rm(THREAD);
322 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
323 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
324 method_name(),
325 method_signature()));
326 }
327 }
329 // 5. check if method is concrete
330 if (resolved_method->is_abstract() && !resolved_klass->is_abstract()) {
331 ResourceMark rm(THREAD);
332 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
333 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
334 method_name(),
335 method_signature()));
336 }
338 // 6. access checks, access checking may be turned off when calling from within the VM.
339 if (check_access) {
340 assert(current_klass.not_null() , "current_klass should not be null");
342 // check if method can be accessed by the referring class
343 check_method_accessability(current_klass,
344 resolved_klass,
345 KlassHandle(THREAD, resolved_method->method_holder()),
346 resolved_method,
347 CHECK);
349 // check loader constraints
350 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader());
351 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader());
352 {
353 ResourceMark rm(THREAD);
354 char* failed_type_name =
355 SystemDictionary::check_signature_loaders(method_signature, loader,
356 class_loader, true, CHECK);
357 if (failed_type_name != NULL) {
358 const char* msg = "loader constraint violation: when resolving method"
359 " \"%s\" the class loader (instance of %s) of the current class, %s,"
360 " and the class loader (instance of %s) for resolved class, %s, have"
361 " different Class objects for the type %s used in the signature";
362 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
363 const char* loader1 = SystemDictionary::loader_name(loader());
364 char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
365 const char* loader2 = SystemDictionary::loader_name(class_loader());
366 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string();
367 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
368 strlen(current) + strlen(loader2) + strlen(resolved) +
369 strlen(failed_type_name);
370 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
371 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
372 resolved, failed_type_name);
373 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
374 }
375 }
376 }
377 }
379 void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
380 KlassHandle resolved_klass,
381 symbolHandle method_name,
382 symbolHandle method_signature,
383 KlassHandle current_klass,
384 bool check_access, TRAPS) {
386 // check if klass is interface
387 if (!resolved_klass->is_interface()) {
388 char buf[200];
389 jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", Klass::cast(resolved_klass())->external_name());
390 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
391 }
393 // lookup method in this interface or its super, java.lang.Object
394 lookup_instance_method_in_klasses(resolved_method, resolved_klass, method_name, method_signature, CHECK);
396 if (resolved_method.is_null()) {
397 // lookup method in all the super-interfaces
398 lookup_method_in_interfaces(resolved_method, resolved_klass, method_name, method_signature, CHECK);
399 if (resolved_method.is_null()) {
400 // no method found
401 ResourceMark rm(THREAD);
402 THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
403 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
404 method_name(),
405 method_signature()));
406 }
407 }
409 if (check_access) {
410 HandleMark hm(THREAD);
411 Handle loader (THREAD, instanceKlass::cast(current_klass())->class_loader());
412 Handle class_loader (THREAD, instanceKlass::cast(resolved_method->method_holder())->class_loader());
413 {
414 ResourceMark rm(THREAD);
415 char* failed_type_name =
416 SystemDictionary::check_signature_loaders(method_signature, loader,
417 class_loader, true, CHECK);
418 if (failed_type_name != NULL) {
419 const char* msg = "loader constraint violation: when resolving "
420 "interface method \"%s\" the class loader (instance of %s) of the "
421 "current class, %s, and the class loader (instance of %s) for "
422 "resolved class, %s, have different Class objects for the type %s "
423 "used in the signature";
424 char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
425 const char* loader1 = SystemDictionary::loader_name(loader());
426 char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
427 const char* loader2 = SystemDictionary::loader_name(class_loader());
428 char* resolved = instanceKlass::cast(resolved_klass())->name()->as_C_string();
429 size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
430 strlen(current) + strlen(loader2) + strlen(resolved) +
431 strlen(failed_type_name);
432 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
433 jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
434 resolved, failed_type_name);
435 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
436 }
437 }
438 }
439 }
441 //------------------------------------------------------------------------------------------------------------------------
442 // Field resolution
444 void LinkResolver::check_field_accessability(KlassHandle ref_klass,
445 KlassHandle resolved_klass,
446 KlassHandle sel_klass,
447 fieldDescriptor& fd,
448 TRAPS) {
449 if (!Reflection::verify_field_access(ref_klass->as_klassOop(),
450 resolved_klass->as_klassOop(),
451 sel_klass->as_klassOop(),
452 fd.access_flags(),
453 true)) {
454 ResourceMark rm(THREAD);
455 Exceptions::fthrow(
456 THREAD_AND_LOCATION,
457 vmSymbolHandles::java_lang_IllegalAccessError(),
458 "tried to access field %s.%s from class %s",
459 sel_klass->external_name(),
460 fd.name()->as_C_string(),
461 ref_klass->external_name()
462 );
463 return;
464 }
465 }
467 void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, TRAPS) {
468 resolve_field(result, pool, index, byte, check_only, true, CHECK);
469 }
471 void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, bool update_pool, TRAPS) {
472 assert(byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic ||
473 byte == Bytecodes::_getfield || byte == Bytecodes::_putfield, "bad bytecode");
475 bool is_static = (byte == Bytecodes::_getstatic || byte == Bytecodes::_putstatic);
476 bool is_put = (byte == Bytecodes::_putfield || byte == Bytecodes::_putstatic);
478 // resolve specified klass
479 KlassHandle resolved_klass;
480 if (update_pool) {
481 resolve_klass(resolved_klass, pool, index, CHECK);
482 } else {
483 resolve_klass_no_update(resolved_klass, pool, index, CHECK);
484 }
485 // Load these early in case the resolve of the containing klass fails
486 symbolOop field = pool->name_ref_at(index);
487 symbolHandle field_h (THREAD, field); // preserve in case we need the name
488 symbolOop sig = pool->signature_ref_at(index);
489 // Check if there's a resolved klass containing the field
490 if( resolved_klass.is_null() ) {
491 ResourceMark rm(THREAD);
492 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
493 }
495 // Resolve instance field
496 fieldDescriptor fd; // find_field initializes fd if found
497 KlassHandle sel_klass(THREAD, instanceKlass::cast(resolved_klass())->find_field(field, sig, &fd));
498 // check if field exists; i.e., if a klass containing the field def has been selected
499 if (sel_klass.is_null()){
500 ResourceMark rm(THREAD);
501 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
502 }
504 // check access
505 KlassHandle ref_klass(THREAD, pool->pool_holder());
506 check_field_accessability(ref_klass, resolved_klass, sel_klass, fd, CHECK);
508 // check for errors
509 if (is_static != fd.is_static()) {
510 char msg[200];
511 jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", Klass::cast(resolved_klass())->external_name(), fd.name()->as_C_string());
512 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
513 }
515 // Final fields can only be accessed from its own class.
516 if (is_put && fd.access_flags().is_final() && sel_klass() != pool->pool_holder()) {
517 THROW(vmSymbols::java_lang_IllegalAccessError());
518 }
520 // initialize resolved_klass if necessary
521 // note 1: the klass which declared the field must be initialized (i.e, sel_klass)
522 // according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
523 //
524 // note 2: we don't want to force initialization if we are just checking
525 // if the field access is legal; e.g., during compilation
526 if (is_static && !check_only) {
527 sel_klass->initialize(CHECK);
528 }
530 {
531 HandleMark hm(THREAD);
532 Handle ref_loader (THREAD, instanceKlass::cast(ref_klass())->class_loader());
533 Handle sel_loader (THREAD, instanceKlass::cast(sel_klass())->class_loader());
534 symbolHandle signature_ref (THREAD, pool->signature_ref_at(index));
535 {
536 ResourceMark rm(THREAD);
537 char* failed_type_name =
538 SystemDictionary::check_signature_loaders(signature_ref,
539 ref_loader, sel_loader,
540 false,
541 CHECK);
542 if (failed_type_name != NULL) {
543 const char* msg = "loader constraint violation: when resolving field"
544 " \"%s\" the class loader (instance of %s) of the referring class, "
545 "%s, and the class loader (instance of %s) for the field's resolved "
546 "type, %s, have different Class objects for that type";
547 char* field_name = field_h()->as_C_string();
548 const char* loader1 = SystemDictionary::loader_name(ref_loader());
549 char* sel = instanceKlass::cast(sel_klass())->name()->as_C_string();
550 const char* loader2 = SystemDictionary::loader_name(sel_loader());
551 size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) +
552 strlen(sel) + strlen(loader2) + strlen(failed_type_name);
553 char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
554 jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2,
555 failed_type_name);
556 THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
557 }
558 }
559 }
561 // return information. note that the klass is set to the actual klass containing the
562 // field, otherwise access of static fields in superclasses will not work.
563 KlassHandle holder (THREAD, fd.field_holder());
564 symbolHandle name (THREAD, fd.name());
565 result.set(holder, name, fd.index(), fd.offset(), fd.field_type(), fd.access_flags());
566 }
569 //------------------------------------------------------------------------------------------------------------------------
570 // Invoke resolution
571 //
572 // Naming conventions:
573 //
574 // resolved_method the specified method (i.e., static receiver specified via constant pool index)
575 // sel_method the selected method (selected via run-time lookup; e.g., based on dynamic receiver class)
576 // resolved_klass the specified klass (i.e., specified via constant pool index)
577 // recv_klass the receiver klass
580 void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, symbolHandle method_name,
581 symbolHandle method_signature, KlassHandle current_klass,
582 bool check_access, bool initialize_class, TRAPS) {
583 methodHandle resolved_method;
584 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
585 resolved_klass = KlassHandle(THREAD, Klass::cast(resolved_method->method_holder()));
587 // Initialize klass (this should only happen if everything is ok)
588 if (initialize_class && resolved_klass->should_be_initialized()) {
589 resolved_klass->initialize(CHECK);
590 linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
591 }
593 // setup result
594 result.set_static(resolved_klass, resolved_method, CHECK);
595 }
597 // throws linktime exceptions
598 void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, KlassHandle resolved_klass,
599 symbolHandle method_name, symbolHandle method_signature,
600 KlassHandle current_klass, bool check_access, TRAPS) {
602 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
603 assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier");
605 // check if static
606 if (!resolved_method->is_static()) {
607 char buf[200];
608 jio_snprintf(buf, sizeof(buf), "Expected static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
609 resolved_method->name(),
610 resolved_method->signature()));
611 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
612 }
613 }
616 void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, symbolHandle method_name,
617 symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
618 methodHandle resolved_method;
619 linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
620 runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK);
621 }
623 // throws linktime exceptions
624 void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method, KlassHandle resolved_klass,
625 symbolHandle method_name, symbolHandle method_signature,
626 KlassHandle current_klass, bool check_access, TRAPS) {
628 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
630 // check if method name is <init>, that it is found in same klass as static type
631 if (resolved_method->name() == vmSymbols::object_initializer_name() &&
632 resolved_method->method_holder() != resolved_klass()) {
633 ResourceMark rm(THREAD);
634 Exceptions::fthrow(
635 THREAD_AND_LOCATION,
636 vmSymbolHandles::java_lang_NoSuchMethodError(),
637 "%s: method %s%s not found",
638 resolved_klass->external_name(),
639 resolved_method->name()->as_C_string(),
640 resolved_method->signature()->as_C_string()
641 );
642 return;
643 }
645 // check if not static
646 if (resolved_method->is_static()) {
647 char buf[200];
648 jio_snprintf(buf, sizeof(buf),
649 "Expecting non-static method %s",
650 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
651 resolved_method->name(),
652 resolved_method->signature()));
653 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
654 }
655 }
657 // throws runtime exceptions
658 void LinkResolver::runtime_resolve_special_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
659 KlassHandle current_klass, bool check_access, TRAPS) {
661 // resolved method is selected method unless we have an old-style lookup
662 methodHandle sel_method(THREAD, resolved_method());
664 // check if this is an old-style super call and do a new lookup if so
665 { KlassHandle method_klass = KlassHandle(THREAD,
666 resolved_method->method_holder());
668 if (check_access &&
669 // a) check if ACC_SUPER flag is set for the current class
670 current_klass->is_super() &&
671 // b) check if the method class is a superclass of the current class (superclass relation is not reflexive!)
672 current_klass->is_subtype_of(method_klass()) && current_klass() != method_klass() &&
673 // c) check if the method is not <init>
674 resolved_method->name() != vmSymbols::object_initializer_name()) {
675 // Lookup super method
676 KlassHandle super_klass(THREAD, current_klass->super());
677 lookup_instance_method_in_klasses(sel_method, super_klass,
678 symbolHandle(THREAD, resolved_method->name()),
679 symbolHandle(THREAD, resolved_method->signature()), CHECK);
680 // check if found
681 if (sel_method.is_null()) {
682 ResourceMark rm(THREAD);
683 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
684 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
685 resolved_method->name(),
686 resolved_method->signature()));
687 }
688 }
689 }
691 // check if not static
692 if (sel_method->is_static()) {
693 char buf[200];
694 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
695 resolved_method->name(),
696 resolved_method->signature()));
697 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
698 }
700 // check if abstract
701 if (sel_method->is_abstract()) {
702 ResourceMark rm(THREAD);
703 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
704 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
705 sel_method->name(),
706 sel_method->signature()));
707 }
709 // setup result
710 result.set_static(resolved_klass, sel_method, CHECK);
711 }
713 void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, KlassHandle resolved_klass,
714 symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
715 bool check_access, bool check_null_and_abstract, TRAPS) {
716 methodHandle resolved_method;
717 linktime_resolve_virtual_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
718 runtime_resolve_virtual_method(result, resolved_method, resolved_klass, recv, receiver_klass, check_null_and_abstract, CHECK);
719 }
721 // throws linktime exceptions
722 void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method, KlassHandle resolved_klass,
723 symbolHandle method_name, symbolHandle method_signature,
724 KlassHandle current_klass, bool check_access, TRAPS) {
725 // normal method resolution
726 resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
728 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
729 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
731 // check if not static
732 if (resolved_method->is_static()) {
733 char buf[200];
734 jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
735 resolved_method->name(),
736 resolved_method->signature()));
737 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
738 }
739 }
741 // throws runtime exceptions
742 void LinkResolver::runtime_resolve_virtual_method(CallInfo& result,
743 methodHandle resolved_method,
744 KlassHandle resolved_klass,
745 Handle recv,
746 KlassHandle recv_klass,
747 bool check_null_and_abstract,
748 TRAPS) {
750 // setup default return values
751 int vtable_index = methodOopDesc::invalid_vtable_index;
752 methodHandle selected_method;
754 assert(recv.is_null() || recv->is_oop(), "receiver is not an oop");
756 // runtime method resolution
757 if (check_null_and_abstract && recv.is_null()) { // check if receiver exists
758 THROW(vmSymbols::java_lang_NullPointerException());
759 }
761 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's
762 // has not been rewritten, and the vtable initialized.
763 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
765 // Virtual methods cannot be resolved before its klass has been linked, for otherwise the methodOop's
766 // has not been rewritten, and the vtable initialized. Make sure to do this after the nullcheck, since
767 // a missing receiver might result in a bogus lookup.
768 assert(instanceKlass::cast(resolved_method->method_holder())->is_linked(), "must be linked");
770 // do lookup based on receiver klass using the vtable index
771 if (resolved_method->method_holder()->klass_part()->is_interface()) { // miranda method
772 vtable_index = vtable_index_of_miranda_method(resolved_klass,
773 symbolHandle(THREAD, resolved_method->name()),
774 symbolHandle(THREAD, resolved_method->signature()), CHECK);
775 assert(vtable_index >= 0 , "we should have valid vtable index at this point");
777 instanceKlass* inst = instanceKlass::cast(recv_klass());
778 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
779 } else {
780 // at this point we are sure that resolved_method is virtual and not
781 // a miranda method; therefore, it must have a valid vtable index.
782 vtable_index = resolved_method->vtable_index();
783 // We could get a negative vtable_index for final methods,
784 // because as an optimization they are they are never put in the vtable,
785 // unless they override an existing method.
786 // If we do get a negative, it means the resolved method is the the selected
787 // method, and it can never be changed by an override.
788 if (vtable_index == methodOopDesc::nonvirtual_vtable_index) {
789 assert(resolved_method->can_be_statically_bound(), "cannot override this method");
790 selected_method = resolved_method;
791 } else {
792 // recv_klass might be an arrayKlassOop but all vtables start at
793 // the same place. The cast is to avoid virtual call and assertion.
794 instanceKlass* inst = (instanceKlass*)recv_klass()->klass_part();
795 selected_method = methodHandle(THREAD, inst->method_at_vtable(vtable_index));
796 }
797 }
799 // check if method exists
800 if (selected_method.is_null()) {
801 ResourceMark rm(THREAD);
802 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
803 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
804 resolved_method->name(),
805 resolved_method->signature()));
806 }
808 // check if abstract
809 if (check_null_and_abstract && selected_method->is_abstract()) {
810 ResourceMark rm(THREAD);
811 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
812 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
813 selected_method->name(),
814 selected_method->signature()));
815 }
817 // setup result
818 result.set_virtual(resolved_klass, recv_klass, resolved_method, selected_method, vtable_index, CHECK);
819 }
821 void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass,
822 symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
823 bool check_access, bool check_null_and_abstract, TRAPS) {
824 methodHandle resolved_method;
825 linktime_resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
826 runtime_resolve_interface_method(result, resolved_method, resolved_klass, recv, recv_klass, check_null_and_abstract, CHECK);
827 }
829 // throws linktime exceptions
830 void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name,
831 symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
832 // normal interface method resolution
833 resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
835 assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier");
836 assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier");
837 }
839 // throws runtime exceptions
840 void LinkResolver::runtime_resolve_interface_method(CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass,
841 Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS) {
842 // check if receiver exists
843 if (check_null_and_abstract && recv.is_null()) {
844 THROW(vmSymbols::java_lang_NullPointerException());
845 }
847 // check if receiver klass implements the resolved interface
848 if (!recv_klass->is_subtype_of(resolved_klass())) {
849 char buf[200];
850 jio_snprintf(buf, sizeof(buf), "Class %s does not implement the requested interface %s",
851 (Klass::cast(recv_klass()))->external_name(),
852 (Klass::cast(resolved_klass()))->external_name());
853 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
854 }
855 // do lookup based on receiver klass
856 methodHandle sel_method;
857 lookup_instance_method_in_klasses(sel_method, recv_klass,
858 symbolHandle(THREAD, resolved_method->name()),
859 symbolHandle(THREAD, resolved_method->signature()), CHECK);
860 // check if method exists
861 if (sel_method.is_null()) {
862 ResourceMark rm(THREAD);
863 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
864 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
865 resolved_method->name(),
866 resolved_method->signature()));
867 }
868 // check if public
869 if (!sel_method->is_public()) {
870 ResourceMark rm(THREAD);
871 THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
872 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
873 sel_method->name(),
874 sel_method->signature()));
875 }
876 // check if abstract
877 if (check_null_and_abstract && sel_method->is_abstract()) {
878 ResourceMark rm(THREAD);
879 THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
880 methodOopDesc::name_and_sig_as_C_string(Klass::cast(recv_klass()),
881 sel_method->name(),
882 sel_method->signature()));
883 }
884 // setup result
885 result.set_interface(resolved_klass, recv_klass, resolved_method, sel_method, CHECK);
886 }
889 methodHandle LinkResolver::linktime_resolve_interface_method_or_null(
890 KlassHandle resolved_klass,
891 symbolHandle method_name,
892 symbolHandle method_signature,
893 KlassHandle current_klass,
894 bool check_access) {
895 EXCEPTION_MARK;
896 methodHandle method_result;
897 linktime_resolve_interface_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
898 if (HAS_PENDING_EXCEPTION) {
899 CLEAR_PENDING_EXCEPTION;
900 return methodHandle();
901 } else {
902 return method_result;
903 }
904 }
906 methodHandle LinkResolver::linktime_resolve_virtual_method_or_null(
907 KlassHandle resolved_klass,
908 symbolHandle method_name,
909 symbolHandle method_signature,
910 KlassHandle current_klass,
911 bool check_access) {
912 EXCEPTION_MARK;
913 methodHandle method_result;
914 linktime_resolve_virtual_method(method_result, resolved_klass, method_name, method_signature, current_klass, check_access, THREAD);
915 if (HAS_PENDING_EXCEPTION) {
916 CLEAR_PENDING_EXCEPTION;
917 return methodHandle();
918 } else {
919 return method_result;
920 }
921 }
923 methodHandle LinkResolver::resolve_virtual_call_or_null(
924 KlassHandle receiver_klass,
925 KlassHandle resolved_klass,
926 symbolHandle name,
927 symbolHandle signature,
928 KlassHandle current_klass) {
929 EXCEPTION_MARK;
930 CallInfo info;
931 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
932 if (HAS_PENDING_EXCEPTION) {
933 CLEAR_PENDING_EXCEPTION;
934 return methodHandle();
935 }
936 return info.selected_method();
937 }
939 methodHandle LinkResolver::resolve_interface_call_or_null(
940 KlassHandle receiver_klass,
941 KlassHandle resolved_klass,
942 symbolHandle name,
943 symbolHandle signature,
944 KlassHandle current_klass) {
945 EXCEPTION_MARK;
946 CallInfo info;
947 resolve_interface_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
948 if (HAS_PENDING_EXCEPTION) {
949 CLEAR_PENDING_EXCEPTION;
950 return methodHandle();
951 }
952 return info.selected_method();
953 }
955 int LinkResolver::resolve_virtual_vtable_index(
956 KlassHandle receiver_klass,
957 KlassHandle resolved_klass,
958 symbolHandle name,
959 symbolHandle signature,
960 KlassHandle current_klass) {
961 EXCEPTION_MARK;
962 CallInfo info;
963 resolve_virtual_call(info, Handle(), receiver_klass, resolved_klass, name, signature, current_klass, true, false, THREAD);
964 if (HAS_PENDING_EXCEPTION) {
965 CLEAR_PENDING_EXCEPTION;
966 return methodOopDesc::invalid_vtable_index;
967 }
968 return info.vtable_index();
969 }
971 methodHandle LinkResolver::resolve_static_call_or_null(
972 KlassHandle resolved_klass,
973 symbolHandle name,
974 symbolHandle signature,
975 KlassHandle current_klass) {
976 EXCEPTION_MARK;
977 CallInfo info;
978 resolve_static_call(info, resolved_klass, name, signature, current_klass, true, false, THREAD);
979 if (HAS_PENDING_EXCEPTION) {
980 CLEAR_PENDING_EXCEPTION;
981 return methodHandle();
982 }
983 return info.selected_method();
984 }
986 methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, symbolHandle name, symbolHandle signature,
987 KlassHandle current_klass) {
988 EXCEPTION_MARK;
989 CallInfo info;
990 resolve_special_call(info, resolved_klass, name, signature, current_klass, true, THREAD);
991 if (HAS_PENDING_EXCEPTION) {
992 CLEAR_PENDING_EXCEPTION;
993 return methodHandle();
994 }
995 return info.selected_method();
996 }
1000 //------------------------------------------------------------------------------------------------------------------------
1001 // ConstantPool entries
1003 void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS) {
1004 switch (byte) {
1005 case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break;
1006 case Bytecodes::_invokespecial : resolve_invokespecial (result, pool, index, CHECK); break;
1007 case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break;
1008 case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break;
1009 case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break;
1010 }
1011 return;
1012 }
1014 void LinkResolver::resolve_pool(KlassHandle& resolved_klass, symbolHandle& method_name, symbolHandle& method_signature,
1015 KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS) {
1016 // resolve klass
1017 resolve_klass(resolved_klass, pool, index, CHECK);
1019 // Get name, signature, and static klass
1020 method_name = symbolHandle(THREAD, pool->name_ref_at(index));
1021 method_signature = symbolHandle(THREAD, pool->signature_ref_at(index));
1022 current_klass = KlassHandle(THREAD, pool->pool_holder());
1023 }
1026 void LinkResolver::resolve_invokestatic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
1027 KlassHandle resolved_klass;
1028 symbolHandle method_name;
1029 symbolHandle method_signature;
1030 KlassHandle current_klass;
1031 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1032 resolve_static_call(result, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1033 }
1036 void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
1037 KlassHandle resolved_klass;
1038 symbolHandle method_name;
1039 symbolHandle method_signature;
1040 KlassHandle current_klass;
1041 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1042 resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
1043 }
1046 void LinkResolver::resolve_invokevirtual(CallInfo& result, Handle recv,
1047 constantPoolHandle pool, int index,
1048 TRAPS) {
1050 KlassHandle resolved_klass;
1051 symbolHandle method_name;
1052 symbolHandle method_signature;
1053 KlassHandle current_klass;
1054 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1055 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
1056 resolve_virtual_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1057 }
1060 void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
1061 KlassHandle resolved_klass;
1062 symbolHandle method_name;
1063 symbolHandle method_signature;
1064 KlassHandle current_klass;
1065 resolve_pool(resolved_klass, method_name, method_signature, current_klass, pool, index, CHECK);
1066 KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
1067 resolve_interface_call(result, recv, recvrKlass, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
1068 }
1071 void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int raw_index, TRAPS) {
1072 assert(EnableInvokeDynamic, "");
1074 // This guy is reached from InterpreterRuntime::resolve_invokedynamic.
1076 // At this point, we only need the signature, and can ignore the name.
1077 symbolHandle method_signature(THREAD, pool->signature_ref_at(raw_index)); // raw_index works directly
1078 symbolHandle method_name = vmSymbolHandles::invokeExact_name();
1079 KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
1081 // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...)
1082 // The extra MH receiver will be inserted into the stack on every call.
1083 methodHandle resolved_method;
1084 KlassHandle current_klass(THREAD, pool->pool_holder());
1085 lookup_implicit_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, CHECK);
1086 if (resolved_method.is_null()) {
1087 THROW(vmSymbols::java_lang_InternalError());
1088 }
1089 result.set_dynamic(resolved_method, CHECK);
1090 }
1092 //------------------------------------------------------------------------------------------------------------------------
1093 #ifndef PRODUCT
1095 void FieldAccessInfo::print() {
1096 ResourceMark rm;
1097 tty->print_cr("Field %s@%d", name()->as_C_string(), field_offset());
1098 }
1100 #endif