119 lines
5.1 KiB
Diff
119 lines
5.1 KiB
Diff
From 6f43328c953e50be924d16b41e35255f694d8794 Mon Sep 17 00:00:00 2001
|
|
Date: Mon, 6 Apr 2020 18:13:30 +0000
|
|
Subject: [PATCH] leaf optimize in ParallelScanvageGC
|
|
|
|
Summary: <leaf gc optimization>: <1. add _is_gc_leaf field in klass, if none of klass field is reference,then this klass's oop is leaf, set this at classfile parser.2. ParallelScanvage copy before push_depth if oop is leaf.3. leaf oop don't push_contents.>
|
|
LLT: <jtreg>
|
|
Bug url: <N/A>
|
|
---
|
|
src/hotspot/share/classfile/classFileParser.cpp | 7 ++++++-
|
|
.../share/gc/parallel/psPromotionManager.inline.hpp | 16 ++++++++++++----
|
|
src/hotspot/share/oops/klass.cpp | 2 ++
|
|
src/hotspot/share/oops/klass.hpp | 5 +++++
|
|
4 files changed, 25 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp
|
|
index bf8ac6f3b..99f99309d 100644
|
|
--- a/src/hotspot/share/classfile/classFileParser.cpp
|
|
+++ b/src/hotspot/share/classfile/classFileParser.cpp
|
|
@@ -4363,7 +4363,7 @@ void ClassFileParser::layout_fields(ConstantPool* cp,
|
|
info->has_nonstatic_fields = has_nonstatic_fields;
|
|
}
|
|
|
|
-static void fill_oop_maps(const InstanceKlass* k,
|
|
+static void fill_oop_maps(InstanceKlass* k,
|
|
unsigned int nonstatic_oop_map_count,
|
|
const int* nonstatic_oop_offsets,
|
|
const unsigned int* nonstatic_oop_counts) {
|
|
@@ -4373,6 +4373,11 @@ static void fill_oop_maps(const InstanceKlass* k,
|
|
OopMapBlock* this_oop_map = k->start_of_nonstatic_oop_maps();
|
|
const InstanceKlass* const super = k->superklass();
|
|
const unsigned int super_count = super ? super->nonstatic_oop_map_count() : 0;
|
|
+
|
|
+ const bool super_is_gc_leaf = super ? super->oop_is_gc_leaf() : true;
|
|
+ bool this_is_gc_leaf = super_is_gc_leaf && (nonstatic_oop_map_count == 0);
|
|
+ k->set_oop_is_gc_leaf(this_is_gc_leaf);
|
|
+
|
|
if (super_count > 0) {
|
|
// Copy maps from superklass
|
|
OopMapBlock* super_oop_map = super->start_of_nonstatic_oop_maps();
|
|
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
index 1ef900783..07f736cf2 100644
|
|
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
|
|
@@ -59,7 +59,12 @@ inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) {
|
|
}
|
|
RawAccess<IS_NOT_NULL>::oop_store(p, o);
|
|
} else {
|
|
- push_depth(p);
|
|
+ //leaf object copy in advanced, reduce cost of push and pop
|
|
+ if (!o->klass()->oop_is_gc_leaf()) {
|
|
+ push_depth(p);
|
|
+ } else {
|
|
+ copy_and_push_safe_barrier<T, false>(p);
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
@@ -214,7 +219,7 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
|
|
|
|
// 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, memory_order_release)) {
|
|
+ if (o->cas_forward_to(new_obj, test_mark, o->klass()->oop_is_gc_leaf()? memory_order_relaxed : memory_order_release)) {
|
|
// We won any races, we "own" this object.
|
|
assert(new_obj == o->forwardee(), "Sanity");
|
|
|
|
@@ -238,8 +243,11 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
|
|
push_depth(masked_o);
|
|
TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes);
|
|
} else {
|
|
- // we'll just push its contents
|
|
- push_contents(new_obj);
|
|
+ //leaf object don't have contents, never need push_contents
|
|
+ if (!o->klass()->oop_is_gc_leaf()) {
|
|
+ // we'll just push its contents
|
|
+ push_contents(new_obj);
|
|
+ }
|
|
}
|
|
} else {
|
|
// We lost, someone else "owns" this object
|
|
diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp
|
|
index 01c5ed5bd..180ba8f41 100644
|
|
--- a/src/hotspot/share/oops/klass.cpp
|
|
+++ b/src/hotspot/share/oops/klass.cpp
|
|
@@ -202,6 +202,8 @@ Klass::Klass(KlassID id) : _id(id),
|
|
CDS_JAVA_HEAP_ONLY(_archived_mirror = 0;)
|
|
_primary_supers[0] = this;
|
|
set_super_check_offset(in_bytes(primary_supers_offset()));
|
|
+
|
|
+ set_oop_is_gc_leaf(false);
|
|
}
|
|
|
|
jint Klass::array_layout_helper(BasicType etype) {
|
|
diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp
|
|
index b77a19deb..a624586aa 100644
|
|
--- a/src/hotspot/share/oops/klass.hpp
|
|
+++ b/src/hotspot/share/oops/klass.hpp
|
|
@@ -165,6 +165,8 @@ class Klass : public Metadata {
|
|
// vtable length
|
|
int _vtable_len;
|
|
|
|
+ bool _is_gc_leaf;
|
|
+
|
|
private:
|
|
// This is an index into FileMapHeader::_shared_path_table[], to
|
|
// associate this class with the JAR file where it's loaded from during
|
|
@@ -603,6 +605,9 @@ protected:
|
|
is_typeArray_klass_slow()); }
|
|
#undef assert_same_query
|
|
|
|
+ void set_oop_is_gc_leaf(bool is_gc_leaf) { _is_gc_leaf = is_gc_leaf; }
|
|
+ inline bool oop_is_gc_leaf() const { return _is_gc_leaf; }
|
|
+
|
|
// Access flags
|
|
AccessFlags access_flags() const { return _access_flags; }
|
|
void set_access_flags(AccessFlags flags) { _access_flags = flags; }
|
|
--
|
|
1.8.3.1
|