ruby-changes:51776
From: k0kubun <ko1@a...>
Date: Wed, 18 Jul 2018 00:09:47 +0900 (JST)
Subject: [ruby-changes:51776] k0kubun:r63988 (trunk): mjit_compile.c: resurrect local variable stack
k0kubun 2018-07-18 00:09:41 +0900 (Wed, 18 Jul 2018) New Revision: 63988 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63988 Log: mjit_compile.c: resurrect local variable stack This optimization was reverted on r63863, but this commit resurrects the optimization to skip some sp motions on JIT execution. tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto tool/ruby_vm/views/_mjit_compile_insn.erb: ditto insns.def: resurrect handles_frame as handles_stack, which was deleted on r63763. tool/ruby_vm/models/bare_instructions.rb: ditto vm_insnhelper.c: prevent moving sp outside insns.def to allow modifying it by JIT. * Optcarrot benchmark $ benchmark-driver benchmark.yml --rbenv 'before --jit;after --jit' --repeat-count 12 -v before --jit: ruby 2.6.0dev (2018-07-17 trunk 63987) +JIT [x86_64-linux] after --jit: ruby 2.6.0dev (2018-07-17 local-stack 63987) +JIT [x86_64-linux] last_commit=mjit_compile.c: resurrect local variable stack Calculating ------------------------------------- before --jit after --jit Optcarrot Lan_Master.nes 70.518 72.144 fps Comparison: Optcarrot Lan_Master.nes after --jit: 72.1 fps before --jit: 70.5 fps - 1.02x slower Modified files: trunk/insns.def trunk/mjit_compile.c trunk/tool/ruby_vm/models/bare_instructions.rb trunk/tool/ruby_vm/views/_mjit_compile_insn.erb trunk/tool/ruby_vm/views/_mjit_compile_insn_body.erb trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb trunk/tool/ruby_vm/views/_mjit_compile_send.erb trunk/tool/ruby_vm/views/mjit_compile.inc.erb trunk/vm_insnhelper.c Index: insns.def =================================================================== --- insns.def (revision 63987) +++ insns.def (revision 63988) @@ -43,6 +43,9 @@ https://github.com/ruby/ruby/blob/trunk/insns.def#L43 * sp_inc: Used to dynamically calculate sp increase in `insn_stack_increase`. + * handles_stack: If this is true, JIT makes sure that values are + set to VM stack. + - Attributes can access operands, but not stack (push/pop) variables. - An instruction's body is a pure C block, copied verbatimly into @@ -451,7 +454,7 @@ expandarray https://github.com/ruby/ruby/blob/trunk/insns.def#L454 (...) // attr rb_snum_t sp_inc = num - 1 + (flag & 1 ? 1 : 0); { - vm_expandarray(GET_CFP(), ary, num, (int)flag); + INC_SP(vm_expandarray(GET_SP(), ary, num, (int)flag)); } /* concat two arrays */ @@ -690,6 +693,7 @@ defineclass https://github.com/ruby/ruby/blob/trunk/insns.def#L693 (ID id, ISEQ class_iseq, rb_num_t flags) (VALUE cbase, VALUE super) (VALUE val) +// attr bool handles_stack = true; { VALUE klass = vm_find_or_create_class_by_id(id, flags, cbase, super); @@ -716,6 +720,7 @@ send https://github.com/ruby/ruby/blob/trunk/insns.def#L720 (CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq) (...) (VALUE val) +// attr bool handles_stack = true; // attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0)); { struct rb_calling_info calling; @@ -771,6 +776,7 @@ opt_send_without_block https://github.com/ruby/ruby/blob/trunk/insns.def#L776 (CALL_INFO ci, CALL_CACHE cc) (...) (VALUE val) +// attr bool handles_stack = true; // attr rb_snum_t sp_inc = -ci->orig_argc; { struct rb_calling_info calling; @@ -785,6 +791,7 @@ invokesuper https://github.com/ruby/ruby/blob/trunk/insns.def#L791 (CALL_INFO ci, CALL_CACHE cc, ISEQ blockiseq) (...) (VALUE val) +// attr bool handles_stack = true; // attr rb_snum_t sp_inc = - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0)); { struct rb_calling_info calling; @@ -802,6 +809,7 @@ invokeblock https://github.com/ruby/ruby/blob/trunk/insns.def#L809 (CALL_INFO ci) (...) (VALUE val) +// attr bool handles_stack = true; // attr rb_snum_t sp_inc = 1 - ci->orig_argc; { struct rb_calling_info calling; @@ -828,6 +836,7 @@ leave https://github.com/ruby/ruby/blob/trunk/insns.def#L836 () (VALUE val) (VALUE val) +// attr bool handles_stack = true; { if (OPT_CHECKED_RUN) { const VALUE *const bp = vm_base_ptr(reg_cfp); @@ -989,9 +998,9 @@ opt_plus https://github.com/ruby/ruby/blob/trunk/insns.def#L998 val = vm_opt_plus(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1008,9 +1017,9 @@ opt_minus https://github.com/ruby/ruby/blob/trunk/insns.def#L1017 val = vm_opt_minus(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1027,9 +1036,9 @@ opt_mult https://github.com/ruby/ruby/blob/trunk/insns.def#L1036 val = vm_opt_mult(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1046,9 +1055,9 @@ opt_div https://github.com/ruby/ruby/blob/trunk/insns.def#L1055 val = vm_opt_div(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1065,9 +1074,9 @@ opt_mod https://github.com/ruby/ruby/blob/trunk/insns.def#L1074 val = vm_opt_mod(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1084,9 +1093,9 @@ opt_eq https://github.com/ruby/ruby/blob/trunk/insns.def#L1093 val = opt_eq_func(recv, obj, ci, cc); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1103,9 +1112,9 @@ opt_neq https://github.com/ruby/ruby/blob/trunk/insns.def#L1112 val = vm_opt_neq(ci, cc, ci_eq, cc_eq, recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1122,9 +1131,9 @@ opt_lt https://github.com/ruby/ruby/blob/trunk/insns.def#L1131 val = vm_opt_lt(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1141,9 +1150,9 @@ opt_le https://github.com/ruby/ruby/blob/trunk/insns.def#L1150 val = vm_opt_le(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1160,9 +1169,9 @@ opt_gt https://github.com/ruby/ruby/blob/trunk/insns.def#L1169 val = vm_opt_gt(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1179,9 +1188,9 @@ opt_ge https://github.com/ruby/ruby/blob/trunk/insns.def#L1188 val = vm_opt_ge(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1198,9 +1207,9 @@ opt_ltlt https://github.com/ruby/ruby/blob/trunk/insns.def#L1207 val = vm_opt_ltlt(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1217,9 +1226,9 @@ opt_aref https://github.com/ruby/ruby/blob/trunk/insns.def#L1226 val = vm_opt_aref(recv, obj); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1236,10 +1245,10 @@ opt_aset https://github.com/ruby/ruby/blob/trunk/insns.def#L1245 val = vm_opt_aset(recv, obj, set); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(recv); PUSH(obj); PUSH(set); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1259,12 +1268,12 @@ opt_aset_with https://github.com/ruby/ruby/blob/trunk/insns.def#L1268 val = tmp; } else { +#ifndef MJIT_HEADER PUSH(recv); #ifndef MJIT_HEADER PUSH(rb_str_resurrect(key)); #endif PUSH(val); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1281,8 +1290,8 @@ opt_aref_with https://github.com/ruby/ruby/blob/trunk/insns.def#L1290 val = vm_opt_aref_with(recv, key); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); PUSH(rb_str_resurrect(key)); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif @@ -1300,8 +1309,8 @@ opt_length https://github.com/ruby/ruby/blob/trunk/insns.def#L1309 val = vm_opt_length(recv, BOP_LENGTH); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1318,8 +1327,8 @@ opt_size https://github.com/ruby/ruby/blob/trunk/insns.def#L1327 val = vm_opt_length(recv, BOP_SIZE); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1336,8 +1345,8 @@ opt_empty_p https://github.com/ruby/ruby/blob/trunk/insns.def#L1345 val = vm_opt_empty_p(recv); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1354,8 +1363,8 @@ opt_succ https://github.com/ruby/ruby/blob/trunk/insns.def#L1363 val = vm_opt_succ(recv); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1372,8 +1381,8 @@ opt_not https://github.com/ruby/ruby/blob/trunk/insns.def#L1381 val = vm_opt_not(ci, cc, recv); if (val == Qundef) { - PUSH(recv); #ifndef MJIT_HEADER + PUSH(recv); ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1400,9 +1409,9 @@ opt_regexpmatch2 https://github.com/ruby/ruby/blob/trunk/insns.def#L1409 val = vm_opt_regexpmatch2(obj2, obj1); if (val == Qundef) { +#ifndef MJIT_HEADER PUSH(obj2); PUSH(obj1); -#ifndef MJIT_HEADER ADD_PC(-WIDTH_OF_opt_send_without_block); #endif DISPATCH_ORIGINAL_INSN(opt_send_without_block); @@ -1415,6 +1424,7 @@ opt_call_c_function https://github.com/ruby/ruby/blob/trunk/insns.def#L1424 (rb_insn_func_t funcptr) () () +// attr bool handles_stack = true; { reg_cfp = (funcptr)(ec, reg_cfp); Index: mjit_compile.c =================================================================== --- mjit_compile.c (revision 63987) +++ mjit_compile.c (revision 63988) @@ -24,6 +24,9 @@ https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L24 struct compile_status { int success; /* has TRUE if compilation has had no issue */ int *stack_size_for_pos; /* stack_size_for_pos[pos] has stack size for the position (otherwise -1) */ + /* If TRUE, JIT-ed code will use local variables to store pushed values instead of + using VM's stack and moving stack pointer. */ + int local_stack_p; }; /* Storage to keep data which is consistent in each conditional branch. @@ -172,7 +175,13 @@ compile_insns(FILE *f, const struct rb_i https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L175 static void compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct compile_status *status) { + unsigned int i; fprintf(f, "\ncancel:\n"); + if (status->local_stack_p) { + for (i = 0; i < body->stack_max; i++) { + fprintf(f, " *((VALUE *)reg_cfp->bp + %d) = stack[%d];\n", i + 1, i); + } + } fprintf(f, " return Qundef;\n"); } @@ -182,6 +191,7 @@ mjit_compile(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L191 { struct compile_status status; status.success = TRUE; + status.local_stack_p = !body->catch_except_p; status.stack_size_for_pos = ALLOC_N(int, body->iseq_size); memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size); @@ -195,7 +205,12 @@ mjit_compile(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L205 fprintf(f, "__declspec(dllexport)\n"); #endif fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname); - fprintf(f, " VALUE *stack = reg_cfp->sp;\n"); + if (status.local_stack_p) { + fprintf(f, " VALUE stack[%d];\n", body->stack_max); + } + else { + fprintf(f, " VALUE *stack = reg_cfp->sp;\n"); + } fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)body->iseq_encoded); Index: tool/ruby_vm/views/_mjit_compile_insn.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_insn.erb (revision 63987) +++ tool/ruby_vm/views/_mjit_compile_insn.erb (revision 63988) @@ -20,6 +20,16 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn.erb#L20 MAYBE_UNUSED(<%= ope.fetch(:decl) %>) = (<%= ope.fetch(:type) %>)operands[<%= i %>]; % end % +% # JIT: Declare stack_size to be used in some macro of _mjit_compile_insn_body.erb + if (status->local_stack_p) { +% # TODO: can we use some functions to calculate this? +% if insn.name == 'send' || insn.name == 'invokesuper' + fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %> - ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0)); +% else + fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %>); +% end + } +% % # JIT: Declare variables for operands, popped values and return values % insn.declarations.each do |decl| fprintf(f, " <%= decl %>;\n"); Index: tool/ruby_vm/views/_mjit_compile_insn_body.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_insn_body.erb (revision 63987) +++ tool/ruby_vm/views/_mjit_compile_insn_body.erb (revision 63988) @@ -69,8 +69,28 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn_body.erb#L69 % end % when /\A\s+DISPATCH_ORIGINAL_INSN\([^)]+\);\s+\z/ % # For `opt_xxx`'s fallbacks. + fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1); fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); fprintf(f, " goto cancel;\n"); +% # If local_stack_p is TRUE, stack values are only available in local variables +% # for stack. So we need to replace those macros if local_stack_p is TRUE here. +% when /\bGET_SP\(\)/ +% # reg_cfp->sp + fprintf(f, <%= to_cstr.call(line.sub(/\bGET_SP\(\)/, '%s')) %>, (status->local_stack_p ? "(stack + stack_size)" : "GET_SP()")); +% when /\bSTACK_ADDR_FROM_TOP\((?<num>[^)]+)\)/ +% # #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n)) +% num = Regexp.last_match[:num] + fprintf(f, <%= to_cstr.call(line.sub(/\bSTACK_ADDR_FROM_TOP\(([^)]+)\)/, '%s')) %>, + (status->local_stack_p ? "stack + (stack_size - (<%= num %>))" : "STACK_ADDR_FROM_TOP(<%= num %>)")); +% when /\bTOPN\((?<num>[^)]+)\)/ +% # #define TOPN(n) (*(GET_SP()-(n)-1)) +% num = Regexp.last_match[:num] + fprintf(f, <%= to_cstr.call(line.sub(/\bTOPN\(([^)]+)\)/, '%s')) %>, + (status->local_stack_p ? "*(stack + (stack_size - (<%= num %>) - 1))" : "TOPN(<%= num %>)")); +% when /\bPOPN\([^)]+\)/ # skip sp motion on JIT + fprintf(f, <%= to_cstr.call(line.sub(/\bPOPN\((?<num>[^)]+)\)/) { Regexp.last_match[:num] }) %>); +% when /\bINC_SP\([^)]+\)/ # skip sp motion on JIT + fprintf(f, <%= to_cstr.call(line.sub(/\bINC_SP\((?<num>[^)]+)\)/) { Regexp.last_match[:num] }) %>); % else fprintf(f, <%= to_cstr.call(line) %>); % end Index: tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb (revision 63987) +++ tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb (revision 63988) @@ -12,4 +12,19 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb#L12 } % % # JIT: move sp to use or preserve stack variables - fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */ + if (status->local_stack_p) { +% # sp motion is optimized away for `handles_frame? #=> false` case. +% # Thus sp should be set properly before `goto cancel`. +% if insn.handles_stack? +% # JIT-only behavior (pushing JIT's local variables to VM's stack): + rb_snum_t i, push_size; + push_size = -<%= insn.call_attribute('sp_inc') %> + <%= insn.rets.size %> - <%= insn.pops.size %>; + fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */ + for (i = 0; i < push_size; i++) { /* TODO: use memcpy? */ + fprintf(f, " *(reg_cfp->sp + %ld) = stack[%ld];\n", i - push_size, (rb_snum_t)b->stack_size - push_size + i); + } +% end + } + else { + fprintf(f, " reg_cfp->sp = (VALUE *)reg_cfp->bp + %d;\n", b->stack_size + 1 - <%= insn.pops.size %>); /* POPN(INSN_ATTR(popn)); */ + } Index: tool/ruby_vm/views/_mjit_compile_send.erb =================================================================== --- tool/ruby_vm/views/_mjit_compile_send.erb (revision 63987) +++ tool/ruby_vm/views/_mjit_compile_send.erb (revision 63988) @@ -24,6 +24,11 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_send.erb#L24 int param_size = iseq->body->param.size; /* TODO: check calling->argc for argument_arity_error */ fprintf(f, "{\n"); +% # JIT: Declare stack_size to be used in some macro of _mjit_compile_insn_body.erb + if (status->local_stack_p) { + /* TODO: can we use some functions to calculate this? */ + fprintf(f, " MAYBE_UNUSED(unsigned int) stack_size = %u;\n", b->stack_size - <%= insn.pops.size %> - ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0)); + } % # JIT: Invalidate call cache if it requires vm_search_method. This allows to inline some of following things. <%= render 'mjit_compile_send_guard' -%> Index: tool/ruby_vm/views/mjit_compile.inc.erb =================================================================== --- tool/ruby_vm/views/mjit_compile.inc.erb (revision 63987) +++ tool/ruby_vm/views/mjit_compile.inc.erb (revision 63988) @@ -31,13 +31,13 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/mjit_compile.inc.erb#L31 % # reg_cfp: the second argument of _mjitXXX % # GET_CFP(): refers to `reg_cfp` % # GET_EP(): refers to `reg_cfp->ep` -% # GET_SP(): refers to `reg_cfp->sp` +% # GET_SP(): refers to `reg_cfp->sp`, or `(stack + stack_size)` if local_stack_p % # GET_SELF(): refers to `reg_cfp->self` % # GET_LEP(): refers to `VM_EP_LEP(reg_cfp->ep)` % # EXEC_EC_CFP(): refers to `val = vm_exec(ec, TRUE)` with frame setup % # CALL_METHOD(): using `GET_CFP()` and `EXEC_EC_CFP()` -% # TOPN(): refers to `reg_cfp->sp` -% # STACK_ADDR_FROM_TOP(): refers to `reg_cfp->sp` +% # TOPN(): refers to `reg_cfp->sp`, or `*(stack + (stack_size - num - 1))` if local_stack_p +% # STACK_ADDR_FROM_TOP(): refers to `reg_cfp->sp`, or `stack + (stack_size - num)` if local_stack_p % # DISPATCH_ORIGINAL_INSN(): expanded in _mjit_compile_insn.erb % # THROW_EXCEPTION(): specially defined for JIT % # RESTORE_REGS(): specially defined for `leave` Index: tool/ruby_vm/models/bare_instructions.rb =================================================================== --- tool/ruby_vm/models/bare_instructions.rb (revision 63987) +++ tool/ruby_vm/models/bare_instructions.rb (revision 63988) @@ -101,6 +101,10 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/