Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8243287: Removal of Unsafe::defineAnonymousClass
Reviewed-by: iklam, mchung, alanb, dholmes
  • Loading branch information
Harold Seigel committed May 13, 2021
1 parent a564f2c commit e14b026
Show file tree
Hide file tree
Showing 122 changed files with 328 additions and 3,679 deletions.
4 changes: 1 addition & 3 deletions src/hotspot/share/c1/c1_GraphBuilder.cpp
Expand Up @@ -1871,9 +1871,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) {

// invoke-special-super
if (bc_raw == Bytecodes::_invokespecial && !target->is_object_initializer()) {
ciInstanceKlass* sender_klass =
calling_klass->is_unsafe_anonymous() ? calling_klass->unsafe_anonymous_host() :
calling_klass;
ciInstanceKlass* sender_klass = calling_klass;
if (sender_klass->is_interface()) {
int index = state()->stack_size() - (target->arg_size_no_receiver() + 1);
Value receiver = state()->stack_at(index);
Expand Down
14 changes: 5 additions & 9 deletions src/hotspot/share/ci/ciEnv.cpp
Expand Up @@ -641,15 +641,11 @@ ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,
} else if (tag.is_string()) {
oop string = NULL;
assert(cache_index >= 0, "should have a cache index");
if (cpool->is_pseudo_string_at(index)) {
string = cpool->pseudo_string_at(index, cache_index);
} else {
string = cpool->string_at(index, cache_index, THREAD);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
record_out_of_memory_failure();
return ciConstant();
}
string = cpool->string_at(index, cache_index, THREAD);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
record_out_of_memory_failure();
return ciConstant();
}
ciObject* constant = get_object(string);
if (constant->is_array()) {
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/ci/ciField.cpp
Expand Up @@ -228,10 +228,9 @@ static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
holder->is_in_package("jdk/internal/vm/vector") || holder->is_in_package("jdk/incubator/vector") ||
holder->is_in_package("java/lang"))
return true;
// Trust hidden classes and VM unsafe anonymous classes. They are created via
// Lookup.defineHiddenClass or the private jdk.internal.misc.Unsafe API and
// Trust hidden classes. They are created via Lookup.defineHiddenClass and
// can't be serialized, so there is no hacking of finals going on with them.
if (holder->is_hidden() || holder->is_unsafe_anonymous())
if (holder->is_hidden())
return true;
// Trust final fields in all boxed classes
if (holder->is_box_klass())
Expand Down
18 changes: 3 additions & 15 deletions src/hotspot/share/ci/ciInstanceKlass.cpp
Expand Up @@ -66,7 +66,6 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) :
_nonstatic_field_size = ik->nonstatic_field_size();
_has_nonstatic_fields = ik->has_nonstatic_fields();
_has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
_is_unsafe_anonymous = ik->is_unsafe_anonymous();
_is_hidden = ik->is_hidden();
_is_record = ik->is_record();
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
Expand All @@ -81,11 +80,11 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) :
oop holder = ik->klass_holder();
if (ik->class_loader_data()->has_class_mirror_holder()) {
// Though ciInstanceKlass records class loader oop, it's not enough to keep
// non-strong hidden classes and VM unsafe anonymous classes alive (loader == NULL). Klass holder should
// non-strong hidden classes alive (loader == NULL). Klass holder should
// be used instead. It is enough to record a ciObject, since cached elements are never removed
// during ciObjectFactory lifetime. ciObjectFactory itself is created for
// every compilation and lives for the whole duration of the compilation.
assert(holder != NULL, "holder of hidden or unsafe anonymous class is the mirror which is never null");
assert(holder != NULL, "holder of hidden class is the mirror which is never null");
(void)CURRENT_ENV->get_object(holder);
}

Expand Down Expand Up @@ -128,7 +127,6 @@ ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
_has_nonstatic_fields = false;
_nonstatic_fields = NULL;
_has_injected_fields = -1;
_is_unsafe_anonymous = false;
_is_hidden = false;
_is_record = false;
_loader = loader;
Expand Down Expand Up @@ -660,16 +658,6 @@ ciInstanceKlass* ciInstanceKlass::implementor() {
return impl;
}

ciInstanceKlass* ciInstanceKlass::unsafe_anonymous_host() {
assert(is_loaded(), "must be loaded");
if (is_unsafe_anonymous()) {
VM_ENTRY_MARK
Klass* unsafe_anonymous_host = get_instanceKlass()->unsafe_anonymous_host();
return CURRENT_ENV->get_instance_klass(unsafe_anonymous_host);
}
return NULL;
}

// Utility class for printing of the contents of the static fields for
// use by compilation replay. It only prints out the information that
// could be consumed by the compiler, so for primitive types it prints
Expand Down Expand Up @@ -753,7 +741,7 @@ void ciInstanceKlass::dump_replay_data(outputStream* out) {
// Try to record related loaded classes
Klass* sub = ik->subklass();
while (sub != NULL) {
if (sub->is_instance_klass() && !sub->is_hidden() && !InstanceKlass::cast(sub)->is_unsafe_anonymous()) {
if (sub->is_instance_klass() && !sub->is_hidden()) {
out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii());
}
sub = sub->next_sibling();
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/share/ci/ciInstanceKlass.hpp
Expand Up @@ -56,7 +56,6 @@ class ciInstanceKlass : public ciKlass {
SubklassValue _has_subklass;
bool _has_nonstatic_fields;
bool _has_nonstatic_concrete_methods;
bool _is_unsafe_anonymous;
bool _is_hidden;
bool _is_record;

Expand Down Expand Up @@ -194,10 +193,6 @@ class ciInstanceKlass : public ciKlass {
return _has_nonstatic_concrete_methods;
}

bool is_unsafe_anonymous() const {
return _is_unsafe_anonymous;
}

bool is_hidden() const {
return _is_hidden;
}
Expand Down Expand Up @@ -290,8 +285,6 @@ class ciInstanceKlass : public ciKlass {
return NULL;
}

ciInstanceKlass* unsafe_anonymous_host();

bool can_be_instantiated() {
assert(is_loaded(), "must be loaded");
return !is_interface() && !is_abstract();
Expand Down

1 comment on commit e14b026

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.