mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 18:03:44 +00:00
8370377: Avoid resolving constant pool entries during preimage generation in the training run
Reviewed-by: adinn, iklam
This commit is contained in:
parent
a925461395
commit
d8ebe38759
@ -225,7 +225,38 @@ void AOTConstantPoolResolver::preresolve_field_and_method_cp_entries(JavaThread*
|
||||
Bytecodes::Code raw_bc = bcs.raw_code();
|
||||
switch (raw_bc) {
|
||||
case Bytecodes::_getfield:
|
||||
// no-fast bytecode
|
||||
case Bytecodes::_nofast_getfield:
|
||||
// fast bytecodes
|
||||
case Bytecodes::_fast_agetfield:
|
||||
case Bytecodes::_fast_bgetfield:
|
||||
case Bytecodes::_fast_cgetfield:
|
||||
case Bytecodes::_fast_dgetfield:
|
||||
case Bytecodes::_fast_fgetfield:
|
||||
case Bytecodes::_fast_igetfield:
|
||||
case Bytecodes::_fast_lgetfield:
|
||||
case Bytecodes::_fast_sgetfield:
|
||||
raw_bc = Bytecodes::_getfield;
|
||||
maybe_resolve_fmi_ref(ik, m, raw_bc, bcs.get_index_u2(), preresolve_list, THREAD);
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
CLEAR_PENDING_EXCEPTION; // just ignore
|
||||
}
|
||||
break;
|
||||
|
||||
case Bytecodes::_putfield:
|
||||
// no-fast bytecode
|
||||
case Bytecodes::_nofast_putfield:
|
||||
// fast bytecodes
|
||||
case Bytecodes::_fast_aputfield:
|
||||
case Bytecodes::_fast_bputfield:
|
||||
case Bytecodes::_fast_zputfield:
|
||||
case Bytecodes::_fast_cputfield:
|
||||
case Bytecodes::_fast_dputfield:
|
||||
case Bytecodes::_fast_fputfield:
|
||||
case Bytecodes::_fast_iputfield:
|
||||
case Bytecodes::_fast_lputfield:
|
||||
case Bytecodes::_fast_sputfield:
|
||||
raw_bc = Bytecodes::_putfield;
|
||||
maybe_resolve_fmi_ref(ik, m, raw_bc, bcs.get_index_u2(), preresolve_list, THREAD);
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
CLEAR_PENDING_EXCEPTION; // just ignore
|
||||
|
||||
@ -127,6 +127,14 @@ void FinalImageRecipes::record_recipes_for_constantpool() {
|
||||
}
|
||||
|
||||
if (cp_indices.length() > 0) {
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
log.print("ConstantPool entries for %s to be pre-resolved:", k->external_name());
|
||||
for (int i = 0; i < cp_indices.length(); i++) {
|
||||
log.print(" %d", cp_indices.at(i));
|
||||
}
|
||||
log.print("\n");
|
||||
}
|
||||
tmp_cp_recipes.append(ArchiveUtils::archive_array(&cp_indices));
|
||||
} else {
|
||||
tmp_cp_recipes.append(nullptr);
|
||||
|
||||
@ -538,18 +538,23 @@ void ConstantPool::remove_resolved_klass_if_non_deterministic(int cp_index) {
|
||||
assert(ArchiveBuilder::current()->is_in_buffer_space(this), "must be");
|
||||
assert(tag_at(cp_index).is_klass(), "must be resolved");
|
||||
|
||||
Klass* k = resolved_klass_at(cp_index);
|
||||
bool can_archive;
|
||||
Klass* k = nullptr;
|
||||
|
||||
if (k == nullptr) {
|
||||
// We'd come here if the referenced class has been excluded via
|
||||
// SystemDictionaryShared::is_excluded_class(). As a result, ArchiveBuilder
|
||||
// has cleared the resolved_klasses()->at(...) pointer to null. Thus, we
|
||||
// need to revert the tag to JVM_CONSTANT_UnresolvedClass.
|
||||
if (CDSConfig::is_dumping_preimage_static_archive()) {
|
||||
can_archive = false;
|
||||
} else {
|
||||
ConstantPool* src_cp = ArchiveBuilder::current()->get_source_addr(this);
|
||||
can_archive = AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index);
|
||||
k = resolved_klass_at(cp_index);
|
||||
if (k == nullptr) {
|
||||
// We'd come here if the referenced class has been excluded via
|
||||
// SystemDictionaryShared::is_excluded_class(). As a result, ArchiveBuilder
|
||||
// has cleared the resolved_klasses()->at(...) pointer to null. Thus, we
|
||||
// need to revert the tag to JVM_CONSTANT_UnresolvedClass.
|
||||
can_archive = false;
|
||||
} else {
|
||||
ConstantPool* src_cp = ArchiveBuilder::current()->get_source_addr(this);
|
||||
can_archive = AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index);
|
||||
}
|
||||
}
|
||||
|
||||
if (!can_archive) {
|
||||
|
||||
@ -430,26 +430,25 @@ void ConstantPoolCache::remove_resolved_field_entries_if_non_deterministic() {
|
||||
bool archived = false;
|
||||
bool resolved = rfi->is_resolved(Bytecodes::_getfield) ||
|
||||
rfi->is_resolved(Bytecodes::_putfield);
|
||||
if (resolved && AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) {
|
||||
if (resolved && !CDSConfig::is_dumping_preimage_static_archive()
|
||||
&& AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) {
|
||||
rfi->mark_and_relocate();
|
||||
archived = true;
|
||||
} else {
|
||||
rfi->remove_unshareable_info();
|
||||
}
|
||||
if (resolved) {
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
|
||||
Symbol* klass_name = cp->klass_name_at(klass_cp_index);
|
||||
Symbol* name = cp->uncached_name_ref_at(cp_index);
|
||||
Symbol* signature = cp->uncached_signature_ref_at(cp_index);
|
||||
log.print("%s field CP entry [%3d]: %s => %s.%s:%s",
|
||||
(archived ? "archived" : "reverted"),
|
||||
cp_index,
|
||||
cp->pool_holder()->name()->as_C_string(),
|
||||
klass_name->as_C_string(), name->as_C_string(), signature->as_C_string());
|
||||
}
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
|
||||
Symbol* klass_name = cp->klass_name_at(klass_cp_index);
|
||||
Symbol* name = cp->uncached_name_ref_at(cp_index);
|
||||
Symbol* signature = cp->uncached_signature_ref_at(cp_index);
|
||||
log.print("%s field CP entry [%3d]: %s => %s.%s:%s",
|
||||
(archived ? "archived" : "reverted"),
|
||||
cp_index,
|
||||
cp->pool_holder()->name()->as_C_string(),
|
||||
klass_name->as_C_string(), name->as_C_string(), signature->as_C_string());
|
||||
}
|
||||
ArchiveBuilder::alloc_stats()->record_field_cp_entry(archived, resolved && !archived);
|
||||
}
|
||||
@ -470,32 +469,31 @@ void ConstantPoolCache::remove_resolved_method_entries_if_non_deterministic() {
|
||||
// Just for safety -- this should not happen, but do not archive if we ever see this.
|
||||
resolved &= !(rme->is_resolved(Bytecodes::_invokestatic));
|
||||
|
||||
if (resolved && can_archive_resolved_method(src_cp, rme)) {
|
||||
if (resolved && !CDSConfig::is_dumping_preimage_static_archive()
|
||||
&& can_archive_resolved_method(src_cp, rme)) {
|
||||
rme->mark_and_relocate(src_cp);
|
||||
archived = true;
|
||||
} else {
|
||||
rme->remove_unshareable_info();
|
||||
}
|
||||
if (resolved) {
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
|
||||
Symbol* klass_name = cp->klass_name_at(klass_cp_index);
|
||||
Symbol* name = cp->uncached_name_ref_at(cp_index);
|
||||
Symbol* signature = cp->uncached_signature_ref_at(cp_index);
|
||||
log.print("%s%s method CP entry [%3d]: %s %s.%s:%s",
|
||||
(archived ? "archived" : "reverted"),
|
||||
(rme->is_resolved(Bytecodes::_invokeinterface) ? " interface" : ""),
|
||||
cp_index,
|
||||
cp->pool_holder()->name()->as_C_string(),
|
||||
klass_name->as_C_string(), name->as_C_string(), signature->as_C_string());
|
||||
if (archived) {
|
||||
Klass* resolved_klass = cp->resolved_klass_at(klass_cp_index);
|
||||
log.print(" => %s%s",
|
||||
resolved_klass->name()->as_C_string(),
|
||||
(rme->is_resolved(Bytecodes::_invokestatic) ? " *** static" : ""));
|
||||
}
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
|
||||
Symbol* klass_name = cp->klass_name_at(klass_cp_index);
|
||||
Symbol* name = cp->uncached_name_ref_at(cp_index);
|
||||
Symbol* signature = cp->uncached_signature_ref_at(cp_index);
|
||||
log.print("%s%s method CP entry [%3d]: %s %s.%s:%s",
|
||||
(archived ? "archived" : "reverted"),
|
||||
(rme->is_resolved(Bytecodes::_invokeinterface) ? " interface" : ""),
|
||||
cp_index,
|
||||
cp->pool_holder()->name()->as_C_string(),
|
||||
klass_name->as_C_string(), name->as_C_string(), signature->as_C_string());
|
||||
if (archived) {
|
||||
Klass* resolved_klass = cp->resolved_klass_at(klass_cp_index);
|
||||
log.print(" => %s%s",
|
||||
resolved_klass->name()->as_C_string(),
|
||||
(rme->is_resolved(Bytecodes::_invokestatic) ? " *** static" : ""));
|
||||
}
|
||||
ArchiveBuilder::alloc_stats()->record_method_cp_entry(archived, resolved && !archived);
|
||||
}
|
||||
@ -510,29 +508,28 @@ void ConstantPoolCache::remove_resolved_indy_entries_if_non_deterministic() {
|
||||
int cp_index = rei->constant_pool_index();
|
||||
bool archived = false;
|
||||
bool resolved = rei->is_resolved();
|
||||
if (resolved && AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) {
|
||||
if (resolved && !CDSConfig::is_dumping_preimage_static_archive()
|
||||
&& AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) {
|
||||
rei->mark_and_relocate();
|
||||
archived = true;
|
||||
} else {
|
||||
rei->remove_unshareable_info();
|
||||
}
|
||||
if (resolved) {
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int bsm = cp->bootstrap_method_ref_index_at(cp_index);
|
||||
int bsm_ref = cp->method_handle_index_at(bsm);
|
||||
Symbol* bsm_name = cp->uncached_name_ref_at(bsm_ref);
|
||||
Symbol* bsm_signature = cp->uncached_signature_ref_at(bsm_ref);
|
||||
Symbol* bsm_klass = cp->klass_name_at(cp->uncached_klass_ref_index_at(bsm_ref));
|
||||
log.print("%s indy CP entry [%3d]: %s (%d)",
|
||||
(archived ? "archived" : "reverted"),
|
||||
cp_index, cp->pool_holder()->name()->as_C_string(), i);
|
||||
log.print(" %s %s.%s:%s", (archived ? "=>" : " "), bsm_klass->as_C_string(),
|
||||
bsm_name->as_C_string(), bsm_signature->as_C_string());
|
||||
}
|
||||
ArchiveBuilder::alloc_stats()->record_indy_cp_entry(archived, resolved && !archived);
|
||||
LogStreamHandle(Trace, aot, resolve) log;
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
int bsm = cp->bootstrap_method_ref_index_at(cp_index);
|
||||
int bsm_ref = cp->method_handle_index_at(bsm);
|
||||
Symbol* bsm_name = cp->uncached_name_ref_at(bsm_ref);
|
||||
Symbol* bsm_signature = cp->uncached_signature_ref_at(bsm_ref);
|
||||
Symbol* bsm_klass = cp->klass_name_at(cp->uncached_klass_ref_index_at(bsm_ref));
|
||||
log.print("%s indy CP entry [%3d]: %s (%d)",
|
||||
(archived ? "archived" : "reverted"),
|
||||
cp_index, cp->pool_holder()->name()->as_C_string(), i);
|
||||
log.print(" %s %s.%s:%s", (archived ? "=>" : " "), bsm_klass->as_C_string(),
|
||||
bsm_name->as_C_string(), bsm_signature->as_C_string());
|
||||
}
|
||||
ArchiveBuilder::alloc_stats()->record_indy_cp_entry(archived, resolved && !archived);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user