Skip to content

Commit 4b19771

Browse files
committed
8264150: CDS dumping code calls TRAPS functions in VM thread
Reviewed-by: dholmes, iklam
1 parent 1dc75e9 commit 4b19771

File tree

10 files changed

+206
-144
lines changed

10 files changed

+206
-144
lines changed

src/hotspot/share/classfile/defaultMethods.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,10 @@ static void create_default_methods(InstanceKlass* klass,
10321032
Method::sort_methods(total_default_methods, /*set_idnums=*/false);
10331033

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

10371041
static void sort_methods(GrowableArray<Method*>* methods) {

src/hotspot/share/gc/shared/memAllocator.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ void MemAllocator::Allocation::check_for_valid_allocation_state() const {
173173
assert(!_thread->has_pending_exception(),
174174
"shouldn't be allocating with pending exception");
175175
// Allocation of an oop can always invoke a safepoint.
176+
assert(_thread->is_Java_thread(), "non Java threads shouldn't allocate on the Heap");
176177
_thread->check_for_valid_safepoint_state();
177178
}
178179
#endif

src/hotspot/share/memory/dynamicArchive.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ void DynamicArchiveBuilder::sort_methods(InstanceKlass* ik) const {
253253
if (ik->default_methods() != NULL) {
254254
Method::sort_methods(ik->default_methods(), /*set_idnums=*/false, dynamic_dump_method_comparator);
255255
}
256-
ik->vtable().initialize_vtable(true, THREAD); assert(!HAS_PENDING_EXCEPTION, "cannot fail");
257-
ik->itable().initialize_itable(true, THREAD); assert(!HAS_PENDING_EXCEPTION, "cannot fail");
256+
ik->vtable().initialize_vtable();
257+
ik->itable().initialize_itable();
258258

259259
// Set all the pointer marking bits after sorting.
260260
remark_pointers_for_instance_klass(ik, true);

src/hotspot/share/memory/universe.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -513,35 +513,35 @@ oop Universe::swap_reference_pending_list(oop list) {
513513
#undef assert_pll_locked
514514
#undef assert_pll_ownership
515515

516-
void Universe::reinitialize_vtable_of(Klass* ko, TRAPS) {
516+
static void reinitialize_vtable_of(Klass* ko) {
517517
// init vtable of k and all subclasses
518-
ko->vtable().initialize_vtable(false, CHECK);
518+
ko->vtable().initialize_vtable();
519519
if (ko->is_instance_klass()) {
520520
for (Klass* sk = ko->subklass();
521521
sk != NULL;
522522
sk = sk->next_sibling()) {
523-
reinitialize_vtable_of(sk, CHECK);
523+
reinitialize_vtable_of(sk);
524524
}
525525
}
526526
}
527527

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

536536

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

541541

542-
void Universe::reinitialize_itables(TRAPS) {
543-
MutexLocker mcld(THREAD, ClassLoaderDataGraph_lock);
544-
ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass, CHECK);
542+
static void reinitialize_itables() {
543+
MutexLocker mcld(ClassLoaderDataGraph_lock);
544+
ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass);
545545
}
546546

547547

@@ -946,9 +946,8 @@ bool universe_post_init() {
946946
Universe::_fully_initialized = true;
947947
EXCEPTION_MARK;
948948
if (!UseSharedSpaces) {
949-
ResourceMark rm;
950-
Universe::reinitialize_vtables(CHECK_false);
951-
Universe::reinitialize_itables(CHECK_false);
949+
reinitialize_vtables();
950+
reinitialize_itables();
952951
}
953952

954953
HandleMark hm(THREAD);

src/hotspot/share/memory/universe.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ class Universe: AllStatic {
172172
static void initialize_basic_type_mirrors(TRAPS);
173173
static void fixup_mirrors(TRAPS);
174174

175-
static void reinitialize_vtable_of(Klass* k, TRAPS);
176-
static void reinitialize_vtables(TRAPS);
177-
static void reinitialize_itables(TRAPS);
178175
static void compute_base_vtable_size(); // compute vtable size of class Object
179176

180177
static void genesis(TRAPS); // Create the initial world

src/hotspot/share/oops/arrayKlass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassID id) :
103103
// since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
104104
void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
105105
k->initialize_supers(super_klass, NULL, CHECK);
106-
k->vtable().initialize_vtable(false, CHECK);
106+
k->vtable().initialize_vtable();
107107

108108
// During bootstrapping, before java.base is defined, the module_entry may not be present yet.
109109
// These classes will be put on a fixup list and their module fields will be patched once

src/hotspot/share/oops/instanceKlass.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,8 @@ bool InstanceKlass::link_class_impl(TRAPS) {
988988
need_init_table = false;
989989
}
990990
if (need_init_table) {
991-
vtable().initialize_vtable(true, CHECK_false);
992-
itable().initialize_itable(true, CHECK_false);
991+
vtable().initialize_vtable_and_check_constraints(CHECK_false);
992+
itable().initialize_itable_and_check_constraints(CHECK_false);
993993
}
994994
#ifdef ASSERT
995995
vtable().verify(tty, true);
@@ -2599,8 +2599,8 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
25992599
// have been redefined.
26002600
bool trace_name_printed = false;
26012601
adjust_default_methods(&trace_name_printed);
2602-
vtable().initialize_vtable(false, CHECK);
2603-
itable().initialize_itable(false, CHECK);
2602+
vtable().initialize_vtable();
2603+
itable().initialize_itable();
26042604
}
26052605
#endif
26062606

0 commit comments

Comments
 (0)