< prev index next >

src/hotspot/share/ci/ciEnv.cpp

Print this page




 382   }
 383   if (resolved_klass->is_instance_klass()) {
 384     return (Reflection::verify_class_access(accessing_klass->get_Klass(),
 385                                             InstanceKlass::cast(resolved_klass),
 386                                             true) == Reflection::ACCESS_OK);
 387   }
 388   return true;
 389 }
 390 
 391 // ------------------------------------------------------------------
 392 // ciEnv::get_klass_by_name_impl
 393 ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
 394                                        const constantPoolHandle& cpool,
 395                                        ciSymbol* name,
 396                                        bool require_local) {
 397   ASSERT_IN_VM;
 398   EXCEPTION_CONTEXT;
 399 
 400   // Now we need to check the SystemDictionary
 401   Symbol* sym = name->get_symbol();
 402   if (sym->byte_at(0) == 'L' &&
 403     sym->byte_at(sym->utf8_length()-1) == ';') {
 404     // This is a name from a signature.  Strip off the trimmings.
 405     // Call recursive to keep scope of strippedsym.
 406     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 407                     sym->utf8_length()-2,
 408                     KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
 409     ciSymbol* strippedname = get_symbol(strippedsym);
 410     return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local);
 411   }
 412 
 413   // Check for prior unloaded klass.  The SystemDictionary's answers
 414   // can vary over time but the compiler needs consistency.
 415   ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
 416   if (unloaded_klass != NULL) {
 417     if (require_local)  return NULL;
 418     return unloaded_klass;
 419   }
 420 
 421   Handle loader(THREAD, (oop)NULL);
 422   Handle domain(THREAD, (oop)NULL);
 423   if (accessing_klass != NULL) {
 424     loader = Handle(THREAD, accessing_klass->loader());
 425     domain = Handle(THREAD, accessing_klass->protection_domain());
 426   }
 427 
 428   // setup up the proper type to return on OOM
 429   ciKlass* fail_type;
 430   if (sym->byte_at(0) == '[') {
 431     fail_type = _unloaded_ciobjarrayklass;
 432   } else {
 433     fail_type = _unloaded_ciinstance_klass;
 434   }
 435   Klass* found_klass;
 436   {
 437     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 438     MutexLocker ml(Compile_lock);
 439     Klass* kls;
 440     if (!require_local) {
 441       kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
 442                                                                        KILL_COMPILE_ON_FATAL_(fail_type));
 443     } else {
 444       kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
 445                                                            KILL_COMPILE_ON_FATAL_(fail_type));
 446     }
 447     found_klass = kls;
 448   }
 449 
 450   // If we fail to find an array klass, look again for its element type.
 451   // The element type may be available either locally or via constraints.
 452   // In either case, if we can find the element type in the system dictionary,
 453   // we must build an array type around it.  The CI requires array klasses
 454   // to be loaded if their element klasses are loaded, except when memory
 455   // is exhausted.
 456   if (sym->byte_at(0) == '[' &&
 457       (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
 458     // We have an unloaded array.
 459     // Build it on the fly if the element class exists.
 460     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 461                                                  sym->utf8_length()-1,
 462                                                  KILL_COMPILE_ON_FATAL_(fail_type));
 463 
 464     // Get element ciKlass recursively.
 465     ciKlass* elem_klass =
 466       get_klass_by_name_impl(accessing_klass,
 467                              cpool,
 468                              get_symbol(elem_sym),
 469                              require_local);
 470     if (elem_klass != NULL && elem_klass->is_loaded()) {
 471       // Now make an array for it
 472       return ciObjArrayKlass::make_impl(elem_klass);
 473     }
 474   }
 475 
 476   if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) {
 477     // Look inside the constant pool for pre-resolved class entries.




 382   }
 383   if (resolved_klass->is_instance_klass()) {
 384     return (Reflection::verify_class_access(accessing_klass->get_Klass(),
 385                                             InstanceKlass::cast(resolved_klass),
 386                                             true) == Reflection::ACCESS_OK);
 387   }
 388   return true;
 389 }
 390 
 391 // ------------------------------------------------------------------
 392 // ciEnv::get_klass_by_name_impl
 393 ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
 394                                        const constantPoolHandle& cpool,
 395                                        ciSymbol* name,
 396                                        bool require_local) {
 397   ASSERT_IN_VM;
 398   EXCEPTION_CONTEXT;
 399 
 400   // Now we need to check the SystemDictionary
 401   Symbol* sym = name->get_symbol();
 402   if (sym->char_at(0) == 'L' &&
 403     sym->char_at(sym->utf8_length()-1) == ';') {
 404     // This is a name from a signature.  Strip off the trimmings.
 405     // Call recursive to keep scope of strippedsym.
 406     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 407                     sym->utf8_length()-2,
 408                     KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
 409     ciSymbol* strippedname = get_symbol(strippedsym);
 410     return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local);
 411   }
 412 
 413   // Check for prior unloaded klass.  The SystemDictionary's answers
 414   // can vary over time but the compiler needs consistency.
 415   ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
 416   if (unloaded_klass != NULL) {
 417     if (require_local)  return NULL;
 418     return unloaded_klass;
 419   }
 420 
 421   Handle loader(THREAD, (oop)NULL);
 422   Handle domain(THREAD, (oop)NULL);
 423   if (accessing_klass != NULL) {
 424     loader = Handle(THREAD, accessing_klass->loader());
 425     domain = Handle(THREAD, accessing_klass->protection_domain());
 426   }
 427 
 428   // setup up the proper type to return on OOM
 429   ciKlass* fail_type;
 430   if (sym->char_at(0) == '[') {
 431     fail_type = _unloaded_ciobjarrayklass;
 432   } else {
 433     fail_type = _unloaded_ciinstance_klass;
 434   }
 435   Klass* found_klass;
 436   {
 437     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 438     MutexLocker ml(Compile_lock);
 439     Klass* kls;
 440     if (!require_local) {
 441       kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
 442                                                                        KILL_COMPILE_ON_FATAL_(fail_type));
 443     } else {
 444       kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
 445                                                            KILL_COMPILE_ON_FATAL_(fail_type));
 446     }
 447     found_klass = kls;
 448   }
 449 
 450   // If we fail to find an array klass, look again for its element type.
 451   // The element type may be available either locally or via constraints.
 452   // In either case, if we can find the element type in the system dictionary,
 453   // we must build an array type around it.  The CI requires array klasses
 454   // to be loaded if their element klasses are loaded, except when memory
 455   // is exhausted.
 456   if (sym->char_at(0) == '[' &&
 457       (sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
 458     // We have an unloaded array.
 459     // Build it on the fly if the element class exists.
 460     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 461                                                  sym->utf8_length()-1,
 462                                                  KILL_COMPILE_ON_FATAL_(fail_type));
 463 
 464     // Get element ciKlass recursively.
 465     ciKlass* elem_klass =
 466       get_klass_by_name_impl(accessing_klass,
 467                              cpool,
 468                              get_symbol(elem_sym),
 469                              require_local);
 470     if (elem_klass != NULL && elem_klass->is_loaded()) {
 471       // Now make an array for it
 472       return ciObjArrayKlass::make_impl(elem_klass);
 473     }
 474   }
 475 
 476   if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) {
 477     // Look inside the constant pool for pre-resolved class entries.


< prev index next >