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

ruby-changes:1785

From: ko1@a...
Date: 26 Aug 2007 06:05:30 +0900
Subject: [ruby-changes:1785] ko1 - Ruby:r13276 (trunk): * insnhelper.ci (vm_setup_method): reorder code for branch prediction.

ko1	2007-08-26 06:05:20 +0900 (Sun, 26 Aug 2007)

  New Revision: 13276

  Modified files:
    trunk/ChangeLog
    trunk/insnhelper.ci

  Log:
    * insnhelper.ci (vm_setup_method): reorder code for branch prediction.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/insnhelper.ci?r1=13276&r2=13275
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13276&r2=13275

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13275)
+++ ChangeLog	(revision 13276)
@@ -1,3 +1,7 @@
+Sun Aug 26 06:04:13 2007  Koichi Sasada  <ko1@a...>
+
+	* insnhelper.ci (vm_setup_method): reorder code for branch prediction.
+
 Sun Aug 26 05:54:49 2007  Koichi Sasada  <ko1@a...>
 
 	* insnhelper.ci (vm_call_method): fix to relaxant safe level check
Index: insnhelper.ci
===================================================================
--- insnhelper.ci	(revision 13275)
+++ insnhelper.ci	(revision 13276)
@@ -425,18 +425,10 @@
     /* stack overflow check */
     CHECK_STACK_OVERFLOW(cfp, iseq->stack_max + 0x10);
 
-    if (flag & VM_CALL_TAILCALL_BIT) {
-	VALUE *p_rsp;
-	cfp = ++th->cfp; /* pop cf */
-	p_rsp = th->cfp->sp;
+    if (LIKELY(!(flag & VM_CALL_TAILCALL_BIT))) {
+	if (0) printf("local_size: %d, arg_size: %d\n",
+		      iseq->local_size, iseq->arg_size);
 
-	/* copy arguments */
-	for (i=0; i < (sp - rsp); i++) {
-	    p_rsp[i] = rsp[i];
-	}
-
-	sp -= rsp - p_rsp;
-
 	/* clear local variables */
 	for (i = 0; i < iseq->local_size - iseq->arg_size; i++) {
 	    *sp++ = Qnil;
@@ -445,11 +437,21 @@
 	vm_push_frame(th, iseq,
 		      FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
 		      iseq->iseq_encoded + opt_pc, sp, 0, 0);
+
+	cfp->sp = rsp - 1 /* recv */;
     }
     else {
-	if (0) printf("local_size: %d, arg_size: %d\n",
-		      iseq->local_size, iseq->arg_size);
+	VALUE *p_rsp;
+	cfp = ++th->cfp; /* pop cf */
+	p_rsp = th->cfp->sp;
 
+	/* copy arguments */
+	for (i=0; i < (sp - rsp); i++) {
+	    p_rsp[i] = rsp[i];
+	}
+
+	sp -= rsp - p_rsp;
+
 	/* clear local variables */
 	for (i = 0; i < iseq->local_size - iseq->arg_size; i++) {
 	    *sp++ = Qnil;
@@ -458,8 +460,6 @@
 	vm_push_frame(th, iseq,
 		      FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
 		      iseq->iseq_encoded + opt_pc, sp, 0, 0);
-
-	cfp->sp = rsp - 1 /* recv */;
     }
 }
 

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

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