77 lines
4.0 KiB
Diff
77 lines
4.0 KiB
Diff
From c470ac79015ad99f1760784cbffcf4b92d5bc8dc Mon Sep 17 00:00:00 2001
|
|
From: DXwangg <wangjiawei80@huawei.com>
|
|
Date: Wed, 26 Oct 2022 12:52:55 +0800
|
|
Subject: [PATCH] qqqqq
|
|
|
|
---
|
|
.../share/gc/parallel/parallel_globals.hpp | 6 +++++-
|
|
.../gc/parallel/psPromotionManager.inline.hpp | 18 ++++++++++++++++--
|
|
2 files changed, 21 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/hotspot/share/gc/parallel/parallel_globals.hpp b/src/hotspot/share/gc/parallel/parallel_globals.hpp
|
|
index 5461bf04f..75ee84d4f 100644
|
|
--- a/src/hotspot/share/gc/parallel/parallel_globals.hpp
|
|
+++ b/src/hotspot/share/gc/parallel/parallel_globals.hpp
|
|
@@ -78,6 +78,10 @@
|
|
"Delay in scheduling GC workers (in milliseconds)") \
|
|
\
|
|
product(bool, PSChunkLargeArrays, true, \
|
|
- "Process large arrays in chunks")
|
|
+ "Process large arrays in chunks") \
|
|
+ \
|
|
+ experimental(bool, UsePSRelaxedForwardee, false, \
|
|
+ "Use the UsePSRelaxedForwardee to enable ps use relaxed" \
|
|
+ "during young gc copying object")
|
|
|
|
#endif // SHARE_GC_PARALLEL_PARALLEL_GLOBALS_HPP
|
|
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
index cc5a4aa98..5a71ca307 100644
|
|
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
@@ -35,6 +35,7 @@
|
|
#include "logging/log.hpp"
|
|
#include "oops/access.inline.hpp"
|
|
#include "oops/oop.inline.hpp"
|
|
+#include "runtime/prefetch.inline.hpp"
|
|
|
|
inline PSPromotionManager* PSPromotionManager::manager_array(uint index) {
|
|
assert(_manager_array != NULL, "access of NULL manager_array");
|
|
@@ -214,12 +215,21 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
|
|
|
|
assert(new_obj != NULL, "allocation should have succeeded");
|
|
|
|
+ Prefetch::write(new_obj, PrefetchCopyIntervalInBytes);
|
|
+
|
|
// Copy obj
|
|
Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
|
|
|
|
// Now we have to CAS in the header.
|
|
- // Make copy visible to threads reading the forwardee.
|
|
- if (o->cas_forward_to(new_obj, test_mark, o->klass()->oop_is_gc_leaf()? memory_order_relaxed : memory_order_release)) {
|
|
+ // When use relaxed CAS, cann't gurantee new obj visible for other threads accessing forwardee.
|
|
+ // As oop_is_gc_leaf is verified for long time without problems, for gc leaf's benefit, we add
|
|
+ // UsePSRelaxedForwardee to enable using relaxed CAS rather than delete oop_is_gc_leaf condition directly.
|
|
+#ifdef PRODUCT
|
|
+ if (o->cas_forward_to(new_obj, test_mark, (UsePSRelaxedForwardee || o->klass()->oop_is_gc_leaf()) ?
|
|
+ memory_order_relaxed : memory_order_release)) {
|
|
+#else
|
|
+ if (o->cas_forward_to(new_obj, test_mark, memory_order_release)) {
|
|
+#endif
|
|
// We won any races, we "own" this object.
|
|
assert(new_obj == o->forwardee(), "Sanity");
|
|
|
|
@@ -275,6 +285,10 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
|
|
|
|
// This code must come after the CAS test, or it will print incorrect
|
|
// information.
|
|
+ // When UsePSRelaxedForwardee is true or object o is gc leaf, CAS failed threads can't access forwardee's content,
|
|
+ // as relaxed CAS cann't gurantee new obj's content visible for these CAS failed threads.The below log output is
|
|
+ // dangerous.So we just support UsePSRelaxedForwardee and gc leaf in product.
|
|
+ // Everywhere access forwardee's content must be careful.
|
|
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
|
|
should_scavenge(&new_obj) ? "copying" : "tenuring",
|
|
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
|
|
--
|
|
2.30.1 (Apple Git-130)
|
|
|