imemo_mask (enum) -> IMEMO_MASK (immediate value).

* internal.h: imemo_mask is not a valid imemo type but
  switch statements show warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-21 10:21:31 +00:00
parent 49ce3ca374
commit 2ab99609e0
3 changed files with 6 additions and 8 deletions

View File

@ -554,7 +554,7 @@ count_tdata_objects(int argc, VALUE *argv, VALUE self)
return hash; return hash;
} }
static ID imemo_type_ids[imemo_mask+1]; static ID imemo_type_ids[IMEMO_MASK+1];
static int static int
count_imemo_objects_i(void *vstart, void *vend, size_t stride, void *data) count_imemo_objects_i(void *vstart, void *vend, size_t stride, void *data)

4
gc.c
View File

@ -4539,7 +4539,6 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
} while ((m = m->next) != NULL); } while ((m = m->next) != NULL);
} }
return; return;
case imemo_mask: break;
#if VM_CHECK_MODE > 0 #if VM_CHECK_MODE > 0
default: default:
VM_UNREACHABLE(gc_mark_imemo); VM_UNREACHABLE(gc_mark_imemo);
@ -9367,7 +9366,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
break; break;
} }
case T_IMEMO: { case T_IMEMO: {
const char *imemo_name; const char *imemo_name = NULL;
switch (imemo_type(obj)) { switch (imemo_type(obj)) {
#define IMEMO_NAME(x) case imemo_##x: imemo_name = #x; break; #define IMEMO_NAME(x) case imemo_##x: imemo_name = #x; break;
IMEMO_NAME(env); IMEMO_NAME(env);
@ -9380,7 +9379,6 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
IMEMO_NAME(iseq); IMEMO_NAME(iseq);
IMEMO_NAME(alloc); IMEMO_NAME(alloc);
#undef IMEMO_NAME #undef IMEMO_NAME
case imemo_mask: break;
} }
snprintf(buff, buff_size, "%s %s", buff, imemo_name); snprintf(buff, buff_size, "%s %s", buff, imemo_name);

View File

@ -844,14 +844,14 @@ enum imemo_type {
imemo_memo = 5, imemo_memo = 5,
imemo_ment = 6, imemo_ment = 6,
imemo_iseq = 7, imemo_iseq = 7,
imemo_alloc = 8, imemo_alloc = 8
imemo_mask = 0x0f
}; };
#define IMEMO_MASK 0x0f
static inline enum imemo_type static inline enum imemo_type
imemo_type(VALUE imemo) imemo_type(VALUE imemo)
{ {
return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask; return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
} }
static inline int static inline int
@ -859,7 +859,7 @@ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
{ {
if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) { if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
/* fixed at compile time if imemo_type is given. */ /* fixed at compile time if imemo_type is given. */
const VALUE mask = (imemo_mask << FL_USHIFT) | RUBY_T_MASK; const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO; const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
/* fixed at runtime. */ /* fixed at runtime. */
return expected_type == (RBASIC(imemo)->flags & mask); return expected_type == (RBASIC(imemo)->flags & mask);