MJIT Support for getblockparamproxy

This commit is contained in:
Takashi Kokubun 2019-07-14 18:04:14 +09:00
parent 043e3d2cdc
commit d30d404bc4
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
5 changed files with 18 additions and 5 deletions

View File

@ -18,7 +18,6 @@ class TestJIT < Test::Unit::TestCase
# trace_* insns are not compiled for now...
TEST_PENDING_INSNS = RubyVM::INSTRUCTION_NAMES.select { |n| n.start_with?('trace_') }.map(&:to_sym) + [
# not supported yet
:getblockparamproxy,
:defineclass,
:opt_call_c_function,
@ -94,7 +93,18 @@ class TestJIT < Test::Unit::TestCase
end
def test_compile_insn_getblockparamproxy
skip "support this in mjit_compile"
assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '4', success_count: 3, insns: %i[getblockparamproxy])
begin;
def bar(&b)
b.call
end
def foo(&b)
bar(&b) * bar(&b)
end
print foo { 2 }
end;
end
def test_compile_insn_getspecial

View File

@ -81,6 +81,9 @@
fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos);
fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_opt_insn);\n");
fprintf(f, " goto cancel;\n");
% when /\A(?<prefix>.+\b)INSN_LABEL\((?<name>[^)]+)\)(?<suffix>.+)\z/m
% prefix, name, suffix = Regexp.last_match[:prefix], Regexp.last_match[:name], Regexp.last_match[:suffix]
fprintf(f, " <%= prefix.gsub(/\t/, ' ' * 8) %>INSN_LABEL(<%= name %>_%d)<%= suffix.sub(/\n/, '\n') %>", pos);
% else
% if insn.handles_sp?
% # If insn.handles_sp? is true, cfp->sp might be changed inside insns (like vm_caller_setup_arg_block)

View File

@ -16,7 +16,6 @@
} -%>
%
% unsupported_insns = [
% 'getblockparamproxy', # TODO: support this
% 'defineclass', # low priority
% 'opt_call_c_function', # low priority
% ]

3
vm.c
View File

@ -323,8 +323,6 @@ extern VALUE rb_vm_invoke_bmethod(rb_execution_context_t *ec, rb_proc_t *proc, V
const rb_callable_method_entry_t *me);
static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, VALUE block_handler);
static VALUE rb_block_param_proxy;
#include "mjit.h"
#include "vm_insnhelper.h"
#include "vm_exec.h"
@ -352,6 +350,7 @@ rb_next_class_serial(void)
VALUE rb_cRubyVM;
VALUE rb_cThread;
VALUE rb_mRubyVMFrozenCore;
VALUE rb_block_param_proxy;
#define ruby_vm_redefined_flag GET_VM()->redefined_flag
VALUE ruby_vm_const_missing_count = 0;

View File

@ -14,6 +14,8 @@
RUBY_SYMBOL_EXPORT_BEGIN
RUBY_EXTERN VALUE rb_block_param_proxy;
RUBY_EXTERN VALUE ruby_vm_const_missing_count;
RUBY_EXTERN rb_serial_t ruby_vm_global_method_state;
RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state;