summaryrefslogtreecommitdiff
path: root/tool/ruby_vm/models
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 14:09:10 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 14:09:10 +0000
commit0a5b4c13ad16bacfa5659f7ac92eb7abf9416261 (patch)
treea50901558bb6bf4831411235c990c14d4abd4c02 /tool/ruby_vm/models
parent24b57b102c1992b679f8f8c0fd1a0239289a129b (diff)
downloadruby-0a5b4c13ad16bacfa5659f7ac92eb7abf9416261.tar.gz
vm.inc now in C99
This changeset modifies the VM generator so that vm.inc is written in C99. Also added some comments in _insn_entry.erb so that the intention of each parts to be made more clear. I think this improves overall readability of the generated VM. Confirmed that the exact same binary is generated before/after this changeset. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ruby_vm/models')
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb8
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb9
2 files changed, 15 insertions, 2 deletions
diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb
index 302c375589..e0fac5ff91 100755
--- a/tool/ruby_vm/models/bare_instructions.rb
+++ b/tool/ruby_vm/models/bare_instructions.rb
@@ -131,6 +131,14 @@ class RubyVM::BareInstructions
sprintf "#<%s %s@%s:%d>", self.class.name, @name, @loc[0], @loc[1]
end
+ def has_ope? var
+ return @opes.any? {|i| i[:name] == var[:name] }
+ end
+
+ def has_pop? var
+ return @pops.any? {|i| i[:name] == var[:name] }
+ end
+
private
def generate_attribute t, k, v
diff --git a/tool/ruby_vm/models/operands_unifications.rb b/tool/ruby_vm/models/operands_unifications.rb
index 1bc1a2a153..ee4e3a695d 100644
--- a/tool/ruby_vm/models/operands_unifications.rb
+++ b/tool/ruby_vm/models/operands_unifications.rb
@@ -31,7 +31,8 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
@preamble = parts[:preamble]
@spec = parts[:spec]
super json.merge(:template => template)
- parts[:vars].each do |v|
+ @konsts = parts[:vars]
+ @konsts.each do |v|
@variables[v[:name]] ||= v
end
end
@@ -63,6 +64,10 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
end
end
+ def has_ope? var
+ super or @konsts.any? {|i| i[:name] == var[:name] }
+ end
+
private
def namegen signature
@@ -101,7 +106,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
vars << k
src << {
location: location,
- expr: " #{k[:name]} = #{j};"
+ expr: " const #{k[:decl]} = #{j};"
}
end
end