mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	This retries r62655, which was reverted at r63863 for r63763.
tool/ruby_vm/views/_mjit_compile_insn.erb: revert the revert.
tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto.
tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb: ditto.
tool/ruby_vm/views/_mjit_compile_send.erb: ditto.
tool/ruby_vm/views/mjit_compile.inc.erb: ditto.
tool/ruby_vm/views/_insn_entry.erb: revert half of r63763. The commit
  was originally reverted since changing pc motion was bad for tracing,
  but changing sp motion was totally fine. For JIT, I wanna resurrect
  the sp motion change in r62051.
tool/ruby_vm/models/bare_instructions.rb: ditto.
insns.def: ditto.
vm_insnhelper.c: ditto.
vm_insnhelper.h: ditto.
* benchmark
$ benchmark-driver benchmark.yml --rbenv 'before;after;before --jit;after --jit' --repeat-count 12 -v
before: ruby 2.6.0dev (2018-07-19 trunk 63998) [x86_64-linux]
after: ruby 2.6.0dev (2018-07-19 add-sp 63998) [x86_64-linux]
last_commit=mjit_compile.c: reduce sp motion on JIT
before --jit: ruby 2.6.0dev (2018-07-19 trunk 63998) +JIT [x86_64-linux]
after --jit: ruby 2.6.0dev (2018-07-19 add-sp 63998) +JIT [x86_64-linux]
last_commit=mjit_compile.c: reduce sp motion on JIT
Calculating -------------------------------------
                             before       after  before --jit  after --jit
Optcarrot Lan_Master.nes     51.354      50.238        70.010       72.139 fps
Comparison:
             Optcarrot Lan_Master.nes
             after --jit:        72.1 fps
            before --jit:        70.0 fps - 1.03x  slower
                  before:        51.4 fps - 1.40x  slower
                   after:        50.2 fps - 1.44x  slower
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
	
			
		
			
				
	
	
		
			75 lines
		
	
	
	
		
			3.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
	
		
			3.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
/* -*- mode:c; style:ruby; coding: utf-8; indent-tabs-mode: nil -*- */
 | 
						|
 | 
						|
% # Copyright (c) 2018 Takashi Kokubun.  All rights reserved.
 | 
						|
% #
 | 
						|
% # This file is a part of  the programming language Ruby.  Permission is hereby
 | 
						|
% # granted, to either  redistribute and/or modify this file,  provided that the
 | 
						|
% # conditions mentioned  in the  file COPYING  are met.   Consult the  file for
 | 
						|
% # details.
 | 
						|
<%= render 'copyright' %>
 | 
						|
%
 | 
						|
% # This is an ERB template that generates Ruby code that generates C code that
 | 
						|
% # generates JIT-ed C code.
 | 
						|
<%= render 'notice', locals: {
 | 
						|
    this_file: 'is the main part of compile_insn() in mjit_compile.c',
 | 
						|
    edit: __FILE__,
 | 
						|
} -%>
 | 
						|
%
 | 
						|
% unsupported_insns = [
 | 
						|
%   'getblockparamproxy',  # TODO: support this
 | 
						|
%   'defineclass',         # low priority
 | 
						|
%   'opt_call_c_function', # low priority
 | 
						|
% ]
 | 
						|
%
 | 
						|
% opt_send_without_block = RubyVM::Instructions.find { |i| i.name == 'opt_send_without_block' }
 | 
						|
% if opt_send_without_block.nil?
 | 
						|
%   raise 'opt_send_without_block not found'
 | 
						|
% end
 | 
						|
%
 | 
						|
% # Available variables and macros in JIT-ed function:
 | 
						|
% #   ec: the first argument of _mjitXXX
 | 
						|
% #   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`, 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`, 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`
 | 
						|
 | 
						|
switch (insn) {
 | 
						|
% (RubyVM::BareInstructions.to_a + RubyVM::OperandsUnifications.to_a).each do |insn|
 | 
						|
%   next if unsupported_insns.include?(insn.name)
 | 
						|
  case BIN(<%= insn.name %>):
 | 
						|
%   # Instruction-specific behavior in JIT
 | 
						|
%   case insn.name
 | 
						|
%   when 'opt_send_without_block', 'send'
 | 
						|
<%=   render 'mjit_compile_send', locals: { insn: insn } -%>
 | 
						|
%   when 'opt_aref' # experimental. TODO: increase insns and make the list automatically by finding DISPATCH_ORIGINAL_INSN
 | 
						|
<%=   render 'mjit_compile_send', locals: { insn: opt_send_without_block } -%>
 | 
						|
%   when 'leave'
 | 
						|
    if (b->stack_size != 1) {
 | 
						|
        if (mjit_opts.warnings || mjit_opts.verbose)
 | 
						|
            fprintf(stderr, "MJIT warning: Unexpected JIT stack_size on leave: %d\n", b->stack_size);
 | 
						|
        status->success = FALSE;
 | 
						|
    }
 | 
						|
%   end
 | 
						|
%
 | 
						|
%   # Main insn implementation generated by insns.def
 | 
						|
<%= render 'mjit_compile_insn', locals: { insn: insn } -%>
 | 
						|
    break;
 | 
						|
% end
 | 
						|
%
 | 
						|
% # We don't support InstructionsUnifications yet because it's not used for now.
 | 
						|
% # We don't support TraceInstructions yet. There is no blocker for it but it's just not implemented.
 | 
						|
  default:
 | 
						|
    if (mjit_opts.warnings || mjit_opts.verbose)
 | 
						|
        fprintf(stderr, "MJIT warning: Skipped to compile unsupported instruction: %s\n", insn_name(insn));
 | 
						|
    status->success = FALSE;
 | 
						|
    break;
 | 
						|
}
 |