summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-23 02:28:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-23 02:28:08 +0000
commita97e80ba74c98853c71ea9efc258487987057867 (patch)
tree2d39ce7a752223f54a2c572b64e1e74065bdb225 /tool
parent92304aa3cd52a390383661c69622195247098deb (diff)
* tool/instruction.rb (make_header_prepare_stack): check stack
overflow. [ruby-core:25714] * tool/instruction.rb (make_footer_stack_val): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-xtool/instruction.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/tool/instruction.rb b/tool/instruction.rb
index 45d57c1..a82ac2c 100755
--- a/tool/instruction.rb
+++ b/tool/instruction.rb
@@ -684,6 +684,9 @@ class RubyVM
push_ba = insn.pushsc
raise "unsupport" if push_ba[0].size > 0 && push_ba[1].size > 0
+ n = 0
+ push_ba.each {|pushs| n += pushs.length}
+ commit " CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
push_ba.each{|pushs|
pushs.each{|r|
commit " PUSH(SCREG(#{r}));"
@@ -816,13 +819,22 @@ class RubyVM
commit " #define LABEL_IS_SC(lab) LABEL_##lab##_###{insn.sc.size == 0 ? 't' : 'f'}"
end
+ def each_footer_stack_val insn
+ insn.rets.reverse_each{|v|
+ break if v[1] == '...'
+ yield v
+ }
+ end
+
def make_footer_stack_val insn
comment " /* push stack val */"
- insn.rets.reverse_each{|v|
- if v[1] == '...'
- break
- end
+ n = 0
+ each_footer_stack_val(insn){|v|
+ n += 1 unless v[2]
+ }
+ commit " CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+ each_footer_stack_val(insn){|v|
if v[2]
commit " SCREG(#{v[2]}) = #{v[1]};"
else