Skip to content

Commit 6e74c3a

Browse files
author
Harold Seigel
committed
8264193: Remove TRAPS parameters for modules and defaultmethods
Reviewed-by: lfoltan, ccheung, coleenp, dholmes
1 parent ee5e00b commit 6e74c3a

File tree

8 files changed

+48
-60
lines changed

8 files changed

+48
-60
lines changed

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6256,8 +6256,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
62566256
_major_version,
62576257
loader,
62586258
_class_name,
6259-
_local_interfaces,
6260-
CHECK);
6259+
_local_interfaces);
62616260

62626261
// Size of Java itable (in words)
62636262
_itable_size = _access_flags.is_interface() ? 0 :

src/hotspot/share/classfile/defaultMethods.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ class MethodFamily : public ResourceObj {
342342
_members.append(method_state);
343343
}
344344

345-
Symbol* generate_no_defaults_message(TRAPS) const;
346-
Symbol* generate_method_message(Symbol *klass_name, Method* method, TRAPS) const;
347-
Symbol* generate_conflicts_message(GrowableArray<MethodState>* methods, TRAPS) const;
345+
Symbol* generate_no_defaults_message() const;
346+
Symbol* generate_method_message(Symbol *klass_name, Method* method) const;
347+
Symbol* generate_conflicts_message(GrowableArray<MethodState>* methods) const;
348348

349349
public:
350350

@@ -377,7 +377,7 @@ class MethodFamily : public ResourceObj {
377377
Symbol* get_exception_name() { return _exception_name; }
378378

379379
// Either sets the target or the exception error message
380-
void determine_target_or_set_exception_message(InstanceKlass* root, TRAPS) {
380+
void determine_target_or_set_exception_message(InstanceKlass* root) {
381381
if (has_target() || throws_exception()) {
382382
return;
383383
}
@@ -400,11 +400,11 @@ class MethodFamily : public ResourceObj {
400400
assert(_members.at(default_index)._state == QUALIFIED, "");
401401
_selected_target = _members.at(default_index)._method;
402402
} else {
403-
generate_and_set_exception_message(root, num_defaults, default_index, CHECK);
403+
generate_and_set_exception_message(root, num_defaults, default_index);
404404
}
405405
}
406406

407-
void generate_and_set_exception_message(InstanceKlass* root, int num_defaults, int default_index, TRAPS) {
407+
void generate_and_set_exception_message(InstanceKlass* root, int num_defaults, int default_index) {
408408
assert(num_defaults != 1, "invariant - should've been handled calling method");
409409

410410
GrowableArray<Method*> qualified_methods;
@@ -419,14 +419,14 @@ class MethodFamily : public ResourceObj {
419419
// then do not generate an overpass method because it will hide the
420420
// static method during resolution.
421421
if (qualified_methods.length() == 0) {
422-
_exception_message = generate_no_defaults_message(CHECK);
422+
_exception_message = generate_no_defaults_message();
423423
} else {
424424
assert(root != NULL, "Null root class");
425-
_exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
425+
_exception_message = generate_method_message(root->name(), qualified_methods.at(0));
426426
}
427427
_exception_name = vmSymbols::java_lang_AbstractMethodError();
428428
} else {
429-
_exception_message = generate_conflicts_message(&_members,CHECK);
429+
_exception_message = generate_conflicts_message(&_members);
430430
_exception_name = vmSymbols::java_lang_IncompatibleClassChangeError();
431431
LogTarget(Debug, defaultmethods) lt;
432432
if (lt.is_enabled()) {
@@ -457,11 +457,11 @@ class MethodFamily : public ResourceObj {
457457
}
458458
};
459459

460-
Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const {
460+
Symbol* MethodFamily::generate_no_defaults_message() const {
461461
return SymbolTable::new_symbol("No qualifying defaults found");
462462
}
463463

464-
Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const {
464+
Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method) const {
465465
stringStream ss;
466466
ss.print("Method ");
467467
Symbol* name = method->name();
@@ -474,7 +474,7 @@ Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method
474474
return SymbolTable::new_symbol(ss.base(), (int)ss.size());
475475
}
476476

477-
Symbol* MethodFamily::generate_conflicts_message(GrowableArray<MethodState>* methods, TRAPS) const {
477+
Symbol* MethodFamily::generate_conflicts_message(GrowableArray<MethodState>* methods) const {
478478
stringStream ss;
479479
ss.print("Conflicting default methods:");
480480
for (int i = 0; i < methods->length(); ++i) {
@@ -625,7 +625,7 @@ static bool already_in_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots, Meth
625625
}
626626

627627
static void find_empty_vtable_slots(GrowableArray<EmptyVtableSlot*>* slots,
628-
InstanceKlass* klass, const GrowableArray<Method*>* mirandas, TRAPS) {
628+
InstanceKlass* klass, const GrowableArray<Method*>* mirandas) {
629629

630630
assert(klass != NULL, "Must be valid class");
631631

@@ -781,7 +781,7 @@ static void create_defaults_and_exceptions(
781781

782782
static void generate_erased_defaults(
783783
FindMethodsByErasedSig* visitor,
784-
InstanceKlass* klass, EmptyVtableSlot* slot, bool is_intf, TRAPS) {
784+
InstanceKlass* klass, EmptyVtableSlot* slot, bool is_intf) {
785785

786786
// the visitor needs to be initialized or re-initialized before use
787787
// - this facilitates reusing the same visitor instance on multiple
@@ -793,7 +793,7 @@ static void generate_erased_defaults(
793793
MethodFamily* family;
794794
visitor->get_discovered_family(&family);
795795
if (family != NULL) {
796-
family->determine_target_or_set_exception_message(klass, CHECK);
796+
family->determine_target_or_set_exception_message(klass);
797797
slot->bind_family(family);
798798
}
799799
}
@@ -835,7 +835,7 @@ void DefaultMethods::generate_default_methods(
835835

836836
LogTarget(Debug, defaultmethods) lt;
837837
if (lt.is_enabled()) {
838-
ResourceMark rm;
838+
ResourceMark rm(THREAD);
839839
lt.print("%s %s requires default method processing",
840840
klass->is_interface() ? "Interface" : "Class",
841841
klass->name()->as_klass_external_name());
@@ -845,7 +845,7 @@ void DefaultMethods::generate_default_methods(
845845
}
846846

847847
GrowableArray<EmptyVtableSlot*> empty_slots;
848-
find_empty_vtable_slots(&empty_slots, klass, mirandas, CHECK);
848+
find_empty_vtable_slots(&empty_slots, klass, mirandas);
849849

850850
if (empty_slots.length() > 0) {
851851
FindMethodsByErasedSig findMethodsByErasedSig;
@@ -859,7 +859,7 @@ void DefaultMethods::generate_default_methods(
859859
slot->print_on(&ls);
860860
ls.cr();
861861
}
862-
generate_erased_defaults(&findMethodsByErasedSig, klass, slot, klass->is_interface(), CHECK);
862+
generate_erased_defaults(&findMethodsByErasedSig, klass, slot, klass->is_interface());
863863
}
864864
log_debug(defaultmethods)("Creating defaults and overpasses...");
865865
create_defaults_and_exceptions(&empty_slots, klass, CHECK);
@@ -868,7 +868,7 @@ void DefaultMethods::generate_default_methods(
868868
}
869869

870870
static int assemble_method_error(
871-
BytecodeConstantPool* cp, BytecodeBuffer* buffer, Symbol* errorName, Symbol* message, TRAPS) {
871+
BytecodeConstantPool* cp, BytecodeBuffer* buffer, Symbol* errorName, Symbol* message) {
872872

873873
Symbol* init = vmSymbols::object_initializer_name();
874874
Symbol* sig = vmSymbols::string_void_signature();
@@ -992,7 +992,7 @@ static void create_defaults_and_exceptions(GrowableArray<EmptyVtableSlot*>* slot
992992
buffer->clear();
993993
}
994994
int max_stack = assemble_method_error(&bpool, buffer,
995-
method->get_exception_name(), method->get_exception_message(), CHECK);
995+
method->get_exception_name(), method->get_exception_message());
996996
AccessFlags flags = accessFlags_from(
997997
JVM_ACC_PUBLIC | JVM_ACC_SYNTHETIC | JVM_ACC_BRIDGE);
998998
Method* m = new_method(&bpool, buffer, slot->name(), slot->signature(),

src/hotspot/share/classfile/modules.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static ModuleEntry* get_module_entry(Handle module, TRAPS) {
109109
}
110110

111111

112-
static PackageEntry* get_locked_package_entry(ModuleEntry* module_entry, const char* package_name, int len, TRAPS) {
112+
static PackageEntry* get_locked_package_entry(ModuleEntry* module_entry, const char* package_name, int len) {
113113
assert(Module_lock->owned_by_self(), "should have the Module_lock");
114114
assert(package_name != NULL, "Precondition");
115115
TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, len);
@@ -120,9 +120,7 @@ static PackageEntry* get_locked_package_entry(ModuleEntry* module_entry, const c
120120
return package_entry;
121121
}
122122

123-
static PackageEntry* get_package_entry_by_name(Symbol* package,
124-
Handle h_loader,
125-
TRAPS) {
123+
static PackageEntry* get_package_entry_by_name(Symbol* package, Handle h_loader) {
126124
if (package != NULL) {
127125
PackageEntryTable* const package_entry_table =
128126
get_package_entry_table(h_loader);
@@ -132,8 +130,8 @@ static PackageEntry* get_package_entry_by_name(Symbol* package,
132130
return NULL;
133131
}
134132

135-
bool Modules::is_package_defined(Symbol* package, Handle h_loader, TRAPS) {
136-
PackageEntry* res = get_package_entry_by_name(package, h_loader, CHECK_false);
133+
bool Modules::is_package_defined(Symbol* package, Handle h_loader) {
134+
PackageEntry* res = get_package_entry_by_name(package, h_loader);
137135
return res != NULL;
138136
}
139137

@@ -586,7 +584,7 @@ void Modules::add_module_exports(Handle from_module, jstring package_name, Handl
586584
const char* pkg = as_internal_package(JNIHandles::resolve_non_null(package_name), buf, sizeof(buf), package_len);
587585
{
588586
MutexLocker ml(THREAD, Module_lock);
589-
package_entry = get_locked_package_entry(from_module_entry, pkg, package_len, CHECK);
587+
package_entry = get_locked_package_entry(from_module_entry, pkg, package_len);
590588
// Do nothing if modules are the same
591589
// If the package is not found we'll throw an exception later
592590
if (from_module_entry != to_module_entry &&
@@ -708,7 +706,7 @@ jobject Modules::get_module(jclass clazz, TRAPS) {
708706
return JNIHandles::make_local(THREAD, module);
709707
}
710708

711-
jobject Modules::get_named_module(Handle h_loader, const char* package_name, TRAPS) {
709+
oop Modules::get_named_module(Handle h_loader, const char* package_name) {
712710
assert(ModuleEntryTable::javabase_defined(),
713711
"Attempt to call get_named_module before " JAVA_BASE_NAME " is defined");
714712
assert(h_loader.is_null() || java_lang_ClassLoader::is_subclass(h_loader->klass()),
@@ -720,11 +718,11 @@ jobject Modules::get_named_module(Handle h_loader, const char* package_name, TRA
720718
}
721719
TempNewSymbol package_sym = SymbolTable::new_symbol(package_name);
722720
const PackageEntry* const pkg_entry =
723-
get_package_entry_by_name(package_sym, h_loader, THREAD);
721+
get_package_entry_by_name(package_sym, h_loader);
724722
const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL);
725723

726724
if (module_entry != NULL && module_entry->module() != NULL && module_entry->is_named()) {
727-
return JNIHandles::make_local(THREAD, module_entry->module());
725+
return module_entry->module();
728726
}
729727
return NULL;
730728
}
@@ -757,7 +755,7 @@ void Modules::add_module_exports_to_all_unnamed(Handle module, jstring package_n
757755
PackageEntry* package_entry = NULL;
758756
{
759757
MutexLocker m1(THREAD, Module_lock);
760-
package_entry = get_locked_package_entry(module_entry, pkg, pkg_len, CHECK);
758+
package_entry = get_locked_package_entry(module_entry, pkg, pkg_len);
761759

762760
// Mark package as exported to all unnamed modules.
763761
if (package_entry != NULL) {

src/hotspot/share/classfile/modules.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ class Modules : AllStatic {
101101
static jobject get_module(jclass clazz, TRAPS);
102102

103103
// Return the java.lang.Module object for this class loader and package.
104-
// Returns NULL if the class loader has not loaded any classes in the package.
104+
// Returns NULL if the package name is empty, if the resulting package
105+
// entry is NULL, if the module is not found or is unnamed.
105106
// The package should contain /'s, not .'s, as in java/lang, not java.lang.
106-
// NullPointerException is thrown if package is null.
107-
// IllegalArgumentException is thrown if loader is neither null nor a subtype of
108-
// java/lang/ClassLoader.
109-
static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
107+
static oop get_named_module(Handle h_loader, const char* package);
110108

111109
// Marks the specified package as exported to all unnamed modules.
112110
// If either module or package is null then NullPointerException is thrown.
@@ -115,7 +113,7 @@ class Modules : AllStatic {
115113
static void add_module_exports_to_all_unnamed(Handle module, jstring package, TRAPS);
116114

117115
// Return TRUE iff package is defined by loader
118-
static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
116+
static bool is_package_defined(Symbol* package_name, Handle h_loader);
119117
static ModuleEntryTable* get_module_entry_table(Handle h_loader);
120118
};
121119

src/hotspot/share/jfr/jni/jfrJavaSupport.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,9 @@ const char* const JDK_JFR_MODULE_NAME = "jdk.jfr";
602602
const char* const JDK_JFR_PACKAGE_NAME = "jdk/jfr";
603603

604604
static bool is_jdk_jfr_module_in_readability_graph() {
605-
Thread* const t = Thread::current();
606605
// take one of the packages in the module to be located and query for its definition.
607606
TempNewSymbol pkg_sym = SymbolTable::new_symbol(JDK_JFR_PACKAGE_NAME);
608-
return Modules::is_package_defined(pkg_sym, Handle(), t);
607+
return Modules::is_package_defined(pkg_sym, Handle());
609608
}
610609

611610
static void print_module_resolution_error(outputStream* stream) {

src/hotspot/share/oops/klassVtable.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ void klassVtable::compute_vtable_size_and_num_mirandas(
6868
int* vtable_length_ret, int* num_new_mirandas,
6969
GrowableArray<Method*>* all_mirandas, const Klass* super,
7070
Array<Method*>* methods, AccessFlags class_flags, u2 major_version,
71-
Handle classloader, Symbol* classname, Array<InstanceKlass*>* local_interfaces,
72-
TRAPS) {
71+
Handle classloader, Symbol* classname, Array<InstanceKlass*>* local_interfaces) {
7372
NoSafepointVerifier nsv;
7473

7574
// set up default result values
@@ -258,7 +257,7 @@ void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
258257
// Interfaces do not need interface methods in their vtables
259258
// This includes miranda methods and during later processing, default methods
260259
if (!ik()->is_interface()) {
261-
initialized = fill_in_mirandas(initialized, THREAD);
260+
initialized = fill_in_mirandas(THREAD, initialized);
262261
}
263262

264263
// In class hierarchies where the accessibility is not increasing (i.e., going from private ->
@@ -937,8 +936,8 @@ void klassVtable::get_mirandas(GrowableArray<Method*>* new_mirandas,
937936
// return the new value of initialized.
938937
// Miranda methods use vtable entries, but do not get assigned a vtable_index
939938
// The vtable_index is discovered by searching from the end of the vtable
940-
int klassVtable::fill_in_mirandas(int initialized, TRAPS) {
941-
ResourceMark rm(THREAD);
939+
int klassVtable::fill_in_mirandas(Thread* current, int initialized) {
940+
ResourceMark rm(current);
942941
GrowableArray<Method*> mirandas(20);
943942
get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
944943
ik()->default_methods(), ik()->local_interfaces(),
@@ -1112,7 +1111,7 @@ void klassItable::initialize_itable(bool checkconstraints, TRAPS) {
11121111
if (_klass->is_interface()) {
11131112
// This needs to go after vtable indices are assigned but
11141113
// before implementors need to know the number of itable indices.
1115-
assign_itable_indices_for_interface(InstanceKlass::cast(_klass), THREAD);
1114+
assign_itable_indices_for_interface(THREAD, InstanceKlass::cast(_klass));
11161115
}
11171116

11181117
// Cannot be setup doing bootstrapping, interfaces don't have
@@ -1158,9 +1157,9 @@ inline bool interface_method_needs_itable_index(Method* m) {
11581157
return true;
11591158
}
11601159

1161-
int klassItable::assign_itable_indices_for_interface(InstanceKlass* klass, TRAPS) {
1160+
int klassItable::assign_itable_indices_for_interface(Thread* current, InstanceKlass* klass) {
11621161
// an interface does not have an itable, but its methods need to be numbered
1163-
ResourceMark rm(THREAD);
1162+
ResourceMark rm(current);
11641163
log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
11651164
++initialize_count, klass->name()->as_C_string());
11661165
Array<Method*>* methods = klass->methods();

src/hotspot/share/oops/klassVtable.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -75,8 +75,7 @@ class klassVtable {
7575
u2 major_version,
7676
Handle classloader,
7777
Symbol* classname,
78-
Array<InstanceKlass*>* local_interfaces,
79-
TRAPS);
78+
Array<InstanceKlass*>* local_interfaces);
8079

8180
#if INCLUDE_JVMTI
8281
// RedefineClasses() API support:
@@ -126,7 +125,7 @@ class klassVtable {
126125

127126
// support for miranda methods
128127
bool is_miranda_entry_at(int i);
129-
int fill_in_mirandas(int initialized, TRAPS);
128+
int fill_in_mirandas(Thread* current, int initialized);
130129
static bool is_miranda(Method* m, Array<Method*>* class_methods,
131130
Array<Method*>* default_methods, const Klass* super,
132131
bool is_interface);
@@ -307,7 +306,7 @@ class klassItable {
307306
#endif // INCLUDE_JVMTI
308307

309308
// Setup of itable
310-
static int assign_itable_indices_for_interface(InstanceKlass* klass, TRAPS);
309+
static int assign_itable_indices_for_interface(Thread* current, InstanceKlass* klass);
311310
static int method_count_for_interface(InstanceKlass* klass);
312311
static int compute_itable_size(Array<InstanceKlass*>* transitive_interfaces);
313312
static void setup_itable_offset_table(InstanceKlass* klass);

src/hotspot/share/prims/jvmtiEnv.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,8 @@ JvmtiEnv::GetNamedModule(jobject class_loader, const char* package_name, jobject
223223
if (h_loader.not_null() && !java_lang_ClassLoader::is_subclass(h_loader->klass())) {
224224
return JVMTI_ERROR_ILLEGAL_ARGUMENT;
225225
}
226-
jobject module = Modules::get_named_module(h_loader, package_name, THREAD);
227-
if (HAS_PENDING_EXCEPTION) {
228-
CLEAR_PENDING_EXCEPTION;
229-
return JVMTI_ERROR_INTERNAL; // unexpected exception
230-
}
231-
*module_ptr = module;
226+
oop module = Modules::get_named_module(h_loader, package_name);
227+
*module_ptr = module != NULL ? JNIHandles::make_local(THREAD, module) : NULL;
232228
return JVMTI_ERROR_NONE;
233229
} /* end GetNamedModule */
234230

0 commit comments

Comments
 (0)