1 Star 0 Fork 74

sigui / openjdk-1.8.0

forked from src-openEuler / openjdk-1.8.0 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
8165860-WorkGroup-classes-are-missing-volatile-speci.patch 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
jdkboy 提交于 2020-03-21 11:30 . delete redundant info
From 92585164635278b4b127f426bf50014d0a03b572 Mon Sep 17 00:00:00 2001
Date: Thu, 14 Nov 2019 15:23:46 +0000
Subject: [PATCH] 8165860: WorkGroup classes are missing volatile specifiers
for lock-free code
Summary: <gc>: WorkGroup classes are missing volatile specifiers for lock-free code
LLT: NA
Bug url: https://bugs.openjdk.java.net/browse/JDK-8165860
---
hotspot/src/share/vm/utilities/workgroup.cpp | 12 +++++-------
hotspot/src/share/vm/utilities/workgroup.hpp | 8 ++++----
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/hotspot/src/share/vm/utilities/workgroup.cpp b/hotspot/src/share/vm/utilities/workgroup.cpp
index 3d1f1eef7a..7123574186 100644
--- a/hotspot/src/share/vm/utilities/workgroup.cpp
+++ b/hotspot/src/share/vm/utilities/workgroup.cpp
@@ -503,23 +503,21 @@ bool SequentialSubTasksDone::valid() {
}
bool SequentialSubTasksDone::is_task_claimed(uint& t) {
- uint* n_claimed_ptr = &_n_claimed;
- t = *n_claimed_ptr;
+ t = _n_claimed;
while (t < _n_tasks) {
- jint res = Atomic::cmpxchg(t+1, n_claimed_ptr, t);
+ jint res = Atomic::cmpxchg(t+1, &_n_claimed, t);
if (res == (jint)t) {
return false;
}
- t = *n_claimed_ptr;
+ t = res;
}
return true;
}
bool SequentialSubTasksDone::all_tasks_completed() {
- uint* n_completed_ptr = &_n_completed;
- uint complete = *n_completed_ptr;
+ uint complete = _n_completed;
while (true) {
- uint res = Atomic::cmpxchg(complete+1, n_completed_ptr, complete);
+ uint res = Atomic::cmpxchg(complete+1, &_n_completed, complete);
if (res == complete) {
break;
}
diff --git a/hotspot/src/share/vm/utilities/workgroup.hpp b/hotspot/src/share/vm/utilities/workgroup.hpp
index 30337f1ef5..ef2dff4932 100644
--- a/hotspot/src/share/vm/utilities/workgroup.hpp
+++ b/hotspot/src/share/vm/utilities/workgroup.hpp
@@ -400,7 +400,7 @@ public:
// enumeration type.
class SubTasksDone: public CHeapObj<mtInternal> {
- uint* _tasks;
+ volatile uint* _tasks;
uint _n_tasks;
// _n_threads is used to determine when a sub task is done.
// It does not control how many threads will execute the subtask
@@ -408,7 +408,7 @@ class SubTasksDone: public CHeapObj<mtInternal> {
// in order to correctly decide when the subtask is done (all the
// threads working on the task have finished).
uint _n_threads;
- uint _threads_completed;
+ volatile uint _threads_completed;
#ifdef ASSERT
volatile uint _claimed;
#endif
@@ -454,11 +454,11 @@ public:
class SequentialSubTasksDone : public StackObj {
protected:
uint _n_tasks; // Total number of tasks available.
- uint _n_claimed; // Number of tasks claimed.
+ volatile uint _n_claimed; // Number of tasks claimed.
// _n_threads is used to determine when a sub task is done.
// See comments on SubTasksDone::_n_threads
uint _n_threads; // Total number of parallel threads.
- uint _n_completed; // Number of completed threads.
+ volatile uint _n_completed; // Number of completed threads.
void clear();
--
2.12.3
1
https://gitee.com/si-gui/openjdk-1.8.0.git
git@gitee.com:si-gui/openjdk-1.8.0.git
si-gui
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助