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 /proc.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 'proc.c')
-rw-r--r-- | proc.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -448,11 +448,11 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid) VM_ASSERT(rb_obj_is_iseq((VALUE)iseq)); - for (i=0; i<iseq->body->local_table_size; i++) { - if (iseq->body->local_table[i] == lid) { - if (iseq->body->local_iseq == iseq && - iseq->body->param.flags.has_block && - (unsigned int)iseq->body->param.block_start == i) { + for (i=0; i<ISEQ_BODY(iseq)->local_table_size; i++) { + if (ISEQ_BODY(iseq)->local_table[i] == lid) { + if (ISEQ_BODY(iseq)->local_iseq == iseq && + ISEQ_BODY(iseq)->param.flags.has_block && + (unsigned int)ISEQ_BODY(iseq)->param.block_start == i) { const VALUE *ep = env->ep; if (!VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)) { RB_OBJ_WRITE(env, &env->env[i], rb_vm_bh_to_procval(GET_EC(), VM_ENV_BLOCK_HANDLER(ep))); @@ -1078,11 +1078,11 @@ proc_arity(VALUE self) static inline int rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max) { - *max = iseq->body->param.flags.has_rest == FALSE ? - iseq->body->param.lead_num + iseq->body->param.opt_num + iseq->body->param.post_num + - (iseq->body->param.flags.has_kw == TRUE || iseq->body->param.flags.has_kwrest == TRUE) + *max = ISEQ_BODY(iseq)->param.flags.has_rest == FALSE ? + ISEQ_BODY(iseq)->param.lead_num + ISEQ_BODY(iseq)->param.opt_num + ISEQ_BODY(iseq)->param.post_num + + (ISEQ_BODY(iseq)->param.flags.has_kw == TRUE || ISEQ_BODY(iseq)->param.flags.has_kwrest == TRUE) : UNLIMITED_ARGUMENTS; - return iseq->body->param.lead_num + iseq->body->param.post_num + (iseq->body->param.flags.has_kw && iseq->body->param.keyword->required_num > 0); + return ISEQ_BODY(iseq)->param.lead_num + ISEQ_BODY(iseq)->param.post_num + (ISEQ_BODY(iseq)->param.flags.has_kw && ISEQ_BODY(iseq)->param.keyword->required_num > 0); } static int @@ -1369,7 +1369,7 @@ iseq_location(const rb_iseq_t *iseq) if (!iseq) return Qnil; rb_iseq_check(iseq); loc[0] = rb_iseq_path(iseq); - loc[1] = iseq->body->location.first_lineno; + loc[1] = ISEQ_BODY(iseq)->location.first_lineno; return rb_ary_new4(2, loc); } @@ -1535,7 +1535,7 @@ rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_i const rb_iseq_t *iseq = rb_iseq_check(block->as.captured.code.iseq); rb_str_catf(str, "%p %"PRIsVALUE":%d", (void *)self, rb_iseq_path(iseq), - FIX2INT(iseq->body->location.first_lineno)); + FIX2INT(ISEQ_BODY(iseq)->location.first_lineno)); } break; case block_type_symbol: @@ -3503,7 +3503,7 @@ proc_binding(VALUE self) if (iseq) { rb_iseq_check(iseq); - RB_OBJ_WRITE(bindval, &bind->pathobj, iseq->body->location.pathobj); + RB_OBJ_WRITE(bindval, &bind->pathobj, ISEQ_BODY(iseq)->location.pathobj); bind->first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); } else { @@ -3889,10 +3889,10 @@ proc_ruby2_keywords(VALUE procval) switch (proc->block.type) { case block_type_iseq: - if (proc->block.as.captured.code.iseq->body->param.flags.has_rest && - !proc->block.as.captured.code.iseq->body->param.flags.has_kw && - !proc->block.as.captured.code.iseq->body->param.flags.has_kwrest) { - proc->block.as.captured.code.iseq->body->param.flags.ruby2_keywords = 1; + if (ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_rest && + !ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_kw && + !ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.has_kwrest) { + ISEQ_BODY(proc->block.as.captured.code.iseq)->param.flags.ruby2_keywords = 1; } else { rb_warn("Skipping set of ruby2_keywords flag for proc (proc accepts keywords or proc does not accept argument splat)"); |