diff options
| -rw-r--r-- | cont.c | 8 | ||||
| -rw-r--r-- | error.c | 2 | ||||
| -rw-r--r-- | eval.c | 4 | ||||
| -rw-r--r-- | gc.c | 10 | ||||
| -rw-r--r-- | jit.c | 2 | ||||
| -rw-r--r-- | thread.c | 10 | ||||
| -rw-r--r-- | vm.c | 60 | ||||
| -rw-r--r-- | vm_backtrace.c | 42 | ||||
| -rw-r--r-- | vm_core.h | 6 | ||||
| -rw-r--r-- | vm_dump.c | 28 | ||||
| -rw-r--r-- | vm_eval.c | 14 | ||||
| -rw-r--r-- | vm_exec.h | 8 | ||||
| -rw-r--r-- | vm_insnhelper.c | 66 | ||||
| -rw-r--r-- | vm_insnhelper.h | 2 | ||||
| -rw-r--r-- | vm_method.c | 4 | ||||
| -rw-r--r-- | vm_trace.c | 8 | ||||
| -rw-r--r-- | zjit.h | 16 | ||||
| -rw-r--r-- | zjit/src/codegen.rs | 2 | ||||
| -rw-r--r-- | zjit/src/cruby_bindings.inc.rs | 2 |
19 files changed, 147 insertions, 147 deletions
@@ -1456,8 +1456,8 @@ rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data) const rb_control_frame_t *cfp = cont->ec->cfp; while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(cont->ec, cfp)) { - if (rb_zjit_cfp_has_pc(cfp) && rb_zjit_cfp_has_iseq(cfp)) { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); + if (rb_cfp_has_pc(cfp) && rb_cfp_has_iseq(cfp)) { + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); if (iseq && imemo_type((VALUE)iseq) == imemo_iseq) { callback(iseq, data); } @@ -1580,8 +1580,8 @@ show_vm_pcs(const rb_control_frame_t *cfp, int i=0; while (cfp != end_of_cfp) { int pc = 0; - if (cfp->iseq) { - pc = cfp->pc - ISEQ_BODY(cfp->iseq)->iseq_encoded; + if (rb_cfp_iseq(cfp)) { + pc = cfp->pc - ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded; } fprintf(stderr, "%2d pc: %d\n", i++, pc); cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); @@ -2376,7 +2376,7 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method) rb_ivar_set(exc, id_name, method); err_init_recv(exc, recv); if (cfp && VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) { - rb_ivar_set(exc, id_iseq, rb_iseqw_new(rb_zjit_cfp_iseq(cfp))); + rb_ivar_set(exc, id_iseq, rb_iseqw_new(rb_cfp_iseq(cfp))); } return exc; } @@ -2011,10 +2011,10 @@ errinfo_place(const rb_execution_context_t *ec) while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) { if (VM_FRAME_RUBYFRAME_P(cfp)) { - if (ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->type == ISEQ_TYPE_RESCUE) { + if (ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_RESCUE) { return &cfp->ep[VM_ENV_INDEX_LAST_LVAR]; } - else if (ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->type == ISEQ_TYPE_ENSURE && + else if (ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_ENSURE && !THROW_DATA_P(cfp->ep[VM_ENV_INDEX_LAST_LVAR]) && !FIXNUM_P(cfp->ep[VM_ENV_INDEX_LAST_LVAR])) { return &cfp->ep[VM_ENV_INDEX_LAST_LVAR]; @@ -1000,11 +1000,11 @@ gc_validate_pc(VALUE obj) rb_execution_context_t *ec = GET_EC(); const rb_control_frame_t *cfp = ec->cfp; - if (cfp && VM_FRAME_RUBYFRAME_P(cfp) && rb_zjit_cfp_has_pc(cfp)) { - const VALUE *iseq_encoded = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_encoded; - const VALUE *iseq_encoded_end = iseq_encoded + ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_size; - RUBY_ASSERT(rb_zjit_cfp_pc(cfp) >= iseq_encoded, "PC not set when allocating, breaking tracing"); - RUBY_ASSERT(rb_zjit_cfp_pc(cfp) <= iseq_encoded_end, "PC not set when allocating, breaking tracing"); + if (cfp && VM_FRAME_RUBYFRAME_P(cfp) && rb_cfp_has_pc(cfp)) { + const VALUE *iseq_encoded = ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded; + const VALUE *iseq_encoded_end = iseq_encoded + ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_size; + RUBY_ASSERT(rb_cfp_pc(cfp) >= iseq_encoded, "PC not set when allocating, breaking tracing"); + RUBY_ASSERT(rb_cfp_pc(cfp) <= iseq_encoded_end, "PC not set when allocating, breaking tracing"); } #endif } @@ -403,7 +403,7 @@ rb_get_ec_cfp(const rb_execution_context_t *ec) const rb_iseq_t * rb_get_cfp_iseq(struct rb_control_frame_struct *cfp) { - return cfp->iseq; + return rb_cfp_iseq(cfp); } VALUE * @@ -5906,7 +5906,7 @@ static void update_line_coverage(VALUE data, const rb_trace_arg_t *trace_arg) { const rb_control_frame_t *cfp = GET_EC()->cfp; - VALUE coverage = rb_iseq_coverage(cfp->iseq); + VALUE coverage = rb_iseq_coverage(rb_cfp_iseq(cfp)); if (RB_TYPE_P(coverage, T_ARRAY) && !RBASIC_CLASS(coverage)) { VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES); if (lines) { @@ -5916,7 +5916,7 @@ update_line_coverage(VALUE data, const rb_trace_arg_t *trace_arg) VALUE num; void rb_iseq_clear_event_flags(const rb_iseq_t *iseq, size_t pos, rb_event_flag_t reset); if (GET_VM()->coverage_mode & COVERAGE_TARGET_ONESHOT_LINES) { - rb_iseq_clear_event_flags(cfp->iseq, rb_zjit_cfp_pc(cfp) - ISEQ_BODY(cfp->iseq)->iseq_encoded - 1, RUBY_EVENT_COVERAGE_LINE); + rb_iseq_clear_event_flags(rb_cfp_iseq(cfp), rb_cfp_pc(cfp) - ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded - 1, RUBY_EVENT_COVERAGE_LINE); rb_ary_push(lines, LONG2FIX(line + 1)); return; } @@ -5937,12 +5937,12 @@ static void update_branch_coverage(VALUE data, const rb_trace_arg_t *trace_arg) { const rb_control_frame_t *cfp = GET_EC()->cfp; - VALUE coverage = rb_iseq_coverage(cfp->iseq); + VALUE coverage = rb_iseq_coverage(rb_cfp_iseq(cfp)); if (RB_TYPE_P(coverage, T_ARRAY) && !RBASIC_CLASS(coverage)) { VALUE branches = RARRAY_AREF(coverage, COVERAGE_INDEX_BRANCHES); if (branches) { - long pc = rb_zjit_cfp_pc(cfp) - ISEQ_BODY(cfp->iseq)->iseq_encoded - 1; - long idx = FIX2INT(RARRAY_AREF(ISEQ_PC2BRANCHINDEX(cfp->iseq), pc)), count; + long pc = rb_cfp_pc(cfp) - ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded - 1; + long idx = FIX2INT(RARRAY_AREF(ISEQ_PC2BRANCHINDEX(rb_cfp_iseq(cfp)), pc)), count; VALUE counters = RARRAY_AREF(branches, 1); VALUE num = RARRAY_AREF(counters, idx); count = FIX2LONG(num) + 1; @@ -516,7 +516,7 @@ rb_yjit_threshold_hit(const rb_iseq_t *iseq, uint64_t entry_calls) static inline rb_jit_func_t yjit_compile(rb_execution_context_t *ec) { - const rb_iseq_t *iseq = ec->cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(ec->cfp); struct rb_iseq_constant_body *body = ISEQ_BODY(iseq); // Increment the ISEQ's call counter and trigger JIT compilation if not compiled @@ -536,7 +536,7 @@ yjit_compile(rb_execution_context_t *ec) static inline rb_jit_func_t zjit_compile(rb_execution_context_t *ec) { - const rb_iseq_t *iseq = ec->cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(ec->cfp); struct rb_iseq_constant_body *body = ISEQ_BODY(iseq); if (body->jit_entry == NULL) { @@ -605,7 +605,7 @@ jit_exec(rb_execution_context_t *ec) static inline rb_jit_func_t jit_compile_exception(rb_execution_context_t *ec) { - const rb_iseq_t *iseq = ec->cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(ec->cfp); struct rb_iseq_constant_body *body = ISEQ_BODY(iseq); #if USE_ZJIT @@ -941,7 +941,7 @@ rb_control_frame_t * rb_vm_get_binding_creatable_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp) { while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)) { - if (rb_zjit_cfp_has_iseq(cfp)) { + if (rb_cfp_has_iseq(cfp)) { return (rb_control_frame_t *)cfp; } cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); @@ -1119,7 +1119,7 @@ vm_make_env_each(const rb_execution_context_t * const ec, rb_control_frame_t *co } } - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); if (!VM_FRAME_RUBYFRAME_P(cfp)) { local_size = VM_ENV_DATA_SIZE; } @@ -1689,8 +1689,8 @@ rb_vm_make_binding(const rb_execution_context_t *ec, const rb_control_frame_t *s GetBindingPtr(bindval, bind); vm_bind_update_env(bindval, bind, envval); RB_OBJ_WRITE(bindval, &bind->block.as.captured.self, cfp->self); - RB_OBJ_WRITE(bindval, &bind->block.as.captured.code.iseq, rb_zjit_cfp_iseq(cfp)); - RB_OBJ_WRITE(bindval, &bind->pathobj, ISEQ_BODY(rb_zjit_cfp_iseq(ruby_level_cfp))->location.pathobj); + RB_OBJ_WRITE(bindval, &bind->block.as.captured.code.iseq, rb_cfp_iseq(cfp)); + RB_OBJ_WRITE(bindval, &bind->pathobj, ISEQ_BODY(rb_cfp_iseq(ruby_level_cfp))->location.pathobj); bind->first_lineno = rb_vm_get_sourceline(ruby_level_cfp); return bindval; @@ -1997,9 +1997,9 @@ rb_vm_invoke_proc_with_self(rb_execution_context_t *ec, rb_proc_t *proc, VALUE s VALUE * rb_vm_svar_lep(const rb_execution_context_t *ec, const rb_control_frame_t *cfp) { - while (!rb_zjit_cfp_has_pc(cfp) || !rb_zjit_cfp_has_iseq(cfp)) { + while (!rb_cfp_has_pc(cfp) || !rb_cfp_has_iseq(cfp)) { if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_IFUNC) { - struct vm_ifunc *ifunc = (struct vm_ifunc *)rb_zjit_cfp_iseq(cfp); + struct vm_ifunc *ifunc = (struct vm_ifunc *)rb_cfp_iseq(cfp); return ifunc->svar_lep; } else { @@ -2082,7 +2082,7 @@ rb_sourcefile(void) const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); if (cfp) { - return RSTRING_PTR(rb_iseq_path(rb_zjit_cfp_iseq(cfp))); + return RSTRING_PTR(rb_iseq_path(rb_cfp_iseq(cfp))); } else { return 0; @@ -2111,7 +2111,7 @@ rb_source_location(int *pline) if (cfp && VM_FRAME_RUBYFRAME_P(cfp)) { if (pline) *pline = rb_vm_get_sourceline(cfp); - return rb_iseq_path(rb_zjit_cfp_iseq(cfp)); + return rb_iseq_path(rb_cfp_iseq(cfp)); } else { if (pline) *pline = 0; @@ -2593,7 +2593,7 @@ hook_before_rewind(rb_execution_context_t *ec, bool cfp_returning_with_value, in return; } else { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(ec->cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(ec->cfp); rb_hook_list_t *local_hooks = NULL; unsigned int local_hooks_cnt = iseq->aux.exec.local_hooks_cnt; if (RB_UNLIKELY(local_hooks_cnt > 0)) { @@ -2855,7 +2855,7 @@ zjit_materialize_frames(rb_control_frame_t *cfp) if (CFP_HAS_JIT_RETURN(cfp)) { const zjit_jit_frame_t *jit_frame = (const zjit_jit_frame_t *)cfp->jit_return; cfp->pc = jit_frame->pc; - cfp->iseq = (rb_iseq_t *)jit_frame->iseq; + cfp->_iseq = (rb_iseq_t *)jit_frame->iseq; if (jit_frame->materialize_block_code) { cfp->block_code = NULL; } @@ -2889,7 +2889,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V cont_pc = cont_sp = 0; catch_iseq = NULL; - while (rb_zjit_cfp_pc(ec->cfp) == 0 || rb_zjit_cfp_iseq(ec->cfp) == 0) { + while (rb_cfp_pc(ec->cfp) == 0 || rb_cfp_iseq(ec->cfp) == 0) { if (UNLIKELY(VM_FRAME_TYPE(ec->cfp) == VM_FRAME_MAGIC_CFUNC)) { EXEC_EVENT_HOOK_AND_POP_FRAME(ec, RUBY_EVENT_C_RETURN, ec->cfp->self, rb_vm_frame_method_entry(ec->cfp)->def->original_id, @@ -2903,7 +2903,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } rb_control_frame_t *const cfp = ec->cfp; - epc = rb_zjit_cfp_pc(cfp) - ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_encoded; + epc = rb_cfp_pc(cfp) - ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded; escape_cfp = NULL; if (state == TAG_BREAK || state == TAG_RETURN) { @@ -2916,7 +2916,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V THROW_DATA_STATE_SET(err, state = TAG_BREAK); } else { - ct = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->catch_table; + ct = ISEQ_BODY(rb_cfp_iseq(cfp))->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); if (entry->start < epc && entry->end >= epc) { @@ -2950,7 +2950,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } if (state == TAG_RAISE) { - ct = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->catch_table; + ct = ISEQ_BODY(rb_cfp_iseq(cfp))->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); if (entry->start < epc && entry->end >= epc) { @@ -2966,7 +2966,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } } else if (state == TAG_RETRY) { - ct = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->catch_table; + ct = ISEQ_BODY(rb_cfp_iseq(cfp))->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); if (entry->start < epc && entry->end >= epc) { @@ -2982,7 +2982,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V escape_cfp = THROW_DATA_CATCH_FRAME(err); if (cfp == escape_cfp) { zjit_materialize_frames(cfp); - cfp->pc = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_encoded + entry->cont; + cfp->pc = ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded + entry->cont; ec->errinfo = Qnil; return Qundef; } @@ -3000,7 +3000,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V /* otherwise = dontcare */ }[state]; - ct = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->catch_table; + ct = ISEQ_BODY(rb_cfp_iseq(cfp))->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); @@ -3013,7 +3013,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } else if (entry->type == type) { zjit_materialize_frames(cfp); - cfp->pc = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_encoded + entry->cont; + cfp->pc = ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded + entry->cont; cfp->sp = vm_base_ptr(cfp) + entry->sp; if (state != TAG_REDO) { @@ -3027,7 +3027,7 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V } } else { - ct = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->catch_table; + ct = ISEQ_BODY(rb_cfp_iseq(cfp))->catch_table; if (ct) for (i = 0; i < ct->size; i++) { entry = UNALIGNED_MEMBER_PTR(ct, entries[i]); if (entry->start < epc && entry->end >= epc) { @@ -3047,9 +3047,9 @@ vm_exec_handle_exception(rb_execution_context_t *ec, enum ruby_tag_type state, V const int arg_size = 1; rb_iseq_check(catch_iseq); - zjit_materialize_frames(cfp); // vm_base_ptr looks at cfp->iseq + zjit_materialize_frames(cfp); // vm_base_ptr looks at cfp->_iseq cfp->sp = vm_base_ptr(cfp) + cont_sp; - cfp->pc = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->iseq_encoded + cont_pc; + cfp->pc = ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded + cont_pc; /* push block frame */ cfp->sp[0] = (VALUE)err; @@ -3680,7 +3680,7 @@ rb_execution_context_update(rb_execution_context_t *ec) cfp->block_code = (void *)rb_gc_location((VALUE)cfp->block_code); } else { - cfp->iseq = (rb_iseq_t *)rb_gc_location((VALUE)cfp->iseq); + cfp->_iseq = (rb_iseq_t *)rb_gc_location((VALUE)cfp->_iseq); cfp->block_code = (void *)rb_gc_location((VALUE)cfp->block_code); } @@ -3733,7 +3733,7 @@ rb_execution_context_mark(const rb_execution_context_t *ec) VM_ASSERT(!!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) == vm_ep_in_heap_p_(ec, ep)); rb_gc_mark_movable(cfp->self); - rb_gc_mark_movable((VALUE)rb_zjit_cfp_iseq(cfp)); + rb_gc_mark_movable((VALUE)rb_cfp_iseq(cfp)); // Mark block_code directly (not through rb_zjit_cfp_block_code) // because rb_iterate0 may write a valid ifunc after JIT frame push. rb_gc_mark_movable((VALUE)cfp->block_code); @@ -4575,7 +4575,7 @@ Init_VM(void) rb_root_fiber_obj_setup(th); rb_vm_register_global_object((VALUE)iseq); - th->ec->cfp->iseq = iseq; + th->ec->cfp->_iseq = iseq; th->ec->cfp->pc = ISEQ_BODY(iseq)->iseq_encoded; th->ec->cfp->self = th->top_self; @@ -4611,7 +4611,7 @@ rb_vm_set_progname(VALUE filename) --cfp; filename = rb_str_new_frozen(filename); - rb_iseq_pathobj_set(cfp->iseq, filename, rb_iseq_realpath(cfp->iseq)); + rb_iseq_pathobj_set(rb_cfp_iseq(cfp), filename, rb_iseq_realpath(rb_cfp_iseq(cfp))); } extern const struct st_hash_type rb_fstring_hash_type; @@ -4943,7 +4943,7 @@ vm_analysis_operand(int insn, int n, VALUE op) HASH_ASET(ihash, INT2FIX(n), ophash); } /* intern */ - valstr = rb_insn_operand_intern(GET_EC()->cfp->iseq, insn, n, op, 0, 0, 0, 0); + valstr = rb_insn_operand_intern(rb_cfp_iseq(GET_EC()->cfp), insn, n, op, 0, 0, 0, 0); /* set count */ if (NIL_P(cv = rb_hash_aref(ophash, valstr))) { @@ -5145,7 +5145,7 @@ vm_collect_usage_operand(int insn, int n, VALUE op) if (RUBY_DTRACE_INSN_OPERAND_ENABLED()) { VALUE valstr; - valstr = rb_insn_operand_intern(GET_EC()->cfp->iseq, insn, n, op, 0, 0, 0, 0); + valstr = rb_insn_operand_intern(rb_cfp_iseq(GET_EC()->cfp), insn, n, op, 0, 0, 0, 0); RUBY_DTRACE_INSN_OPERAND(RSTRING_PTR(valstr), rb_insns_name(insn)); RB_GC_GUARD(valstr); diff --git a/vm_backtrace.c b/vm_backtrace.c index 674cfe2427..022249afa0 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -102,9 +102,9 @@ calc_node_id(const rb_iseq_t *iseq, const VALUE *pc) int rb_vm_get_sourceline(const rb_control_frame_t *cfp) { - if (VM_FRAME_RUBYFRAME_P(cfp) && rb_zjit_cfp_has_iseq(cfp)) { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); - int line = calc_lineno(iseq, rb_zjit_cfp_pc(cfp)); + if (VM_FRAME_RUBYFRAME_P(cfp) && rb_cfp_has_iseq(cfp)) { + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); + int line = calc_lineno(iseq, rb_cfp_pc(cfp)); if (line != 0) { return line; } @@ -618,7 +618,7 @@ backtrace_size(const rb_execution_context_t *ec) static bool is_rescue_or_ensure_frame(const rb_control_frame_t *cfp) { - enum rb_iseq_type type = ISEQ_BODY(rb_zjit_cfp_iseq(cfp))->type; + enum rb_iseq_type type = ISEQ_BODY(rb_cfp_iseq(cfp))->type; return type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE; } @@ -688,17 +688,17 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram } for (; cfp != end_cfp && (bt->backtrace_size < num_frames); cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { - if (rb_zjit_cfp_has_iseq(cfp)) { - if (rb_zjit_cfp_has_pc(cfp)) { + if (rb_cfp_has_iseq(cfp)) { + if (rb_cfp_has_pc(cfp)) { if (start_frame > 0) { start_frame--; } else { - bool internal = is_internal_location(rb_zjit_cfp_iseq(cfp)); + bool internal = is_internal_location(rb_cfp_iseq(cfp)); if (skip_internal && internal) continue; if (!skip_next_frame) { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); - const VALUE *pc = rb_zjit_cfp_pc(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); + const VALUE *pc = rb_cfp_pc(cfp); if (internal && backpatch_counter > 0) { // To keep only one internal frame, discard the previous backpatch frames bt->backtrace_size -= backpatch_counter; @@ -753,10 +753,10 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram // is the one of the caller Ruby frame, so if the last entry is a C frame we find the caller Ruby frame here. if (backpatch_counter > 0) { for (; cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { - if (rb_zjit_cfp_has_iseq(cfp) && rb_zjit_cfp_has_pc(cfp) && !(skip_internal && is_internal_location(rb_zjit_cfp_iseq(cfp)))) { + if (rb_cfp_has_iseq(cfp) && rb_cfp_has_pc(cfp) && !(skip_internal && is_internal_location(rb_cfp_iseq(cfp)))) { VM_ASSERT(!skip_next_frame); // ISEQ_TYPE_RESCUE/ISEQ_TYPE_ENSURE should have a caller Ruby ISEQ, not a cfunc - bt_backpatch_loc(backpatch_counter, loc, rb_zjit_cfp_iseq(cfp), rb_zjit_cfp_pc(cfp)); - RB_OBJ_WRITTEN(btobj, Qundef, rb_zjit_cfp_iseq(cfp)); + bt_backpatch_loc(backpatch_counter, loc, rb_cfp_iseq(cfp), rb_cfp_pc(cfp)); + RB_OBJ_WRITTEN(btobj, Qundef, rb_cfp_iseq(cfp)); if (do_yield) { bt_yield_loc(loc - backpatch_counter, backpatch_counter, btobj); } @@ -1020,8 +1020,8 @@ backtrace_each(const rb_execution_context_t *ec, /* SDR(); */ for (i=0, cfp = start_cfp; i<size; i++, cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) { /* fprintf(stderr, "cfp: %d\n", (rb_control_frame_t *)(ec->vm_stack + ec->vm_stack_size) - cfp); */ - if (rb_zjit_cfp_has_iseq(cfp)) { - if (rb_zjit_cfp_has_pc(cfp)) { + if (rb_cfp_has_iseq(cfp)) { + if (rb_cfp_has_pc(cfp)) { iter_iseq(arg, cfp); } } @@ -1053,8 +1053,8 @@ oldbt_init(void *ptr, size_t dmy) static void oldbt_iter_iseq(void *ptr, const rb_control_frame_t *cfp) { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); - const VALUE *pc = rb_zjit_cfp_pc(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); + const VALUE *pc = rb_cfp_pc(cfp); struct oldbt_arg *arg = (struct oldbt_arg *)ptr; VALUE file = arg->filename = rb_iseq_path(iseq); VALUE name = ISEQ_BODY(iseq)->location.label; @@ -1551,7 +1551,7 @@ collect_caller_bindings_iseq(void *arg, const rb_control_frame_t *cfp) { struct collect_caller_bindings_data *data = (struct collect_caller_bindings_data *)arg; VALUE frame = rb_ary_new2(6); - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); rb_ary_store(frame, CALLER_BINDING_SELF, cfp->self); rb_ary_store(frame, CALLER_BINDING_CLASS, get_klass(cfp)); @@ -1562,7 +1562,7 @@ collect_caller_bindings_iseq(void *arg, const rb_control_frame_t *cfp) rb_backtrace_location_t *loc = &data->bt->backtrace[data->bt->backtrace_size++]; RB_OBJ_WRITE(data->btobj, &loc->cme, rb_vm_frame_method_entry(cfp)); RB_OBJ_WRITE(data->btobj, &loc->iseq, iseq); - loc->pc = rb_zjit_cfp_pc(cfp); + loc->pc = rb_cfp_pc(cfp); VALUE vloc = location_create(loc, (void *)data->btobj); rb_ary_store(frame, CALLER_BINDING_LOC, vloc); @@ -1747,7 +1747,7 @@ thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *b end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp); for (i=0; i<limit && cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { - if (VM_FRAME_RUBYFRAME_P_UNCHECKED(cfp) && rb_zjit_cfp_has_pc(cfp)) { + if (VM_FRAME_RUBYFRAME_P_UNCHECKED(cfp) && rb_cfp_has_pc(cfp)) { if (start > 0) { start--; continue; @@ -1755,7 +1755,7 @@ thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *b /* record frame info */ cme = rb_vm_frame_method_entry_unchecked(cfp); - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); if (cme && cme->def->type == VM_METHOD_TYPE_ISEQ) { buff[i] = (VALUE)cme; } @@ -1764,7 +1764,7 @@ thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *b } if (lines) { - const VALUE *pc = rb_zjit_cfp_pc(cfp); + const VALUE *pc = rb_cfp_pc(cfp); VALUE *iseq_encoded = ISEQ_BODY(iseq)->iseq_encoded; VALUE *pc_end = iseq_encoded + ISEQ_BODY(iseq)->iseq_size; @@ -920,7 +920,7 @@ struct rb_block { typedef struct rb_control_frame_struct { const VALUE *pc; // cfp[0] VALUE *sp; // cfp[1] - const rb_iseq_t *iseq; // cfp[2] + const rb_iseq_t *_iseq; // cfp[2] -- use rb_cfp_iseq(cfp) to read VALUE self; // cfp[3] / block[0] const VALUE *ep; // cfp[4] / block[1] const void *block_code; // cfp[5] / block[2] -- iseq, ifunc, or forwarded block handler @@ -1532,10 +1532,10 @@ static inline int VM_FRAME_CFRAME_P(const rb_control_frame_t *cfp) { int cframe_p = VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME) != 0; - // With ZJIT lightweight frames, cfp->iseq may be stale (not yet materialized), + // With ZJIT lightweight frames, cfp->_iseq may be stale (not yet materialized), // so skip this assertion when jit_return is set (zjit.h is not available here). VM_ASSERT(cfp->jit_return || - RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) != cframe_p || + RUBY_VM_NORMAL_ISEQ_P(cfp->_iseq) != cframe_p || (VM_FRAME_TYPE(cfp) & VM_FRAME_MAGIC_MASK) == VM_FRAME_MAGIC_DUMMY); return cframe_p; } @@ -119,8 +119,8 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c selfstr = ""; } - if (rb_zjit_cfp_has_iseq(cfp)) { - iseq = rb_zjit_cfp_iseq(cfp); + if (rb_cfp_has_iseq(cfp)) { + iseq = rb_cfp_iseq(cfp); #define RUBY_VM_IFUNC_P(ptr) IMEMO_TYPE_P(ptr, imemo_ifunc) if (RUBY_VM_IFUNC_P(iseq)) { iseq_name = "<ifunc>"; @@ -132,8 +132,8 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c line = -1; } else { - if (rb_zjit_cfp_has_pc(cfp)) { - pc = rb_zjit_cfp_pc(cfp) - ISEQ_BODY(iseq)->iseq_encoded; + if (rb_cfp_has_pc(cfp)) { + pc = rb_cfp_pc(cfp) - ISEQ_BODY(iseq)->iseq_encoded; iseq_name = RSTRING_PTR(ISEQ_BODY(iseq)->location.label); if (pc >= 0 && (size_t)pc <= ISEQ_BODY(iseq)->iseq_size) { line = rb_vm_get_sourceline(cfp); @@ -210,7 +210,7 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c if (ISEQ_BODY(iseq)->local_table_size > 0) { kprintf(" lvars:\n"); for (unsigned int i=0; i<ISEQ_BODY(iseq)->local_table_size; i++) { - const VALUE *argv = cfp->ep - ISEQ_BODY(cfp->iseq)->local_table_size - VM_ENV_DATA_SIZE + 1; + const VALUE *argv = cfp->ep - ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size - VM_ENV_DATA_SIZE + 1; kprintf(" %s: %s\n", rb_id2name(ISEQ_BODY(iseq)->local_table[i]), rb_raw_obj_info(buff, 0x100, argv[i])); @@ -341,9 +341,9 @@ box_env_dump(const rb_execution_context_t *ec, const VALUE *env, const rb_contro break; } - if (cfp && rb_zjit_cfp_has_iseq(cfp)) { + if (cfp && rb_cfp_has_iseq(cfp)) { #define RUBY_VM_IFUNC_P(ptr) IMEMO_TYPE_P(ptr, imemo_ifunc) - const rb_iseq_t *resolved_iseq = rb_zjit_cfp_iseq(cfp); + const rb_iseq_t *resolved_iseq = rb_cfp_iseq(cfp); if (RUBY_VM_IFUNC_P(resolved_iseq)) { iseq_name = "<ifunc>"; } @@ -354,9 +354,9 @@ box_env_dump(const rb_execution_context_t *ec, const VALUE *env, const rb_contro line = -1; } else { - if (rb_zjit_cfp_has_pc(cfp)) { + if (rb_cfp_has_pc(cfp)) { iseq = resolved_iseq; - pc = rb_zjit_cfp_pc(cfp) - ISEQ_BODY(iseq)->iseq_encoded; + pc = rb_cfp_pc(cfp) - ISEQ_BODY(iseq)->iseq_encoded; iseq_name = RSTRING_PTR(ISEQ_BODY(iseq)->location.label); if (pc >= 0 && (size_t)pc <= ISEQ_BODY(iseq)->iseq_size) { line = rb_vm_get_sourceline(cfp); @@ -567,9 +567,9 @@ static const VALUE * vm_base_ptr(const rb_control_frame_t *cfp) { const rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); - const VALUE *bp = prev_cfp->sp + ISEQ_BODY(cfp->iseq)->local_table_size + VM_ENV_DATA_SIZE; + const VALUE *bp = prev_cfp->sp + ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size + VM_ENV_DATA_SIZE; - if (ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_METHOD || VM_FRAME_BMETHOD_P(cfp)) { + if (ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_METHOD || VM_FRAME_BMETHOD_P(cfp)) { bp += 1; } return bp; @@ -584,7 +584,7 @@ vm_stack_dump_each(const rb_execution_context_t *ec, const rb_control_frame_t *c const VALUE *ep = cfp->ep; if (VM_FRAME_RUBYFRAME_P(cfp)) { - const rb_iseq_t *iseq = cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); argc = ISEQ_BODY(iseq)->param.lead_num; local_table_size = ISEQ_BODY(iseq)->local_table_size; } @@ -655,7 +655,7 @@ rb_vmdebug_debug_print_register(const rb_execution_context_t *ec, FILE *errout) ptrdiff_t cfpi; if (VM_FRAME_RUBYFRAME_P(cfp)) { - pc = cfp->pc - ISEQ_BODY(cfp->iseq)->iseq_encoded; + pc = cfp->pc - ISEQ_BODY(rb_cfp_iseq(cfp))->iseq_encoded; } if (ep < 0 || (size_t)ep > ec->vm_stack_size) { @@ -680,7 +680,7 @@ rb_vmdebug_thread_dump_regs(VALUE thval, FILE *errout) bool rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc, FILE *errout) { - const rb_iseq_t *iseq = cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); if (iseq != 0) { ptrdiff_t pc = _pc - ISEQ_BODY(iseq)->iseq_encoded; @@ -1988,12 +1988,12 @@ eval_string_with_cref(VALUE self, VALUE src, rb_cref_t *cref, VALUE file, int li block.as.captured = *VM_CFP_TO_CAPTURED_BLOCK(cfp); block.as.captured.self = self; - block.as.captured.code.iseq = rb_zjit_cfp_iseq(cfp); + block.as.captured.code.iseq = rb_cfp_iseq(cfp); block.type = block_type_iseq; // EP is not escaped to the heap here, but captured and reused by another frame. // ZJIT's locals are incompatible with it unlike YJIT's, so invalidate the ISEQ for ZJIT. - rb_zjit_invalidate_no_ep_escape(rb_zjit_cfp_iseq(cfp)); + rb_zjit_invalidate_no_ep_escape(rb_cfp_iseq(cfp)); iseq = eval_make_iseq(src, file, line, &block); if (!iseq) { @@ -2773,9 +2773,9 @@ rb_f_local_variables(VALUE _) local_var_list_init(&vars); while (cfp) { - if (cfp->iseq) { - for (i = 0; i < ISEQ_BODY(cfp->iseq)->local_table_size; i++) { - local_var_list_add(&vars, ISEQ_BODY(cfp->iseq)->local_table[i]); + if (rb_cfp_iseq(cfp)) { + for (i = 0; i < ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size; i++) { + local_var_list_add(&vars, ISEQ_BODY(rb_cfp_iseq(cfp))->local_table[i]); } } if (!VM_ENV_LOCAL_P(cfp->ep)) { @@ -2849,7 +2849,7 @@ rb_current_realfilepath(void) rb_control_frame_t *cfp = ec->cfp; cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)); if (cfp != NULL) { - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); VALUE path = rb_iseq_realpath(iseq); if (RTEST(path)) return path; // eval context @@ -2879,7 +2879,7 @@ struct vm_ifunc * rb_current_ifunc(void) { // Search VM_FRAME_MAGIC_IFUNC to see ifunc imemos put on the iseq field. - VALUE ifunc = (VALUE)GET_EC()->cfp->iseq; + VALUE ifunc = (VALUE)rb_cfp_iseq(GET_EC()->cfp); RUBY_ASSERT_ALWAYS(imemo_type_p(ifunc, imemo_ifunc)); return (struct vm_ifunc *)ifunc; } @@ -68,10 +68,10 @@ error ! #define INSN_ENTRY_SIG(insn) \ if (0) { \ ruby_debug_printf("exec: %s@(%"PRIdPTRDIFF", %"PRIdPTRDIFF")@%s:%u\n", #insn, \ - (reg_pc - ISEQ_BODY(reg_cfp->iseq)->iseq_encoded), \ - (reg_cfp->pc - ISEQ_BODY(reg_cfp->iseq)->iseq_encoded), \ - RSTRING_PTR(rb_iseq_path(reg_cfp->iseq)), \ - rb_iseq_line_no(reg_cfp->iseq, reg_pc - ISEQ_BODY(reg_cfp->iseq)->iseq_encoded)); \ + (reg_pc - ISEQ_BODY(rb_cfp_iseq(reg_cfp))->iseq_encoded), \ + (reg_cfp->pc - ISEQ_BODY(rb_cfp_iseq(reg_cfp))->iseq_encoded), \ + RSTRING_PTR(rb_iseq_path(rb_cfp_iseq(reg_cfp))), \ + rb_iseq_line_no(rb_cfp_iseq(reg_cfp), reg_pc - ISEQ_BODY(rb_cfp_iseq(reg_cfp))->iseq_encoded)); \ } #define INSN_DISPATCH_SIG(insn) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 1b5a40bc97..3d9f6062aa 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -405,7 +405,7 @@ vm_push_frame(rb_execution_context_t *ec, *cfp = (const struct rb_control_frame_struct) { .pc = pc, .sp = sp, - .iseq = iseq, + ._iseq = iseq, .self = self, .ep = sp - 1, .block_code = NULL, @@ -1767,16 +1767,16 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c escape_cfp = reg_cfp; while (ISEQ_BODY(base_iseq)->type != ISEQ_TYPE_BLOCK) { - if (ISEQ_BODY(rb_zjit_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_CLASS) { + if (ISEQ_BODY(rb_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_CLASS) { escape_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(escape_cfp); ep = escape_cfp->ep; - base_iseq = rb_zjit_cfp_iseq(escape_cfp); + base_iseq = rb_cfp_iseq(escape_cfp); } else { ep = VM_ENV_PREV_EP(ep); base_iseq = ISEQ_BODY(base_iseq)->parent_iseq; escape_cfp = rb_vm_search_cf_from_ep(ec, escape_cfp, ep); - VM_ASSERT(rb_zjit_cfp_iseq(escape_cfp) == base_iseq); + VM_ASSERT(rb_cfp_iseq(escape_cfp) == base_iseq); } } @@ -1790,8 +1790,8 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c while (escape_cfp < eocfp) { if (escape_cfp->ep == ep) { - const rb_iseq_t *const iseq = rb_zjit_cfp_iseq(escape_cfp); - const VALUE epc = rb_zjit_cfp_pc(escape_cfp) - ISEQ_BODY(iseq)->iseq_encoded; + const rb_iseq_t *const iseq = rb_cfp_iseq(escape_cfp); + const VALUE epc = rb_cfp_pc(escape_cfp) - ISEQ_BODY(iseq)->iseq_encoded; const struct iseq_catch_table *const ct = ISEQ_BODY(iseq)->catch_table; unsigned int i; @@ -1850,7 +1850,7 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c if (lep == target_lep && VM_FRAME_RUBYFRAME_P(escape_cfp) && - ISEQ_BODY(rb_zjit_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_CLASS) { + ISEQ_BODY(rb_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_CLASS) { in_class_frame = 1; target_lep = 0; } @@ -1880,7 +1880,7 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c } } else if (VM_FRAME_RUBYFRAME_P(escape_cfp)) { - switch (ISEQ_BODY(rb_zjit_cfp_iseq(escape_cfp))->type) { + switch (ISEQ_BODY(rb_cfp_iseq(escape_cfp))->type) { case ISEQ_TYPE_TOP: case ISEQ_TYPE_MAIN: if (toplevel) { @@ -1894,7 +1894,7 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c } break; case ISEQ_TYPE_EVAL: { - const rb_iseq_t *is = rb_zjit_cfp_iseq(escape_cfp); + const rb_iseq_t *is = rb_cfp_iseq(escape_cfp); enum rb_iseq_type t = ISEQ_BODY(is)->type; while (t == ISEQ_TYPE_RESCUE || t == ISEQ_TYPE_ENSURE || t == ISEQ_TYPE_EVAL) { if (!(is = ISEQ_BODY(is)->parent_iseq)) break; @@ -1912,7 +1912,7 @@ vm_throw_start(const rb_execution_context_t *ec, rb_control_frame_t *const reg_c } } - if (escape_cfp->ep == target_lep && ISEQ_BODY(rb_zjit_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_METHOD) { + if (escape_cfp->ep == target_lep && ISEQ_BODY(rb_cfp_iseq(escape_cfp))->type == ISEQ_TYPE_METHOD) { if (target_ep == NULL) { goto valid_return; } @@ -2376,7 +2376,7 @@ vm_search_method_fastpath(const struct rb_control_frame_struct *reg_cfp, struct } #endif - return vm_search_method_slowpath0((VALUE)rb_zjit_cfp_iseq(reg_cfp), cd, klass); + return vm_search_method_slowpath0((VALUE)rb_cfp_iseq(reg_cfp), cd, klass); } static const struct rb_callable_method_entry_struct * @@ -2661,18 +2661,18 @@ vm_base_ptr(const rb_control_frame_t *cfp) { const rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); - if (cfp->iseq && VM_FRAME_RUBYFRAME_P(cfp)) { - VALUE *bp = prev_cfp->sp + ISEQ_BODY(cfp->iseq)->local_table_size + VM_ENV_DATA_SIZE; + if (rb_cfp_iseq(cfp) && VM_FRAME_RUBYFRAME_P(cfp)) { + VALUE *bp = prev_cfp->sp + ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size + VM_ENV_DATA_SIZE; - if (ISEQ_BODY(cfp->iseq)->param.flags.forwardable && VM_ENV_LOCAL_P(cfp->ep)) { - int lts = ISEQ_BODY(cfp->iseq)->local_table_size; - int params = ISEQ_BODY(cfp->iseq)->param.size; + if (ISEQ_BODY(rb_cfp_iseq(cfp))->param.flags.forwardable && VM_ENV_LOCAL_P(cfp->ep)) { + int lts = ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size; + int params = ISEQ_BODY(rb_cfp_iseq(cfp))->param.size; CALL_INFO ci = (CALL_INFO)cfp->ep[-(VM_ENV_DATA_SIZE + (lts - params))]; // skip EP stuff, CI should be last local bp += vm_ci_argc(ci); } - if (ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_METHOD || VM_FRAME_BMETHOD_P(cfp)) { + if (ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_METHOD || VM_FRAME_BMETHOD_P(cfp)) { /* adjust `self' */ bp += 1; } @@ -3406,7 +3406,7 @@ vm_adjust_stack_forwarding(const struct rb_execution_context_struct *ec, struct iseq = env->iseq; } else { // Otherwise use the lep to find the caller - iseq = rb_vm_search_cf_from_ep(ec, cfp, lep)->iseq; + iseq = rb_cfp_iseq(rb_vm_search_cf_from_ep(ec, cfp, lep)); } // Our local storage is below the args we need to copy @@ -4613,8 +4613,8 @@ current_method_entry(const rb_execution_context_t *ec, rb_control_frame_t *cfp) { rb_control_frame_t *top_cfp = cfp; - if (cfp->iseq && ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_BLOCK) { - const rb_iseq_t *local_iseq = ISEQ_BODY(cfp->iseq)->local_iseq; + if (rb_cfp_iseq(cfp) && ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_BLOCK) { + const rb_iseq_t *local_iseq = ISEQ_BODY(rb_cfp_iseq(cfp))->local_iseq; do { cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); @@ -4622,7 +4622,7 @@ current_method_entry(const rb_execution_context_t *ec, rb_control_frame_t *cfp) /* TODO: orphan block */ return top_cfp; } - } while (cfp->iseq != local_iseq); + } while (rb_cfp_iseq(cfp) != local_iseq); } return cfp; } @@ -4705,7 +4705,7 @@ vm_call_refined(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_c if (ref_cme) { if (calling->cd->cc) { const struct rb_callcache *cc = calling->cc = vm_cc_new(vm_cc_cme(calling->cc)->defined_class, ref_cme, vm_call_general, cc_type_refinement); - RB_OBJ_WRITE(rb_zjit_cfp_iseq(cfp), &calling->cd->cc, cc); + RB_OBJ_WRITE(rb_cfp_iseq(cfp), &calling->cd->cc, cc); return vm_call_method(ec, cfp, calling); } else { @@ -5126,7 +5126,7 @@ static const struct rb_callcache * vm_search_super_method(const rb_control_frame_t *reg_cfp, struct rb_call_data *cd, VALUE recv) { VALUE current_defined_class; - const rb_iseq_t *iseq = rb_zjit_cfp_iseq(reg_cfp); + const rb_iseq_t *iseq = rb_cfp_iseq(reg_cfp); const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(reg_cfp); if (!me) { @@ -6170,7 +6170,7 @@ rb_vm_sendforward(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, CALL_ VALUE val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_method); if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) { - RB_OBJ_WRITE(rb_zjit_cfp_iseq(GET_CFP()), &cd->cc, adjusted_cd.cd.cc); + RB_OBJ_WRITE(rb_cfp_iseq(GET_CFP()), &cd->cc, adjusted_cd.cd.cc); } VM_EXEC(ec, val); @@ -6212,7 +6212,7 @@ rb_vm_invokesuperforward(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp VALUE val = vm_sendish(ec, GET_CFP(), &adjusted_cd.cd, bh, mexp_search_super); if (cd->cc != adjusted_cd.cd.cc && vm_cc_markable(adjusted_cd.cd.cc)) { - RB_OBJ_WRITE(rb_zjit_cfp_iseq(GET_CFP()), &cd->cc, adjusted_cd.cd.cc); + RB_OBJ_WRITE(rb_cfp_iseq(GET_CFP()), &cd->cc, adjusted_cd.cd.cc); } VM_EXEC(ec, val); @@ -6620,7 +6620,7 @@ rb_vm_opt_getconstant_path(rb_execution_context_t *ec, rb_control_frame_t *const vm_ic_track_const_chain(GET_CFP(), ic, segments); // Undo the PC increment to get the address to this instruction // INSN_ATTR(width) == 2 - vm_ic_update(rb_zjit_cfp_iseq(GET_CFP()), ic, val, GET_EP(), rb_zjit_cfp_pc(GET_CFP()) - 2); + vm_ic_update(rb_cfp_iseq(GET_CFP()), ic, val, GET_EP(), rb_cfp_pc(GET_CFP()) - 2); } return val; } @@ -6645,7 +6645,7 @@ vm_once_dispatch(rb_execution_context_t *ec, ISEQ iseq, ISE is) RB_OBJ_SET_SHAREABLE(val); } - RB_OBJ_WRITE(ec->cfp->iseq, &is->once.value, val); + RB_OBJ_WRITE(rb_cfp_iseq(ec->cfp), &is->once.value, val); /* is->once.running_thread is cleared by vm_once_clear() */ is->once.running_thread = RUNNING_THREAD_ONCE_DONE; /* success */ @@ -6714,7 +6714,7 @@ vm_stack_consistency_error(const rb_execution_context_t *ec, #if defined RUBY_DEVEL VALUE mesg = rb_sprintf(stack_consistency_error, nsp, nbp); rb_str_cat_cstr(mesg, "\n"); - rb_str_append(mesg, rb_iseq_disasm(cfp->iseq)); + rb_str_append(mesg, rb_iseq_disasm(rb_cfp_iseq(cfp))); rb_exc_fatal(rb_exc_new3(rb_eFatal, mesg)); #else rb_bug(stack_consistency_error, nsp, nbp); @@ -7244,7 +7244,7 @@ static VALUE rescue_errinfo(rb_execution_context_t *ec, rb_control_frame_t *cfp) { VM_ASSERT(VM_FRAME_RUBYFRAME_P(cfp)); - VM_ASSERT(ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_RESCUE); + VM_ASSERT(ISEQ_BODY(rb_cfp_iseq(cfp))->type == ISEQ_TYPE_RESCUE); return cfp->ep[VM_ENV_INDEX_LAST_LVAR]; } @@ -7260,7 +7260,7 @@ vm_trace(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) return; } else { - const rb_iseq_t *iseq = reg_cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(reg_cfp); size_t pos = pc - ISEQ_BODY(iseq)->iseq_encoded; rb_event_flag_t pc_events = rb_iseq_event_flags(iseq, pos); unsigned int local_hooks_cnt = iseq->aux.exec.local_hooks_cnt; @@ -7546,7 +7546,7 @@ lookup_builtin_invoker(int argc) static inline VALUE invoke_bf(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const struct rb_builtin_function* bf, const VALUE *argv) { - const bool canary_p = ISEQ_BODY(reg_cfp->iseq)->builtin_attrs & BUILTIN_ATTR_LEAF; // Verify an assumption of `Primitive.attr! :leaf` + const bool canary_p = ISEQ_BODY(rb_cfp_iseq(reg_cfp))->builtin_attrs & BUILTIN_ATTR_LEAF; // Verify an assumption of `Primitive.attr! :leaf` SETUP_CANARY(canary_p); rb_insn_func_t func_ptr = (rb_insn_func_t)(uintptr_t)bf->func_ptr; VALUE ret = (*lookup_builtin_invoker(bf->argc))(ec, reg_cfp->self, argv, func_ptr); @@ -7566,7 +7566,7 @@ vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp, if (0) { // debug print fputs("vm_invoke_builtin_delegate: passing -> ", stderr); for (int i=0; i<bf->argc; i++) { - ruby_debug_printf(":%s ", rb_id2name(ISEQ_BODY(cfp->iseq)->local_table[i+start_index])); + ruby_debug_printf(":%s ", rb_id2name(ISEQ_BODY(rb_cfp_iseq(cfp))->local_table[i+start_index])); } ruby_debug_printf("\n" "%s %s(%d):%p\n", RUBY_FUNCTION_NAME_STRING, bf->name, bf->argc, (void *)(uintptr_t)bf->func_ptr); @@ -7576,7 +7576,7 @@ vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp, return invoke_bf(ec, cfp, bf, NULL); } else { - const VALUE *argv = cfp->ep - ISEQ_BODY(cfp->iseq)->local_table_size - VM_ENV_DATA_SIZE + 1 + start_index; + const VALUE *argv = cfp->ep - ISEQ_BODY(rb_cfp_iseq(cfp))->local_table_size - VM_ENV_DATA_SIZE + 1 + start_index; return invoke_bf(ec, cfp, bf, argv); } } diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 6d32a7535b..d1bd57753d 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -114,7 +114,7 @@ enum vm_regan_acttype { /* set current stack value as x */ /* instruction sequence C struct */ -#define GET_ISEQ() (GET_CFP()->iseq) +#define GET_ISEQ() (rb_cfp_iseq(GET_CFP())) /**********************************************************/ /* deal with variables */ diff --git a/vm_method.c b/vm_method.c index 521595d0b1..eb0eb005eb 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1084,7 +1084,7 @@ rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *de cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); if (cfp && (line = rb_vm_get_sourceline(cfp))) { - VALUE location = rb_ary_new3(2, rb_iseq_path(cfp->iseq), INT2FIX(line)); + VALUE location = rb_ary_new3(2, rb_iseq_path(rb_cfp_iseq(cfp)), INT2FIX(line)); rb_ary_freeze(location); RB_OBJ_SET_SHAREABLE(location); RB_OBJ_WRITE(me, &def->body.attr.location, location); @@ -2330,7 +2330,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 && ISEQ_BODY(cfp->iseq)->type == ISEQ_TYPE_METHOD) { + if (cfp && rb_cfp_iseq(cfp) && ISEQ_BODY(rb_cfp_iseq(cfp))->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())); } diff --git a/vm_trace.c b/vm_trace.c index 1dc1760814..62e03442e2 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -812,7 +812,7 @@ get_path_and_lineno(const rb_execution_context_t *ec, const rb_control_frame_t * cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp); if (cfp) { - const rb_iseq_t *iseq = cfp->iseq; + const rb_iseq_t *iseq = rb_cfp_iseq(cfp); *pathp = rb_iseq_path(iseq); if (event & (RUBY_EVENT_CLASS | @@ -862,7 +862,7 @@ call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas if (self && (filename != Qnil) && event != RUBY_EVENT_C_CALL && event != RUBY_EVENT_C_RETURN && - (VM_FRAME_RUBYFRAME_P(ec->cfp) && imemo_type_p((VALUE)ec->cfp->iseq, imemo_iseq))) { + (VM_FRAME_RUBYFRAME_P(ec->cfp) && imemo_type_p((VALUE)rb_cfp_iseq(ec->cfp), imemo_iseq))) { argv[4] = rb_binding_new(); } argv[5] = klass ? klass : Qnil; @@ -1041,7 +1041,7 @@ rb_tracearg_parameters(rb_trace_arg_t *trace_arg) if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_BLOCK && !VM_FRAME_LAMBDA_P(cfp)) { is_proc = 1; } - return rb_iseq_parameters(cfp->iseq, is_proc); + return rb_iseq_parameters(rb_cfp_iseq(cfp), is_proc); } break; } @@ -1103,7 +1103,7 @@ rb_tracearg_binding(rb_trace_arg_t *trace_arg) } cfp = rb_vm_get_binding_creatable_next_cfp(trace_arg->ec, trace_arg->cfp); - if (cfp && imemo_type_p((VALUE)cfp->iseq, imemo_iseq)) { + if (cfp && imemo_type_p((VALUE)rb_cfp_iseq(cfp), imemo_iseq)) { return rb_vm_make_binding(trace_arg->ec, cfp); } else { @@ -83,7 +83,7 @@ CFP_HAS_JIT_RETURN(const rb_control_frame_t *cfp) } static inline const VALUE* -rb_zjit_cfp_pc(const rb_control_frame_t *cfp) +rb_cfp_pc(const rb_control_frame_t *cfp) { if (CFP_HAS_JIT_RETURN(cfp)) { return ((const zjit_jit_frame_t *)cfp->jit_return)->pc; @@ -92,30 +92,30 @@ rb_zjit_cfp_pc(const rb_control_frame_t *cfp) } static inline const rb_iseq_t* -rb_zjit_cfp_iseq(const rb_control_frame_t *cfp) +rb_cfp_iseq(const rb_control_frame_t *cfp) { if (CFP_HAS_JIT_RETURN(cfp)) { return ((const zjit_jit_frame_t *)cfp->jit_return)->iseq; } - return cfp->iseq; + return cfp->_iseq; } // Returns true if cfp has an ISEQ, either directly or via JITFrame. -// When JITFrame is present, it is authoritative (cfp->iseq may be stale). +// When JITFrame is present, it is authoritative (cfp->_iseq may be stale). // C frames with JITFrame have iseq=NULL, so this returns false for them. static inline bool -rb_zjit_cfp_has_iseq(const rb_control_frame_t *cfp) +rb_cfp_has_iseq(const rb_control_frame_t *cfp) { - return !!rb_zjit_cfp_iseq(cfp); + return !!rb_cfp_iseq(cfp); } // Returns true if cfp has a PC, either directly or via JITFrame. // When JITFrame is present, it is authoritative (cfp->pc may be stale/poisoned). // C frames with JITFrame have pc=NULL, so this returns false for them. static inline bool -rb_zjit_cfp_has_pc(const rb_control_frame_t *cfp) +rb_cfp_has_pc(const rb_control_frame_t *cfp) { - return !!rb_zjit_cfp_pc(cfp); + return !!rb_cfp_pc(cfp); } #endif // #ifndef ZJIT_H diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index c59dfbe525..9846a0e70a 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -3072,7 +3072,7 @@ c_callable! { // Clear jit_return so the interpreter reads cfp->pc and cfp->iseq directly. let pc = unsafe { rb_iseq_pc_at_idx(iseq, entry_insn_idxs[iseq_call.jit_entry_idx.to_usize()]) }; unsafe { rb_set_cfp_pc(cfp, pc) }; - unsafe { (*cfp).iseq = iseq }; + unsafe { (*cfp)._iseq = iseq }; unsafe { (*cfp).jit_return = std::ptr::null_mut() }; } diff --git a/zjit/src/cruby_bindings.inc.rs b/zjit/src/cruby_bindings.inc.rs index 9a82d6a29f..d8fdcbb845 100644 --- a/zjit/src/cruby_bindings.inc.rs +++ b/zjit/src/cruby_bindings.inc.rs @@ -1303,7 +1303,7 @@ pub struct rb_block__bindgen_ty_1 { pub struct rb_control_frame_struct { pub pc: *const VALUE, pub sp: *mut VALUE, - pub iseq: *const rb_iseq_t, + pub _iseq: *const rb_iseq_t, pub self_: VALUE, pub ep: *const VALUE, pub block_code: *const ::std::os::raw::c_void, |
