ruby-changes:57511
From: Takashi <ko1@a...>
Date: Tue, 3 Sep 2019 14:23:04 +0900 (JST)
Subject: [ruby-changes:57511] 1a9cc3b27c (master): Avoid defining unused instructions
https://git.ruby-lang.org/ruby.git/commit/?id=1a9cc3b27c From 1a9cc3b27c020c33c87d8b4fe659243aacfeedf3 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Tue, 3 Sep 2019 02:51:48 +0900 Subject: Avoid defining unused instructions diff --git a/.travis.yml b/.travis.yml index 02bfc9c..37e2003 100644 --- a/.travis.yml +++ b/.travis.yml @@ -154,7 +154,7 @@ env: https://github.com/ruby/ruby/blob/trunk/.travis.yml#L154 <<: *cron-only <<: *make-test-only env: - - BEFORE_INSTALL="sed vm_opts.h -e 's/SUPPORT_JOKE *0/SUPPORT_JOKE 1/' -i" + - BEFORE_INSTALL="sed vm_opts.h -e 's/OPT_SUPPORT_JOKE *0/OPT_SUPPORT_JOKE 1/' -i" - &WITH_COROUTINE_UCONTEXT name: COROUTINE=ucontext diff --git a/insns.def b/insns.def index 1399687..e3edc5e 100644 --- a/insns.def +++ b/insns.def @@ -624,7 +624,7 @@ reverse https://github.com/ruby/ruby/blob/trunk/insns.def#L624 } /* for stack caching. */ -DEFINE_INSN +DEFINE_INSN_IF(STACK_CACHING) reput () (..., VALUE val) @@ -1485,7 +1485,7 @@ opt_call_c_function https://github.com/ruby/ruby/blob/trunk/insns.def#L1485 } /* BLT */ -DEFINE_INSN +DEFINE_INSN_IF(SUPPORT_JOKE) bitblt () () @@ -1495,7 +1495,7 @@ bitblt https://github.com/ruby/ruby/blob/trunk/insns.def#L1495 } /* The Answer to Life, the Universe, and Everything */ -DEFINE_INSN +DEFINE_INSN_IF(SUPPORT_JOKE) answer () () diff --git a/tool/ruby_vm/loaders/insns_def.rb b/tool/ruby_vm/loaders/insns_def.rb index a7d27ad..a29d13a 100644 --- a/tool/ruby_vm/loaders/insns_def.rb +++ b/tool/ruby_vm/loaders/insns_def.rb @@ -11,6 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L11 # details. require_relative '../helpers/scanner' +require_relative './vm_opts_h' json = [] scanner = RubyVM::Scanner.new '../../../insns.def' @@ -33,7 +34,7 @@ grammar = %r' https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L34 (?<pragma:name> \g<ident> ) \g<ws>* = \g<ws>* (?<pragma:expr> .+?; ) \g<ws>* ){0} - (?<insn> DEFINE_INSN \g<ws>+ + (?<insn> DEFINE_INSN(_IF\((?<insn:if>\w+)\))? \g<ws>+ (?<insn:name> \g<ident> ) \g<ws>* [(] \g<ws>* (?<insn:opes> \g<argv> ) \g<ws>* [)] \g<ws>* [(] \g<ws>* (?<insn:pops> \g<argv> ) \g<ws>* [)] \g<ws>* @@ -52,6 +53,7 @@ until scanner.eos? do https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L53 l1 = scanner.scan!(/\G#{grammar}\g<insn>/o) name = scanner["insn:name"] + opt = scanner["insn:if"] ope = split.(scanner["insn:opes"]) pop = split.(scanner["insn:pops"]) ret = split.(scanner["insn:rets"]) @@ -67,21 +69,23 @@ until scanner.eos? do https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L69 end l3 = scanner.scan!(/\G#{grammar}\g<block>/o) - json << { - name: name, - location: [path, l1], - signature: { + if opt.nil? || RubyVM::VmOptsH[opt] + json << { name: name, - ope: ope, - pop: pop, - ret: ret, - }, - attributes: attrs, - expr: { - location: [path, l3], - expr: scanner["block"], - }, - } + location: [path, l1], + signature: { + name: name, + ope: ope, + pop: pop, + ret: ret, + }, + attributes: attrs, + expr: { + location: [path, l3], + expr: scanner["block"], + }, + } + end end RubyVM::InsnsDef = json diff --git a/vm_opts.h b/vm_opts.h index 6a7dd3d..9892d3c 100644 --- a/vm_opts.h +++ b/vm_opts.h @@ -61,7 +61,8 @@ https://github.com/ruby/ruby/blob/trunk/vm_opts.h#L61 #define OPT_STACK_CACHING 0 /* misc */ -#define SUPPORT_JOKE 0 +#define OPT_SUPPORT_JOKE 0 +#define SUPPORT_JOKE OPT_SUPPORT_JOKE #ifndef VM_COLLECT_USAGE_DETAILS #define VM_COLLECT_USAGE_DETAILS 0 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/