Skip to content

Commit

Permalink
WIP: Use new API for setting MMTk options
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Aug 2, 2022
1 parent e478bd3 commit b27b4dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
15 changes: 6 additions & 9 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1883,20 +1883,17 @@ rb_objspace_alloc(void)
dont_gc_on();

#ifdef USE_THIRD_PARTY_HEAP
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_Options mmtk_options = mmtk_options_default();

mmtk_options_set_plan(mmtk_options, 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_options_set_heap_size(mmtk_options, 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_options, &ruby_upcalls);
#endif

return objspace;
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,8 @@ extern "C" {
#define MMTK_MIN_OBJ_ALIGN 8
#define MMTK_OBJREF_OFFSET 8

typedef void* MMTk_Options;

typedef void* MMTk_Mutator;
typedef void* MMTk_TraceLocal;

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

/**
* Options
*/
extern MMTk_Options mmtk_options_default();

extern void mmtk_options_set_heap_size(MMTk_Options options, uintptr_t heap_size);

extern void mmtk_options_set_plan(MMTk_Options options, const char *plan_name);


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

Expand Down

0 comments on commit b27b4dd

Please sign in to comment.