8249837: Avoid direct or implicit Thread::current() calls when we already have a current thread variable

Add current thread OR remove unneeded HandleMark

Reviewed-by: kvn, dholmes
This commit is contained in:
Coleen Phillimore 2020-07-30 10:41:31 -04:00
parent 79f02a67ce
commit 9798a0846b
50 changed files with 108 additions and 143 deletions

View file

@ -1108,8 +1108,8 @@ void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level
}
int ciReplay::replay_impl(TRAPS) {
HandleMark hm;
ResourceMark rm;
HandleMark hm(THREAD);
ResourceMark rm(THREAD);
if (ReplaySuppressInitializers > 2) {
// ReplaySuppressInitializers > 2 means that we want to allow

View file

@ -306,14 +306,14 @@ LockedClassesDo::~LockedClassesDo() {
// unloading can remove entries concurrently soon.
class ClassLoaderDataGraphIterator : public StackObj {
ClassLoaderData* _next;
Thread* _thread;
HandleMark _hm; // clean up handles when this is done.
Handle _holder;
Thread* _thread;
NoSafepointVerifier _nsv; // No safepoints allowed in this scope
// unless verifying at a safepoint.
public:
ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head) {
ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head), _thread(Thread::current()), _hm(_thread) {
_thread = Thread::current();
assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
}

View file

@ -173,8 +173,8 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,
assert(loader_data != NULL, "invariant");
assert(THREAD->is_Java_thread(), "must be a JavaThread");
ResourceMark rm;
HandleMark hm;
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
JvmtiCachedClassFileData* cached_class_file = NULL;

View file

@ -1773,7 +1773,7 @@ bool SystemDictionaryShared::check_linking_constraints(InstanceKlass* klass, TRA
RunTimeSharedClassInfo* info = RunTimeSharedClassInfo::get_for(klass);
assert(info != NULL, "Sanity");
if (info->_num_loader_constraints > 0) {
HandleMark hm;
HandleMark hm(THREAD);
for (int i = 0; i < info->_num_loader_constraints; i++) {
RunTimeSharedClassInfo::RTLoaderConstraint* lc = info->loader_constraint_at(i);
Symbol* name = lc->constraint_name();

View file

@ -873,7 +873,6 @@ void nmethod::log_identity(xmlStream* log) const {
void nmethod::log_new_nmethod() const {
if (LogCompilation && xtty != NULL) {
ttyLocker ttyl;
HandleMark hm;
xtty->begin_elem("nmethod");
log_identity(xtty);
xtty->print(" entry='" INTPTR_FORMAT "' size='%d'", p2i(code_begin()), size());
@ -931,7 +930,6 @@ void nmethod::print_nmethod(bool printmethod) {
// Print the header part, then print the requested information.
// This is both handled in decode2().
if (printmethod) {
HandleMark hm;
ResourceMark m;
if (is_compiled_by_c1()) {
tty->cr();
@ -2405,6 +2403,7 @@ void nmethod::verify() {
void nmethod::verify_interrupt_point(address call_site) {
// Verify IC only when nmethod installation is finished.
if (!is_not_installed()) {
if (CompiledICLocker::is_safe(this)) {
@ -2415,6 +2414,8 @@ void nmethod::verify_interrupt_point(address call_site) {
}
}
HandleMark hm(Thread::current());
PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address());
assert(pd != NULL, "PcDesc must exist");
for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
@ -2554,7 +2555,6 @@ void nmethod::print(outputStream* st) const {
}
void nmethod::print_code() {
HandleMark hm;
ResourceMark m;
ttyLocker ttyl;
// Call the specialized decode method of this class.
@ -2584,7 +2584,6 @@ void nmethod::print_dependencies() {
// Print the oops from the underlying CodeBlob.
void nmethod::print_oops(outputStream* st) {
HandleMark hm;
ResourceMark m;
st->print("Oops:");
if (oops_begin() < oops_end()) {
@ -2610,7 +2609,6 @@ void nmethod::print_oops(outputStream* st) {
// Print metadata pool.
void nmethod::print_metadata(outputStream* st) {
HandleMark hm;
ResourceMark m;
st->print("Metadata:");
if (metadata_begin() < metadata_end()) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@ -253,7 +253,9 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const {
#endif
void ScopeDesc::verify() {
ResourceMark rm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
guarantee(method()->is_method(), "type check");
// check if we have any illegal elements on the expression stack

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@ -320,7 +320,6 @@ void VtableStubs::vtable_stub_do(void f(VtableStub*)) {
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index) {
ResourceMark rm;
HandleMark hm;
Klass* klass = receiver->klass();
InstanceKlass* ik = InstanceKlass::cast(klass);
klassVtable vt = ik->vtable();

View file

@ -3416,7 +3416,6 @@ public:
virtual void work(uint worker_id) {
// The reference processing task executed by a single worker.
ResourceMark rm;
HandleMark hm;
G1STWIsAliveClosure is_alive(_g1h);
@ -3789,7 +3788,6 @@ public:
{
ResourceMark rm;
HandleMark hm;
G1ParScanThreadState* pss = _per_thread_states->state_for_worker(worker_id);
pss->set_ref_discoverer(_g1h->ref_processor_stw());

View file

@ -1479,7 +1479,6 @@ public:
virtual void work(uint worker_id) {
ResourceMark rm;
HandleMark hm;
G1CMTask* task = _cm->task(worker_id);
G1CMIsAliveClosure g1_is_alive(_g1h);
G1CMKeepAliveAndDrainClosure g1_par_keep_alive(_cm, task, false /* is_serial */);
@ -1508,7 +1507,6 @@ void G1CMRefProcTaskExecutor::execute(ProcessTask& proc_task, uint ergo_workers)
void G1ConcurrentMark::weak_refs_work(bool clear_all_soft_refs) {
ResourceMark rm;
HandleMark hm;
// Is alive closure.
G1CMIsAliveClosure g1_is_alive(_g1h);
@ -1755,7 +1753,6 @@ public:
task->record_start_time();
{
ResourceMark rm;
HandleMark hm;
G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task);
Threads::threads_do(&threads_f);
@ -1779,7 +1776,6 @@ public:
void G1ConcurrentMark::finalize_marking() {
ResourceMark rm;
HandleMark hm;
_g1h->ensure_parsability(false);

View file

@ -153,7 +153,7 @@ void G1ConcurrentMarkThread::run_service() {
GCTraceConcTime(Info, gc) tt("Concurrent Cycle");
{
ResourceMark rm;
HandleMark hm;
double cycle_start = os::elapsedVTime();
{

View file

@ -277,7 +277,6 @@ void G1FullCollector::verify_after_marking() {
return;
}
HandleMark hm; // handle scope
#if COMPILER2_OR_JVMCI
DerivedPointerTableDeactivate dpt_deact;
#endif

View file

@ -449,7 +449,6 @@ public:
}
void work(uint worker_id) {
HandleMark hm;
VerifyRegionClosure blk(true, _vo);
_g1h->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
if (blk.failures()) {
@ -619,7 +618,6 @@ double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* ms
if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
double verify_start = os::elapsedTime();
HandleMark hm; // Discard invalid handles created during verification
prepare_for_verify();
Universe::verify(vo, msg);
verify_time_ms = (os::elapsedTime() - verify_start) * 1000;

View file

@ -1007,7 +1007,6 @@ void PSParallelCompact::pre_compact()
heap->ensure_parsability(true); // retire TLABs
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("Before GC");
}
@ -1788,7 +1787,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
{
ResourceMark rm;
HandleMark hm;
const uint active_workers =
WorkerPolicy::calc_active_workers(ParallelScavengeHeap::heap()->workers().total_workers(),
@ -1945,7 +1943,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
#endif // ASSERT
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("After GC");
}

View file

@ -430,13 +430,11 @@ bool PSScavenge::invoke_no_policy() {
heap->ensure_parsability(true); // retire TLABs
if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("Before GC");
}
{
ResourceMark rm;
HandleMark hm;
GCTraceCPUTime tcpu;
GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true);
@ -714,7 +712,6 @@ bool PSScavenge::invoke_no_policy() {
}
if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("After GC");
}

View file

@ -229,20 +229,21 @@ CollectedHeap::CollectedHeap() :
// heap lock is already held and that we are executing in
// the context of the vm thread.
void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) {
assert(Thread::current()->is_VM_thread(), "Precondition#1");
Thread* thread = Thread::current();
assert(thread->is_VM_thread(), "Precondition#1");
assert(Heap_lock->is_locked(), "Precondition#2");
GCCauseSetter gcs(this, cause);
switch (cause) {
case GCCause::_heap_inspection:
case GCCause::_heap_dump:
case GCCause::_metadata_GC_threshold : {
HandleMark hm;
HandleMark hm(thread);
do_full_collection(false); // don't clear all soft refs
break;
}
case GCCause::_archive_time_gc:
case GCCause::_metadata_GC_clear_soft_refs: {
HandleMark hm;
HandleMark hm(thread);
do_full_collection(true); // do clear all soft refs
break;
}
@ -412,14 +413,14 @@ CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap)
void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap)
{
DEBUG_ONLY(fill_args_check(start, words);)
HandleMark hm; // Free handles before leaving.
HandleMark hm(Thread::current()); // Free handles before leaving.
fill_with_object_impl(start, words, zap);
}
void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap)
{
DEBUG_ONLY(fill_args_check(start, words);)
HandleMark hm; // Free handles before leaving.
HandleMark hm(Thread::current()); // Free handles before leaving.
// Multiple objects may be required depending on the filler array maximum size. Fill
// the range up to that with objects that are filler_array_max_size sized. The

View file

@ -130,7 +130,6 @@ bool VM_GC_HeapInspection::collect() {
}
void VM_GC_HeapInspection::doit() {
HandleMark hm;
Universe::heap()->ensure_parsability(false); // must happen, even if collection does
// not happen (e.g. due to GCLocker)
// or _full_gc being false

View file

@ -317,7 +317,6 @@ HeapWord* GenCollectedHeap::mem_allocate_work(size_t size,
// Loop until the allocation is satisfied, or unsatisfied after GC.
for (uint try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) {
HandleMark hm; // Discard any handles allocated in each iteration.
// First allocation attempt is lock-free.
Generation *young = _young_gen;
@ -477,7 +476,6 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
log_trace(gc)("%s invoke=%d size=" SIZE_FORMAT, heap()->is_young_gen(gen) ? "Young" : "Old", gen->stat_record()->invocations, size * HeapWordSize);
if (run_verification && VerifyBeforeGC) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("Before GC");
}
COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::clear());
@ -502,7 +500,6 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
// weak refs more uniform (and indeed remove such concerns
// from GCH). XXX
HandleMark hm; // Discard invalid handles created during gc
save_marks(); // save marks for all gens
// We want to discover references, but not process them yet.
// This mode is disabled in process_discovered_references if the
@ -535,7 +532,6 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
update_gc_stats(gen, full);
if (run_verification && VerifyAfterGC) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("After GC");
}
}

View file

@ -654,8 +654,9 @@ public:
}
void work(uint worker_id) {
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahParallelWorkerSession worker_session(worker_id);

View file

@ -1103,8 +1103,6 @@ JRT_LEAF(void, InterpreterRuntime::verify_mdp(Method* method, address bcp, addre
address mdp2 = mdo->bci_to_dp(bci);
if (mdp != mdp2) {
ResourceMark rm;
ResetNoHandleMark rnm; // In a LEAF entry.
HandleMark hm;
tty->print_cr("FAILED verify : actual mdp %p expected mdp %p @ bci %d", mdp, mdp2, bci);
int current_di = mdo->dp_to_di(mdp);
int expected_di = mdo->dp_to_di(mdp2);
@ -1125,7 +1123,6 @@ JRT_END
JRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci))
assert(ProfileInterpreter, "must be profiling interpreter");
ResourceMark rm(thread);
HandleMark hm(thread);
LastFrameAccessor last_frame(thread);
assert(last_frame.is_interpreted_frame(), "must come from interpreter");
MethodData* h_mdo = last_frame.method()->method_data();
@ -1479,8 +1476,6 @@ JRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* threa
if (src_address == dest_address) {
return;
}
ResetNoHandleMark rnm; // In a LEAF entry.
HandleMark hm;
ResourceMark rm;
LastFrameAccessor last_frame(thread);
assert(last_frame.is_interpreted_frame(), "");

View file

@ -321,7 +321,6 @@ void OopMapCacheEntry::fill_for_native(const methodHandle& mh) {
void OopMapCacheEntry::fill(const methodHandle& method, int bci) {
HandleMark hm;
// Flush entry to deallocate an existing entry
flush();
set_method(method());

View file

@ -835,7 +835,7 @@ void JfrJavaSupport::on_thread_start(Thread* t) {
return;
}
DEBUG_ONLY(check_new_unstarted_java_thread(t);)
HandleMark hm;
HandleMark hm(t);
if (check_exclusion_state_on_thread_start((JavaThread*)t)) {
JfrThreadLocal::exclude(t);
}

View file

@ -246,8 +246,9 @@ bool JfrRecorder::is_created() {
}
bool JfrRecorder::create_components() {
ResourceMark rm;
HandleMark hm;
// Move these down into the functions that might create handles!
ResourceMark rm(Thread::current());
HandleMark hm(Thread::current());
if (!create_java_event_writer()) {
return false;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, 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
@ -788,7 +788,7 @@ int CodeInstaller::estimate_stubs_size(JVMCI_TRAPS) {
// perform data and call relocation on the CodeBuffer
JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bool check_size, JVMCI_TRAPS) {
HandleMark hm;
HandleMark hm(Thread::current());
JVMCIObjectArray sites = this->sites();
int locs_buffer_size = JVMCIENV->get_length(sites) * (relocInfo::length_limit + sizeof(relocInfo));

View file

@ -57,8 +57,8 @@ void JVMCICompiler::bootstrap(TRAPS) {
return;
}
_bootstrapping = true;
ResourceMark rm;
HandleMark hm;
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
if (PrintBootstrap) {
tty->print("Bootstrapping JVMCI");
}

View file

@ -819,7 +819,7 @@ C2V_END
C2V_VMENTRY_0(jint, installCode, (JNIEnv *env, jobject, jobject target, jobject compiled_code,
jobject installed_code, jlong failed_speculations_address, jbyteArray speculations_obj))
HandleMark hm;
HandleMark hm(THREAD);
JNIHandleMark jni_hm(thread);
JVMCIObject target_handle = JVMCIENV->wrap(target);
@ -880,7 +880,7 @@ C2V_END
C2V_VMENTRY_0(jint, getMetadata, (JNIEnv *env, jobject, jobject target, jobject compiled_code, jobject metadata))
#if INCLUDE_AOT
HandleMark hm;
HandleMark hm(THREAD);
assert(JVMCIENV->is_hotspot(), "AOT code is executed only in HotSpot mode");
JVMCIObject target_handle = JVMCIENV->wrap(target);
@ -968,7 +968,7 @@ C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv* env, jobject))
C2V_END
C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject installedCode))
HandleMark hm;
HandleMark hm(THREAD);
if (installedCode == NULL) {
JVMCI_THROW_MSG_NULL(NullPointerException, "installedCode is null");
@ -1006,7 +1006,7 @@ C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject in
C2V_END
C2V_VMENTRY_NULL(jobject, getStackTraceElement, (JNIEnv* env, jobject, jobject jvmci_method, int bci))
HandleMark hm;
HandleMark hm(THREAD);
methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
JVMCIObject element = JVMCIENV->new_StackTraceElement(method, bci, JVMCI_CHECK_NULL);
@ -1018,7 +1018,7 @@ C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject
// and the return value would have to be wrapped as a JavaConstant.
requireInHotSpot("executeHotSpotNmethod", JVMCI_CHECK_NULL);
HandleMark hm;
HandleMark hm(THREAD);
JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
nmethodLocker locker;
@ -1157,7 +1157,7 @@ C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
C2V_END
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
HandleMark hm;
HandleMark hm(THREAD);
if (jvmci_method == NULL) {
JVMCI_THROW_0(NullPointerException);
}
@ -2246,7 +2246,7 @@ C2V_VMENTRY_NULL(jlongArray, registerNativeMethods, (JNIEnv* env, jobject, jclas
// Ensure the JVMCI shared library runtime is initialized.
JVMCIEnv __peer_jvmci_env__(thread, false, __FILE__, __LINE__);
JVMCIEnv* peerEnv = &__peer_jvmci_env__;
HandleMark hm;
HandleMark hm(THREAD);
JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(peerEnv);
if (peerEnv->has_pending_exception()) {
peerEnv->describe_pending_exception(true);

View file

@ -661,8 +661,8 @@ void JVMCIEnv::call_HotSpotJVMCIRuntime_bootstrapFinished (JVMCIObject runtime,
}
void JVMCIEnv::call_HotSpotJVMCIRuntime_shutdown (JVMCIObject runtime) {
HandleMark hm;
JavaThread* THREAD = JavaThread::current();
HandleMark hm(THREAD);
if (is_hotspot()) {
JavaCallArguments jargs;
jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime)));

View file

@ -925,9 +925,9 @@ void JVMCIRuntime::initialize(JVMCIEnv* JVMCIENV) {
{
MutexUnlocker unlock(JVMCI_lock);
HandleMark hm;
ResourceMark rm;
JavaThread* THREAD = JavaThread::current();
HandleMark hm(THREAD);
ResourceMark rm(THREAD);
if (JVMCIENV->is_hotspot()) {
HotSpotJVMCI::compute_offsets(CHECK_EXIT);
} else {
@ -1013,7 +1013,7 @@ JVM_ENTRY_NO_ENV(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
JVMCIENV->runtime()->initialize(JVMCIENV);
{
ResourceMark rm;
ResourceMark rm(thread);
HandleMark hm(thread);
ThreadToNativeFromVM trans(thread);
@ -1483,7 +1483,7 @@ void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, c
return;
}
HandleMark hm;
HandleMark hm(thread);
JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
if (JVMCIENV->has_pending_exception()) {
fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");

View file

@ -561,7 +561,6 @@ public:
void verify_universe(const char* info) {
if (VerifyBeforeExit) {
log_info(cds)("Verify %s", info);
HandleMark hm;
// Among other things, this ensures that Eden top is correct.
Universe::heap()->prepare_for_verify();
Universe::verify(info);

View file

@ -324,6 +324,7 @@ void initialize_basic_type_klass(Klass* k, TRAPS) {
void Universe::genesis(TRAPS) {
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
{ AutoModifyRestore<bool> temporarily(_bootstrapping, true);
@ -1141,8 +1142,9 @@ void Universe::verify(VerifyOption option, const char* prefix) {
"(of thread stacks below)");
)
ResourceMark rm;
HandleMark hm; // Handles created during verification can be zapped
Thread* thread = Thread::current();
ResourceMark rm(thread);
HandleMark hm(thread); // Handles created during verification can be zapped
_verify_count++;
FormatBuffer<> title("Verifying %s", prefix);

View file

@ -1198,7 +1198,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta
assert(interf->is_interface(), "must be");
Array<Method*>* methods = interf->methods();
int nof_methods = methods->length();
HandleMark hm;
HandleMark hm(THREAD);
Handle interface_loader (THREAD, interf->class_loader());
int ime_count = method_count_for_interface(interf);
@ -1590,7 +1590,6 @@ int VtableStats::array_entries = 0;
void klassVtable::print_statistics() {
ResourceMark rm;
HandleMark hm;
VtableStats::compute();
tty->print_cr("vtable statistics:");
tty->print_cr("%6d classes (%d instance, %d array)", VtableStats::no_klasses, VtableStats::no_instance_klasses, VtableStats::no_array_klasses);

View file

@ -3778,7 +3778,7 @@ static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) {
JVMCICompiler* compiler = JVMCICompiler::instance(true, CATCH);
compiler->bootstrap(THREAD);
if (HAS_PENDING_EXCEPTION) {
HandleMark hm;
HandleMark hm(THREAD);
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
}
}
@ -3812,7 +3812,7 @@ static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) {
// otherwise no pending exception possible - VM will already have aborted
JavaThread* THREAD = JavaThread::current();
if (HAS_PENDING_EXCEPTION) {
HandleMark hm;
HandleMark hm(THREAD);
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
}
}

View file

@ -660,7 +660,7 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
// lock the loader
Thread* thread = Thread::current();
HandleMark hm;
HandleMark hm(thread);
Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock());
ObjectLocker ol(loader_lock, thread);
@ -697,7 +697,8 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
// The phase is checked by the wrapper that called this function,
// but this thread could be racing with the thread that is
// terminating the VM so we check one more time.
HandleMark hm;
Thread* THREAD = Thread::current();
HandleMark hm(THREAD);
// create the zip entry (which will open the zip file and hence
// check that the segment is indeed a zip file).
@ -708,9 +709,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
delete zip_entry; // no longer needed
// lock the loader
Thread* THREAD = Thread::current();
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
ObjectLocker ol(loader, THREAD);
// need the path as java.lang.String
@ -915,11 +914,12 @@ jvmtiError
JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) {
int nthreads = 0;
Handle *thread_objs = NULL;
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
// enumerate threads (including agent threads)
ThreadsListEnumerator tle(Thread::current(), true);
ThreadsListEnumerator tle(current_thread, true);
nthreads = tle.num_threads();
*threads_count_ptr = nthreads;
@ -1125,10 +1125,10 @@ JvmtiEnv::InterruptThread(jthread thread) {
// info_ptr - pre-checked for NULL
jvmtiError
JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
ResourceMark rm;
HandleMark hm;
JavaThread* current_thread = JavaThread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
ThreadsListHandle tlh(current_thread);
// if thread is NULL the current thread is used
@ -1400,10 +1400,9 @@ JvmtiEnv::GetTopThreadGroups(jint* group_count_ptr, jthreadGroup** groups_ptr) {
// info_ptr - pre-checked for NULL
jvmtiError
JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr) {
ResourceMark rm;
HandleMark hm;
JavaThread* current_thread = JavaThread::current();
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
Handle group_obj (current_thread, JNIHandles::resolve_external_guard(group));
NULL_CHECK(group_obj(), JVMTI_ERROR_INVALID_THREAD_GROUP);
@ -3177,7 +3176,6 @@ jvmtiError
JvmtiEnv::GetBytecodes(Method* method, jint* bytecode_count_ptr, unsigned char** bytecodes_ptr) {
NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID);
HandleMark hm;
methodHandle mh(Thread::current(), method);
jint size = (jint)mh->code_size();
jvmtiError err = allocate(size, bytecodes_ptr);

View file

@ -622,8 +622,9 @@ JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) {
return ret; // no Java frames so no monitors
}
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(java_thread);
for(javaVFrame *jvf=java_thread->last_java_vframe(&reg_map); jvf != NULL;
@ -675,7 +676,7 @@ JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThre
if (obj == NULL) {
*monitor_ptr = NULL;
} else {
HandleMark hm;
HandleMark hm(current_jt);
Handle hobj(current_jt, obj);
*monitor_ptr = jni_reference(calling_thread, hobj);
}
@ -693,8 +694,8 @@ JvmtiEnvBase::get_owned_monitors(JavaThread *calling_thread, JavaThread* java_th
"call by myself or at direct handshake");
if (java_thread->has_last_Java_frame()) {
ResourceMark rm;
HandleMark hm;
ResourceMark rm(current_jt);
HandleMark hm(current_jt);
RegisterMap reg_map(java_thread);
int depth = 0;
@ -723,8 +724,9 @@ jvmtiError
JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread* java_thread,
javaVFrame *jvf, GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list, jint stack_depth) {
jvmtiError err = JVMTI_ERROR_NONE;
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
GrowableArray<MonitorInfo*>* mons = jvf->monitors();
if (mons->is_empty()) {

View file

@ -105,7 +105,7 @@ private:
JavaThread *_jthread;
public:
JvmtiThreadEventTransition(Thread *thread) : _rm(), _hm() {
JvmtiThreadEventTransition(Thread *thread) : _rm(), _hm(thread) {
if (thread->is_Java_thread()) {
_jthread = (JavaThread *)thread;
_saved_state = _jthread->thread_state();

View file

@ -695,7 +695,8 @@ void VM_GetOrSetLocal::doit() {
return;
}
StackValueCollection *locals = _jvf->locals();
HandleMark hm;
Thread* current_thread = Thread::current();
HandleMark hm(current_thread);
switch (_type) {
case T_INT: locals->set_int_at (_index, _value.i); break;
@ -703,7 +704,7 @@ void VM_GetOrSetLocal::doit() {
case T_FLOAT: locals->set_float_at (_index, _value.f); break;
case T_DOUBLE: locals->set_double_at(_index, _value.d); break;
case T_OBJECT: {
Handle ob_h(Thread::current(), JNIHandles::resolve_external_guard(_value.l));
Handle ob_h(current_thread, JNIHandles::resolve_external_guard(_value.l));
locals->set_obj_at (_index, ob_h);
break;
}

View file

@ -841,7 +841,6 @@ void ClassFieldMap::add(int index, char type, int offset) {
// of the given class.
//
ClassFieldMap* ClassFieldMap::create_map_of_static_fields(Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k);
// create the field map
@ -866,7 +865,6 @@ ClassFieldMap* ClassFieldMap::create_map_of_static_fields(Klass* k) {
// and private fields declared in superclasses and superinterfaces too).
//
ClassFieldMap* ClassFieldMap::create_map_of_instance_fields(oop obj) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(obj->klass());
// create the field map

View file

@ -2031,11 +2031,11 @@ WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_han
}
public:
TraceSelfClosure() : HandshakeClosure("WB_TraceSelf"), _num_threads_completed(0) {}
TraceSelfClosure(Thread* thread) : HandshakeClosure("WB_TraceSelf"), _num_threads_completed(0) {}
jint num_threads_completed() const { return _num_threads_completed; }
};
TraceSelfClosure tsc;
TraceSelfClosure tsc(Thread::current());
if (all_threads) {
Handshake::execute(&tsc);

View file

@ -216,7 +216,8 @@ static bool eliminate_allocations(JavaThread* thread, int exec_mode, CompiledMet
}
static void eliminate_locks(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) {
HandleMark hm;
assert(thread == Thread::current(), "should be");
HandleMark hm(thread);
#ifndef PRODUCT
bool first = true;
#endif
@ -636,7 +637,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
// but makes the entry a little slower. There is however a little dance we have to
// do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro
ResetNoHandleMark rnhm; // No-op in release/product versions
HandleMark hm;
HandleMark hm(thread);
frame stub_frame = thread->last_frame();
@ -1534,8 +1535,9 @@ void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, Reg
if (!UseBiasedLocking) {
return;
}
ResourceMark rm;
HandleMark hm;
assert(thread == Thread::current(), "should be");
ResourceMark rm(thread);
HandleMark hm(thread);
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
get_monitors_from_stack(objects_to_revoke, thread, fr, map);
@ -1767,7 +1769,7 @@ static void post_deoptimization_event(CompiledMethod* nm,
#endif // INCLUDE_JFR
JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) {
HandleMark hm;
HandleMark hm(thread);
// uncommon_trap() is called at the beginning of the uncommon trap
// handler. Note this fact before we start generating temporary frames

View file

@ -116,7 +116,7 @@ void HandleArea::oops_do(OopClosure* f) {
}
void HandleMark::initialize(Thread* thread) {
_thread = thread;
_thread = thread; // Not the current thread during thread creation.
// Save area
_area = thread->handle_area();
// Save current top

View file

@ -228,7 +228,7 @@ class HandleArea: public Arena {
//
// Handle h;
// {
// HandleMark hm;
// HandleMark hm(THREAD);
// h = Handle(THREAD, obj);
// }
// h()->print(); // WRONG, h destroyed by HandleMark destructor.
@ -257,7 +257,6 @@ class HandleMark {
// remove all chunks beginning with the next
void chop_later_chunks();
public:
HandleMark(); // see handles_inline.hpp
HandleMark(Thread* thread) { initialize(thread); }
~HandleMark();

View file

@ -67,10 +67,6 @@ inline name##Handle::name##Handle(Thread* thread, type* obj) : _value(obj), _thr
DEF_METADATA_HANDLE_FN(method, Method)
DEF_METADATA_HANDLE_FN(constantPool, ConstantPool)
inline HandleMark::HandleMark() {
initialize(Thread::current());
}
inline void HandleMark::push() {
// This is intentionally a NOP. pop_and_restore will reset
// values to the HandleMark further down the stack, typically

View file

@ -105,7 +105,6 @@ void vm_init_globals() {
jint init_globals() {
HandleMark hm;
management_init();
bytecodes_init();
classLoader_init1();

View file

@ -111,7 +111,6 @@ void print_method_profiling_data() {
if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData) &&
(PrintMethodData || CompilerOracle::should_print_methods())) {
ResourceMark rm;
HandleMark hm;
collected_profiled_methods = new GrowableArray<Method*>(1024);
SystemDictionary::methods_do(collect_profiled_methods);
collected_profiled_methods->sort(&compare_methods);
@ -158,7 +157,6 @@ void collect_invoked_methods(Method* m) {
void print_method_invocation_histogram() {
ResourceMark rm;
HandleMark hm;
collected_invoked_methods = new GrowableArray<Method*>(1024);
SystemDictionary::methods_do(collect_invoked_methods);
collected_invoked_methods->sort(&compare_methods);

View file

@ -3266,8 +3266,10 @@ oop JavaThread::current_park_blocker() {
void JavaThread::print_stack_on(outputStream* st) {
if (!has_last_Java_frame()) return;
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(this);
vframe* start_vf = last_java_vframe(&reg_map);
@ -3396,8 +3398,9 @@ void JavaThread::trace_stack_from(vframe* start_vf) {
void JavaThread::trace_stack() {
if (!has_last_Java_frame()) return;
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(this);
trace_stack_from(last_java_vframe(&reg_map));
}
@ -3920,8 +3923,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// Should be done after the heap is fully created
main_thread->cache_global_variables();
HandleMark hm;
{ MutexLocker mu(Threads_lock);
Threads::add(main_thread);
}
@ -3968,6 +3969,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
Arguments::update_vm_info_property(VM_Version::vm_info_string());
Thread* THREAD = Thread::current();
HandleMark hm(THREAD);
// Always call even when there are not JVMTI environments yet, since environments
// may be attached late and JVMTI must track phases of VM execution

View file

@ -518,7 +518,6 @@ void vframeStreamCommon::security_next() {
void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
ResourceMark rm;
HandleMark hm;
int method_prefix_count = 0;
char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count);
@ -627,8 +626,9 @@ static void print_stack_values(const char* title, StackValueCollection* values)
void javaVFrame::print() {
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
vframe::print();
tty->print("\t");

View file

@ -71,8 +71,10 @@ void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
int index;
{
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
// Get the monitors off-stack
GrowableArray<MonitorInfo*>* list = vf->monitors();

View file

@ -63,7 +63,7 @@ static InstanceKlass* load_and_initialize_klass(Symbol* sh, TRAPS) {
static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) {
Thread* THREAD = Thread::current();
HandleMark hm;
HandleMark hm(THREAD);
// load VMSupport
Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport();

View file

@ -830,7 +830,6 @@ void DumperSupport::dump_field_value(DumpWriter* writer, char type, oop obj, int
// returns the size of the instance of the given class
u4 DumperSupport::instance_size(Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k);
u4 size = 0;
@ -843,7 +842,6 @@ u4 DumperSupport::instance_size(Klass* k) {
}
u4 DumperSupport::get_static_fields_size(InstanceKlass* ik, u2& field_count) {
HandleMark hm;
field_count = 0;
u4 size = 0;
@ -886,7 +884,6 @@ u4 DumperSupport::get_static_fields_size(InstanceKlass* ik, u2& field_count) {
// dumps static fields of the given class
void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k);
// dump the field descriptors and raw values
@ -930,7 +927,6 @@ void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
// dump the raw values of the instance fields of the given object
void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(o->klass());
for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) {
@ -943,7 +939,6 @@ void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
// dumps the definition of the instance fields for a given class
u2 DumperSupport::get_instance_fields_count(InstanceKlass* ik) {
HandleMark hm;
u2 field_count = 0;
for (FieldStream fldc(ik, true, true); !fldc.eos(); fldc.next()) {
@ -955,7 +950,6 @@ u2 DumperSupport::get_instance_fields_count(InstanceKlass* ik) {
// dumps the definition of the instance fields for a given class
void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k);
// dump the field descriptors
@ -1777,7 +1771,6 @@ void VM_HeapDumper::do_threads() {
void VM_HeapDumper::doit() {
HandleMark hm;
CollectedHeap* ch = Universe::heap();
ch->ensure_parsability(false); // must happen, even if collection does

View file

@ -566,8 +566,9 @@ StackFrameInfo::StackFrameInfo(javaVFrame* jvf, bool with_lock_info) {
_class_holder = OopHandle(Universe::vm_global(), _method->method_holder()->klass_holder());
_locked_monitors = NULL;
if (with_lock_info) {
ResourceMark rm;
HandleMark hm;
Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
GrowableArray<MonitorInfo*>* list = jvf->locked_monitors();
int length = list->length();
if (length > 0) {

View file

@ -355,8 +355,6 @@ void report_java_out_of_memory(const char* message) {
class Command : public StackObj {
private:
ResourceMark rm;
ResetNoHandleMark rnhm;
HandleMark hm;
bool debug_save;
public:
static int level;