Skip to content

Commit c0edad7

Browse files
Merge pull request ruby#49 from eightbitraptor/mvh-harness-semantics
Only enable harness use when MMTk is enabled
2 parents 7ee34cd + 397f709 commit c0edad7

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6134,6 +6134,7 @@ error.$(OBJEXT): {$(VPATH)}constant.h
61346134
error.$(OBJEXT): {$(VPATH)}defines.h
61356135
error.$(OBJEXT): {$(VPATH)}encoding.h
61366136
error.$(OBJEXT): {$(VPATH)}error.c
6137+
error.$(OBJEXT): {$(VPATH)}gc.h
61376138
error.$(OBJEXT): {$(VPATH)}id.h
61386139
error.$(OBJEXT): {$(VPATH)}id_table.h
61396140
error.$(OBJEXT): {$(VPATH)}intern.h

error.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#endif
2929

3030
#include "internal.h"
31+
#include "gc.h"
3132
#include "internal/error.h"
3233
#include "internal/eval.h"
3334
#include "internal/hash.h"

gc.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ MMTk_RubyUpcalls ruby_upcalls;
156156
#define MAP_ANONYMOUS MAP_ANON
157157
#endif
158158

159-
#if USE_MMTK
160159
static bool mmtk_enable = false;
160+
161+
#if USE_MMTK
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;
@@ -1966,6 +1967,7 @@ rb_objspace_alloc(void)
19661967

19671968
#if USE_MMTK
19681969
if (rb_mmtk_enabled_p()) {
1970+
19691971
MMTk_Builder *mmtk_builder = mmtk_builder_default();
19701972

19711973
mmtk_builder_set_plan(mmtk_builder, mmtk_chosen_plan);
@@ -15140,6 +15142,9 @@ gc_using_rvargc_p(VALUE mod)
1514015142
static VALUE
1514115143
rb_mmtk_plan_name(VALUE _)
1514215144
{
15145+
if (!rb_mmtk_enabled_p()) {
15146+
rb_raise(rb_eRuntimeError, "Debug harness can only be used when MMTk is enabled, re-run with --mmtk.");
15147+
}
1514315148
const char* plan_name = mmtk_plan_name();
1514415149
return rb_str_new(plan_name, strlen(plan_name));
1514515150
}
@@ -15175,6 +15180,9 @@ rb_mmtk_enabled(VALUE _)
1517515180
static VALUE
1517615181
rb_mmtk_harness_begin(VALUE _)
1517715182
{
15183+
if (!rb_mmtk_enabled_p()) {
15184+
rb_raise(rb_eRuntimeError, "Debug harness can only be used when MMTk is enabled, re-run with --mmtk.");
15185+
}
1517815186
mmtk_harness_begin((MMTk_VMMutatorThread)GET_THREAD());
1517915187
return Qnil;
1518015188
}
@@ -15191,6 +15199,9 @@ rb_mmtk_harness_begin(VALUE _)
1519115199
static VALUE
1519215200
rb_mmtk_harness_end(VALUE _)
1519315201
{
15202+
if (!rb_mmtk_enabled_p()) {
15203+
rb_raise(rb_eRuntimeError, "Debug harness can only be used when MMTk is enabled, re-run with --mmtk.");
15204+
}
1519415205
mmtk_harness_end((MMTk_VMMutatorThread)GET_THREAD());
1519515206
return Qnil;
1519615207
}
@@ -16193,8 +16204,9 @@ void rb_mmtk_post_process_opts_finish(bool feature_enable) {
1619316204
}
1619416205
}
1619516206

16207+
#endif
16208+
1619616209
bool rb_mmtk_enabled_p(void) {
1619716210
return mmtk_enable;
1619816211
}
1619916212

16200-
#endif

gc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ void rb_gc_init_collection(void);
126126
void rb_mmtk_pre_process_opts(int argc, char **argv);
127127
void rb_mmtk_post_process_opts(const char *arg);
128128
void rb_mmtk_post_process_opts_finish(bool feature_enable);
129-
bool rb_mmtk_enabled_p(void);
130129
#endif
131130

131+
bool rb_mmtk_enabled_p(void);
132+
132133
RUBY_SYMBOL_EXPORT_BEGIN
133134

134135
/* exports for objspace module */

0 commit comments

Comments
 (0)