Skip to content

Commit 91e163a

Browse files
authored
Pass hotspot command line flags to mmtk-core (#229)
* Pass hotspot cmdline flags to mmtk * lower hotspot flag priority * Remove println * Use typed setter * Update mmtk-core
1 parent 511e726 commit 91e163a

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

mmtk/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mmtk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ once_cell = "1.10.0"
3030
# - change branch
3131
# - change repo name
3232
# But other changes including adding/removing whitespaces in commented lines may break the CI.
33-
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "04a47feb4598b2120598453c2cceec83986c2122" }
33+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4873b4ab4016a2a5ef413463443856efa373e90c" }
3434
# Uncomment the following to build locally
3535
# mmtk = { path = "../repos/mmtk-core" }
3636

mmtk/src/api.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,20 @@ pub extern "C" fn process(name: *const c_char, value: *const c_char) -> bool {
290290
)
291291
}
292292

293+
/// Pass hotspot `ParallelGCThreads` flag to mmtk
294+
#[no_mangle]
295+
pub extern "C" fn mmtk_builder_set_threads(value: usize) {
296+
let mut builder = BUILDER.lock().unwrap();
297+
builder.options.threads.set(value);
298+
}
299+
300+
/// Pass hotspot `UseTransparentHugePages` flag to mmtk
301+
#[no_mangle]
302+
pub extern "C" fn mmtk_builder_set_transparent_hugepages(value: bool) {
303+
let mut builder = BUILDER.lock().unwrap();
304+
builder.options.transparent_hugepages.set(value);
305+
}
306+
293307
#[no_mangle]
294308
// We trust the name/value pointer is valid.
295309
#[allow(clippy::not_unsafe_ptr_arg_deref)]

openjdk/mmtk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ extern void add_phantom_candidate(void* ref, void* referent);
211211
extern void mmtk_harness_begin_impl();
212212
extern void mmtk_harness_end_impl();
213213

214+
extern void mmtk_builder_set_threads(size_t value);
215+
extern void mmtk_builder_set_transparent_hugepages(bool value);
216+
214217
#ifdef __cplusplus
215218
}
216219
#endif

openjdk/mmtkHeap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jint MMTkHeap::initialize() {
8484
// printf("policy max heap size %zu, min heap size %zu\n", heap_size, collector_policy()->min_heap_byte_size());
8585

8686
// Set options
87+
mmtk_builder_set_threads(ParallelGCThreads);
88+
mmtk_builder_set_transparent_hugepages(UseTransparentHugePages);
8789
if (ThirdPartyHeapOptions != NULL) {
8890
bool set_options = process_bulk(strdup(ThirdPartyHeapOptions));
8991
guarantee(set_options, "Failed to set MMTk options. Please check if the options are valid: %s\n", ThirdPartyHeapOptions);

openjdk/thirdPartyHeapArguments.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ void ThirdPartyHeapArguments::initialize() {
4545
FLAG_SET_DEFAULT(UseTLAB, false);
4646
FLAG_SET_DEFAULT(UseCompressedOops, false);
4747
FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
48+
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
49+
if (ParallelGCThreads == 0) {
50+
assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "ParallelGCThreads should not be 0.");
51+
vm_exit_during_initialization("The flag -XX:+UseUseThirdPartyHeap can not be combined with -XX:ParallelGCThreads=0", NULL);
52+
}
53+
4854
}
4955

5056
CollectedHeap* ThirdPartyHeapArguments::create_heap() {

0 commit comments

Comments
 (0)