diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-22 06:30:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-22 06:30:12 +0000 |
commit | a356fe1c3550892902103f66928426ac8279e072 (patch) | |
tree | bee931e36267315487d45d5776ae8f4a568feddf /insns.def | |
parent | 5a599dde0c43b62ff32c8a0c36a05a758a309818 (diff) | |
download | ruby-a356fe1c3550892902103f66928426ac8279e072.tar.gz |
Safe navigation operator
* compile.c (iseq_peephole_optimize): peephole optimization for
branchnil jumps.
* compile.c (iseq_compile_each): generate save navigation operator
code.
* insns.def (branchnil): new opcode to pop the tos and branch if
it is nil.
* parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'.
[Feature #11537]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1132,6 +1132,23 @@ branchunless } } +/** + @c jump + @e if val is nil, set PC to (PC + dst). + @j もし val が nil ならば、PC を (PC + dst) にする。 + */ +DEFINE_INSN +branchnil +(OFFSET dst) +(VALUE val) +() +{ + if (NIL_P(val)) { + RUBY_VM_CHECK_INTS(th); + JUMP(dst); + } +} + /**********************************************************/ /* for optimize */ |