diff options
author | Peter Zhu <[email protected]> | 2022-03-23 15:19:48 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-03-24 10:03:51 -0400 |
commit | 5f10bd634fb6ae8f74a4ea730176233b0ca96954 (patch) | |
tree | 170c1c81ea63184290c9e021cc45bffbfc3f4f41 /vm_method.c | |
parent | 04591e1be7618f64bd3bed8c53c0fcde5fcbddb8 (diff) |
Add ISEQ_BODY macro
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using
this macro will make it easier for us to change the allocation strategy
of rb_iseq_constant_body when using Variable Width Allocation.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5698
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/vm_method.c b/vm_method.c index 0400aab801..03d2ed09d1 100644 --- a/vm_method.c +++ b/vm_method.c @@ -496,7 +496,7 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de /* setup iseq first (before invoking GC) */ RB_OBJ_WRITE(me, &def->body.iseq.iseqptr, iseq); - if (iseq->body->mandatory_only_iseq) def->iseq_overload = 1; + if (ISEQ_BODY(iseq)->mandatory_only_iseq) def->iseq_overload = 1; if (0) vm_cref_dump("rb_method_definition_create", cref); @@ -889,7 +889,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil } if (iseq) { rb_compile_warning(RSTRING_PTR(rb_iseq_path(iseq)), - FIX2INT(iseq->body->location.first_lineno), + FIX2INT(ISEQ_BODY(iseq)->location.first_lineno), "previous definition of %"PRIsVALUE" was here", rb_id2str(old_def->original_id)); } @@ -1020,7 +1020,7 @@ get_overloaded_cme(const rb_callable_method_entry_t *cme) // create rb_method_definition_t *def = rb_method_definition_create(VM_METHOD_TYPE_ISEQ, cme->def->original_id); def->body.iseq.cref = cme->def->body.iseq.cref; - def->body.iseq.iseqptr = cme->def->body.iseq.iseqptr->body->mandatory_only_iseq; + def->body.iseq.iseqptr = ISEQ_BODY(cme->def->body.iseq.iseqptr)->mandatory_only_iseq; rb_method_entry_t *me = rb_method_entry_alloc(cme->called_id, cme->owner, @@ -1040,7 +1040,7 @@ check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_call { if (UNLIKELY(cme->def->iseq_overload) && (vm_ci_flag(ci) & (VM_CALL_ARGS_SIMPLE)) && - (int)vm_ci_argc(ci) == method_entry_iseqptr(cme)->body->param.lead_num) { + (int)vm_ci_argc(ci) == ISEQ_BODY(method_entry_iseqptr(cme))->param.lead_num) { VM_ASSERT(cme->def->type == VM_METHOD_TYPE_ISEQ); // iseq_overload is marked only on ISEQ methods cme = get_overloaded_cme(cme); @@ -1675,7 +1675,7 @@ scope_visibility_check(void) { /* Check for public/protected/private/module_function called inside a method */ rb_control_frame_t *cfp = GET_EC()->cfp+1; - if (cfp && cfp->iseq && cfp->iseq->body->type == ISEQ_TYPE_METHOD) { + if (cfp && cfp->iseq && ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_METHOD) { rb_warn("calling %s without arguments inside a method may not have the intended effect", rb_id2name(rb_frame_this_func())); } @@ -2416,10 +2416,10 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module) if (module == defined_class || origin_class == defined_class) { switch (me->def->type) { case VM_METHOD_TYPE_ISEQ: - if (me->def->body.iseq.iseqptr->body->param.flags.has_rest && - !me->def->body.iseq.iseqptr->body->param.flags.has_kw && - !me->def->body.iseq.iseqptr->body->param.flags.has_kwrest) { - me->def->body.iseq.iseqptr->body->param.flags.ruby2_keywords = 1; + if (ISEQ_BODY(me->def->body.iseq.iseqptr)->param.flags.has_rest && + !ISEQ_BODY(me->def->body.iseq.iseqptr)->param.flags.has_kw && + !ISEQ_BODY(me->def->body.iseq.iseqptr)->param.flags.has_kwrest) { + ISEQ_BODY(me->def->body.iseq.iseqptr)->param.flags.ruby2_keywords = 1; rb_clear_method_cache(module, name); } else { @@ -2435,10 +2435,10 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module) if (vm_block_handler_type(procval) == block_handler_type_iseq) { const struct rb_captured_block *captured = VM_BH_TO_ISEQ_BLOCK(procval); const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq); - if (iseq->body->param.flags.has_rest && - !iseq->body->param.flags.has_kw && - !iseq->body->param.flags.has_kwrest) { - iseq->body->param.flags.ruby2_keywords = 1; + if (ISEQ_BODY(iseq)->param.flags.has_rest && + !ISEQ_BODY(iseq)->param.flags.has_kw && + !ISEQ_BODY(iseq)->param.flags.has_kwrest) { + ISEQ_BODY(iseq)->param.flags.ruby2_keywords = 1; rb_clear_method_cache(module, name); } else { |