# HG changeset patch # Parent 9f66d7d5407ac40ab206ab83467f1a3598f4c731 # User tschatzl diff -r 9f66d7d5407a src/share/vm/gc/g1/g1ParScanThreadState.cpp --- a/src/share/vm/gc/g1/g1ParScanThreadState.cpp Tue May 10 15:29:31 2016 +0200 +++ b/src/share/vm/gc/g1/g1ParScanThreadState.cpp Tue May 10 15:33:15 2016 +0200 @@ -137,7 +137,9 @@ do { // Drain the overflow stack first, so other threads can steal. while (_refs->pop_overflow(ref)) { - dispatch_reference(ref); + if (!_refs->try_push(ref)) { + dispatch_reference(ref); + } } while (_refs->pop_local(ref)) { diff -r 9f66d7d5407a src/share/vm/gc/shared/taskqueue.hpp --- a/src/share/vm/gc/shared/taskqueue.hpp Tue May 10 15:29:31 2016 +0200 +++ b/src/share/vm/gc/shared/taskqueue.hpp Tue May 10 15:33:15 2016 +0200 @@ -330,6 +330,8 @@ // Push task t onto the queue or onto the overflow stack. Return true. inline bool push(E t); + // Push task t onto the queue only. Returns true if successful, false otherwise. + inline bool try_push(E t); // Attempt to pop from the overflow stack; return true if anything was popped. inline bool pop_overflow(E& t); diff -r 9f66d7d5407a src/share/vm/gc/shared/taskqueue.inline.hpp --- a/src/share/vm/gc/shared/taskqueue.inline.hpp Tue May 10 15:29:31 2016 +0200 +++ b/src/share/vm/gc/shared/taskqueue.inline.hpp Tue May 10 15:33:15 2016 +0200 @@ -103,6 +103,11 @@ return true; } +template +inline bool OverflowTaskQueue::try_push(E t) { + return taskqueue_t::push(t); +} + // pop_local_slow() is done by the owning thread and is trying to // get the last task in the queue. It will compete with pop_global() // that will be used by other threads. The tag age is incremented