ruby-changes:62205
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 13 Jul 2020 12:31:17 +0900 (JST)
Subject: [ruby-changes:62205] 927fe2422f (master): mk_builtin_loader.rb: STACK_ADDR_FROM_TOP unusable
https://git.ruby-lang.org/ruby.git/commit/?id=927fe2422f From 927fe2422fe8ca3ee50b76c3ee82d3238ea2daca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Mon, 13 Jul 2020 12:27:53 +0900 Subject: mk_builtin_loader.rb: STACK_ADDR_FROM_TOP unusable Stacks are emulated in MJIT, must not touch the original VM stack. See also http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3061353 diff --git a/builtin.h b/builtin.h index 0da200f..607458e 100644 --- a/builtin.h +++ b/builtin.h @@ -13,7 +13,7 @@ struct rb_builtin_function { https://github.com/ruby/ruby/blob/trunk/builtin.h#L13 const char * const name; // for jit - void (*compiler)(FILE *, long); + void (*compiler)(FILE *, long, unsigned); }; #define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\ diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index 18fa361..271c47f 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -286,7 +286,7 @@ def mk_builtin_header file https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L286 bs.each_pair{|func, (argc, cfunc_name)| f.puts %'static void' - f.puts %'mjit_compile_invokebuiltin_for_#{func}(FILE *f, long index)' + f.puts %'mjit_compile_invokebuiltin_for_#{func}(FILE *f, long index, unsigned stack_size)' f.puts %'{' if inlines.has_key? cfunc_name f.puts %' fprintf(f, " MAYBE_UNUSED(VALUE) self = GET_SELF();\\n");' @@ -304,7 +304,7 @@ def mk_builtin_header file https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L304 f.puts %' fprintf(f, " typedef VALUE (*func)(rb_execution_context_t *, VALUE#{decl});\\n");' if argc > 0 f.puts %' if (index == -1) {' - f.puts %' fprintf(f, " const VALUE *argv = STACK_ADDR_FROM_TOP(%d);\\n", #{argc});' + f.puts %' fprintf(f, " const VALUE *argv = &stack[%d];\\n", stack_size - #{argc});' f.puts %' }' f.puts %' else {' f.puts %' fprintf(f, " const unsigned int lnum = GET_ISEQ()->body->local_table_size;\\n");' diff --git a/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb index a95a8a7..29a21b1 100644 --- a/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb +++ b/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb @@ -19,7 +19,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_invokebuiltin.erb#L19 fprintf(f, " VALUE val;\n"); bf->compiler(f, <%= insn.name == 'invokebuiltin' ? '-1' : '(rb_num_t)operands[1]' - %>); + %>, b->stack_size); fprintf(f, " stack[%u] = val;\n", sp - 1); fprintf(f, "}\n"); % if insn.name != 'opt_invokebuiltin_delegate_leave' -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/