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

Add a runtime flag to enable MMTk #1

Open
angussidney opened this issue Dec 15, 2020 · 1 comment
Open

Add a runtime flag to enable MMTk #1

angussidney opened this issue Dec 15, 2020 · 1 comment

Comments

@angussidney
Copy link
Owner

In my initial iteration of the Ruby/MMTk binding, the Ruby compiler modifications are enabled/disabled via a compiler flag. Although this should be functional, it won't be ideal because the entire language must be rebuilt whenever we want to turn the third party heap on/off (e.g. to perform comparative benchmarks etc).

My initial attempt to implement a runtime flag was to add a feature as a command line option to the ruby interpreter. However, this attempt proved unfruitful because the VM/heap is initialised before the command line arguments are parsed, which makes it impossible to configure MMTk usage without majorly refactoring the code (something which I am not comfortable doing).

Chris's suggestion was to use an environment variable instead. The get_param function in vm.c may be useful for this.

@angussidney
Copy link
Owner Author

My (now discarded) changes for adding the command line option:

diff --git a/ruby.c b/ruby.c
index 96d8f75a56..025cd09071 100644
--- a/ruby.c
+++ b/ruby.c
@@ -73,6 +73,21 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
 
 #define COMMA ,
 #define FEATURE_BIT(bit) (1U << feature_##bit)
+#ifdef USE_THIRD_PARTY_HEAP
+#define EACH_FEATURES(X, SEP) \
+    X(gems) \
+    SEP \
+    X(did_you_mean) \
+    SEP \
+    X(rubyopt) \
+    SEP \
+    X(frozen_string_literal) \
+    SEP \
+    X(jit) \
+    SEP \
+    X(third_party_heap) \
+    /* END OF FEATURES */
+#else
 #define EACH_FEATURES(X, SEP) \
     X(gems) \
     SEP \
@@ -84,6 +99,7 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
     SEP \
     X(jit) \
     /* END OF FEATURES */
+#endif
 #define EACH_DEBUG_FEATURES(X, SEP) \
     X(frozen_string_literal) \
     /* END OF DEBUG FEATURES */
@@ -193,7 +209,10 @@ enum {
 	& ~FEATURE_BIT(gems)
 #endif
 	& ~FEATURE_BIT(frozen_string_literal)
-        & ~FEATURE_BIT(jit)
+	& ~FEATURE_BIT(jit)
+#ifdef USE_THIRD_PARTY_HEAP
+	& ~FEATURE_BIT(third_party_heap)
+#endif
 	)
 };
 
@@ -298,7 +317,10 @@ usage(const char *name, int help)
 	M("did_you_mean", "",   "did_you_mean (default: "DEFAULT_RUBYGEMS_ENABLED")"),
 	M("rubyopt", "",        "RUBYOPT environment variable (default: enabled)"),
 	M("frozen-string-literal", "", "freeze all string literals (default: disabled)"),
-        M("jit", "",            "JIT compiler (default: disabled)"),
+	M("jit", "",            "JIT compiler (default: disabled)"),
+#ifdef USE_THIRD_PARTY_HEAP
+	M("third_party_heap", "", "third party heap and GC (default: disabled)"),
+#endif
     };
     static const struct message warn_categories[] = {
         M("deprecated", "",       "deprecated features"),

(yes... I could have made a branch and linked to it here, but I was too lazy to selectively pick out the correct lines of code to commit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant