Skip to content

Pass hotspot command line flags to mmtk-core #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mmtk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ once_cell = "1.10.0"
# - change branch
# - change repo name
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "04a47feb4598b2120598453c2cceec83986c2122" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4873b4ab4016a2a5ef413463443856efa373e90c" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }

Expand Down
14 changes: 14 additions & 0 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ pub extern "C" fn process(name: *const c_char, value: *const c_char) -> bool {
)
}

/// Pass hotspot `ParallelGCThreads` flag to mmtk
#[no_mangle]
pub extern "C" fn mmtk_builder_set_threads(value: usize) {
let mut builder = BUILDER.lock().unwrap();
builder.options.threads.set(value);
}

/// Pass hotspot `UseTransparentHugePages` flag to mmtk
#[no_mangle]
pub extern "C" fn mmtk_builder_set_transparent_hugepages(value: bool) {
let mut builder = BUILDER.lock().unwrap();
builder.options.transparent_hugepages.set(value);
}

#[no_mangle]
// We trust the name/value pointer is valid.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
Expand Down
3 changes: 3 additions & 0 deletions openjdk/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ extern void add_phantom_candidate(void* ref, void* referent);
extern void mmtk_harness_begin_impl();
extern void mmtk_harness_end_impl();

extern void mmtk_builder_set_threads(size_t value);
extern void mmtk_builder_set_transparent_hugepages(bool value);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions openjdk/mmtkHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ jint MMTkHeap::initialize() {
// printf("policy max heap size %zu, min heap size %zu\n", heap_size, collector_policy()->min_heap_byte_size());

// Set options
mmtk_builder_set_threads(ParallelGCThreads);
mmtk_builder_set_transparent_hugepages(UseTransparentHugePages);
if (ThirdPartyHeapOptions != NULL) {
bool set_options = process_bulk(strdup(ThirdPartyHeapOptions));
guarantee(set_options, "Failed to set MMTk options. Please check if the options are valid: %s\n", ThirdPartyHeapOptions);
Expand Down
6 changes: 6 additions & 0 deletions openjdk/thirdPartyHeapArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ void ThirdPartyHeapArguments::initialize() {
FLAG_SET_DEFAULT(UseTLAB, false);
FLAG_SET_DEFAULT(UseCompressedOops, false);
FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
if (ParallelGCThreads == 0) {
assert(!FLAG_IS_DEFAULT(ParallelGCThreads), "ParallelGCThreads should not be 0.");
vm_exit_during_initialization("The flag -XX:+UseUseThirdPartyHeap can not be combined with -XX:ParallelGCThreads=0", NULL);
}

}

CollectedHeap* ThirdPartyHeapArguments::create_heap() {
Expand Down