Skip to content

Add an +MMTk description flag #1

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

Closed
Closed
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
7 changes: 7 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14394,6 +14394,9 @@ Init_GC(void)
#undef rb_intern
VALUE rb_mObjSpace;
VALUE rb_mProfiler;
#ifdef USE_THIRD_PARTY_HEAP
VALUE rb_mMMTk;
#endif
VALUE gc_constants;

rb_mGC = rb_define_module("GC");
Expand Down Expand Up @@ -14485,6 +14488,10 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
#endif

#ifdef USE_THIRD_PARTY_HEAP
rb_mMMTk = rb_define_module_under(rb_mGC, "MMTk");
#endif

{
VALUE opts;
/* GC build options */
Expand Down
23 changes: 13 additions & 10 deletions template/fake.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ if inc = arg['i']
scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|STR)\(([^()]*)\)/m) do |n, v|
version[n] = src.value(v)
end
arg['RUBY_DESCRIPTION_WITH_MJIT'] = src.value('description_with_mjit')
arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit')
arg['RUBY_DESCRIPTION_PRE'] = src.value('description_pre')
arg['RUBY_DESCRIPTION_POST'] = src.value('description_post')
end
%>baseruby="<%=arg['BASERUBY']%>"
_\
Expand All @@ -35,15 +35,18 @@ class Object
CROSS_COMPILING = RUBY_PLATFORM
constants.grep(/^RUBY_/) {|n| remove_const n}
% arg['versions'].each {|n, v|
<%=n%> = <%if n=='RUBY_DESCRIPTION' %>case
when RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled?
<%=arg['RUBY_DESCRIPTION_WITH_MJIT'].inspect%>
when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
<%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%>
else
<%=v.inspect%>
end<%else%><%=v.inspect%><%end%>
<%=n%> = <%=v.inspect%>
% }
options = []
if RubyVM.const_defined?(:MJIT) && RubyVM::MJIT.enabled?
options << ' +MJIT'
elsif RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
options << ' +YJIT'
end
if GC.const_defined?(:MMTk)
options << ' +MMTk'
end
RUBY_DESCRIPTION = (<%=arg['RUBY_DESCRIPTION_PRE'].inspect%> + options.join('') + <%=arg['RUBY_DESCRIPTION_POST'].inspect%>).freeze
end
builddir = File.dirname(File.expand_path(__FILE__))
srcdir = "<%=arg['srcdir']%>"
Expand Down
35 changes: 19 additions & 16 deletions version.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ const char ruby_revision[] = RUBY_FULL_REVISION;
const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_patchlevel = RUBY_PATCHLEVEL;
const char ruby_description[] = RUBY_DESCRIPTION_WITH("");
static const char ruby_description_with_mjit[] = RUBY_DESCRIPTION_WITH(" +MJIT");
static const char ruby_description_with_yjit[] = RUBY_DESCRIPTION_WITH(" +YJIT");
const char ruby_description[] = RUBY_DESCRIPTION_PRE RUBY_DESCRIPTION_POST;
const char ruby_description_pre[] = RUBY_DESCRIPTION_PRE;
const char ruby_description_post[] = RUBY_DESCRIPTION_POST;
const char ruby_copyright[] = RUBY_COPYRIGHT;
const char ruby_engine[] = "ruby";

// Enough space for any combination of option flags
static char ruby_dynamic_description_buffer[sizeof(ruby_description) + sizeof("+MJIT +YJIT +MMTk") - 1];

// Might change after initialization
const char *rb_dynamic_description = ruby_description;

Expand Down Expand Up @@ -104,24 +107,24 @@ Init_version(void)
void
Init_ruby_description(void)
{
VALUE description;

if (MJIT_OPTS_ON) {
rb_dynamic_description = ruby_description_with_mjit;
description = MKSTR(description_with_mjit);
}
else if (rb_yjit_enabled_p()) {
rb_dynamic_description = ruby_description_with_yjit;
description = MKSTR(description_with_yjit);
}
else {
description = MKSTR(description);
if (snprintf(ruby_dynamic_description_buffer, sizeof(ruby_dynamic_description_buffer), "%s%s%s%s%s",
ruby_description_pre,
MJIT_OPTS_ON ? " +MJIT" : "",
rb_yjit_enabled_p() ? " +YJIT" : "",
#ifdef USE_THIRD_PARTY_HEAP
" +MMTk",
#else
"",
#endif
ruby_description_post) < 0) {
rb_bug("could not format dynamic description string");
}
rb_dynamic_description = ruby_dynamic_description_buffer;

/*
* The full ruby version string, like <tt>ruby -v</tt> prints
*/
rb_define_global_const("RUBY_DESCRIPTION", /* MKSTR(description) */ description);
rb_define_global_const("RUBY_DESCRIPTION", rb_obj_freeze(rb_str_new2(rb_dynamic_description)));
}

void
Expand Down
13 changes: 7 additions & 6 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@
# define RUBY_RELEASE_DATETIME RUBY_RELEASE_DATE
#endif

# define RUBY_DESCRIPTION_WITH(opt) \
"ruby "RUBY_VERSION \
RUBY_PATCHLEVEL_STR \
" ("RUBY_RELEASE_DATETIME \
RUBY_REVISION_STR")"opt" " \
"["RUBY_PLATFORM"]"
# define RUBY_DESCRIPTION_PRE \
"ruby "RUBY_VERSION \
RUBY_PATCHLEVEL_STR \
" ("RUBY_RELEASE_DATETIME \
RUBY_REVISION_STR")"
# define RUBY_DESCRIPTION_POST \
" ["RUBY_PLATFORM"]"
# define RUBY_COPYRIGHT \
"ruby - Copyright (C) " \
RUBY_BIRTH_YEAR_STR"-" \
Expand Down