From db54008b5f4bbf19f1a3a5dd93e33ec03ef28f56 Mon Sep 17 00:00:00 2001 From: jiefu Date: Wed, 7 Aug 2019 17:00:19 +0800 Subject: [PATCH] 8229169: False failure of GenericTaskQueue::pop_local on architectures with weak memory model Reviewed-by: mdoerr, kbarrett, tschatzl --- src/share/vm/utilities/taskqueue.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/share/vm/utilities/taskqueue.hpp b/src/share/vm/utilities/taskqueue.hpp index d2b39c943..0a2af4cdb 100644 --- a/src/share/vm/utilities/taskqueue.hpp +++ b/src/share/vm/utilities/taskqueue.hpp @@ -714,6 +714,11 @@ GenericTaskQueue::pop_local(volatile E& t) { } else { // Otherwise, the queue contained exactly one element; we take the slow // path. + + // The barrier is required to prevent reordering the two reads of _age: + // one is the _age.get() below, and the other is _age.top() above the if-stmt. + // The algorithm may fail if _age.get() reads an older value than _age.top(). + OrderAccess::loadload(); return pop_local_slow(localBot, _age.get()); } } -- GitLab