Skip to content
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

Use new API for setting MMTk options #15

Merged
merged 1 commit into from
Aug 3, 2022
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
15 changes: 6 additions & 9 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1877,20 +1877,17 @@ rb_objspace_alloc(void)

#if USE_MMTK
if (rb_mmtk_enabled_p()) {
if (!mmtk_env_plan && setenv("MMTK_PLAN", mmtk_chosen_plan, 0) != 0) {
fputs("[FATAL] could not set MMTK_PLAN\n", stderr);
exit(EXIT_FAILURE);
}
MMTk_Builder mmtk_builder = mmtk_builder_default();

mmtk_builder_set_plan(mmtk_builder, mmtk_chosen_plan);

// Note: the limit is currently broken for NoGC, but we still attempt to
// initialise it properly regardless.
// See https://github.com/mmtk/mmtk-core/issues/214
mmtk_init_binding(rb_mmtk_heap_limit(), &ruby_upcalls);
size_t heap_size = rb_mmtk_heap_limit();
mmtk_builder_set_heap_size(mmtk_builder, heap_size);

if (!mmtk_env_plan && unsetenv("MMTK_PLAN") != 0) {
fputs("[FATAL] could not unset MMTK_PLAN\n", stderr);
exit(EXIT_FAILURE);
}
mmtk_init_binding(mmtk_builder, &ruby_upcalls);
}
#endif

Expand Down
14 changes: 13 additions & 1 deletion mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern "C" {
#define MMTK_MIN_OBJ_ALIGN 8
#define MMTK_OBJREF_OFFSET 8

typedef void* MMTk_Builder;
typedef void* MMTk_Mutator;
typedef void* MMTk_TraceLocal;

Expand All @@ -38,10 +39,21 @@ typedef struct {
void (*scan_object_ruby_style)(void *object);
} RubyUpcalls;

/**
* MMTK builder and options
*/
MMTk_Builder mmtk_builder_default();

void mmtk_builder_set_heap_size(MMTk_Builder builder, uintptr_t heap_size);

void mmtk_builder_set_plan(MMTk_Builder builder, const char *plan_name);

void mmtk_init_binding(MMTk_Builder builder, const RubyUpcalls *upcalls);

/**
* Initialization
*/
extern void mmtk_init_binding(size_t heap_size, RubyUpcalls *ruby_upcalls);
extern void mmtk_init_binding(MMTk_Builder builder, const RubyUpcalls *upcalls);
extern void mmtk_initialize_collection(void *tls);
extern void mmtk_enable_collection();

Expand Down