summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-07-09 18:37:03 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2020-07-10 22:42:35 -0400
commitcbf52087a2d4ac3c2db698ddc5b0b023f6bb2eca (patch)
tree842ed5b35d025abc47e54f47c54d7ead80397b1b /gc.c
parent021cec938af55a7ef368eadc99a6e3ff2252510e (diff)
Fix missing imemo cases in objspace_dump by refactoring
imemo_callcache and imemo_callinfo were not handled by the `objspace` module and were showing up as "unknown" in the dump. Extract the code for naming imemos and use that in both the GC and the `objspace` module.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3304
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/gc.c b/gc.c
index 1e3b6c279d..9baddb969d 100644
--- a/gc.c
+++ b/gc.c
@@ -2256,6 +2256,30 @@ rb_newobj_of(VALUE klass, VALUE flags)
rb_bug(#func"(): GC does not handle T_NODE 0x%x(%p) 0x%"PRIxVALUE, \
BUILTIN_TYPE(obj), (void*)(obj), RBASIC(obj)->flags)
+const char *
+rb_imemo_name(enum imemo_type type)
+{
+ // put no default case to get a warning if an imemo type is missing
+ switch (type) {
+#define IMEMO_NAME(x) case imemo_##x: return #x;
+ IMEMO_NAME(env);
+ IMEMO_NAME(cref);
+ IMEMO_NAME(svar);
+ IMEMO_NAME(throw_data);
+ IMEMO_NAME(ifunc);
+ IMEMO_NAME(memo);
+ IMEMO_NAME(ment);
+ IMEMO_NAME(iseq);
+ IMEMO_NAME(tmpbuf);
+ IMEMO_NAME(ast);
+ IMEMO_NAME(parser_strterm);
+ IMEMO_NAME(callinfo);
+ IMEMO_NAME(callcache);
+#undef IMEMO_NAME
+ }
+ return "unknown";
+}
+
#undef rb_imemo_new
VALUE
@@ -11662,26 +11686,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
break;
}
case T_IMEMO: {
- const char *imemo_name = "\0";
- switch (imemo_type(obj)) {
-#define IMEMO_NAME(x) case imemo_##x: imemo_name = #x; break;
- IMEMO_NAME(env);
- IMEMO_NAME(cref);
- IMEMO_NAME(svar);
- IMEMO_NAME(throw_data);
- IMEMO_NAME(ifunc);
- IMEMO_NAME(memo);
- IMEMO_NAME(ment);
- IMEMO_NAME(iseq);
- IMEMO_NAME(tmpbuf);
- IMEMO_NAME(ast);
- IMEMO_NAME(parser_strterm);
- IMEMO_NAME(callinfo);
- IMEMO_NAME(callcache);
-#undef IMEMO_NAME
- default: UNREACHABLE;
- }
- APPENDF((BUFF_ARGS, "<%s> ", imemo_name));
+ APPENDF((BUFF_ARGS, "<%s> ", rb_imemo_name(imemo_type(obj))));
switch (imemo_type(obj)) {
case imemo_ment: {