summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-10 03:45:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-10 03:45:10 +0000
commitf11a85c72600026f6e26afe6dda2548c785ce1d3 (patch)
tree01b8f07d7f64848927c2170777b6a0d6cdc4c58d
parentf12746d165023fd0277a6817f870e1b12b4dc948 (diff)
compile.c: peephole
* compile.c (iseq_peephole_optimize): remove putting object to be popped just soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 5ad7625..bd41fef 100644
--- a/compile.c
+++ b/compile.c
@@ -2000,6 +2000,18 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
+ if (iobj->insn_id == BIN(pop)) {
+ LINK_ELEMENT *prev = iobj->link.prev;
+ if (prev->type == ISEQ_ELEMENT_INSN) {
+ enum ruby_vminsn_type previ = ((INSN *)prev)->insn_id;
+ if (previ == BIN(putobject) || previ == BIN(putnil) ||
+ previ == BIN(putself) || previ == BIN(putstring)) {
+ REMOVE_ELEM(prev);
+ REMOVE_ELEM(&iobj->link);
+ }
+ }
+ }
+
if (do_tailcallopt && iobj->insn_id == BIN(leave)) {
/*
* send ...