< prev index next >

src/hotspot/share/ci/ciEnv.cpp

Print this page




 378   }
 379   if (resolved_klass->is_instance_klass()) {
 380     return (Reflection::verify_class_access(accessing_klass->get_Klass(),
 381                                             InstanceKlass::cast(resolved_klass),
 382                                             true) == Reflection::ACCESS_OK);
 383   }
 384   return true;
 385 }
 386 
 387 // ------------------------------------------------------------------
 388 // ciEnv::get_klass_by_name_impl
 389 ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
 390                                        const constantPoolHandle& cpool,
 391                                        ciSymbol* name,
 392                                        bool require_local) {
 393   ASSERT_IN_VM;
 394   EXCEPTION_CONTEXT;
 395 
 396   // Now we need to check the SystemDictionary
 397   Symbol* sym = name->get_symbol();
 398   if ((sym->byte_at(0) == 'L' || sym->byte_at(0) == 'Q') &&
 399     sym->byte_at(sym->utf8_length()-1) == ';') {
 400     // This is a name from a signature.  Strip off the trimmings.
 401     // Call recursive to keep scope of strippedsym.
 402     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 403                     sym->utf8_length()-2,
 404                     KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
 405     ciSymbol* strippedname = get_symbol(strippedsym);
 406     return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local);
 407   }
 408 
 409   // Check for prior unloaded klass.  The SystemDictionary's answers
 410   // can vary over time but the compiler needs consistency.
 411   ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
 412   if (unloaded_klass != NULL) {
 413     if (require_local)  return NULL;
 414     return unloaded_klass;
 415   }
 416 
 417   Handle loader(THREAD, (oop)NULL);
 418   Handle domain(THREAD, (oop)NULL);


 433     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 434     MutexLocker ml(Compile_lock);
 435     Klass* kls;
 436     if (!require_local) {
 437       kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
 438                                                                        KILL_COMPILE_ON_FATAL_(fail_type));
 439     } else {
 440       kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
 441                                                            KILL_COMPILE_ON_FATAL_(fail_type));
 442     }
 443     found_klass = kls;
 444   }
 445 
 446   // If we fail to find an array klass, look again for its element type.
 447   // The element type may be available either locally or via constraints.
 448   // In either case, if we can find the element type in the system dictionary,
 449   // we must build an array type around it.  The CI requires array klasses
 450   // to be loaded if their element klasses are loaded, except when memory
 451   // is exhausted.
 452   if (sym->byte_at(0) == '[' &&
 453       (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L' || sym->byte_at(1) == 'Q')) {
 454     // We have an unloaded array.
 455     // Build it on the fly if the element class exists.
 456     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 457                                                  sym->utf8_length()-1,
 458                                                  KILL_COMPILE_ON_FATAL_(fail_type));
 459 
 460     // Get element ciKlass recursively.
 461     ciKlass* elem_klass =
 462       get_klass_by_name_impl(accessing_klass,
 463                              cpool,
 464                              get_symbol(elem_sym),
 465                              require_local);
 466     if (elem_klass != NULL && elem_klass->is_loaded()) {
 467       // Now make an array for it
 468       if (elem_klass->is_valuetype() && elem_klass->as_value_klass()->flatten_array()) {
 469         return ciValueArrayKlass::make_impl(elem_klass);
 470       } else {
 471         return ciObjArrayKlass::make_impl(elem_klass);
 472       }
 473     }




 378   }
 379   if (resolved_klass->is_instance_klass()) {
 380     return (Reflection::verify_class_access(accessing_klass->get_Klass(),
 381                                             InstanceKlass::cast(resolved_klass),
 382                                             true) == Reflection::ACCESS_OK);
 383   }
 384   return true;
 385 }
 386 
 387 // ------------------------------------------------------------------
 388 // ciEnv::get_klass_by_name_impl
 389 ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
 390                                        const constantPoolHandle& cpool,
 391                                        ciSymbol* name,
 392                                        bool require_local) {
 393   ASSERT_IN_VM;
 394   EXCEPTION_CONTEXT;
 395 
 396   // Now we need to check the SystemDictionary
 397   Symbol* sym = name->get_symbol();
 398   if (sym->byte_at(0) == 'L' &&
 399     sym->byte_at(sym->utf8_length()-1) == ';') {
 400     // This is a name from a signature.  Strip off the trimmings.
 401     // Call recursive to keep scope of strippedsym.
 402     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 403                     sym->utf8_length()-2,
 404                     KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
 405     ciSymbol* strippedname = get_symbol(strippedsym);
 406     return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local);
 407   }
 408 
 409   // Check for prior unloaded klass.  The SystemDictionary's answers
 410   // can vary over time but the compiler needs consistency.
 411   ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
 412   if (unloaded_klass != NULL) {
 413     if (require_local)  return NULL;
 414     return unloaded_klass;
 415   }
 416 
 417   Handle loader(THREAD, (oop)NULL);
 418   Handle domain(THREAD, (oop)NULL);


 433     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 434     MutexLocker ml(Compile_lock);
 435     Klass* kls;
 436     if (!require_local) {
 437       kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
 438                                                                        KILL_COMPILE_ON_FATAL_(fail_type));
 439     } else {
 440       kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
 441                                                            KILL_COMPILE_ON_FATAL_(fail_type));
 442     }
 443     found_klass = kls;
 444   }
 445 
 446   // If we fail to find an array klass, look again for its element type.
 447   // The element type may be available either locally or via constraints.
 448   // In either case, if we can find the element type in the system dictionary,
 449   // we must build an array type around it.  The CI requires array klasses
 450   // to be loaded if their element klasses are loaded, except when memory
 451   // is exhausted.
 452   if (sym->byte_at(0) == '[' &&
 453       (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
 454     // We have an unloaded array.
 455     // Build it on the fly if the element class exists.
 456     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 457                                                  sym->utf8_length()-1,
 458                                                  KILL_COMPILE_ON_FATAL_(fail_type));
 459 
 460     // Get element ciKlass recursively.
 461     ciKlass* elem_klass =
 462       get_klass_by_name_impl(accessing_klass,
 463                              cpool,
 464                              get_symbol(elem_sym),
 465                              require_local);
 466     if (elem_klass != NULL && elem_klass->is_loaded()) {
 467       // Now make an array for it
 468       if (elem_klass->is_valuetype() && elem_klass->as_value_klass()->flatten_array()) {
 469         return ciValueArrayKlass::make_impl(elem_klass);
 470       } else {
 471         return ciObjArrayKlass::make_impl(elem_klass);
 472       }
 473     }


< prev index next >