Skip to content

Commit 614ba9f

Browse files
committed
8356075: Support Shenandoah GC in JVMCI
Reviewed-by: shade, dnsimon, cslucas
1 parent ecfaf35 commit 614ba9f

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
#include "utilities/events.hpp"
9999
#include "utilities/globalDefinitions.hpp"
100100
#include "utilities/powerOfTwo.hpp"
101+
#if INCLUDE_JVMCI
102+
#include "jvmci/jvmci.hpp"
103+
#endif
101104
#if INCLUDE_JFR
102105
#include "gc/shenandoah/shenandoahJfrSupport.hpp"
103106
#endif
@@ -2233,6 +2236,9 @@ void ShenandoahHeap::stw_unload_classes(bool full_gc) {
22332236
ShenandoahGCWorkerPhase worker_phase(phase);
22342237
bool unloading_occurred = SystemDictionary::do_unloading(gc_timer());
22352238

2239+
// Clean JVMCI metadata handles.
2240+
JVMCI_ONLY(JVMCI::do_unloading(unloading_occurred));
2241+
22362242
uint num_workers = _workers->active_workers();
22372243
ShenandoahClassUnloadingTask unlink_task(phase, num_workers, unloading_occurred);
22382244
_workers->run_task(&unlink_task);

src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre(oopDesc * orig, JavaThread
4848
ShenandoahBarrierSet::satb_mark_queue_set().enqueue_known_active(queue, orig);
4949
JRT_END
5050

51+
void ShenandoahRuntime::write_barrier_pre(oopDesc* orig) {
52+
write_ref_field_pre(orig, JavaThread::current());
53+
}
54+
5155
JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_strong(oopDesc* src, oop* load_addr))
5256
return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr);
5357
JRT_END

src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ShenandoahRuntime : public AllStatic {
3737
static void arraycopy_barrier_narrow_oop(narrowOop* src, narrowOop* dst, size_t length);
3838

3939
static void write_ref_field_pre(oopDesc* orig, JavaThread* thread);
40+
static void write_barrier_pre(oopDesc* orig);
4041

4142
static oopDesc* load_reference_barrier_strong(oopDesc* src, oop* load_addr);
4243
static oopDesc* load_reference_barrier_strong_narrow(oopDesc* src, narrowOop* load_addr);

src/hotspot/share/jvmci/jvmciCompilerToVM.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ class CompilerToVM {
111111
#if INCLUDE_ZGC
112112
static int sizeof_ZStoreBarrierEntry;
113113
#endif
114+
#if INCLUDE_SHENANDOAHGC
115+
static address shenandoah_in_cset_fast_test_addr;
116+
static int shenandoah_region_size_bytes_shift;
117+
#endif
114118

115119
#ifdef X86
116120
static int L1_line_size;

src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#include "runtime/sharedRuntime.hpp"
5353
#include "runtime/stubRoutines.hpp"
5454
#include "utilities/resourceHash.hpp"
55+
#if INCLUDE_SHENANDOAHGC
56+
#include "gc/shenandoah/shenandoahHeap.hpp"
57+
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
58+
#endif
5559

5660
int CompilerToVM::Data::oopDesc_klass_offset_in_bytes;
5761
int CompilerToVM::Data::arrayOopDesc_length_offset_in_bytes;
@@ -86,6 +90,11 @@ address CompilerToVM::Data::ZPointerVectorLoadBadMask_address;
8690
address CompilerToVM::Data::ZPointerVectorStoreBadMask_address;
8791
address CompilerToVM::Data::ZPointerVectorStoreGoodMask_address;
8892

93+
#if INCLUDE_SHENANDOAHGC
94+
address CompilerToVM::Data::shenandoah_in_cset_fast_test_addr;
95+
int CompilerToVM::Data::shenandoah_region_size_bytes_shift;
96+
#endif
97+
8998
bool CompilerToVM::Data::continuations_enabled;
9099

91100
#ifdef AARCH64
@@ -227,12 +236,22 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
227236
assert(base != nullptr, "unexpected byte_map_base");
228237
cardtable_start_address = base;
229238
cardtable_shift = CardTable::card_shift();
239+
} else if (bs->is_a(BarrierSet::ShenandoahBarrierSet)) {
240+
cardtable_start_address = nullptr;
241+
cardtable_shift = CardTable::card_shift();
230242
} else {
231243
// No card mark barriers
232244
cardtable_start_address = nullptr;
233245
cardtable_shift = 0;
234246
}
235247

248+
#if INCLUDE_SHENANDOAHGC
249+
if (UseShenandoahGC) {
250+
shenandoah_in_cset_fast_test_addr = ShenandoahHeap::in_cset_fast_test_addr();
251+
shenandoah_region_size_bytes_shift = ShenandoahHeapRegion::region_size_bytes_shift_jint();
252+
}
253+
#endif
254+
236255
#ifdef X86
237256
L1_line_size = VM_Version::L1_line_size();
238257
#endif

src/hotspot/share/jvmci/jvmci_globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graa
229229
}
230230

231231
bool JVMCIGlobals::gc_supports_jvmci() {
232-
return UseSerialGC || UseParallelGC || UseG1GC || UseZGC || UseEpsilonGC;
232+
return UseSerialGC || UseParallelGC || UseG1GC || UseZGC || UseShenandoahGC || UseEpsilonGC;
233233
}
234234

235235
void JVMCIGlobals::check_jvmci_supported_gc() {

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
#include "gc/z/zBarrierSetRuntime.hpp"
5454
#include "gc/z/zThreadLocalData.hpp"
5555
#endif
56+
#if INCLUDE_SHENANDOAHGC
57+
#include "gc/shenandoah/shenandoahRuntime.hpp"
58+
#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
59+
#endif
5660

5761
#define VM_STRUCTS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field) \
5862
static_field(CompilerToVM::Data, oopDesc_klass_offset_in_bytes, int) \
@@ -129,6 +133,8 @@
129133
static_field(CompilerToVM::Data, sizeof_arrayOopDesc, int) \
130134
static_field(CompilerToVM::Data, sizeof_BasicLock, int) \
131135
ZGC_ONLY(static_field(CompilerToVM::Data, sizeof_ZStoreBarrierEntry, int)) \
136+
SHENANDOAHGC_ONLY(static_field(CompilerToVM::Data, shenandoah_in_cset_fast_test_addr, address)) \
137+
SHENANDOAHGC_ONLY(static_field(CompilerToVM::Data, shenandoah_region_size_bytes_shift,int)) \
132138
\
133139
static_field(CompilerToVM::Data, dsin, address) \
134140
static_field(CompilerToVM::Data, dcos, address) \
@@ -895,6 +901,13 @@
895901
declare_function(JVMCIRuntime::load_and_clear_exception) \
896902
G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_pre)) \
897903
G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_post)) \
904+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_strong)) \
905+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_strong_narrow)) \
906+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_weak)) \
907+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_weak_narrow)) \
908+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_phantom)) \
909+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_phantom_narrow)) \
910+
SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::write_barrier_pre)) \
898911
declare_function(JVMCIRuntime::validate_object) \
899912
\
900913
declare_function(JVMCIRuntime::test_deoptimize_call_int)
@@ -941,6 +954,15 @@
941954

942955
#endif // INCLUDE_ZGC
943956

957+
#if INCLUDE_SHENANDOAHGC
958+
959+
#define VM_INT_CONSTANTS_JVMCI_SHENANDOAH(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \
960+
declare_constant_with_value("ShenandoahThreadLocalData::gc_state_offset", in_bytes(ShenandoahThreadLocalData::gc_state_offset())) \
961+
declare_constant_with_value("ShenandoahThreadLocalData::satb_mark_queue_index_offset", in_bytes(ShenandoahThreadLocalData::satb_mark_queue_index_offset())) \
962+
declare_constant_with_value("ShenandoahThreadLocalData::satb_mark_queue_buffer_offset", in_bytes(ShenandoahThreadLocalData::satb_mark_queue_buffer_offset())) \
963+
declare_constant_with_value("ShenandoahThreadLocalData::card_table_offset", in_bytes(ShenandoahThreadLocalData::card_table_offset())) \
964+
965+
#endif
944966

945967
#ifdef LINUX
946968

@@ -1063,6 +1085,11 @@ VMIntConstantEntry JVMCIVMStructs::localHotSpotVMIntConstants[] = {
10631085
GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
10641086
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
10651087
#endif
1088+
#if INCLUDE_SHENANDOAHGC
1089+
VM_INT_CONSTANTS_JVMCI_SHENANDOAH(GENERATE_VM_INT_CONSTANT_ENTRY,
1090+
GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
1091+
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
1092+
#endif
10661093
#ifdef VM_INT_CPU_FEATURE_CONSTANTS
10671094
VM_INT_CPU_FEATURE_CONSTANTS
10681095
#endif

0 commit comments

Comments
 (0)