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