Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8261127: Cleanup THREAD/TRAPS/CHECK usage in CDS code
Reviewed-by: iklam, coleenp
  • Loading branch information
David Holmes committed Feb 8, 2021
1 parent 7451962 commit f03e839
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 84 deletions.
21 changes: 10 additions & 11 deletions src/hotspot/share/classfile/javaClasses.cpp
Expand Up @@ -863,7 +863,7 @@ static void initialize_static_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
if (DumpSharedSpaces && HeapShared::is_archived_object(mirror())) {
// Archive the String field and update the pointer.
oop s = mirror()->obj_field(fd->offset());
oop archived_s = StringTable::create_archived_string(s, CHECK);
oop archived_s = StringTable::create_archived_string(s);
mirror()->obj_field_put(fd->offset(), archived_s);
} else {
oop string = fd->string_initial_value(CHECK);
Expand Down Expand Up @@ -1140,7 +1140,7 @@ static void set_klass_field_in_archived_mirror(oop mirror_obj, int offset, Klass
mirror_obj->metadata_field_put(offset, def);
}

void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
void java_lang_Class::archive_basic_type_mirrors() {
assert(HeapShared::is_heap_object_archiving_allowed(),
"HeapShared::is_heap_object_archiving_allowed() must be true");

Expand All @@ -1149,7 +1149,7 @@ void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
oop m = Universe::_mirrors[t].resolve();
if (m != NULL) {
// Update the field at _array_klass_offset to point to the relocated array klass.
oop archived_m = HeapShared::archive_heap_object(m, THREAD);
oop archived_m = HeapShared::archive_heap_object(m);
assert(archived_m != NULL, "sanity");
Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
assert(ak != NULL || t == T_VOID, "should not be NULL");
Expand All @@ -1159,7 +1159,7 @@ void java_lang_Class::archive_basic_type_mirrors(TRAPS) {

// Clear the fields. Just to be safe
Klass *k = m->klass();
Handle archived_mirror_h(THREAD, archived_m);
Handle archived_mirror_h(Thread::current(), archived_m);
ResetMirrorField reset(archived_mirror_h);
InstanceKlass::cast(k)->do_nonstatic_fields(&reset);

Expand All @@ -1179,7 +1179,7 @@ void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
// archived mirror is restored. If archived java heap data cannot
// be used at runtime, new mirror object is created for the shared
// class. The _has_archived_raw_mirror is cleared also during the process.
oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
oop java_lang_Class::archive_mirror(Klass* k) {
assert(HeapShared::is_heap_object_archiving_allowed(),
"HeapShared::is_heap_object_archiving_allowed() must be true");

Expand Down Expand Up @@ -1208,12 +1208,12 @@ oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
}

// Now start archiving the mirror object
oop archived_mirror = HeapShared::archive_heap_object(mirror, THREAD);
oop archived_mirror = HeapShared::archive_heap_object(mirror);
if (archived_mirror == NULL) {
return NULL;
}

archived_mirror = process_archived_mirror(k, mirror, archived_mirror, THREAD);
archived_mirror = process_archived_mirror(k, mirror, archived_mirror);
if (archived_mirror == NULL) {
return NULL;
}
Expand All @@ -1230,12 +1230,11 @@ oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {

// The process is based on create_mirror().
oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror,
oop archived_mirror,
Thread *THREAD) {
oop archived_mirror) {
// Clear nonstatic fields in archived mirror. Some of the fields will be set
// to archived metadata and objects below.
Klass *c = archived_mirror->klass();
Handle archived_mirror_h(THREAD, archived_mirror);
Handle archived_mirror_h(Thread::current(), archived_mirror);
ResetMirrorField reset(archived_mirror_h);
InstanceKlass::cast(c)->do_nonstatic_fields(&reset);

Expand All @@ -1250,7 +1249,7 @@ oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror,
assert(k->is_objArray_klass(), "Must be");
Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
assert(element_klass != NULL, "Must have an element klass");
archived_comp_mirror = archive_mirror(element_klass, THREAD);
archived_comp_mirror = archive_mirror(element_klass);
if (archived_comp_mirror == NULL) {
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/javaClasses.hpp
Expand Up @@ -276,9 +276,9 @@ class java_lang_Class : AllStatic {

// Archiving
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
static void archive_basic_type_mirrors(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static oop archive_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
static oop process_archived_mirror(Klass* k, oop mirror, oop archived_mirror, Thread *THREAD)
static void archive_basic_type_mirrors() NOT_CDS_JAVA_HEAP_RETURN;
static oop archive_mirror(Klass* k) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
static oop process_archived_mirror(Klass* k, oop mirror, oop archived_mirror)
NOT_CDS_JAVA_HEAP_RETURN_(NULL);
static bool restore_archived_mirror(Klass *k, Handle class_loader, Handle module,
Handle protection_domain,
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/classfile/stringTable.cpp
Expand Up @@ -717,18 +717,18 @@ oop StringTable::lookup_shared(const jchar* name, int len, unsigned int hash) {
return _shared_table.lookup(name, hash, len);
}

oop StringTable::create_archived_string(oop s, Thread* THREAD) {
oop StringTable::create_archived_string(oop s) {
assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
assert(java_lang_String::is_instance(s), "sanity");
assert(!HeapShared::is_archived_object(s), "sanity");

oop new_s = NULL;
typeArrayOop v = java_lang_String::value_no_keepalive(s);
typeArrayOop new_v = (typeArrayOop)HeapShared::archive_heap_object(v, THREAD);
typeArrayOop new_v = (typeArrayOop)HeapShared::archive_heap_object(v);
if (new_v == NULL) {
return NULL;
}
new_s = HeapShared::archive_heap_object(s, THREAD);
new_s = HeapShared::archive_heap_object(s);
if (new_s == NULL) {
return NULL;
}
Expand All @@ -745,7 +745,7 @@ class CopyToArchive : StackObj {
bool do_entry(oop s, bool value_ignored) {
assert(s != NULL, "sanity");
unsigned int hash = java_lang_String::hash_code(s);
oop new_s = StringTable::create_archived_string(s, Thread::current());
oop new_s = StringTable::create_archived_string(s);
if (new_s == NULL) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/stringTable.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -107,7 +107,7 @@ class StringTable : public CHeapObj<mtSymbol>{
private:
static oop lookup_shared(const jchar* name, int len, unsigned int hash) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
public:
static oop create_archived_string(oop s, Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
static oop create_archived_string(oop s) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
static void shared_oops_do(OopClosure* f) NOT_CDS_JAVA_HEAP_RETURN;
static void write_to_archive(const DumpedInternedStrings* dumped_interned_strings) NOT_CDS_JAVA_HEAP_RETURN;
static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/systemDictionary.cpp
Expand Up @@ -1808,7 +1808,7 @@ void SystemDictionary::initialize(TRAPS) {
vmClasses::resolve_all(CHECK);
// Resolve classes used by archived heap objects
if (UseSharedSpaces) {
HeapShared::resolve_classes(CHECK);
HeapShared::resolve_classes(THREAD);
}
}

Expand Down

1 comment on commit f03e839

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