< prev index next >

src/share/vm/jvmci/jvmciEnv.cpp

Print this page



 269     return;
 270   }
 271 
 272   assert(canonical_holder == field_desc.field_holder(), "just checking");
 273 }
 274 
 275 // ------------------------------------------------------------------
 276 // Get a field by index from a klass's constant pool.
 277 void JVMCIEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd, int index) {
 278   ResourceMark rm;
 279   return get_field_by_index_impl(accessor, fd, index);
 280 }
 281 
 282 // ------------------------------------------------------------------
 283 // Perform an appropriate method lookup based on accessor, holder,
 284 // name, signature, and bytecode.
 285 methodHandle JVMCIEnv::lookup_method(instanceKlassHandle h_accessor,
 286                                instanceKlassHandle h_holder,
 287                                Symbol*       name,
 288                                Symbol*       sig,
 289                                Bytecodes::Code bc) {

 290   JVMCI_EXCEPTION_CONTEXT;
 291   LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
 292   methodHandle dest_method;
 293   LinkInfo link_info(h_holder, name, sig, h_accessor, /*check_access*/true);
 294   switch (bc) {
 295   case Bytecodes::_invokestatic:
 296     dest_method =
 297       LinkResolver::resolve_static_call_or_null(link_info);
 298     break;
 299   case Bytecodes::_invokespecial:
 300     dest_method =
 301       LinkResolver::resolve_special_call_or_null(link_info);
 302     break;
 303   case Bytecodes::_invokeinterface:
 304     dest_method =
 305       LinkResolver::linktime_resolve_interface_method_or_null(link_info);
 306     break;
 307   case Bytecodes::_invokevirtual:
 308     dest_method =
 309       LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
 310     break;
 311   default: ShouldNotReachHere();
 312   }
 313 


 346     // Short-circuit lookups for JSR 292-related call sites.
 347     // That is, do not rely only on name-based lookups, because they may fail
 348     // if the names are not resolvable in the boot class loader (7056328).
 349     switch (bc) {
 350     case Bytecodes::_invokevirtual:
 351     case Bytecodes::_invokeinterface:
 352     case Bytecodes::_invokespecial:
 353     case Bytecodes::_invokestatic:
 354       {
 355         Method* m = ConstantPool::method_at_if_loaded(cpool, index);
 356         if (m != NULL) {
 357           return m;
 358         }
 359       }
 360       break;
 361     }
 362   }
 363 
 364   if (holder_is_accessible) { // Our declared holder is loaded.
 365     instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder);
 366     methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc);

 367     if (!m.is_null() &&
 368         (bc == Bytecodes::_invokestatic
 369          ?  InstanceKlass::cast(m->method_holder())->is_not_initialized()
 370          : !InstanceKlass::cast(m->method_holder())->is_loaded())) {
 371       m = NULL;
 372     }
 373     if (!m.is_null()) {
 374       // We found the method.
 375       return m;
 376     }
 377   }
 378 
 379   // Either the declared holder was not loaded, or the method could
 380   // not be found.
 381 
 382   return NULL;
 383 }
 384 
 385 // ------------------------------------------------------------------
 386 instanceKlassHandle JVMCIEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) {



 269     return;
 270   }
 271 
 272   assert(canonical_holder == field_desc.field_holder(), "just checking");
 273 }
 274 
 275 // ------------------------------------------------------------------
 276 // Get a field by index from a klass's constant pool.
 277 void JVMCIEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd, int index) {
 278   ResourceMark rm;
 279   return get_field_by_index_impl(accessor, fd, index);
 280 }
 281 
 282 // ------------------------------------------------------------------
 283 // Perform an appropriate method lookup based on accessor, holder,
 284 // name, signature, and bytecode.
 285 methodHandle JVMCIEnv::lookup_method(instanceKlassHandle h_accessor,
 286                                instanceKlassHandle h_holder,
 287                                Symbol*       name,
 288                                Symbol*       sig,
 289                                Bytecodes::Code bc,
 290                                constantTag   tag) {
 291   JVMCI_EXCEPTION_CONTEXT;
 292   LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
 293   methodHandle dest_method;
 294   LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag);
 295   switch (bc) {
 296   case Bytecodes::_invokestatic:
 297     dest_method =
 298       LinkResolver::resolve_static_call_or_null(link_info);
 299     break;
 300   case Bytecodes::_invokespecial:
 301     dest_method =
 302       LinkResolver::resolve_special_call_or_null(link_info);
 303     break;
 304   case Bytecodes::_invokeinterface:
 305     dest_method =
 306       LinkResolver::linktime_resolve_interface_method_or_null(link_info);
 307     break;
 308   case Bytecodes::_invokevirtual:
 309     dest_method =
 310       LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
 311     break;
 312   default: ShouldNotReachHere();
 313   }
 314 


 347     // Short-circuit lookups for JSR 292-related call sites.
 348     // That is, do not rely only on name-based lookups, because they may fail
 349     // if the names are not resolvable in the boot class loader (7056328).
 350     switch (bc) {
 351     case Bytecodes::_invokevirtual:
 352     case Bytecodes::_invokeinterface:
 353     case Bytecodes::_invokespecial:
 354     case Bytecodes::_invokestatic:
 355       {
 356         Method* m = ConstantPool::method_at_if_loaded(cpool, index);
 357         if (m != NULL) {
 358           return m;
 359         }
 360       }
 361       break;
 362     }
 363   }
 364 
 365   if (holder_is_accessible) { // Our declared holder is loaded.
 366     instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder);
 367     constantTag tag = cpool->tag_ref_at(index);
 368     methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc, tag);
 369     if (!m.is_null() &&
 370         (bc == Bytecodes::_invokestatic
 371          ?  InstanceKlass::cast(m->method_holder())->is_not_initialized()
 372          : !InstanceKlass::cast(m->method_holder())->is_loaded())) {
 373       m = NULL;
 374     }
 375     if (!m.is_null()) {
 376       // We found the method.
 377       return m;
 378     }
 379   }
 380 
 381   // Either the declared holder was not loaded, or the method could
 382   // not be found.
 383 
 384   return NULL;
 385 }
 386 
 387 // ------------------------------------------------------------------
 388 instanceKlassHandle JVMCIEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) {


< prev index next >