Skip to content

Commit

Permalink
8264711: More runtime TRAPS cleanups
Browse files Browse the repository at this point in the history
Reviewed-by: lfoltan, pchilanomate, dholmes, dcubed
  • Loading branch information
Harold Seigel committed Apr 8, 2021
1 parent 3aec2d9 commit af13c64
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 96 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/os/posix/perfMemory_posix.cpp
Expand Up @@ -1311,7 +1311,7 @@ void PerfMemory::attach(const char* user, int vmid, PerfMemoryMode mode, char**
// the indicated process's PerfData memory region from this
// process's address space.
//
void PerfMemory::detach(char* addr, size_t bytes, TRAPS) {
void PerfMemory::detach(char* addr, size_t bytes) {

assert(addr != 0, "address sanity check");
assert(bytes > 0, "capacity sanity check");
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/perfMemory_windows.cpp
Expand Up @@ -1823,7 +1823,7 @@ void PerfMemory::attach(const char* user, int vmid, PerfMemoryMode mode,
// the indicated process's PerfData memory region from this
// process's address space.
//
void PerfMemory::detach(char* addr, size_t bytes, TRAPS) {
void PerfMemory::detach(char* addr, size_t bytes) {

assert(addr != 0, "address sanity check");
assert(bytes > 0, "capacity sanity check");
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/classfile/javaClasses.cpp
Expand Up @@ -968,7 +968,7 @@ void java_lang_Class::initialize_mirror_fields(Klass* k,
}

// Set the java.lang.Module module field in the java_lang_Class mirror
void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
void java_lang_Class::set_mirror_module_field(JavaThread* current, Klass* k, Handle mirror, Handle module) {
if (module.is_null()) {
// During startup, the module may be NULL only if java.base has not been defined yet.
// Put the class on the fixup_module_list to patch later when the java.lang.Module
Expand All @@ -977,7 +977,7 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo

bool javabase_was_defined = false;
{
MutexLocker m1(THREAD, Module_lock);
MutexLocker m1(current, Module_lock);
// Keep list of classes needing java.base module fixup
if (!ModuleEntryTable::javabase_defined()) {
assert(k->java_mirror() != NULL, "Class's mirror is null");
Expand All @@ -994,7 +994,7 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
assert(javabase_entry != NULL && javabase_entry->module() != NULL,
"Setting class module field, " JAVA_BASE_NAME " should be defined");
Handle javabase_handle(THREAD, javabase_entry->module());
Handle javabase_handle(current, javabase_entry->module());
set_module(mirror(), javabase_handle());
}
} else {
Expand Down Expand Up @@ -1087,7 +1087,7 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader,

// Set the module field in the java_lang_Class instance. This must be done
// after the mirror is set.
set_mirror_module_field(k, mirror, module, THREAD);
set_mirror_module_field(THREAD->as_Java_thread(), k, mirror, module);

if (comp_mirror() != NULL) {
// Set after k->java_mirror() is published, because compiled code running
Expand Down Expand Up @@ -1394,7 +1394,7 @@ bool java_lang_Class::restore_archived_mirror(Klass *k,

k->set_java_mirror(mirror);

set_mirror_module_field(k, mirror, module, THREAD);
set_mirror_module_field(THREAD->as_Java_thread(), k, mirror, module);

if (log_is_enabled(Trace, cds, heap, mirror)) {
ResourceMark rm(THREAD);
Expand Down Expand Up @@ -2881,7 +2881,7 @@ void java_lang_StackFrameInfo::set_method_and_bci(Handle stackFrame, const metho
Handle mname(THREAD, stackFrame->obj_field(_memberName_offset));
InstanceKlass* ik = method->method_holder();
CallInfo info(method(), ik, CHECK);
MethodHandles::init_method_MemberName(mname, info, THREAD);
MethodHandles::init_method_MemberName(mname, info);
// set bci
java_lang_StackFrameInfo::set_bci(stackFrame(), bci);
// method may be redefined; store the version
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/javaClasses.hpp
Expand Up @@ -261,7 +261,7 @@ class java_lang_Class : AllStatic {
static void set_component_mirror(oop java_class, oop comp_mirror);
static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain,
Handle classData, TRAPS);
static void set_mirror_module_field(Klass* K, Handle mirror, Handle module, TRAPS);
static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
public:
static void allocate_fixup_lists();
static void compute_offsets();
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/systemDictionary.cpp
Expand Up @@ -1214,11 +1214,11 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
ik->restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK_NULL);
}

load_shared_class_misc(ik, loader_data, CHECK_NULL);
load_shared_class_misc(ik, loader_data);
return ik;
}

void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) {
void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) {
ik->print_class_load_logging(loader_data, NULL, NULL);

// For boot loader, ensure that GetSystemPackage knows that a class in this
Expand All @@ -1240,7 +1240,7 @@ void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData
ik->set_has_passed_fingerprint_check(true);
} else {
if (log_is_enabled(Info, class, fingerprint)) {
ResourceMark rm(THREAD);
ResourceMark rm;
log_info(class, fingerprint)("%s : expected = " PTR64_FORMAT " actual = " PTR64_FORMAT, ik->external_name(), aot_fp, cds_fp);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/systemDictionary.hpp
Expand Up @@ -366,7 +366,7 @@ class SystemDictionary : AllStatic {
static bool check_shared_class_super_types(InstanceKlass* ik, Handle class_loader,
Handle protection_domain, TRAPS);
// Second part of load_shared_class
static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) NOT_CDS_RETURN;
static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) NOT_CDS_RETURN;
protected:
// Used by SystemDictionaryShared

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/vmClasses.cpp
Expand Up @@ -239,7 +239,7 @@ void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* load
}

klass->restore_unshareable_info(loader_data, domain, NULL, THREAD);
SystemDictionary::load_shared_class_misc(klass, loader_data, CHECK);
SystemDictionary::load_shared_class_misc(klass, loader_data);
Dictionary* dictionary = loader_data->dictionary();
unsigned int hash = dictionary->compute_hash(klass->name());
dictionary->add_klass(hash, klass->name(), klass);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/vmSymbols.cpp
@@ -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 @@ -76,7 +76,7 @@ static const char* vm_symbol_enum_name(vmSymbolID sid) {
#define VM_SYMBOL_BODY(name, string) string "\0"
static const char* vm_symbol_bodies = VM_SYMBOLS_DO(VM_SYMBOL_BODY, VM_ALIAS_IGNORE);

void vmSymbols::initialize(TRAPS) {
void vmSymbols::initialize() {
assert(SID_LIMIT <= (1<<log2_SID_LIMIT), "must fit in this bitfield");
assert(SID_LIMIT*5 > (1<<log2_SID_LIMIT), "make the bitfield smaller, please");
assert(vmIntrinsics::FLAG_LIMIT <= (1 << vmIntrinsics::log2_FLAG_LIMIT), "must fit in this bitfield");
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/vmSymbols.hpp
Expand Up @@ -769,7 +769,7 @@ class vmSymbols: AllStatic {

public:
// Initialization
static void initialize(TRAPS);
static void initialize();
// Accessing
#define VM_SYMBOL_DECLARE(name, ignore) \
static Symbol* name() { \
Expand Down
11 changes: 1 addition & 10 deletions src/hotspot/share/interpreter/bytecode.cpp
@@ -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 @@ -157,15 +157,6 @@ Method* Bytecode_invoke::static_target(TRAPS) {
return LinkResolver::resolve_method_statically(bc, constants, index(), THREAD);
}

Handle Bytecode_invoke::appendix(TRAPS) {
ConstantPoolCacheEntry* cpce = cpcache_entry();
if (cpce->has_appendix()) {
constantPoolHandle cp(THREAD, constants());
return Handle(THREAD, cpce->appendix_if_resolved(cp));
}
return Handle(); // usual case
}

int Bytecode_member_ref::index() const {
// Note: Rewriter::rewrite changes the Java_u2 of an invokedynamic to a native_u4,
// at the same time it allocates per-call-site CP cache entries.
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/interpreter/bytecode.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, 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 @@ -210,7 +210,6 @@ class Bytecode_invoke: public Bytecode_member_ref {

// Attributes
Method* static_target(TRAPS); // "specified" method (from constant pool)
Handle appendix(TRAPS); // if CPCE::has_appendix (from constant pool)

// Testers
bool is_invokeinterface() const { return invoke_code() == Bytecodes::_invokeinterface; }
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/interpreter/linkResolver.cpp
Expand Up @@ -462,7 +462,7 @@ Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info,
// Do not erase last argument type (MemberName) if it is a static linkTo method.
bool keep_last_arg = MethodHandles::is_signature_polymorphic_static(iid);
TempNewSymbol basic_signature =
MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg, CHECK_NULL);
MethodHandles::lookup_basic_type_signature(full_signature, keep_last_arg);
log_info(methodhandles)("lookup_polymorphic_method %s %s => basic %s",
name->as_C_string(),
full_signature->as_C_string(),
Expand Down Expand Up @@ -519,7 +519,7 @@ Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info,
ResourceMark rm(THREAD);

TempNewSymbol basic_signature =
MethodHandles::lookup_basic_type_signature(full_signature, CHECK_NULL);
MethodHandles::lookup_basic_type_signature(full_signature);
int actual_size_of_params = result->size_of_parameters();
int expected_size_of_params = ArgumentSizeComputer(basic_signature).size();
// +1 for MethodHandle.this, +1 for trailing MethodType
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/memory/universe.cpp
Expand Up @@ -329,7 +329,7 @@ void Universe::genesis(TRAPS) {
}
}

vmSymbols::initialize(CHECK);
vmSymbols::initialize();

SystemDictionary::initialize(CHECK);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jni.cpp
Expand Up @@ -1078,7 +1078,7 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str,
// Throw a NoSuchMethodError exception if we have an instance of a
// primitive java.lang.Class
if (java_lang_Class::is_primitive(mirror)) {
ResourceMark rm;
ResourceMark rm(THREAD);
THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
}

Expand All @@ -1102,7 +1102,7 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str,
}
}
if (m == NULL || (m->is_static() != is_static)) {
ResourceMark rm;
ResourceMark rm(THREAD);
THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
}
return m->jmethod_id();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jvm.cpp
Expand Up @@ -1502,7 +1502,7 @@ JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls))
JVM_END


static bool jvm_get_field_common(jobject field, fieldDescriptor& fd, TRAPS) {
static bool jvm_get_field_common(jobject field, fieldDescriptor& fd) {
// some of this code was adapted from from jni_FromReflectedField

oop reflected = JNIHandles::resolve_non_null(field);
Expand Down Expand Up @@ -1593,7 +1593,7 @@ JVM_END
JVM_ENTRY(jbyteArray, JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field))
assert (field != NULL, "illegal field");
fieldDescriptor fd;
bool gotFd = jvm_get_field_common(field, fd, CHECK_NULL);
bool gotFd = jvm_get_field_common(field, fd);
if (!gotFd) {
return NULL;
}
Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/prims/methodHandles.cpp
Expand Up @@ -214,7 +214,7 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) {
if (m == NULL || is_signature_polymorphic(m->intrinsic_id()))
return NULL; // do not resolve unless there is a concrete signature
CallInfo info(m, k, CHECK_NULL);
return init_method_MemberName(mname, info, THREAD);
return init_method_MemberName(mname, info);
}
} else if (target_klass == vmClasses::reflect_Constructor_klass()) {
oop clazz = java_lang_reflect_Constructor::clazz(target_oop);
Expand All @@ -224,13 +224,13 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) {
Method* m = InstanceKlass::cast(k)->method_with_idnum(slot);
if (m == NULL) return NULL;
CallInfo info(m, k, CHECK_NULL);
return init_method_MemberName(mname, info, THREAD);
return init_method_MemberName(mname, info);
}
}
return NULL;
}

oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, TRAPS) {
oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
assert(info.resolved_appendix().is_null(), "only normal methods here");
methodHandle m(Thread::current(), info.resolved_method());
assert(m.not_null(), "null method handle");
Expand Down Expand Up @@ -574,7 +574,7 @@ bool MethodHandles::is_basic_type_signature(Symbol* sig) {
return true;
}

Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_arg, TRAPS) {
Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_arg) {
Symbol* bsig = NULL;
if (sig == NULL) {
return sig;
Expand Down Expand Up @@ -801,7 +801,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup
THROW_MSG_(vmSymbols::java_lang_InternalError(), "appendix", empty);
}
result.set_resolved_method_name(CHECK_(empty));
oop mname2 = init_method_MemberName(mname, result, THREAD);
oop mname2 = init_method_MemberName(mname, result);
return Handle(THREAD, mname2);
}
case IS_CONSTRUCTOR:
Expand All @@ -824,7 +824,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup
}
assert(result.is_statically_bound(), "");
result.set_resolved_method_name(CHECK_(empty));
oop mname2 = init_method_MemberName(mname, result, THREAD);
oop mname2 = init_method_MemberName(mname, result);
return Handle(THREAD, mname2);
}
case IS_FIELD:
Expand Down Expand Up @@ -1025,7 +1025,7 @@ int MethodHandles::find_MemberNames(Klass* k,
if (!java_lang_invoke_MemberName::is_instance(result()))
return -99; // caller bug!
CallInfo info(m, NULL, CHECK_0);
oop saved = MethodHandles::init_method_MemberName(result, info, THREAD);
oop saved = MethodHandles::init_method_MemberName(result, info);
if (saved != result())
results->obj_at_put(rfill-1, saved); // show saved instance to user
} else if (++overflow >= overflow_limit) {
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/prims/methodHandles.hpp
Expand Up @@ -69,7 +69,7 @@ class MethodHandles: AllStatic {
static void expand_MemberName(Handle mname, int suppress, TRAPS); // expand defc/name/type if missing
static oop init_MemberName(Handle mname_h, Handle target_h, TRAPS); // compute vmtarget/vmindex from target
static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false);
static oop init_method_MemberName(Handle mname_h, CallInfo& info, TRAPS);
static oop init_method_MemberName(Handle mname_h, CallInfo& info);
static int find_MemberNames(Klass* k, Symbol* name, Symbol* sig,
int mflags, Klass* caller,
int skip, objArrayHandle results, TRAPS);
Expand Down Expand Up @@ -152,9 +152,9 @@ class MethodHandles: AllStatic {

public:
static Symbol* lookup_signature(oop type_str, bool polymorphic, TRAPS); // use TempNewSymbol
static Symbol* lookup_basic_type_signature(Symbol* sig, bool keep_last_arg, TRAPS); // use TempNewSymbol
static Symbol* lookup_basic_type_signature(Symbol* sig, TRAPS) {
return lookup_basic_type_signature(sig, false, THREAD);
static Symbol* lookup_basic_type_signature(Symbol* sig, bool keep_last_arg); // use TempNewSymbol
static Symbol* lookup_basic_type_signature(Symbol* sig) {
return lookup_basic_type_signature(sig, false);
}
static bool is_basic_type_signature(Symbol* sig);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/perf.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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 @@ -115,7 +115,7 @@ PERF_ENTRY(void, Perf_Detach(JNIEnv *env, jobject unused, jobject buffer))
capacity = env->GetDirectBufferCapacity(buffer);
}

PerfMemory::detach((char*)address, capacity, CHECK);
PerfMemory::detach((char*)address, capacity);

PERF_END

Expand Down

1 comment on commit af13c64

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