Skip to content

Commit

Permalink
8264150: CDS dumping code calls TRAPS functions in VM thread
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, iklam
  • Loading branch information
coleenp committed Apr 1, 2021
1 parent 1dc75e9 commit 4b19771
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 144 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/classfile/defaultMethods.cpp
Expand Up @@ -1032,6 +1032,10 @@ static void create_default_methods(InstanceKlass* klass,
Method::sort_methods(total_default_methods, /*set_idnums=*/false);

klass->set_default_methods(total_default_methods);
// Create an array for mapping default methods to their vtable indices in
// this class, since default methods vtable indices are the indices for
// the defining class.
klass->create_new_default_vtable_indices(new_size, CHECK);
}

static void sort_methods(GrowableArray<Method*>* methods) {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shared/memAllocator.cpp
Expand Up @@ -173,6 +173,7 @@ void MemAllocator::Allocation::check_for_valid_allocation_state() const {
assert(!_thread->has_pending_exception(),
"shouldn't be allocating with pending exception");
// Allocation of an oop can always invoke a safepoint.
assert(_thread->is_Java_thread(), "non Java threads shouldn't allocate on the Heap");
_thread->check_for_valid_safepoint_state();
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/memory/dynamicArchive.cpp
Expand Up @@ -253,8 +253,8 @@ void DynamicArchiveBuilder::sort_methods(InstanceKlass* ik) const {
if (ik->default_methods() != NULL) {
Method::sort_methods(ik->default_methods(), /*set_idnums=*/false, dynamic_dump_method_comparator);
}
ik->vtable().initialize_vtable(true, THREAD); assert(!HAS_PENDING_EXCEPTION, "cannot fail");
ik->itable().initialize_itable(true, THREAD); assert(!HAS_PENDING_EXCEPTION, "cannot fail");
ik->vtable().initialize_vtable();
ik->itable().initialize_itable();

// Set all the pointer marking bits after sorting.
remark_pointers_for_instance_klass(ik, true);
Expand Down
25 changes: 12 additions & 13 deletions src/hotspot/share/memory/universe.cpp
Expand Up @@ -513,35 +513,35 @@ oop Universe::swap_reference_pending_list(oop list) {
#undef assert_pll_locked
#undef assert_pll_ownership

void Universe::reinitialize_vtable_of(Klass* ko, TRAPS) {
static void reinitialize_vtable_of(Klass* ko) {
// init vtable of k and all subclasses
ko->vtable().initialize_vtable(false, CHECK);
ko->vtable().initialize_vtable();
if (ko->is_instance_klass()) {
for (Klass* sk = ko->subklass();
sk != NULL;
sk = sk->next_sibling()) {
reinitialize_vtable_of(sk, CHECK);
reinitialize_vtable_of(sk);
}
}
}

void Universe::reinitialize_vtables(TRAPS) {
static void reinitialize_vtables() {
// The vtables are initialized by starting at java.lang.Object and
// initializing through the subclass links, so that the super
// classes are always initialized first.
Klass* ok = vmClasses::Object_klass();
Universe::reinitialize_vtable_of(ok, THREAD);
reinitialize_vtable_of(ok);
}


void initialize_itable_for_klass(InstanceKlass* k, TRAPS) {
k->itable().initialize_itable(false, CHECK);
static void initialize_itable_for_klass(InstanceKlass* k) {
k->itable().initialize_itable();
}


void Universe::reinitialize_itables(TRAPS) {
MutexLocker mcld(THREAD, ClassLoaderDataGraph_lock);
ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass, CHECK);
static void reinitialize_itables() {
MutexLocker mcld(ClassLoaderDataGraph_lock);
ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass);
}


Expand Down Expand Up @@ -946,9 +946,8 @@ bool universe_post_init() {
Universe::_fully_initialized = true;
EXCEPTION_MARK;
if (!UseSharedSpaces) {
ResourceMark rm;
Universe::reinitialize_vtables(CHECK_false);
Universe::reinitialize_itables(CHECK_false);
reinitialize_vtables();
reinitialize_itables();
}

HandleMark hm(THREAD);
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/memory/universe.hpp
Expand Up @@ -172,9 +172,6 @@ class Universe: AllStatic {
static void initialize_basic_type_mirrors(TRAPS);
static void fixup_mirrors(TRAPS);

static void reinitialize_vtable_of(Klass* k, TRAPS);
static void reinitialize_vtables(TRAPS);
static void reinitialize_itables(TRAPS);
static void compute_base_vtable_size(); // compute vtable size of class Object

static void genesis(TRAPS); // Create the initial world
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/arrayKlass.cpp
Expand Up @@ -103,7 +103,7 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassID id) :
// since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
k->initialize_supers(super_klass, NULL, CHECK);
k->vtable().initialize_vtable(false, CHECK);
k->vtable().initialize_vtable();

// During bootstrapping, before java.base is defined, the module_entry may not be present yet.
// These classes will be put on a fixup list and their module fields will be patched once
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/oops/instanceKlass.cpp
Expand Up @@ -988,8 +988,8 @@ bool InstanceKlass::link_class_impl(TRAPS) {
need_init_table = false;
}
if (need_init_table) {
vtable().initialize_vtable(true, CHECK_false);
itable().initialize_itable(true, CHECK_false);
vtable().initialize_vtable_and_check_constraints(CHECK_false);
itable().initialize_itable_and_check_constraints(CHECK_false);
}
#ifdef ASSERT
vtable().verify(tty, true);
Expand Down Expand Up @@ -2599,8 +2599,8 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
// have been redefined.
bool trace_name_printed = false;
adjust_default_methods(&trace_name_printed);
vtable().initialize_vtable(false, CHECK);
itable().initialize_itable(false, CHECK);
vtable().initialize_vtable();
itable().initialize_itable();
}
#endif

Expand Down

1 comment on commit 4b19771

@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.