8240774: [REDO] G1DirtyCardQueue destructor has useless flush

Reviewed-by: dholmes, ayang, tschatzl
This commit is contained in:
Kim Barrett 2023-05-31 01:52:05 +00:00
parent 119994f3ce
commit 927a9ed683
5 changed files with 31 additions and 15 deletions

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, 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
@ -144,18 +144,18 @@ void G1BarrierSet::on_thread_destroy(Thread* thread) {
void G1BarrierSet::on_thread_attach(Thread* thread) {
BarrierSet::on_thread_attach(thread);
SATBMarkQueue& queue = G1ThreadLocalData::satb_mark_queue(thread);
assert(!queue.is_active(), "SATB queue should not be active");
assert(queue.buffer() == nullptr, "SATB queue should not have a buffer");
assert(queue.index() == 0, "SATB queue index should be zero");
// Can't assert that the DCQ is empty. There is early execution on
// the main thread, before it gets added to the threads list, which
// is where this is called. That execution may enqueue dirty cards.
SATBMarkQueue& satbq = G1ThreadLocalData::satb_mark_queue(thread);
assert(!satbq.is_active(), "SATB queue should not be active");
assert(satbq.buffer() == nullptr, "SATB queue should not have a buffer");
assert(satbq.index() == 0, "SATB queue index should be zero");
G1DirtyCardQueue& dirtyq = G1ThreadLocalData::dirty_card_queue(thread);
assert(dirtyq.buffer() == nullptr, "Dirty Card queue should not have a buffer");
assert(dirtyq.index() == 0, "Dirty Card queue index should be zero");
// If we are creating the thread during a marking cycle, we should
// set the active field of the SATB queue to true. That involves
// copying the global is_active value to this thread's queue.
queue.set_active(_satb_mark_queue_set.is_active());
satbq.set_active(_satb_mark_queue_set.is_active());
}
void G1BarrierSet::on_thread_detach(Thread* thread) {

@ -58,7 +58,6 @@ G1DirtyCardQueue::G1DirtyCardQueue(G1DirtyCardQueueSet* qset) :
{ }
G1DirtyCardQueue::~G1DirtyCardQueue() {
G1BarrierSet::dirty_card_queue_set().flush_queue(*this);
delete _refinement_stats;
}

@ -143,6 +143,10 @@ jint init_globals() {
InterfaceSupport_init();
VMRegImpl::set_regName(); // need this before generate_stubs (for printing oop maps).
SharedRuntime::generate_stubs();
return JNI_OK;
}
jint init_globals2() {
universe2_init(); // dependent on codeCache_init and initial_stubs_init
javaClasses_init(); // must happen after vtable initialization, before referenceProcessor_init
interpreter_init_code(); // after javaClasses_init and before any method gets linked

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -36,6 +36,7 @@
// to init_foo in init.cpp.
jint init_globals(); // call constructors at startup (main Java thread)
jint init_globals2(); // construction of early Java objects (main Java thread)
void vm_init_globals(); // call constructors at startup (VM thread)
void exit_globals(); // call destructors before exit

@ -553,15 +553,27 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
return status;
}
// Add main_thread to threads list to finish barrier setup with
// on_thread_attach. Should be before starting to build Java objects in
// init_globals2, which invokes barriers.
{
MutexLocker mu(Threads_lock);
Threads::add(main_thread);
}
status = init_globals2();
if (status != JNI_OK) {
Threads::remove(main_thread, false);
main_thread->smr_delete();
*canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
return status;
}
JFR_ONLY(Jfr::on_create_vm_1();)
// Should be done after the heap is fully created
main_thread->cache_global_variables();
{ MutexLocker mu(Threads_lock);
Threads::add(main_thread);
}
// Any JVMTI raw monitors entered in onload will transition into
// real raw monitor. VM is setup enough here for raw monitor enter.
JvmtiExport::transition_pending_onload_raw_monitors();