aboutsummaryrefslogtreecommitdiffstats
path: root/insns.def
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 06:12:37 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 06:12:37 +0000
commitaf56490dfe38837cdd8add3394006353c9ffa7fb (patch)
treeae62eee552e736a3ad32367af21c12eee0b24b7d /insns.def
parentd8d3292c23fe221820ccc5f2b73f63e361b81714 (diff)
downloadruby-af56490dfe38837cdd8add3394006353c9ffa7fb.tar.gz
fix redefinition optimization for -"literal string" (UMinus)
Unfortunately this enlarges insns.def by yet another instruction. However, it is much prettier than opt_str_freeze in use, and maybe we can avoid having so many instructions in the future. [ruby-core:80368] * insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary) * compile.c (iseq_compile_each0): split instructions * test/ruby/test_optimization.rb (test_string_uminus): new test * vm.c (vm_init_redefined_flag): set redefinintion flag for uminus * vm_core.h (enum ruby_basic_operators): add BOP_UMINUS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def14
1 files changed, 14 insertions, 0 deletions
diff --git a/insns.def b/insns.def
index 9bae14b5a9..a4f2526bef 100644
--- a/insns.def
+++ b/insns.def
@@ -982,6 +982,20 @@ opt_str_freeze
}
DEFINE_INSN
+opt_str_uminus
+(VALUE str)
+()
+(VALUE val)
+{
+ if (BASIC_OP_UNREDEFINED_P(BOP_UMINUS, STRING_REDEFINED_OP_FLAG)) {
+ val = str;
+ }
+ else {
+ val = rb_funcall(rb_str_resurrect(str), idUMinus, 0);
+ }
+}
+
+DEFINE_INSN
opt_newarray_max
(rb_num_t num)
(...)