# HG changeset patch # User zgu # Date 1551283426 18000 # Wed Feb 27 11:03:46 2019 -0500 # Node ID 22e581efe7eb97fb56d58cf63a7e125f6a39f4cd # Parent 72ce7dd54939da90d02f295579d2c1522fc0ac62 Shenandoah GC may initialize thread's gclab twice diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -482,7 +482,9 @@ class ShenandoahInitGCLABClosure : public ThreadClosure { public: void do_thread(Thread* thread) { - if (thread != NULL && (thread->is_Java_thread() || thread->is_Worker_thread())) { + assert(thread != NULL, "Sanity"); + assert(!thread->is_Java_thread(), "Don't expect JavaThread this early"); + if (thread->is_Worker_thread()) { ShenandoahThreadLocalData::initialize_gclab(thread); } } @@ -494,8 +496,6 @@ ShenandoahInitGCLABClosure init_gclabs; Threads::threads_do(&init_gclabs); - _workers->threads_do(&init_gclabs); - _safepoint_workers->threads_do(&init_gclabs); // gclab can not be initialized early during VM startup, as it can not determinate its max_size. // Now, we will let WorkGang to initialize gclab when new worker is created. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -122,6 +122,7 @@ static void initialize_gclab(Thread* thread) { assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs"); + assert(data(thread)->_gclab == NULL, "Only initialize once"); data(thread)->_gclab = new PLAB(PLAB::min_size()); data(thread)->_gclab_size = 0; }