summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-03-23 15:19:48 -0400
committerPeter Zhu <peter@peterzhu.ca>2022-03-24 10:03:51 -0400
commit5f10bd634fb6ae8f74a4ea730176233b0ca96954 (patch)
tree170c1c81ea63184290c9e021cc45bffbfc3f4f41 /compile.c
parent04591e1be7618f64bd3bed8c53c0fcde5fcbddb8 (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 'compile.c')
-rw-r--r--compile.c334
1 files changed, 166 insertions, 168 deletions
diff --git a/compile.c b/compile.c
index cd3f0e2a9d..67641fcfb6 100644
--- a/compile.c
+++ b/compile.c
@@ -534,11 +534,9 @@ static void
verify_call_cache(rb_iseq_t *iseq)
{
#if CPDEBUG
- // fprintf(stderr, "ci_size:%d\t", iseq->body->ci_size); rp(iseq);
-
VALUE *original = rb_iseq_original_iseq(iseq);
size_t i = 0;
- while (i < iseq->body->iseq_size) {
+ while (i < ISEQ_BODY(iseq)->iseq_size) {
VALUE insn = original[i];
const char *types = insn_op_types(insn);
@@ -556,8 +554,8 @@ verify_call_cache(rb_iseq_t *iseq)
i += insn_len(insn);
}
- for (unsigned int i=0; i<iseq->body->ci_size; i++) {
- struct rb_call_data *cd = &iseq->body->call_data[i];
+ for (unsigned int i=0; i<ISEQ_BODY(iseq)->ci_size; i++) {
+ struct rb_call_data *cd = &ISEQ_BODY(iseq)->call_data[i];
const struct rb_callinfo *ci = cd->ci;
const struct rb_callcache *cc = cd->cc;
if (cc != NULL && cc != vm_cc_empty()) {
@@ -758,7 +756,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
iseq_set_local_table(iseq, node->nd_tbl);
iseq_set_arguments(iseq, ret, node->nd_args);
- switch (iseq->body->type) {
+ switch (ISEQ_BODY(iseq)->type) {
case ISEQ_TYPE_BLOCK:
{
LABEL *start = ISEQ_COMPILE_DATA(iseq)->start_label = NEW_LABEL(0);
@@ -768,13 +766,13 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
end->rescued = LABEL_RESCUE_END;
ADD_TRACE(ret, RUBY_EVENT_B_CALL);
- NODE dummy_line_node = generate_dummy_line_node(FIX2INT(iseq->body->location.first_lineno), -1);
+ NODE dummy_line_node = generate_dummy_line_node(FIX2INT(ISEQ_BODY(iseq)->location.first_lineno), -1);
ADD_INSN (ret, &dummy_line_node, nop);
ADD_LABEL(ret, start);
CHECK(COMPILE(ret, "block body", node->nd_body));
ADD_LABEL(ret, end);
ADD_TRACE(ret, RUBY_EVENT_B_RETURN);
- ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_location.end_pos.lineno;
+ ISEQ_COMPILE_DATA(iseq)->last_line = ISEQ_BODY(iseq)->location.code_location.end_pos.lineno;
/* wide range catch handler must put at last */
ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, NULL, start);
@@ -809,7 +807,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
const char *m;
#define INVALID_ISEQ_TYPE(type) \
ISEQ_TYPE_##type: m = #type; goto invalid_iseq_type
- switch (iseq->body->type) {
+ switch (ISEQ_BODY(iseq)->type) {
case INVALID_ISEQ_TYPE(METHOD);
case INVALID_ISEQ_TYPE(CLASS);
case INVALID_ISEQ_TYPE(BLOCK);
@@ -829,7 +827,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
CHECK(COMPILE(ret, "ensure", node));
break;
default:
- COMPILE_ERROR(ERROR_ARGS "unknown scope: %d", iseq->body->type);
+ COMPILE_ERROR(ERROR_ARGS "unknown scope: %d", ISEQ_BODY(iseq)->type);
return COMPILE_NG;
invalid_iseq_type:
COMPILE_ERROR(ERROR_ARGS "compile/ISEQ_TYPE_%s should not be reached", m);
@@ -837,7 +835,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
}
}
- if (iseq->body->type == ISEQ_TYPE_RESCUE || iseq->body->type == ISEQ_TYPE_ENSURE) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_RESCUE || ISEQ_BODY(iseq)->type == ISEQ_TYPE_ENSURE) {
NODE dummy_line_node = generate_dummy_line_node(0, -1);
ADD_GETLOCAL(ret, &dummy_line_node, LVAR_ERRINFO, 0);
ADD_INSN1(ret, &dummy_line_node, throw, INT2FIX(0) /* continue throw */ );
@@ -864,10 +862,10 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
const void * const *table = rb_vm_get_insns_address_table();
unsigned int i;
- VALUE *encoded = (VALUE *)iseq->body->iseq_encoded;
+ VALUE *encoded = (VALUE *)ISEQ_BODY(iseq)->iseq_encoded;
- for (i = 0; i < iseq->body->iseq_size; /* */ ) {
- int insn = (int)iseq->body->iseq_encoded[i];
+ for (i = 0; i < ISEQ_BODY(iseq)->iseq_size; /* */ ) {
+ int insn = (int)ISEQ_BODY(iseq)->iseq_encoded[i];
int len = insn_len(insn);
encoded[i] = (VALUE)table[insn];
i += len;
@@ -883,14 +881,14 @@ rb_iseq_original_iseq(const rb_iseq_t *iseq) /* cold path */
VALUE *original_code;
if (ISEQ_ORIGINAL_ISEQ(iseq)) return ISEQ_ORIGINAL_ISEQ(iseq);
- original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, iseq->body->iseq_size);
- MEMCPY(original_code, iseq->body->iseq_encoded, VALUE, iseq->body->iseq_size);
+ original_code = ISEQ_ORIGINAL_ISEQ_ALLOC(iseq, ISEQ_BODY(iseq)->iseq_size);
+ MEMCPY(original_code, ISEQ_BODY(iseq)->iseq_encoded, VALUE, ISEQ_BODY(iseq)->iseq_size);
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
{
unsigned int i;
- for (i = 0; i < iseq->body->iseq_size; /* */ ) {
+ for (i = 0; i < ISEQ_BODY(iseq)->iseq_size; /* */ ) {
const void *addr = (const void *)original_code[i];
const int insn = rb_vm_insn_addr2insn(addr);
@@ -1298,8 +1296,7 @@ new_callinfo(rb_iseq_t *iseq, ID mid, int argc, unsigned int flag, struct rb_cal
argc += kw_arg->keyword_len;
}
- // fprintf(stderr, "[%d] id:%s\t", (int)iseq->body->ci_size, rb_id2name(mid)); rp(iseq);
- iseq->body->ci_size++;
+ ISEQ_BODY(iseq)->ci_size++;
const struct rb_callinfo *ci = vm_ci_new(mid, flag, argc, kw_arg);
RB_OBJ_WRITTEN(iseq, Qundef, ci);
return ci;
@@ -1330,7 +1327,7 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
ast.root = node;
ast.compile_option = 0;
- ast.script_lines = iseq->body->variable.script_lines;
+ ast.script_lines = ISEQ_BODY(iseq)->variable.script_lines;
debugs("[new_child_iseq]> ---------------------------------------\n");
int isolated_depth = ISEQ_COMPILE_DATA(iseq)->isolated_depth;
@@ -1362,7 +1359,7 @@ set_catch_except_p(struct rb_iseq_constant_body *body)
{
body->catch_except_p = TRUE;
if (body->parent_iseq != NULL) {
- set_catch_except_p(body->parent_iseq->body);
+ set_catch_except_p(ISEQ_BODY(body->parent_iseq));
}
}
@@ -1499,16 +1496,16 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (!rb_iseq_translate_threaded_code(iseq)) return COMPILE_NG;
debugs("[compile step 6 (update_catch_except_flags)] \n");
- update_catch_except_flags(iseq->body);
+ update_catch_except_flags(ISEQ_BODY(iseq));
debugs("[compile step 6.1 (remove unused catch tables)] \n");
- if (!iseq->body->catch_except_p && iseq->body->catch_table) {
- xfree(iseq->body->catch_table);
- iseq->body->catch_table = NULL;
+ if (!ISEQ_BODY(iseq)->catch_except_p && ISEQ_BODY(iseq)->catch_table) {
+ xfree(ISEQ_BODY(iseq)->catch_table);
+ ISEQ_BODY(iseq)->catch_table = NULL;
}
#if VM_INSN_INFO_TABLE_IMPL == 2
- if (iseq->body->insns_info.succ_index_table == NULL) {
+ if (ISEQ_BODY(iseq)->insns_info.succ_index_table == NULL) {
debugs("[compile step 7 (rb_iseq_insns_info_encode_positions)] \n");
rb_iseq_insns_info_encode_positions(iseq);
}
@@ -1527,8 +1524,8 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
static int
iseq_set_exception_local_table(rb_iseq_t *iseq)
{
- iseq->body->local_table_size = numberof(rb_iseq_shared_exc_local_tbl);
- iseq->body->local_table = rb_iseq_shared_exc_local_tbl;
+ ISEQ_BODY(iseq)->local_table_size = numberof(rb_iseq_shared_exc_local_tbl);
+ ISEQ_BODY(iseq)->local_table = rb_iseq_shared_exc_local_tbl;
return COMPILE_OK;
}
@@ -1536,9 +1533,9 @@ static int
get_lvar_level(const rb_iseq_t *iseq)
{
int lev = 0;
- while (iseq != iseq->body->local_iseq) {
+ while (iseq != ISEQ_BODY(iseq)->local_iseq) {
lev++;
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
}
return lev;
}
@@ -1548,8 +1545,8 @@ get_dyna_var_idx_at_raw(const rb_iseq_t *iseq, ID id)
{
unsigned int i;
- for (i = 0; i < iseq->body->local_table_size; i++) {
- if (iseq->body->local_table[i] == id) {
+ for (i = 0; i < ISEQ_BODY(iseq)->local_table_size; i++) {
+ if (ISEQ_BODY(iseq)->local_table[i] == id) {
return (int)i;
}
}
@@ -1559,7 +1556,7 @@ get_dyna_var_idx_at_raw(const rb_iseq_t *iseq, ID id)
static int
get_local_var_idx(const rb_iseq_t *iseq, ID id)
{
- int idx = get_dyna_var_idx_at_raw(iseq->body->local_iseq, id);
+ int idx = get_dyna_var_idx_at_raw(ISEQ_BODY(iseq)->local_iseq, id);
if (idx < 0) {
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq),
@@ -1580,7 +1577,7 @@ get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
if (idx >= 0) {
break;
}
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
lv++;
}
@@ -1590,7 +1587,7 @@ get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
}
*level = lv;
- *ls = iseq->body->local_table_size;
+ *ls = ISEQ_BODY(iseq)->local_table_size;
return idx;
}
@@ -1599,10 +1596,10 @@ iseq_local_block_param_p(const rb_iseq_t *iseq, unsigned int idx, unsigned int l
{
const struct rb_iseq_constant_body *body;
while (level > 0) {
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
level--;
}
- body = iseq->body;
+ body = ISEQ_BODY(iseq);
if (body->local_iseq == iseq && /* local variables */
body->param.flags.has_block &&
body->local_table_size - body->param.block_start == idx) {
@@ -1644,22 +1641,22 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write)
for (int i=0; i<level; i++) {
VALUE val;
- struct rb_id_table *ovs = iseq->body->outer_variables;
+ struct rb_id_table *ovs = ISEQ_BODY(iseq)->outer_variables;
if (!ovs) {
- ovs = iseq->body->outer_variables = rb_id_table_create(8);
+ ovs = ISEQ_BODY(iseq)->outer_variables = rb_id_table_create(8);
}
- if (rb_id_table_lookup(iseq->body->outer_variables, id, &val)) {
+ if (rb_id_table_lookup(ISEQ_BODY(iseq)->outer_variables, id, &val)) {
if (write && !val) {
- rb_id_table_insert(iseq->body->outer_variables, id, Qtrue);
+ rb_id_table_insert(ISEQ_BODY(iseq)->outer_variables, id, Qtrue);
}
}
else {
- rb_id_table_insert(iseq->body->outer_variables, id, RBOOL(write));
+ rb_id_table_insert(ISEQ_BODY(iseq)->outer_variables, id, RBOOL(write));
}
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
}
}
@@ -1667,10 +1664,10 @@ static ID
iseq_lvar_id(const rb_iseq_t *iseq, int idx, int level)
{
for (int i=0; i<level; i++) {
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
}
- ID id = iseq->body->local_table[iseq->body->local_table_size - idx];
+ ID id = ISEQ_BODY(iseq)->local_table[ISEQ_BODY(iseq)->local_table_size - idx];
// fprintf(stderr, "idx:%d level:%d ID:%s\n", idx, level, rb_id2name(id));
return id;
}
@@ -1704,7 +1701,7 @@ iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *const lin
static void
iseq_calc_param_size(rb_iseq_t *iseq)
{
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
if (body->param.flags.has_opt ||
body->param.flags.has_post ||
body->param.flags.has_rest ||
@@ -1744,7 +1741,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
const struct rb_args_info *args, int arg_size)
{
const NODE *node = args->kw_args;
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
struct rb_iseq_param_keyword *keyword;
const VALUE default_values = rb_ary_tmp_new(1);
const VALUE complex_mark = rb_str_tmp_new(0);
@@ -1826,7 +1823,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
debugs("iseq_set_arguments: %s\n", node_args ? "" : "0");
if (node_args) {
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
struct rb_args_info *args = node_args->nd_ainfo;
ID rest_id = 0;
int last_comma = 0;
@@ -1953,11 +1950,11 @@ iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl)
if (size > 0) {
ID *ids = (ID *)ALLOC_N(ID, size);
MEMCPY(ids, tbl->ids, ID, size);
- iseq->body->local_table = ids;
+ ISEQ_BODY(iseq)->local_table = ids;
}
- iseq->body->local_table_size = size;
+ ISEQ_BODY(iseq)->local_table_size = size;
- debugs("iseq_set_local_table: %u\n", iseq->body->local_table_size);
+ debugs("iseq_set_local_table: %u\n", ISEQ_BODY(iseq)->local_table_size);
return COMPILE_OK;
}
@@ -2072,7 +2069,7 @@ get_ivar_ic_value(rb_iseq_t *iseq,ID id)
tbl = rb_id_table_create(1);
ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = tbl;
}
- val = INT2FIX(iseq->body->is_size++);
+ val = INT2FIX(ISEQ_BODY(iseq)->is_size++);
rb_id_table_insert(tbl,id,val);
return val;
}
@@ -2247,7 +2244,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
{
VALUE iseqv = (VALUE)iseq;
struct iseq_insn_info_entry *insns_info;
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
unsigned int *positions;
LINK_ELEMENT *list;
VALUE *generated_iseq;
@@ -2543,7 +2540,7 @@ iseq_set_exception_table(rb_iseq_t *iseq)
unsigned int tlen, i;
struct iseq_catch_table_entry *entry;
- iseq->body->catch_table = NULL;
+ ISEQ_BODY(iseq)->catch_table = NULL;
if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) return COMPILE_OK;
tlen = (int)RARRAY_LEN(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
tptr = RARRAY_CONST_PTR_TRANSIENT(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
@@ -2578,7 +2575,7 @@ iseq_set_exception_table(rb_iseq_t *iseq)
entry->cont = 0;
}
}
- iseq->body->catch_table = table;
+ ISEQ_BODY(iseq)->catch_table = table;
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, 0); /* free */
}
@@ -2598,10 +2595,10 @@ static int
iseq_set_optargs_table(rb_iseq_t *iseq)
{
int i;
- VALUE *opt_table = (VALUE *)iseq->body->param.opt_table;
+ VALUE *opt_table = (VALUE *)ISEQ_BODY(iseq)->param.opt_table;
- if (iseq->body->param.flags.has_opt) {
- for (i = 0; i < iseq->body->param.opt_num + 1; i++) {
+ if (ISEQ_BODY(iseq)->param.flags.has_opt) {
+ for (i = 0; i < ISEQ_BODY(iseq)->param.opt_num + 1; i++) {
opt_table[i] = label_get_position((LABEL *)opt_table[i]);
}
}
@@ -2745,7 +2742,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
i = first;
do {
if (IS_INSN(i)) {
- struct rb_iseq_constant_body *body = iseq->body;
+ struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
VALUE insn = INSN_OF(i);
int pos, len = insn_len(insn);
for (pos = 0; pos < len; ++pos) {
@@ -3555,7 +3552,7 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
static inline int
tailcallable_p(rb_iseq_t *iseq)
{
- switch (iseq->body->type) {
+ switch (ISEQ_BODY(iseq)->type) {
case ISEQ_TYPE_TOP:
case ISEQ_TYPE_EVAL:
case ISEQ_TYPE_MAIN:
@@ -3585,7 +3582,7 @@ iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
int do_block_optimization = 0;
- if (iseq->body->type == ISEQ_TYPE_BLOCK && !iseq->body->catch_except_p) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK && !ISEQ_BODY(iseq)->catch_except_p) {
do_block_optimization = 1;
}
@@ -3997,7 +3994,7 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
{
const int line = nd_line(node);
LABEL *lend = NEW_LABEL(line);
- rb_num_t cnt = ISEQ_FLIP_CNT_INCREMENT(iseq->body->local_iseq)
+ rb_num_t cnt = ISEQ_FLIP_CNT_INCREMENT(ISEQ_BODY(iseq)->local_iseq)
+ VM_SVAR_FLIPFLOP_START;
VALUE key = INT2FIX(cnt);
@@ -5396,9 +5393,9 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
struct rb_iseq_new_with_callback_callback_func *ifunc =
rb_iseq_new_with_callback_new_callback(build_defined_rescue_iseq, NULL);
rescue = new_child_iseq_with_callback(iseq, ifunc,
- rb_str_concat(rb_str_new2("defined guard in "),
- iseq->body->location.label),
- iseq, ISEQ_TYPE_RESCUE, 0);
+ rb_str_concat(rb_str_new2("defined guard in "),
+ ISEQ_BODY(iseq)->location.label),
+ iseq, ISEQ_TYPE_RESCUE, 0);
lstart->rescued = LABEL_RESCUE_BEG;
lend->rescued = LABEL_RESCUE_END;
APPEND_LABEL(ret, lcur, lstart);
@@ -5443,20 +5440,20 @@ make_name_for_block(const rb_iseq_t *orig_iseq)
int level = 1;
const rb_iseq_t *iseq = orig_iseq;
- if (orig_iseq->body->parent_iseq != 0) {
- while (orig_iseq->body->local_iseq != iseq) {
- if (iseq->body->type == ISEQ_TYPE_BLOCK) {
+ if (ISEQ_BODY(orig_iseq)->parent_iseq != 0) {
+ while (ISEQ_BODY(orig_iseq)->local_iseq != iseq) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK) {
level++;
}
- iseq = iseq->body->parent_iseq;
+ iseq = ISEQ_BODY(iseq)->parent_iseq;
}
}
if (level == 1) {
- return rb_sprintf("block in %"PRIsVALUE, iseq->body->location.label);
+ return rb_sprintf("block in %"PRIsVALUE, ISEQ_BODY(iseq)->location.label);
}
else {
- return rb_sprintf("block (%d levels) in %"PRIsVALUE, level, iseq->body->location.label);
+ return rb_sprintf("block (%d levels) in %"PRIsVALUE, level, ISEQ_BODY(iseq)->location.label);
}
}
@@ -5652,7 +5649,7 @@ build_postexe_iseq(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *ptr)
const NODE *body = ptr;
int line = nd_line(body);
VALUE argc = INT2FIX(0);
- const rb_iseq_t *block = NEW_CHILD_ISEQ(body, make_name_for_block(iseq->body->parent_iseq), ISEQ_TYPE_BLOCK, line);
+ const rb_iseq_t *block = NEW_CHILD_ISEQ(body, make_name_for_block(ISEQ_BODY(iseq)->parent_iseq), ISEQ_TYPE_BLOCK, line);
ADD_INSN1(ret, body, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_CALL_WITH_BLOCK(ret, body, id_core_set_postexe, argc, block);
@@ -5737,7 +5734,7 @@ optimizable_range_item_p(const NODE *n)
static int
compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
const NODE *const node_body = type == NODE_IF ? node->nd_body : node->nd_else;
const NODE *const node_else = type == NODE_IF ? node->nd_else : node->nd_body;
@@ -6607,9 +6604,9 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSNL(ret, line_node, jump, unmatched);
break;
case NODE_LASGN: {
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
ID id = node->nd_vid;
- int idx = body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
+ int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
if (in_alt_pattern) {
const char *name = rb_id2name(id);
@@ -7298,15 +7295,15 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
throw_flag = VM_THROW_NO_ESCAPE_FLAG;
}
- else if (ip->body->type == ISEQ_TYPE_BLOCK) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
throw_flag = 0;
}
- else if (ip->body->type == ISEQ_TYPE_EVAL) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
COMPILE_ERROR(ERROR_ARGS "Can't escape from eval with break");
return COMPILE_NG;
}
else {
- ip = ip->body->parent_iseq;
+ ip = ISEQ_BODY(ip)->parent_iseq;
continue;
}
@@ -7372,15 +7369,15 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
/* while loop */
break;
}
- else if (ip->body->type == ISEQ_TYPE_BLOCK) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
break;
}
- else if (ip->body->type == ISEQ_TYPE_EVAL) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
COMPILE_ERROR(ERROR_ARGS "Can't escape from eval with next");
return COMPILE_NG;
}
- ip = ip->body->parent_iseq;
+ ip = ISEQ_BODY(ip)->parent_iseq;
}
if (ip != 0) {
CHECK(COMPILE(ret, "next val", node->nd_stts));
@@ -7415,7 +7412,7 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ADD_INSN(ret, line_node, putnil);
}
}
- else if (iseq->body->type != ISEQ_TYPE_EVAL && ISEQ_COMPILE_DATA(iseq)->start_label && can_add_ensure_iseq(iseq)) {
+ else if (ISEQ_BODY(iseq)->type != ISEQ_TYPE_EVAL && ISEQ_COMPILE_DATA(iseq)->start_label && can_add_ensure_iseq(iseq)) {
LABEL *splabel = NEW_LABEL(0);
debugs("redo in block");
@@ -7441,15 +7438,15 @@ compile_redo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
if (ISEQ_COMPILE_DATA(ip)->redo_label != 0) {
break;
}
- else if (ip->body->type == ISEQ_TYPE_BLOCK) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_BLOCK) {
break;
}
- else if (ip->body->type == ISEQ_TYPE_EVAL) {
+ else if (ISEQ_BODY(ip)->type == ISEQ_TYPE_EVAL) {
COMPILE_ERROR(ERROR_ARGS "Can't escape from eval with redo");
return COMPILE_NG;
}
- ip = ip->body->parent_iseq;
+ ip = ISEQ_BODY(ip)->parent_iseq;
}
if (ip != 0) {
ADD_INSN(ret, line_node, putnil);
@@ -7472,7 +7469,7 @@ compile_retry(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
{
const NODE *line_node = node;
- if (iseq->body->type == ISEQ_TYPE_RESCUE) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_RESCUE) {
ADD_INSN(ret, line_node, putnil);
ADD_INSN1(ret, line_node, throw, INT2FIX(TAG_RETRY));
@@ -7496,8 +7493,9 @@ compile_rescue(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
LABEL *lend = NEW_LABEL(line);
LABEL *lcont = NEW_LABEL(line);
const rb_iseq_t *rescue = NEW_CHILD_ISEQ(node->nd_resq,
- rb_str_concat(rb_str_new2("rescue in "), iseq->body->location.label),
- ISEQ_TYPE_RESCUE, line);
+ rb_str_concat(rb_str_new2("rescue in "),
+ ISEQ_BODY(iseq)->location.label),
+ ISEQ_TYPE_RESCUE, line);
lstart->rescued = LABEL_RESCUE_BEG;
lend->rescued = LABEL_RESCUE_END;
@@ -7591,7 +7589,7 @@ compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
const NODE *line_node = node;
DECL_ANCHOR(ensr);
const rb_iseq_t *ensure = NEW_CHILD_ISEQ(node->nd_ensr,
- rb_str_concat(rb_str_new2 ("ensure in "), iseq->body->location.label),
+ rb_str_concat(rb_str_new2 ("ensure in "), ISEQ_BODY(iseq)->location.label),
ISEQ_TYPE_ENSURE, line);
LABEL *lstart = NEW_LABEL(line);
LABEL *lend = NEW_LABEL(line);
@@ -7639,15 +7637,15 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
const NODE *line_node = node;
if (iseq) {
- enum iseq_type type = iseq->body->type;
+ enum iseq_type type = ISEQ_BODY(iseq)->type;
const rb_iseq_t *is = iseq;
enum iseq_type t = type;
const NODE *retval = node->nd_stts;
LABEL *splabel = 0;
while (t == ISEQ_TYPE_RESCUE || t == ISEQ_TYPE_ENSURE) {
- if (!(is = is->body->parent_iseq)) break;
- t = is->body->type;
+ if (!(is = ISEQ_BODY(is)->parent_iseq)) break;
+ t = ISEQ_BODY(is)->type;
}
switch (t) {
case ISEQ_TYPE_TOP:
@@ -7713,7 +7711,7 @@ compile_evstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
static void
compile_lvar(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *line_node, ID id)
{
- int idx = iseq->body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
+ int idx = ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
debugs("id: %s idx: %d\n", rb_id2name(id), idx);
ADD_GETLOCAL(ret, line_node, idx, get_lvar_level(iseq));
@@ -7856,13 +7854,13 @@ delegate_call_p(const rb_iseq_t *iseq, unsigned int argc, const LINK_ANCHOR *arg
*pstart_index = 0;
return TRUE;
}
- else if (argc <= iseq->body->local_table_size) {
+ else if (argc <= ISEQ_BODY(iseq)->local_table_size) {
unsigned int start=0;
// local_table: [p1, p2, p3, l1, l2, l3]
// arguments: [p3, l1, l2] -> 2
for (start = 0;
- argc + start <= iseq->body->local_table_size;
+ argc + start <= ISEQ_BODY(iseq)->local_table_size;
start++) {
const LINK_ELEMENT *elem = FIRST_ELEMENT(args);
@@ -7873,12 +7871,12 @@ delegate_call_p(const rb_iseq_t *iseq, unsigned int argc, const LINK_ANCHOR *arg
int local_level = FIX2INT(OPERAND_AT(elem, 1));
if (local_level == 0) {
- unsigned int index = iseq->body->local_table_size - (local_index - VM_ENV_DATA_SIZE + 1);
+ unsigned int index = ISEQ_BODY(iseq)->local_table_size - (local_index - VM_ENV_DATA_SIZE + 1);
if (0) { // for debug
fprintf(stderr, "lvar:%s (%d), id:%s (%d) local_index:%d, local_size:%d\n",
- rb_id2name(iseq->body->local_table[i]), i,
- rb_id2name(iseq->body->local_table[index]), index,
- local_index, (int)iseq->body->local_table_size);
+ rb_id2name(ISEQ_BODY(iseq)->local_table[i]), i,
+ rb_id2name(ISEQ_BODY(iseq)->local_table[index]), index,
+ local_index, (int)ISEQ_BODY(iseq)->local_table_size);
}
if (i == index) {
elem = elem->next;
@@ -7956,14 +7954,14 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
{
// arguments
struct rb_args_info args = {
- .pre_args_num = iseq->body->param.lead_num,
+ .pre_args_num = ISEQ_BODY(iseq)->param.lead_num,
};
NODE args_node;
rb_node_init(&args_node, NODE_ARGS, 0, 0, (VALUE)&args);
// local table without non-mandatory parameters
- const int skip_local_size = iseq->body->param.size - iseq->body->param.lead_num;
- const int table_size = iseq->body->local_table_size - skip_local_size;
+ const int skip_local_size = ISEQ_BODY(iseq)->param.size - ISEQ_BODY(iseq)->param.lead_num;
+ const int table_size = ISEQ_BODY(iseq)->local_table_size - skip_local_size;
VALUE idtmp = 0;
rb_ast_id_table_t *tbl = ALLOCV(idtmp, sizeof(rb_ast_id_table_t) + table_size * sizeof(ID));
@@ -7972,12 +7970,12 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
int i;
// lead parameters
- for (i=0; i<iseq->body->param.lead_num; i++) {
- tbl->ids[i] = iseq->body->local_table[i];
+ for (i=0; i<ISEQ_BODY(iseq)->param.lead_num; i++) {
+ tbl->ids[i] = ISEQ_BODY(iseq)->local_table[i];
}
// local variables
for (; i<table_size; i++) {
- tbl->ids[i] = iseq->body->local_table[i + skip_local_size];
+ tbl->ids[i] = ISEQ_BODY(iseq)->local_table[i + skip_local_size];
}
NODE scope_node;
@@ -7986,12 +7984,12 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
rb_ast_body_t ast = {
.root = &scope_node,
.compile_option = 0,
- .script_lines = iseq->body->variable.script_lines,
+ .script_lines = ISEQ_BODY(iseq)->variable.script_lines,
};
int prev_inline_index = GET_VM()->builtin_inline_index;
- iseq->body->mandatory_only_iseq =
+ ISEQ_BODY(iseq)->mandatory_only_iseq =
rb_iseq_new_with_opt(&ast, rb_iseq_base_label(iseq),
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
INT2FIX(nd_line(line_node)), NULL, 0,
@@ -8034,7 +8032,7 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
}
else if (strcmp("attr!", builtin_func) == 0) {
// There's only "inline" attribute for now
- iseq->body->builtin_inline_p = true;
+ ISEQ_BODY(iseq)->builtin_inline_p = true;
return COMPILE_OK;
}
else if (strcmp("arg!", builtin_func) == 0) {
@@ -8618,7 +8616,7 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
DECL_ANCHOR(args);
int argc;
unsigned int flag = 0;
@@ -8636,7 +8634,7 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
/* NODE_ZSUPER */
int i;
const rb_iseq_t *liseq = body->local_iseq;
- const struct rb_iseq_constant_body *const local_body = liseq->body;
+ const struct rb_iseq_constant_body *const local_body = ISEQ_BODY(liseq);
const struct rb_iseq_param_keyword *const local_kwd = local_body->param.keyword;
int lvar_level = get_lvar_level(iseq);
@@ -8763,7 +8761,7 @@ compile_yield(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
INIT_ANCHOR(args);
- switch (iseq->body->local_iseq->body->type) {
+ switch (ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->type) {
case ISEQ_TYPE_TOP:
case ISEQ_TYPE_MAIN:
case ISEQ_TYPE_CLASS:
@@ -8789,8 +8787,8 @@ compile_yield(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
int level = 0;
const rb_iseq_t *tmp_iseq = iseq;
- for (; tmp_iseq != iseq->body->local_iseq; level++ ) {
- tmp_iseq = tmp_iseq->body->parent_iseq;
+ for (; tmp_iseq != ISEQ_BODY(iseq)->local_iseq; level++ ) {
+ tmp_iseq = ISEQ_BODY(tmp_iseq)->parent_iseq;
}
if (level > 0) access_outer_variables(iseq, level, rb_intern("yield"), true);
@@ -8842,7 +8840,7 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
if (rb_is_const_id(node->nd_mid)) {
/* constant */
LABEL *lend = NEW_LABEL(line);
- int ic_index = iseq->body->is_size++;
+ int ic_index = ISEQ_BODY(iseq)->is_size++;
DECL_ANCHOR(pref);
DECL_ANCHOR(body);
@@ -8887,7 +8885,7 @@ compile_colon3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
{
const int line = nd_line(node);
LABEL *lend = NEW_LABEL(line);
- int ic_index = iseq->body->is_size++;
+ int ic_index = ISEQ_BODY(iseq)->is_size++;
debugi("colon3#nd_mid", node->nd_mid);
@@ -8942,17 +8940,17 @@ static int
compile_errinfo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
if (!popped) {
- if (iseq->body->type == ISEQ_TYPE_RESCUE) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_RESCUE) {
ADD_GETLOCAL(ret, node, LVAR_ERRINFO, 0);
}
else {
const rb_iseq_t *ip = iseq;
int level = 0;
while (ip) {
- if (ip->body->type == ISEQ_TYPE_RESCUE) {
+ if (ISEQ_BODY(ip)->type == ISEQ_TYPE_RESCUE) {
break;
}
- ip = ip->body->parent_iseq;
+ ip = ISEQ_BODY(ip)->parent_iseq;
level++;
}
if (ip) {
@@ -8969,7 +8967,7 @@ compile_errinfo(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_kw_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
LABEL *end_label = NEW_LABEL(nd_line(node));
const NODE *default_value = node->nd_body->nd_value;
@@ -9117,7 +9115,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
{
const int line = (int)nd_line(node);
const enum node_type type = nd_type(node);
- struct rb_iseq_constant_body *const body = iseq->body;
+ struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
if (ISEQ_COMPILE_DATA(iseq)->last_line == line) {
/* ignore */
@@ -9219,7 +9217,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_LASGN:{
ID id = node->nd_vid;
- int idx = body->local_iseq->body->local_table_size - get_local_var_idx(iseq, id);
+ int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
CHECK(COMPILE(ret, "rvalue", node->nd_value));
@@ -10297,9 +10295,9 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
case TS_IVC: /* inline ivar cache */
case TS_ICVARC: /* inline cvar cache */
argv[j] = op;
- if (NUM2UINT(op) >= iseq->body->is_size) {
- iseq->body->is_size = NUM2INT(op) + 1;
- }
+ if (NUM2UINT(op) >= ISEQ_BODY(iseq)->is_size) {
+ ISEQ_BODY(iseq)->is_size = NUM2INT(op) + 1;
+ }
FL_SET((VALUE)iseq, ISEQ_MARKABLE_ISEQ);
break;
case TS_CALLDATA:
@@ -10388,13 +10386,13 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
ID *ids;
struct rb_iseq_param_keyword *keyword = ZALLOC(struct rb_iseq_param_keyword);
- iseq->body->param.flags.has_kw = TRUE;
+ ISEQ_BODY(iseq)->param.flags.has_kw = TRUE;
keyword->num = len;
#define SYM(s) ID2SYM(rb_intern_const(#s))
(void)int_param(&keyword->bits_start, params, SYM(kwbits));
i = keyword->bits_start - keyword->num;
- ids = (ID *)&iseq->body->local_table[i];
+ ids = (ID *)&ISEQ_BODY(iseq)->local_table[i];
#undef SYM
/* required args */
@@ -10517,8 +10515,8 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
INIT_ANCHOR(anchor);
len = RARRAY_LENINT(locals);
- iseq->body->local_table_size = len;
- iseq->body->local_table = tbl = len > 0 ? (ID *)ALLOC_N(ID, iseq->body->local_table_size) : NULL;
+ ISEQ_BODY(iseq)->local_table_size = len;
+ ISEQ_BODY(iseq)->local_table = tbl = len > 0 ? (ID *)ALLOC_N(ID, ISEQ_BODY(iseq)->local_table_size) : NULL;
for (i = 0; i < len; i++) {
VALUE lv = RARRAY_AREF(locals, i);
@@ -10531,14 +10529,14 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
}
}
-#define INT_PARAM(F) int_param(&iseq->body->param.F, params, SYM(F))
+#define INT_PARAM(F) int_param(&ISEQ_BODY(iseq)->param.F, params, SYM(F))
if (INT_PARAM(lead_num)) {
- iseq->body->param.flags.has_lead = TRUE;
+ ISEQ_BODY(iseq)->param.flags.has_lead = TRUE;
}
- if (INT_PARAM(post_num)) iseq->body->param.flags.has_post = TRUE;
- if (INT_PARAM(post_start)) iseq->body->param.flags.has_post = TRUE;
- if (INT_PARAM(rest_start)) iseq->body->param.flags.has_rest = TRUE;
- if (INT_PARAM(block_start)) iseq->body->param.flags.has_block = TRUE;
+ if (INT_PARAM(post_num)) ISEQ_BODY(iseq)->param.flags.has_post = TRUE;
+ if (INT_PARAM(post_start)) ISEQ_BODY(iseq)->param.flags.has_post = TRUE;
+ if (INT_PARAM(rest_start)) ISEQ_BODY(iseq)->param.flags.has_rest = TRUE;
+ if (INT_PARAM(block_start)) ISEQ_BODY(iseq)->param.flags.has_block = TRUE;
#undef INT_PARAM
{
#define INT_PARAM(F) F = (int_param(&x, misc, SYM(F)) ? (unsigned int)x : 0)
@@ -10559,9 +10557,9 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
if (RB_TYPE_P(arg_opt_labels, T_ARRAY)) {
len = RARRAY_LENINT(arg_opt_labels);
- iseq->body->param.flags.has_opt = !!(len - 1 >= 0);
+ ISEQ_BODY(iseq)->param.flags.has_opt = !!(len - 1 >= 0);
- if (iseq->body->param.flags.has_opt) {
+ if (ISEQ_BODY(iseq)->param.flags.has_opt) {
VALUE *opt_table = ALLOC_N(VALUE, len);
for (i = 0; i < len; i++) {
@@ -10570,8 +10568,8 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
opt_table[i] = (VALUE)label;
}
- iseq->body->param.opt_num = len - 1;
- iseq->body->param.opt_table = opt_table;
+ ISEQ_BODY(iseq)->param.opt_num = len - 1;
+ ISEQ_BODY(iseq)->param.opt_table = opt_table;
}
}
else if (!NIL_P(arg_opt_labels)) {
@@ -10580,7 +10578,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
}
if (RB_TYPE_P(keywords, T_ARRAY)) {
- iseq->body->param.keyword = iseq_build_kw(iseq, params, keywords);
+ ISEQ_BODY(iseq)->param.keyword = iseq_build_kw(iseq, params, keywords);
}
else if (!NIL_P(keywords)) {
rb_raise(rb_eTypeError, ":keywords param is not an array: %+"PRIsVALUE,
@@ -10588,16 +10586,16 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
}
if (Qtrue == rb_hash_aref(params, SYM(ambiguous_param0))) {
- iseq->body->param.flags.ambiguous_param0 = TRUE;
+ ISEQ_BODY(iseq)->param.flags.ambiguous_param0 = TRUE;
}
if (int_param(&i, params, SYM(kwrest))) {
- struct rb_iseq_param_keyword *keyword = (struct rb_iseq_param_keyword *)iseq->body->param.keyword;
+ struct rb_iseq_param_keyword *keyword = (struct rb_iseq_param_keyword *)ISEQ_BODY(iseq)->param.keyword;
if (keyword == NULL) {
- iseq->body->param.keyword = keyword = ZALLOC(struct rb_iseq_param_keyword);
+ ISEQ_BODY(iseq)->param.keyword = keyword = ZALLOC(struct rb_iseq_param_keyword);
}
keyword->rest_start = i;
- iseq->body->param.flags.has_kwrest = TRUE;
+ ISEQ_BODY(iseq)->param.flags.has_kwrest = TRUE;
}
#undef SYM
iseq_calc_param_size(iseq);
@@ -10608,9 +10606,9 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params,
/* body */
iseq_build_from_ary_body(iseq, anchor, body, node_ids, labels_wrapper);
- iseq->body->param.size = arg_size;
- iseq->body->local_table_size = local_size;
- iseq->body->stack_max = stack_max;
+ ISEQ_BODY(iseq)->param.size = arg_size;
+ ISEQ_BODY(iseq)->local_table_size = local_size;
+ ISEQ_BODY(iseq)->stack_max = stack_max;
}
/* for parser */
@@ -10619,7 +10617,7 @@ int
rb_dvar_defined(ID id, const rb_iseq_t *iseq)
{
if (iseq) {
- const struct rb_iseq_constant_body *body = iseq->body;
+ const struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
while (body->type == ISEQ_TYPE_BLOCK ||
body->type == ISEQ_TYPE_RESCUE ||
body->type == ISEQ_TYPE_ENSURE ||
@@ -10634,7 +10632,7 @@ rb_dvar_defined(ID id, const rb_iseq_t *iseq)
}
}
iseq = body->parent_iseq;
- body = iseq->body;
+ body = ISEQ_BODY(iseq);
}
}
return 0;
@@ -10645,7 +10643,7 @@ rb_local_defined(ID id, const rb_iseq_t *iseq)
{
if (iseq) {
unsigned int i;
- const struct rb_iseq_constant_body *const body = iseq->body->local_iseq->body;
+ const struct rb_iseq_constant_body *const body = ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq);
for (i=0; i<body->local_table_size; i++) {
if (body->local_table[i] == id) {
@@ -11081,7 +11079,7 @@ ibf_load_builtin(const struct ibf_load *load, ibf_offset_t *offset)
static ibf_offset_t
ibf_dump_code(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
+ const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
const int iseq_size = body->iseq_size;
int code_index;
const VALUE *orig_code = rb_iseq_original_iseq(iseq);
@@ -11158,7 +11156,7 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
ibf_offset_t reading_pos = bytecode_offset;
VALUE *code = ALLOC_N(VALUE, iseq_size);
- struct rb_iseq_constant_body *load_body = iseq->body;
+ struct rb_iseq_constant_body *load_body = ISEQ_BODY(iseq);
struct rb_call_data *cd_entries = load_body->call_data;
union iseq_inline_storage_entry *is_entries = load_body->is_entries;
@@ -11269,11 +11267,11 @@ ibf_load_code(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t bytecod
static ibf_offset_t
ibf_dump_param_opt_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- int opt_num = iseq->body->param.opt_num;
+ int opt_num = ISEQ_BODY(iseq)->param.opt_num;
if (opt_num > 0) {
IBF_W_ALIGN(VALUE);
- return ibf_dump_write(dump, iseq->body->param.opt_table, sizeof(VALUE) * (opt_num + 1));
+ return ibf_dump_write(dump, ISEQ_BODY(iseq)->param.opt_table, sizeof(VALUE) * (opt_num + 1));
}
else {
return ibf_dump_pos(dump);
@@ -11296,7 +11294,7 @@ ibf_load_param_opt_table(const struct ibf_load *load, ibf_offset_t opt_table_off
static ibf_offset_t
ibf_dump_param_keyword(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_param_keyword *kw = iseq->body->param.keyword;
+ const struct rb_iseq_param_keyword *kw = ISEQ_BODY(iseq)->param.keyword;
if (kw) {
struct rb_iseq_param_keyword dump_kw = *kw;
@@ -11348,10 +11346,10 @@ static ibf_offset_t
ibf_dump_insns_info_body(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
ibf_offset_t offset = ibf_dump_pos(dump);
- const struct iseq_insn_info_entry *entries = iseq->body->insns_info.body;
+ const struct iseq_insn_info_entry *entries = ISEQ_BODY(iseq)->insns_info.body;
unsigned int i;
- for (i = 0; i < iseq->body->insns_info.size; i++) {
+ for (i = 0; i < ISEQ_BODY(iseq)->insns_info.size; i++) {
ibf_dump_write_small_value(dump, entries[i].line_no);
#ifdef USE_ISEQ_NODE_ID
ibf_dump_write_small_value(dump, entries[i].node_id);
@@ -11414,7 +11412,7 @@ ibf_load_insns_info_positions(const struct ibf_load *load, ibf_offset_t position
static ibf_offset_t
ibf_dump_local_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
+ const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
const int size = body->local_table_size;
ID *table = ALLOCA_N(ID, size);
int i;
@@ -11447,7 +11445,7 @@ ibf_load_local_table(const struct ibf_load *load, ibf_offset_t local_table_offse
static ibf_offset_t
ibf_dump_catch_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct iseq_catch_table *table = iseq->body->catch_table;
+ const struct iseq_catch_table *table = ISEQ_BODY(iseq)->catch_table;
if (table) {
int *iseq_indices = ALLOCA_N(int, table->size);
@@ -11504,7 +11502,7 @@ ibf_load_catch_table(const struct ibf_load *load, ibf_offset_t catch_table_offse
static ibf_offset_t
ibf_dump_ci_entries(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- const struct rb_iseq_constant_body *const body = iseq->body;
+ const struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
const unsigned int ci_size = body->ci_size;
const struct rb_call_data *cds = body->call_data;
@@ -11553,7 +11551,7 @@ dump_outer_variable(ID id, VALUE val, void *dump)
static ibf_offset_t
ibf_dump_outer_variables(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
- struct rb_id_table * ovs = iseq->body->outer_variables;
+ struct rb_id_table * ovs = ISEQ_BODY(iseq)->outer_variables;
ibf_offset_t offset = ibf_dump_pos(dump);
@@ -11642,7 +11640,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
unsigned int *positions;
- const struct rb_iseq_constant_body *body = iseq->body;
+ const struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
const VALUE location_pathobj_index = ibf_dump_object(dump, body->location.pathobj); /* TODO: freeze */
const VALUE location_base_label_index = ibf_dump_object(dump, body->location.base_label);
@@ -11664,16 +11662,16 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
const ibf_offset_t param_keyword_offset = ibf_dump_param_keyword(dump, iseq);
const ibf_offset_t insns_info_body_offset = ibf_dump_insns_info_body(dump, iseq);
- positions = rb_iseq_insns_info_decode_positions(iseq->body);
+ positions = rb_iseq_insns_info_decode_positions(ISEQ_BODY(iseq));
const ibf_offset_t insns_info_positions_offset = ibf_dump_insns_info_positions(dump, positions, body->insns_info.size);
ruby_xfree(positions);
const ibf_offset_t local_table_offset = ibf_dump_local_table(dump, iseq);
const unsigned int catch_table_size = body->catch_table ? body->catch_table->size : 0;
const ibf_offset_t catch_table_offset = ibf_dump_catch_table(dump, iseq);
- const int parent_iseq_index = ibf_dump_iseq(dump, iseq->body->parent_iseq);
- const int local_iseq_index = ibf_dump_iseq(dump, iseq->body->local_iseq);
- const int mandatory_only_iseq_index = ibf_dump_iseq(dump, iseq->body->mandatory_only_iseq);
+ const int parent_iseq_index = ibf_dump_iseq(dump, ISEQ_BODY(iseq)->parent_iseq);
+ const int local_iseq_index = ibf_dump_iseq(dump, ISEQ_BODY(iseq)->local_iseq);
+ const int mandatory_only_iseq_index = ibf_dump_iseq(dump, ISEQ_BODY(iseq)->mandatory_only_iseq);
const ibf_offset_t ci_entries_offset = ibf_dump_ci_entries(dump, iseq);
const ibf_offset_t outer_variables_offset = ibf_dump_outer_variables(dump, iseq);
@@ -11784,7 +11782,7 @@ ibf_load_location_str(const struct ibf_load *load, VALUE str_index)
static void
ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
{
- struct rb_iseq_constant_body *load_body = iseq->body = rb_iseq_constant_body_alloc();
+ struct rb_iseq_constant_body *load_body = ISEQ_BODY(iseq) = rb_iseq_constant_body_alloc();
ibf_offset_t reading_pos = offset;
@@ -12729,8 +12727,8 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
VALUE dump_obj;
VALUE str;
- if (iseq->body->parent_iseq != NULL ||
- iseq->body->local_iseq != iseq) {
+ if (ISEQ_BODY(iseq)->parent_iseq != NULL ||
+ ISEQ_BODY(iseq)->local_iseq != iseq) {
rb_raise(rb_eRuntimeError, "should be top of iseq");
}
if (RTEST(ISEQ_COVERAGE(iseq))) {