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) { int ciReplay::replay_impl(TRAPS) {
HandleMark hm; HandleMark hm(THREAD);
ResourceMark rm; ResourceMark rm(THREAD);
if (ReplaySuppressInitializers > 2) { if (ReplaySuppressInitializers > 2) {
// ReplaySuppressInitializers > 2 means that we want to allow // ReplaySuppressInitializers > 2 means that we want to allow

View file

@ -306,14 +306,14 @@ LockedClassesDo::~LockedClassesDo() {
// unloading can remove entries concurrently soon. // unloading can remove entries concurrently soon.
class ClassLoaderDataGraphIterator : public StackObj { class ClassLoaderDataGraphIterator : public StackObj {
ClassLoaderData* _next; ClassLoaderData* _next;
Thread* _thread;
HandleMark _hm; // clean up handles when this is done. HandleMark _hm; // clean up handles when this is done.
Handle _holder; Handle _holder;
Thread* _thread;
NoSafepointVerifier _nsv; // No safepoints allowed in this scope NoSafepointVerifier _nsv; // No safepoints allowed in this scope
// unless verifying at a safepoint. // unless verifying at a safepoint.
public: public:
ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head) { ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head), _thread(Thread::current()), _hm(_thread) {
_thread = Thread::current(); _thread = Thread::current();
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); 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(loader_data != NULL, "invariant");
assert(THREAD->is_Java_thread(), "must be a JavaThread"); assert(THREAD->is_Java_thread(), "must be a JavaThread");
ResourceMark rm; ResourceMark rm(THREAD);
HandleMark hm; HandleMark hm(THREAD);
JvmtiCachedClassFileData* cached_class_file = NULL; 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); RunTimeSharedClassInfo* info = RunTimeSharedClassInfo::get_for(klass);
assert(info != NULL, "Sanity"); assert(info != NULL, "Sanity");
if (info->_num_loader_constraints > 0) { if (info->_num_loader_constraints > 0) {
HandleMark hm; HandleMark hm(THREAD);
for (int i = 0; i < info->_num_loader_constraints; i++) { for (int i = 0; i < info->_num_loader_constraints; i++) {
RunTimeSharedClassInfo::RTLoaderConstraint* lc = info->loader_constraint_at(i); RunTimeSharedClassInfo::RTLoaderConstraint* lc = info->loader_constraint_at(i);
Symbol* name = lc->constraint_name(); Symbol* name = lc->constraint_name();

View file

@ -873,7 +873,6 @@ void nmethod::log_identity(xmlStream* log) const {
void nmethod::log_new_nmethod() const { void nmethod::log_new_nmethod() const {
if (LogCompilation && xtty != NULL) { if (LogCompilation && xtty != NULL) {
ttyLocker ttyl; ttyLocker ttyl;
HandleMark hm;
xtty->begin_elem("nmethod"); xtty->begin_elem("nmethod");
log_identity(xtty); log_identity(xtty);
xtty->print(" entry='" INTPTR_FORMAT "' size='%d'", p2i(code_begin()), size()); 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. // Print the header part, then print the requested information.
// This is both handled in decode2(). // This is both handled in decode2().
if (printmethod) { if (printmethod) {
HandleMark hm;
ResourceMark m; ResourceMark m;
if (is_compiled_by_c1()) { if (is_compiled_by_c1()) {
tty->cr(); tty->cr();
@ -2405,6 +2403,7 @@ void nmethod::verify() {
void nmethod::verify_interrupt_point(address call_site) { void nmethod::verify_interrupt_point(address call_site) {
// Verify IC only when nmethod installation is finished. // Verify IC only when nmethod installation is finished.
if (!is_not_installed()) { if (!is_not_installed()) {
if (CompiledICLocker::is_safe(this)) { 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()); PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address());
assert(pd != NULL, "PcDesc must exist"); assert(pd != NULL, "PcDesc must exist");
for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(), for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
@ -2554,7 +2555,6 @@ void nmethod::print(outputStream* st) const {
} }
void nmethod::print_code() { void nmethod::print_code() {
HandleMark hm;
ResourceMark m; ResourceMark m;
ttyLocker ttyl; ttyLocker ttyl;
// Call the specialized decode method of this class. // Call the specialized decode method of this class.
@ -2584,7 +2584,6 @@ void nmethod::print_dependencies() {
// Print the oops from the underlying CodeBlob. // Print the oops from the underlying CodeBlob.
void nmethod::print_oops(outputStream* st) { void nmethod::print_oops(outputStream* st) {
HandleMark hm;
ResourceMark m; ResourceMark m;
st->print("Oops:"); st->print("Oops:");
if (oops_begin() < oops_end()) { if (oops_begin() < oops_end()) {
@ -2610,7 +2609,6 @@ void nmethod::print_oops(outputStream* st) {
// Print metadata pool. // Print metadata pool.
void nmethod::print_metadata(outputStream* st) { void nmethod::print_metadata(outputStream* st) {
HandleMark hm;
ResourceMark m; ResourceMark m;
st->print("Metadata:"); st->print("Metadata:");
if (metadata_begin() < metadata_end()) { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 #endif
void ScopeDesc::verify() { void ScopeDesc::verify() {
ResourceMark rm; Thread* current_thread = Thread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
guarantee(method()->is_method(), "type check"); guarantee(method()->is_method(), "type check");
// check if we have any illegal elements on the expression stack // 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index) {
ResourceMark rm; ResourceMark rm;
HandleMark hm;
Klass* klass = receiver->klass(); Klass* klass = receiver->klass();
InstanceKlass* ik = InstanceKlass::cast(klass); InstanceKlass* ik = InstanceKlass::cast(klass);
klassVtable vt = ik->vtable(); klassVtable vt = ik->vtable();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -229,20 +229,21 @@ CollectedHeap::CollectedHeap() :
// heap lock is already held and that we are executing in // heap lock is already held and that we are executing in
// the context of the vm thread. // the context of the vm thread.
void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { 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"); assert(Heap_lock->is_locked(), "Precondition#2");
GCCauseSetter gcs(this, cause); GCCauseSetter gcs(this, cause);
switch (cause) { switch (cause) {
case GCCause::_heap_inspection: case GCCause::_heap_inspection:
case GCCause::_heap_dump: case GCCause::_heap_dump:
case GCCause::_metadata_GC_threshold : { case GCCause::_metadata_GC_threshold : {
HandleMark hm; HandleMark hm(thread);
do_full_collection(false); // don't clear all soft refs do_full_collection(false); // don't clear all soft refs
break; break;
} }
case GCCause::_archive_time_gc: case GCCause::_archive_time_gc:
case GCCause::_metadata_GC_clear_soft_refs: { case GCCause::_metadata_GC_clear_soft_refs: {
HandleMark hm; HandleMark hm(thread);
do_full_collection(true); // do clear all soft refs do_full_collection(true); // do clear all soft refs
break; 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) void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap)
{ {
DEBUG_ONLY(fill_args_check(start, words);) 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); fill_with_object_impl(start, words, zap);
} }
void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap) void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap)
{ {
DEBUG_ONLY(fill_args_check(start, words);) 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 // 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 // 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() { void VM_GC_HeapInspection::doit() {
HandleMark hm;
Universe::heap()->ensure_parsability(false); // must happen, even if collection does Universe::heap()->ensure_parsability(false); // must happen, even if collection does
// not happen (e.g. due to GCLocker) // not happen (e.g. due to GCLocker)
// or _full_gc being false // 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. // 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) { 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. // First allocation attempt is lock-free.
Generation *young = _young_gen; 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); 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) { if (run_verification && VerifyBeforeGC) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("Before GC"); Universe::verify("Before GC");
} }
COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::clear()); 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 // weak refs more uniform (and indeed remove such concerns
// from GCH). XXX // from GCH). XXX
HandleMark hm; // Discard invalid handles created during gc
save_marks(); // save marks for all gens save_marks(); // save marks for all gens
// We want to discover references, but not process them yet. // We want to discover references, but not process them yet.
// This mode is disabled in process_discovered_references if the // 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); update_gc_stats(gen, full);
if (run_verification && VerifyAfterGC) { if (run_verification && VerifyAfterGC) {
HandleMark hm; // Discard invalid handles created during verification
Universe::verify("After GC"); Universe::verify("After GC");
} }
} }

View file

@ -654,8 +654,9 @@ public:
} }
void work(uint worker_id) { void work(uint worker_id) {
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint"); assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahParallelWorkerSession worker_session(worker_id); 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); address mdp2 = mdo->bci_to_dp(bci);
if (mdp != mdp2) { if (mdp != mdp2) {
ResourceMark rm; 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); 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 current_di = mdo->dp_to_di(mdp);
int expected_di = mdo->dp_to_di(mdp2); 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)) JRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci))
assert(ProfileInterpreter, "must be profiling interpreter"); assert(ProfileInterpreter, "must be profiling interpreter");
ResourceMark rm(thread); ResourceMark rm(thread);
HandleMark hm(thread);
LastFrameAccessor last_frame(thread); LastFrameAccessor last_frame(thread);
assert(last_frame.is_interpreted_frame(), "must come from interpreter"); assert(last_frame.is_interpreted_frame(), "must come from interpreter");
MethodData* h_mdo = last_frame.method()->method_data(); 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) { if (src_address == dest_address) {
return; return;
} }
ResetNoHandleMark rnm; // In a LEAF entry.
HandleMark hm;
ResourceMark rm; ResourceMark rm;
LastFrameAccessor last_frame(thread); LastFrameAccessor last_frame(thread);
assert(last_frame.is_interpreted_frame(), ""); 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) { void OopMapCacheEntry::fill(const methodHandle& method, int bci) {
HandleMark hm;
// Flush entry to deallocate an existing entry // Flush entry to deallocate an existing entry
flush(); flush();
set_method(method()); set_method(method());

View file

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

View file

@ -246,8 +246,9 @@ bool JfrRecorder::is_created() {
} }
bool JfrRecorder::create_components() { bool JfrRecorder::create_components() {
ResourceMark rm; // Move these down into the functions that might create handles!
HandleMark hm; ResourceMark rm(Thread::current());
HandleMark hm(Thread::current());
if (!create_java_event_writer()) { if (!create_java_event_writer()) {
return false; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 // perform data and call relocation on the CodeBuffer
JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bool check_size, JVMCI_TRAPS) { JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bool check_size, JVMCI_TRAPS) {
HandleMark hm; HandleMark hm(Thread::current());
JVMCIObjectArray sites = this->sites(); JVMCIObjectArray sites = this->sites();
int locs_buffer_size = JVMCIENV->get_length(sites) * (relocInfo::length_limit + sizeof(relocInfo)); int locs_buffer_size = JVMCIENV->get_length(sites) * (relocInfo::length_limit + sizeof(relocInfo));

View file

@ -57,8 +57,8 @@ void JVMCICompiler::bootstrap(TRAPS) {
return; return;
} }
_bootstrapping = true; _bootstrapping = true;
ResourceMark rm; ResourceMark rm(THREAD);
HandleMark hm; HandleMark hm(THREAD);
if (PrintBootstrap) { if (PrintBootstrap) {
tty->print("Bootstrapping JVMCI"); 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, C2V_VMENTRY_0(jint, installCode, (JNIEnv *env, jobject, jobject target, jobject compiled_code,
jobject installed_code, jlong failed_speculations_address, jbyteArray speculations_obj)) jobject installed_code, jlong failed_speculations_address, jbyteArray speculations_obj))
HandleMark hm; HandleMark hm(THREAD);
JNIHandleMark jni_hm(thread); JNIHandleMark jni_hm(thread);
JVMCIObject target_handle = JVMCIENV->wrap(target); 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)) C2V_VMENTRY_0(jint, getMetadata, (JNIEnv *env, jobject, jobject target, jobject compiled_code, jobject metadata))
#if INCLUDE_AOT #if INCLUDE_AOT
HandleMark hm; HandleMark hm(THREAD);
assert(JVMCIENV->is_hotspot(), "AOT code is executed only in HotSpot mode"); assert(JVMCIENV->is_hotspot(), "AOT code is executed only in HotSpot mode");
JVMCIObject target_handle = JVMCIENV->wrap(target); JVMCIObject target_handle = JVMCIENV->wrap(target);
@ -968,7 +968,7 @@ C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv* env, jobject))
C2V_END C2V_END
C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject installedCode)) C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject installedCode))
HandleMark hm; HandleMark hm(THREAD);
if (installedCode == NULL) { if (installedCode == NULL) {
JVMCI_THROW_MSG_NULL(NullPointerException, "installedCode is 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_END
C2V_VMENTRY_NULL(jobject, getStackTraceElement, (JNIEnv* env, jobject, jobject jvmci_method, int bci)) 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)); methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
JVMCIObject element = JVMCIENV->new_StackTraceElement(method, bci, JVMCI_CHECK_NULL); 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. // and the return value would have to be wrapped as a JavaConstant.
requireInHotSpot("executeHotSpotNmethod", JVMCI_CHECK_NULL); requireInHotSpot("executeHotSpotNmethod", JVMCI_CHECK_NULL);
HandleMark hm; HandleMark hm(THREAD);
JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod); JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
nmethodLocker locker; nmethodLocker locker;
@ -1157,7 +1157,7 @@ C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size))
C2V_END C2V_END
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci)) C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
HandleMark hm; HandleMark hm(THREAD);
if (jvmci_method == NULL) { if (jvmci_method == NULL) {
JVMCI_THROW_0(NullPointerException); 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. // Ensure the JVMCI shared library runtime is initialized.
JVMCIEnv __peer_jvmci_env__(thread, false, __FILE__, __LINE__); JVMCIEnv __peer_jvmci_env__(thread, false, __FILE__, __LINE__);
JVMCIEnv* peerEnv = &__peer_jvmci_env__; JVMCIEnv* peerEnv = &__peer_jvmci_env__;
HandleMark hm; HandleMark hm(THREAD);
JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(peerEnv); JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(peerEnv);
if (peerEnv->has_pending_exception()) { if (peerEnv->has_pending_exception()) {
peerEnv->describe_pending_exception(true); 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) { void JVMCIEnv::call_HotSpotJVMCIRuntime_shutdown (JVMCIObject runtime) {
HandleMark hm;
JavaThread* THREAD = JavaThread::current(); JavaThread* THREAD = JavaThread::current();
HandleMark hm(THREAD);
if (is_hotspot()) { if (is_hotspot()) {
JavaCallArguments jargs; JavaCallArguments jargs;
jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime)));

View file

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

View file

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

View file

@ -324,6 +324,7 @@ void initialize_basic_type_klass(Klass* k, TRAPS) {
void Universe::genesis(TRAPS) { void Universe::genesis(TRAPS) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
HandleMark hm(THREAD);
{ AutoModifyRestore<bool> temporarily(_bootstrapping, true); { AutoModifyRestore<bool> temporarily(_bootstrapping, true);
@ -1141,8 +1142,9 @@ void Universe::verify(VerifyOption option, const char* prefix) {
"(of thread stacks below)"); "(of thread stacks below)");
) )
ResourceMark rm; Thread* thread = Thread::current();
HandleMark hm; // Handles created during verification can be zapped ResourceMark rm(thread);
HandleMark hm(thread); // Handles created during verification can be zapped
_verify_count++; _verify_count++;
FormatBuffer<> title("Verifying %s", prefix); 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"); assert(interf->is_interface(), "must be");
Array<Method*>* methods = interf->methods(); Array<Method*>* methods = interf->methods();
int nof_methods = methods->length(); int nof_methods = methods->length();
HandleMark hm; HandleMark hm(THREAD);
Handle interface_loader (THREAD, interf->class_loader()); Handle interface_loader (THREAD, interf->class_loader());
int ime_count = method_count_for_interface(interf); int ime_count = method_count_for_interface(interf);
@ -1590,7 +1590,6 @@ int VtableStats::array_entries = 0;
void klassVtable::print_statistics() { void klassVtable::print_statistics() {
ResourceMark rm; ResourceMark rm;
HandleMark hm;
VtableStats::compute(); VtableStats::compute();
tty->print_cr("vtable statistics:"); 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); 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); JVMCICompiler* compiler = JVMCICompiler::instance(true, CATCH);
compiler->bootstrap(THREAD); compiler->bootstrap(THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
HandleMark hm; HandleMark hm(THREAD);
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); 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 // otherwise no pending exception possible - VM will already have aborted
JavaThread* THREAD = JavaThread::current(); JavaThread* THREAD = JavaThread::current();
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
HandleMark hm; HandleMark hm(THREAD);
vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
} }
} }

View file

@ -660,7 +660,7 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
// lock the loader // lock the loader
Thread* thread = Thread::current(); Thread* thread = Thread::current();
HandleMark hm; HandleMark hm(thread);
Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock()); Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock());
ObjectLocker ol(loader_lock, thread); 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, // The phase is checked by the wrapper that called this function,
// but this thread could be racing with the thread that is // but this thread could be racing with the thread that is
// terminating the VM so we check one more time. // 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 // create the zip entry (which will open the zip file and hence
// check that the segment is indeed a zip file). // check that the segment is indeed a zip file).
@ -708,9 +709,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
delete zip_entry; // no longer needed delete zip_entry; // no longer needed
// lock the loader // lock the loader
Thread* THREAD = Thread::current();
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader()); Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
ObjectLocker ol(loader, THREAD); ObjectLocker ol(loader, THREAD);
// need the path as java.lang.String // need the path as java.lang.String
@ -915,11 +914,12 @@ jvmtiError
JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) { JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) {
int nthreads = 0; int nthreads = 0;
Handle *thread_objs = NULL; Handle *thread_objs = NULL;
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
// enumerate threads (including agent threads) // enumerate threads (including agent threads)
ThreadsListEnumerator tle(Thread::current(), true); ThreadsListEnumerator tle(current_thread, true);
nthreads = tle.num_threads(); nthreads = tle.num_threads();
*threads_count_ptr = nthreads; *threads_count_ptr = nthreads;
@ -1125,10 +1125,10 @@ JvmtiEnv::InterruptThread(jthread thread) {
// info_ptr - pre-checked for NULL // info_ptr - pre-checked for NULL
jvmtiError jvmtiError
JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) {
ResourceMark rm;
HandleMark hm;
JavaThread* current_thread = JavaThread::current(); JavaThread* current_thread = JavaThread::current();
ResourceMark rm(current_thread);
HandleMark hm(current_thread);
ThreadsListHandle tlh(current_thread); ThreadsListHandle tlh(current_thread);
// if thread is NULL the current thread is used // 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 // info_ptr - pre-checked for NULL
jvmtiError jvmtiError
JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr) { JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr) {
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
JavaThread* current_thread = JavaThread::current();
Handle group_obj (current_thread, JNIHandles::resolve_external_guard(group)); Handle group_obj (current_thread, JNIHandles::resolve_external_guard(group));
NULL_CHECK(group_obj(), JVMTI_ERROR_INVALID_THREAD_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) { JvmtiEnv::GetBytecodes(Method* method, jint* bytecode_count_ptr, unsigned char** bytecodes_ptr) {
NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID);
HandleMark hm;
methodHandle mh(Thread::current(), method); methodHandle mh(Thread::current(), method);
jint size = (jint)mh->code_size(); jint size = (jint)mh->code_size();
jvmtiError err = allocate(size, bytecodes_ptr); 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 return ret; // no Java frames so no monitors
} }
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(java_thread); RegisterMap reg_map(java_thread);
for(javaVFrame *jvf=java_thread->last_java_vframe(&reg_map); jvf != NULL; 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) { if (obj == NULL) {
*monitor_ptr = NULL; *monitor_ptr = NULL;
} else { } else {
HandleMark hm; HandleMark hm(current_jt);
Handle hobj(current_jt, obj); Handle hobj(current_jt, obj);
*monitor_ptr = jni_reference(calling_thread, hobj); *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"); "call by myself or at direct handshake");
if (java_thread->has_last_Java_frame()) { if (java_thread->has_last_Java_frame()) {
ResourceMark rm; ResourceMark rm(current_jt);
HandleMark hm; HandleMark hm(current_jt);
RegisterMap reg_map(java_thread); RegisterMap reg_map(java_thread);
int depth = 0; int depth = 0;
@ -723,8 +724,9 @@ jvmtiError
JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread* java_thread, JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread* java_thread,
javaVFrame *jvf, GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list, jint stack_depth) { javaVFrame *jvf, GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list, jint stack_depth) {
jvmtiError err = JVMTI_ERROR_NONE; jvmtiError err = JVMTI_ERROR_NONE;
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
GrowableArray<MonitorInfo*>* mons = jvf->monitors(); GrowableArray<MonitorInfo*>* mons = jvf->monitors();
if (mons->is_empty()) { if (mons->is_empty()) {

View file

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

View file

@ -695,7 +695,8 @@ void VM_GetOrSetLocal::doit() {
return; return;
} }
StackValueCollection *locals = _jvf->locals(); StackValueCollection *locals = _jvf->locals();
HandleMark hm; Thread* current_thread = Thread::current();
HandleMark hm(current_thread);
switch (_type) { switch (_type) {
case T_INT: locals->set_int_at (_index, _value.i); break; 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_FLOAT: locals->set_float_at (_index, _value.f); break;
case T_DOUBLE: locals->set_double_at(_index, _value.d); break; case T_DOUBLE: locals->set_double_at(_index, _value.d); break;
case T_OBJECT: { 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); locals->set_obj_at (_index, ob_h);
break; break;
} }

View file

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

View file

@ -2031,11 +2031,11 @@ WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_han
} }
public: 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; } jint num_threads_completed() const { return _num_threads_completed; }
}; };
TraceSelfClosure tsc; TraceSelfClosure tsc(Thread::current());
if (all_threads) { if (all_threads) {
Handshake::execute(&tsc); 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) { 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 #ifndef PRODUCT
bool first = true; bool first = true;
#endif #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 // 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 // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro
ResetNoHandleMark rnhm; // No-op in release/product versions ResetNoHandleMark rnhm; // No-op in release/product versions
HandleMark hm; HandleMark hm(thread);
frame stub_frame = thread->last_frame(); frame stub_frame = thread->last_frame();
@ -1534,8 +1535,9 @@ void Deoptimization::revoke_from_deopt_handler(JavaThread* thread, frame fr, Reg
if (!UseBiasedLocking) { if (!UseBiasedLocking) {
return; return;
} }
ResourceMark rm; assert(thread == Thread::current(), "should be");
HandleMark hm; ResourceMark rm(thread);
HandleMark hm(thread);
GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>();
get_monitors_from_stack(objects_to_revoke, thread, fr, map); get_monitors_from_stack(objects_to_revoke, thread, fr, map);
@ -1767,7 +1769,7 @@ static void post_deoptimization_event(CompiledMethod* nm,
#endif // INCLUDE_JFR #endif // INCLUDE_JFR
JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint trap_request)) { 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 // uncommon_trap() is called at the beginning of the uncommon trap
// handler. Note this fact before we start generating temporary frames // 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) { void HandleMark::initialize(Thread* thread) {
_thread = thread; _thread = thread; // Not the current thread during thread creation.
// Save area // Save area
_area = thread->handle_area(); _area = thread->handle_area();
// Save current top // Save current top

View file

@ -228,7 +228,7 @@ class HandleArea: public Arena {
// //
// Handle h; // Handle h;
// { // {
// HandleMark hm; // HandleMark hm(THREAD);
// h = Handle(THREAD, obj); // h = Handle(THREAD, obj);
// } // }
// h()->print(); // WRONG, h destroyed by HandleMark destructor. // h()->print(); // WRONG, h destroyed by HandleMark destructor.
@ -257,7 +257,6 @@ class HandleMark {
// remove all chunks beginning with the next // remove all chunks beginning with the next
void chop_later_chunks(); void chop_later_chunks();
public: public:
HandleMark(); // see handles_inline.hpp
HandleMark(Thread* thread) { initialize(thread); } HandleMark(Thread* thread) { initialize(thread); }
~HandleMark(); ~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(method, Method)
DEF_METADATA_HANDLE_FN(constantPool, ConstantPool) DEF_METADATA_HANDLE_FN(constantPool, ConstantPool)
inline HandleMark::HandleMark() {
initialize(Thread::current());
}
inline void HandleMark::push() { inline void HandleMark::push() {
// This is intentionally a NOP. pop_and_restore will reset // This is intentionally a NOP. pop_and_restore will reset
// values to the HandleMark further down the stack, typically // values to the HandleMark further down the stack, typically

View file

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

View file

@ -111,7 +111,6 @@ void print_method_profiling_data() {
if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData) && if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData) &&
(PrintMethodData || CompilerOracle::should_print_methods())) { (PrintMethodData || CompilerOracle::should_print_methods())) {
ResourceMark rm; ResourceMark rm;
HandleMark hm;
collected_profiled_methods = new GrowableArray<Method*>(1024); collected_profiled_methods = new GrowableArray<Method*>(1024);
SystemDictionary::methods_do(collect_profiled_methods); SystemDictionary::methods_do(collect_profiled_methods);
collected_profiled_methods->sort(&compare_methods); collected_profiled_methods->sort(&compare_methods);
@ -158,7 +157,6 @@ void collect_invoked_methods(Method* m) {
void print_method_invocation_histogram() { void print_method_invocation_histogram() {
ResourceMark rm; ResourceMark rm;
HandleMark hm;
collected_invoked_methods = new GrowableArray<Method*>(1024); collected_invoked_methods = new GrowableArray<Method*>(1024);
SystemDictionary::methods_do(collect_invoked_methods); SystemDictionary::methods_do(collect_invoked_methods);
collected_invoked_methods->sort(&compare_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) { void JavaThread::print_stack_on(outputStream* st) {
if (!has_last_Java_frame()) return; 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); RegisterMap reg_map(this);
vframe* start_vf = last_java_vframe(&reg_map); vframe* start_vf = last_java_vframe(&reg_map);
@ -3396,8 +3398,9 @@ void JavaThread::trace_stack_from(vframe* start_vf) {
void JavaThread::trace_stack() { void JavaThread::trace_stack() {
if (!has_last_Java_frame()) return; if (!has_last_Java_frame()) return;
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
RegisterMap reg_map(this); RegisterMap reg_map(this);
trace_stack_from(last_java_vframe(&reg_map)); 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 // Should be done after the heap is fully created
main_thread->cache_global_variables(); main_thread->cache_global_variables();
HandleMark hm;
{ MutexLocker mu(Threads_lock); { MutexLocker mu(Threads_lock);
Threads::add(main_thread); 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()); Arguments::update_vm_info_property(VM_Version::vm_info_string());
Thread* THREAD = Thread::current(); Thread* THREAD = Thread::current();
HandleMark hm(THREAD);
// Always call even when there are not JVMTI environments yet, since environments // Always call even when there are not JVMTI environments yet, since environments
// may be attached late and JVMTI must track phases of VM execution // 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() { void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
ResourceMark rm; ResourceMark rm;
HandleMark hm;
int method_prefix_count = 0; int method_prefix_count = 0;
char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count); 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() { void javaVFrame::print() {
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
vframe::print(); vframe::print();
tty->print("\t"); tty->print("\t");

View file

@ -71,8 +71,10 @@ void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
int index; int index;
{ {
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
// Get the monitors off-stack // Get the monitors off-stack
GrowableArray<MonitorInfo*>* list = vf->monitors(); 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) { static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) {
Thread* THREAD = Thread::current(); Thread* THREAD = Thread::current();
HandleMark hm; HandleMark hm(THREAD);
// load VMSupport // load VMSupport
Symbol* klass = vmSymbols::jdk_internal_vm_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 // returns the size of the instance of the given class
u4 DumperSupport::instance_size(Klass* k) { u4 DumperSupport::instance_size(Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k); InstanceKlass* ik = InstanceKlass::cast(k);
u4 size = 0; u4 size = 0;
@ -843,7 +842,6 @@ u4 DumperSupport::instance_size(Klass* k) {
} }
u4 DumperSupport::get_static_fields_size(InstanceKlass* ik, u2& field_count) { u4 DumperSupport::get_static_fields_size(InstanceKlass* ik, u2& field_count) {
HandleMark hm;
field_count = 0; field_count = 0;
u4 size = 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 // dumps static fields of the given class
void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) { void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k); InstanceKlass* ik = InstanceKlass::cast(k);
// dump the field descriptors and raw values // 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 // dump the raw values of the instance fields of the given object
void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) { void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(o->klass()); InstanceKlass* ik = InstanceKlass::cast(o->klass());
for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) { 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 // dumps the definition of the instance fields for a given class
u2 DumperSupport::get_instance_fields_count(InstanceKlass* ik) { u2 DumperSupport::get_instance_fields_count(InstanceKlass* ik) {
HandleMark hm;
u2 field_count = 0; u2 field_count = 0;
for (FieldStream fldc(ik, true, true); !fldc.eos(); fldc.next()) { 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 // dumps the definition of the instance fields for a given class
void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) { void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) {
HandleMark hm;
InstanceKlass* ik = InstanceKlass::cast(k); InstanceKlass* ik = InstanceKlass::cast(k);
// dump the field descriptors // dump the field descriptors
@ -1777,7 +1771,6 @@ void VM_HeapDumper::do_threads() {
void VM_HeapDumper::doit() { void VM_HeapDumper::doit() {
HandleMark hm;
CollectedHeap* ch = Universe::heap(); CollectedHeap* ch = Universe::heap();
ch->ensure_parsability(false); // must happen, even if collection does 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()); _class_holder = OopHandle(Universe::vm_global(), _method->method_holder()->klass_holder());
_locked_monitors = NULL; _locked_monitors = NULL;
if (with_lock_info) { if (with_lock_info) {
ResourceMark rm; Thread* current_thread = Thread::current();
HandleMark hm; ResourceMark rm(current_thread);
HandleMark hm(current_thread);
GrowableArray<MonitorInfo*>* list = jvf->locked_monitors(); GrowableArray<MonitorInfo*>* list = jvf->locked_monitors();
int length = list->length(); int length = list->length();
if (length > 0) { if (length > 0) {

View file

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