Skip to content

Commit 1f5d8cb

Browse files
authored
Use process_bulk() API and ThirdPartyHeapOptions (#132)
1 parent 1ee047d commit 1f5d8cb

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

mmtk/Cargo.toml

Lines changed: 1 addition & 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 = "ad95d7797f020eaab1e608dc03b7db6a3d79839a" }
23+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4851e7ac7e8a7bd70ce65935c4ac1ff430cab6f1" }
2424
# Uncomment the following to build locally
2525
# mmtk = { path = "../repos/mmtk-core" }
2626

mmtk/src/api.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ pub extern "C" fn process(name: *const c_char, value: *const c_char) -> bool {
217217
)
218218
}
219219

220+
#[no_mangle]
221+
// We trust the name/value pointer is valid.
222+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
223+
pub extern "C" fn process_bulk(options: *const c_char) -> bool {
224+
let options_str: &CStr = unsafe { CStr::from_ptr(options) };
225+
memory_manager::process_bulk(&SINGLETON, options_str.to_str().unwrap())
226+
}
227+
220228
#[no_mangle]
221229
pub extern "C" fn starting_heap_address() -> Address {
222230
memory_manager::starting_heap_address()

openjdk/mmtk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extern void initialize_collection(void *tls);
7474
extern void gc_init(size_t heap_size);
7575
extern bool will_never_move(void* object);
7676
extern bool process(char* name, char* value);
77+
extern bool process_bulk(char* options);
7778
extern void scan_region();
7879
extern void handle_user_collection_request(void *tls);
7980

openjdk/mmtkHeap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ jint MMTkHeap::initialize() {
7777
size_t mmtk_heap_size = heap_size;
7878
/*forcefully*/ //mmtk_heap_size = (1<<31) -1;
7979

80+
// Set options
81+
if (ThirdPartyHeapOptions != NULL) {
82+
bool set_options = process_bulk(strdup(ThirdPartyHeapOptions));
83+
guarantee(set_options, "Failed to set MMTk options. Please check if the options are valid: %s\n", ThirdPartyHeapOptions);
84+
}
85+
8086
openjdk_gc_init(&mmtk_upcalls, mmtk_heap_size);
8187
// Cache the value here. It is a constant depending on the selected plan. The plan won't change from now, so value won't change.
8288
MMTkMutatorContext::max_non_los_default_alloc_bytes = get_max_non_los_default_alloc_bytes();

0 commit comments

Comments
 (0)