[前][次][番号順一覧][スレッド一覧]

ruby-changes:40436

From: nobu <ko1@a...>
Date: Tue, 10 Nov 2015 12:45:25 +0900 (JST)
Subject: [ruby-changes:40436] nobu:r52517 (trunk): compile.c: peephole

nobu	2015-11-10 12:45:10 +0900 (Tue, 10 Nov 2015)

  New Revision: 52517

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52517

  Log:
    compile.c: peephole
    
    * compile.c (iseq_peephole_optimize): remove putting object to be
      popped just soon.

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 52516)
+++ compile.c	(revision 52517)
@@ -2000,6 +2000,18 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/compile.c#L2000
 	}
     }
 
+    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 ...

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]