diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-11 09:48:58 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-11 09:48:58 +0000 |
commit | c2bfb4e93c674347b7eb09a30856e3d75f74cf4d (patch) | |
tree | b898add4e9f9ab117aebcad189d47e79984c2f16 /tool/ruby_vm/models | |
parent | ecda2d23d593eea81a4daf97ec0d74945fa96baf (diff) | |
download | ruby-c2bfb4e93c674347b7eb09a30856e3d75f74cf4d.tar.gz |
add new instruction attribute called leaf
An instruction is leaf if it has no rb_funcall inside. In order to
check this property, we introduce stack canary which is a random
number collected at runtime. Stack top is always filled with this
number and checked for stack smashing operations, when VM_CHECK_MODE.
[GH-1947]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ruby_vm/models')
-rwxr-xr-x | tool/ruby_vm/models/bare_instructions.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb index d2ff1341a0..5c27af3a38 100755 --- a/tool/ruby_vm/models/bare_instructions.rb +++ b/tool/ruby_vm/models/bare_instructions.rb @@ -105,6 +105,10 @@ class RubyVM::BareInstructions /\b(false|0)\b/ !~ @attrs['handles_sp'].expr.expr end + def complicated_return_values? + @sig[:ret].any? {|i| i == '...' } + end + def inspect sprintf "#<%s %s@%s:%d>", self.class.name, @name, @loc[0], @loc[1] end @@ -130,6 +134,10 @@ class RubyVM::BareInstructions generate_attribute 'rb_num_t', 'width', width generate_attribute 'rb_snum_t', 'sp_inc', rets.size - pops.size generate_attribute 'bool', 'handles_sp', false + generate_attribute 'bool', 'leaf', opes.all? {|o| + # Insn with ISEQ should yield it; can never be a leaf. + o[:type] != 'ISEQ' + } end def typesplit a |