Skip to content

Commit ec10907

Browse files
authored
Add Immix GC (#90)
1 parent a5cc1c3 commit ec10907

File tree

8 files changed

+83
-17
lines changed

8 files changed

+83
-17
lines changed

.github/scripts/ci-test-assertions.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export MMTK_PLAN=SemiSpace
1919
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar fop
2020
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar luindex
2121

22+
# --- Immix ---
23+
export MMTK_PLAN=Immix
24+
25+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar fop
26+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar luindex
27+
2228
# -- GenCopy --
2329
export MMTK_PLAN=GenCopy
2430

.github/scripts/ci-test-normal.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHea
3232
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar hsqldb
3333
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar eclipse
3434

35+
# --- Immix ---
36+
export MMTK_PLAN=Immix
37+
38+
# Test - the benchmarks that are commented out do not work yet
39+
# Note: the command line options are necessary for now to ensure the benchmarks work. We may later change the options if we do not have these many constraints.
40+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar antlr
41+
#build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar bloat - does not work for stock build
42+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar fop
43+
#build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar jython - does not work for stock build
44+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar luindex
45+
#build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar lusearch - validation failed
46+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar pmd
47+
#build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar xalan - mmtk-core gets stuck in slowdebug build
48+
49+
# These benchmarks take 40s+ for slowdebug build, we may consider removing them from the CI
50+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar hsqldb
51+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar benchmarks/dacapo-2006-10-MR2.jar eclipse
52+
3553
# --- GenCopy ---
3654
export MMTK_PLAN=GenCopy
3755

mmtk/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lazy_static = "1.1"
2020
# - change branch
2121
# - change repo name
2222
# But other changes including adding/removing whitespaces in commented lines may break the CI.
23-
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "f1655d8644cc260b4c23d3ceb74ca31599447581" }
23+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "093da769a71067dcd4f37db6f453213e7dace660" }
2424
# Uncomment the following to build locally
2525
# mmtk = { path = "../repos/mmtk-core" }
2626

@@ -42,3 +42,4 @@ semispace = []
4242
gencopy = []
4343
marksweep = []
4444
pageprotect = []
45+
immix = []

mmtk/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ lazy_static! {
112112
std::env::set_var("MMTK_PLAN", "MarkSweep");
113113
#[cfg(feature = "pageprotect")]
114114
std::env::set_var("MMTK_PLAN", "PageProtect");
115+
#[cfg(feature = "immix")]
116+
std::env::set_var("MMTK_PLAN", "Immix");
115117
MMTK::new()
116118
};
117119
}

openjdk/mmtk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct AllocatorSelector {
5151
#define TAG_BUMP_POINTER 0
5252
#define TAG_LARGE_OBJECT 1
5353
#define TAG_MALLOC 2
54+
#define TAG_IMMIX 3
5455

5556
extern AllocatorSelector get_allocator_mapping(int allocator);
5657
extern size_t get_max_non_los_default_alloc_bytes();

openjdk/mmtkBarrierSetAssembler_x86.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,29 @@ void MMTkBarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register threa
7070
}
7171

7272
// Only bump pointer allocator is implemented.
73-
if (selector.tag != TAG_BUMP_POINTER) {
73+
if (selector.tag != TAG_BUMP_POINTER && selector.tag != TAG_IMMIX) {
7474
fatal("unimplemented allocator fastpath\n");
7575
}
7676

77-
// Calculate offsets of top and end. We now assume we are using bump pointer.
78-
int allocator_base_offset = in_bytes(JavaThread::third_party_heap_mutator_offset())
79-
+ in_bytes(byte_offset_of(MMTkMutatorContext, allocators))
80-
+ in_bytes(byte_offset_of(Allocators, bump_pointer))
81-
+ selector.index * sizeof(BumpAllocator);
77+
// Calculat offsets of top and end. We now assume we are using bump pointer.
78+
int allocator_base_offset;
79+
Address cursor, limit;
8280

83-
Address cursor = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, cursor)));
84-
Address limit = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, limit)));
81+
if (selector.tag == TAG_IMMIX) {
82+
allocator_base_offset = in_bytes(JavaThread::third_party_heap_mutator_offset())
83+
+ in_bytes(byte_offset_of(MMTkMutatorContext, allocators))
84+
+ in_bytes(byte_offset_of(Allocators, immix))
85+
+ selector.index * sizeof(ImmixAllocator);
86+
cursor = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(ImmixAllocator, cursor)));
87+
limit = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(ImmixAllocator, limit)));
88+
} else {
89+
allocator_base_offset = in_bytes(JavaThread::third_party_heap_mutator_offset())
90+
+ in_bytes(byte_offset_of(MMTkMutatorContext, allocators))
91+
+ in_bytes(byte_offset_of(Allocators, bump_pointer))
92+
+ selector.index * sizeof(BumpAllocator);
93+
cursor = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, cursor)));
94+
limit = Address(r15_thread, allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, limit)));
95+
}
8596
// obj = load lab.cursor
8697
__ movptr(obj, cursor);
8798
// end = obj + size

openjdk/mmtkBarrierSetC2.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,28 @@ void MMTkBarrierSetC2::expand_allocate(
177177

178178
{
179179
// Only bump pointer allocator fastpath is implemented.
180-
if (selector.tag != TAG_BUMP_POINTER) {
180+
if (selector.tag != TAG_BUMP_POINTER && selector.tag != TAG_IMMIX) {
181181
fatal("unimplemented allocator fastpath\n");
182182
}
183183

184184
// Calculat offsets of top and end. We now assume we are using bump pointer.
185-
int allocator_base_offset = in_bytes(JavaThread::third_party_heap_mutator_offset())
186-
+ in_bytes(byte_offset_of(MMTkMutatorContext, allocators))
187-
+ in_bytes(byte_offset_of(Allocators, bump_pointer))
188-
+ selector.index * sizeof(BumpAllocator);
189-
185+
int allocators_base_offset = in_bytes(JavaThread::third_party_heap_mutator_offset())
186+
+ in_bytes(byte_offset_of(MMTkMutatorContext, allocators));
187+
int tlab_top_offset, tlab_end_offset;
188+
if (selector.tag == TAG_IMMIX) {
189+
int allocator_base_offset = allocators_base_offset
190+
+ in_bytes(byte_offset_of(Allocators, immix))
191+
+ selector.index * sizeof(ImmixAllocator);
192+
tlab_top_offset = allocator_base_offset + in_bytes(byte_offset_of(ImmixAllocator, cursor));
193+
tlab_end_offset = allocator_base_offset + in_bytes(byte_offset_of(ImmixAllocator, limit));
194+
} else {
195+
int allocator_base_offset = allocators_base_offset
196+
+ in_bytes(byte_offset_of(Allocators, bump_pointer))
197+
+ selector.index * sizeof(BumpAllocator);
198+
tlab_top_offset = allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, cursor));
199+
tlab_end_offset = allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, limit));
200+
}
190201
Node* thread = x->transform_later(new ThreadLocalNode());
191-
int tlab_top_offset = allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, cursor));
192-
int tlab_end_offset = allocator_base_offset + in_bytes(byte_offset_of(BumpAllocator, limit));
193202
eden_top_adr = x->basic_plus_adr(x->top()/*not oop*/, thread, tlab_top_offset);
194203
eden_end_adr = x->basic_plus_adr(x->top()/*not oop*/, thread, tlab_end_offset);
195204
}

openjdk/mmtkMutator.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct RustDynPtr {
2222
const int MAX_BUMP_ALLOCATORS = 5;
2323
const int MAX_LARGE_OBJECT_ALLOCATORS = 1;
2424
const int MAX_MALLOC_ALLOCATORS = 1;
25+
const int MAX_IMMIX_ALLOCATORS = 1;
2526

2627
// The following types should have the same layout as the types with the same name in MMTk core (Rust)
2728

@@ -39,6 +40,22 @@ struct LargeObjectAllocator {
3940
RustDynPtr plan;
4041
};
4142

43+
struct ImmixAllocator {
44+
void* tls;
45+
void* cursor;
46+
void* limit;
47+
void* immix_space;
48+
RustDynPtr plan;
49+
uint8_t hot;
50+
uint8_t copy;
51+
void* large_cursor;
52+
void* large_limit;
53+
uint8_t request_for_large;
54+
uint8_t _align[7];
55+
uint8_t line_opt_tag;
56+
uintptr_t line_opt;
57+
};
58+
4259
struct MallocAllocator {
4360
void* tls;
4461
void* space;
@@ -49,6 +66,7 @@ struct Allocators {
4966
BumpAllocator bump_pointer[MAX_BUMP_ALLOCATORS];
5067
LargeObjectAllocator large_object[MAX_LARGE_OBJECT_ALLOCATORS];
5168
MallocAllocator malloc[MAX_MALLOC_ALLOCATORS];
69+
ImmixAllocator immix[MAX_IMMIX_ALLOCATORS];
5270
};
5371

5472
struct MutatorConfig {

0 commit comments

Comments
 (0)