Skip to content

Commit 9db02a6

Browse files
committed
Add --mmtk option, but at the moment it has to match the compilation configuration
1 parent 5b8c050 commit 9db02a6

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

gc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ RubyUpcalls ruby_upcalls;
158158
#endif
159159

160160
#ifdef USE_THIRD_PARTY_HEAP
161+
static bool mmtk_enable = false;
161162
static const char *mmtk_env_plan = NULL;
162163
static const char *mmtk_pre_arg_plan = NULL;
163164
static const char *mmtk_post_arg_plan = NULL;
@@ -15143,6 +15144,9 @@ void rb_mmtk_pre_process_opts(int argc, char **argv) {
1514315144
bool enable_rubyopt = true;
1514415145

1514515146
mmtk_env_plan = getenv("MMTK_PLAN");
15147+
if (mmtk_env_plan) {
15148+
mmtk_enable = true;
15149+
}
1514615150

1514715151
for (int n = 1; n < argc; n++) {
1514815152
if (strcmp(argv[n], "--") == 0) {
@@ -15222,10 +15226,14 @@ void rb_mmtk_post_process_opts(const char *s) {
1522215226
}
1522315227
}
1522415228

15225-
void rb_mmtk_post_process_opts_finish(void) {
15229+
void rb_mmtk_post_process_opts_finish(bool enable) {
15230+
mmtk_enable |= enable;
1522615231
if (strcmp(mmtk_pre_arg_plan ? mmtk_pre_arg_plan : "", mmtk_post_arg_plan ? mmtk_post_arg_plan : "") != 0) {
1522715232
rb_raise(rb_eRuntimeError, "--mmtk-plan values disagree");
1522815233
}
15234+
if (!mmtk_enable) {
15235+
rb_bug("must enable MMTk");
15236+
}
1522915237
}
1523015238

1523115239
#endif

gc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct rb_thread_struct;
123123
void rb_gc_init_collection();
124124
void rb_mmtk_pre_process_opts(int argc, char **argv);
125125
void rb_mmtk_post_process_opts(const char *arg);
126-
void rb_mmtk_post_process_opts_finish(void);
126+
void rb_mmtk_post_process_opts_finish(bool enable);
127127
#endif // USE_THIRD_PARTY_HEAP
128128

129129
RUBY_SYMBOL_EXPORT_BEGIN

ruby.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
105105
X(mjit) \
106106
SEP \
107107
X(yjit) \
108+
SEP \
109+
X(mmtk) \
108110
/* END OF FEATURES */
109111
#define EACH_DEBUG_FEATURES(X, SEP) \
110112
X(frozen_string_literal) \
@@ -194,6 +196,7 @@ enum {
194196
#endif
195197
& ~FEATURE_BIT(frozen_string_literal)
196198
& ~feature_jit_mask
199+
& ~FEATURE_BIT(mmtk)
197200
)
198201
};
199202

@@ -211,6 +214,9 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
211214
#elif defined(YJIT_FORCE_ENABLE)
212215
opt->features.set |= FEATURE_BIT(yjit);
213216
#endif
217+
#ifdef MMTK_FORCE_ENABLE /* to use with: ./configure cppflags="-DMMTK_FORCE_ENABLE" */
218+
opt->features.set |= FEATURE_BIT(mmtk);
219+
#endif
214220

215221
return opt;
216222
}
@@ -284,6 +290,9 @@ usage(const char *name, int help, int highlight, int columns)
284290
#endif
285291
#if YJIT_BUILD
286292
M("--yjit", "", "enable in-process JIT compiler (experimental)"),
293+
#endif
294+
#ifdef USE_THIRD_PARTY_HEAP
295+
M("--mmtk", "", "use MMTk for garbage collection (experimental)"),
287296
#endif
288297
M("-h", "", "show this message, --help for more info"),
289298
};
@@ -318,6 +327,9 @@ usage(const char *name, int help, int highlight, int columns)
318327
#endif
319328
#if YJIT_BUILD
320329
M("yjit", "", "in-process JIT compiler (default: disabled)"),
330+
#endif
331+
#ifdef USE_THIRD_PARTY_HEAP
332+
M("mmtk", "", "MMTk garbage collection (default: disabled)"),
321333
#endif
322334
};
323335
static const struct ruby_opt_message warn_categories[] = {
@@ -1457,6 +1469,7 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
14571469
}
14581470
else if (is_option_with_optarg("mmtk", '-', true, false, false)) {
14591471
#ifdef USE_THIRD_PARTY_HEAP
1472+
FEATURE_SET(opt->features, FEATURE_BIT(mmtk));
14601473
rb_mmtk_post_process_opts(s);
14611474
#undef opt_match_noarg
14621475
#undef opt_match_arg
@@ -1829,7 +1842,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
18291842
}
18301843

18311844
#ifdef USE_THIRD_PARTY_HEAP
1832-
rb_mmtk_post_process_opts_finish();
1845+
rb_mmtk_post_process_opts_finish(FEATURE_SET_P(opt->features, mmtk));
18331846
#endif
18341847

18351848
if (opt->src.enc.name)

0 commit comments

Comments
 (0)