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

ruby-changes:9814

From: nobu <ko1@a...>
Date: Tue, 6 Jan 2009 19:18:25 +0900 (JST)
Subject: [ruby-changes:9814] Ruby:r21355 (trunk): * cont.c (cont_restore_0): streamlined to ensure O(1) time. based on

nobu	2009-01-06 19:09:54 +0900 (Tue, 06 Jan 2009)

  New Revision: 21355

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

  Log:
    * cont.c (cont_restore_0): streamlined to ensure O(1) time.  based on
      a patch by Brent Roman <brent AT mbari.org>.

  Modified files:
    trunk/ChangeLog
    trunk/cont.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21354)
+++ ChangeLog	(revision 21355)
@@ -1,3 +1,8 @@
+Tue Jan  6 19:09:51 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* cont.c (cont_restore_0): streamlined to ensure O(1) time.  based on
+	  a patch by Brent Roman <brent AT mbari.org>.
+
 Tue Jan  6 00:34:25 2009  Tanaka Akira  <akr@f...>
 
 	* io.c (rb_close_before_exec): more heuristics to detect maximum fd.
Index: cont.c
===================================================================
--- cont.c	(revision 21354)
+++ cont.c	(revision 21355)
@@ -371,10 +371,13 @@
 static volatile int C(f), C(g), C(h), C(i), C(j);
 static volatile int C(k), C(l), C(m), C(n), C(o);
 static volatile int C(p), C(q), C(r), C(s), C(t);
+#if 0
+{/* the above lines make cc-mode.el confused so much */}
+#endif
 int rb_dummy_false = 0;
 NORETURN(NOINLINE(static void register_stack_extend(rb_context_t *, VALUE *)));
 static void
-register_stack_extend(rb_context_t *cont, VALUE *curr_bsp)
+register_stack_extend(rb_context_t *cont, VALUE *vp, VALUE *curr_bsp)
 {
     if (rb_dummy_false) {
         /* use registers as much as possible */
@@ -388,9 +391,9 @@
         E(p) = E(q) = E(r) = E(s) = E(t) = 0;
     }
     if (curr_bsp < cont->machine_register_stack_src+cont->machine_register_stack_size) {
-        register_stack_extend(cont, (VALUE*)rb_ia64_bsp());
+        register_stack_extend(cont, vp, (VALUE*)rb_ia64_bsp());
     }
-    cont_restore_1(cont);
+    cont_restore_0(cont, vp);
 }
 #undef C
 #undef E
@@ -403,35 +406,42 @@
 #define STACK_PAD_SIZE 1024
 	VALUE space[STACK_PAD_SIZE];
 
-#if STACK_GROW_DIRECTION < 0 /* downward */
-	if (addr_in_prev_frame > cont->machine_stack_src) {
-	    cont_restore_0(cont, &space[0]);
-	}
-#elif STACK_GROW_DIRECTION > 0 /* upward */
-	if (addr_in_prev_frame < cont->machine_stack_src + cont->machine_stack_size) {
-	    cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
-	}
-#else
+#if !STACK_GROW_DIRECTION
 	if (addr_in_prev_frame > &space[0]) {
 	    /* Stack grows downward */
-	    if (addr_in_prev_frame > cont->machine_stack_src) {
+#endif
+#if STACK_GROW_DIRECTION <= 0
+	    if (&space[0] > cont->machine_stack_src) {
+# ifdef HAVE_ALLOCA
+		ALLOCA_N(VALUE, &space[0] - cont->machine_stack_src);
+# else
 		cont_restore_0(cont, &space[0]);
+# endif
 	    }
+#endif
+#if !STACK_GROW_DIRECTION
 	}
 	else {
 	    /* Stack grows upward */
-	    if (addr_in_prev_frame < cont->machine_stack_src + cont->machine_stack_size) {
+#endif
+#if STACK_GROW_DIRECTION >= 0
+	    if (&space[STACK_PAD_SIZE] < cont->machine_stack_src + cont->machine_stack_size) {
+# ifdef HAVE_ALLOCA
+		ALLOCA_N(VALUE, cont->machine_stack_src + cont->machine_stack_size - &space[STACK_PAD_SIZE]);
+# else
 		cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
+# endif
 	    }
+#endif
+#if !STACK_GROW_DIRECTION
 	}
 #endif
     }
+    cont_restore_1(cont);
+}
 #ifdef __ia64
-    register_stack_extend(cont, (VALUE*)rb_ia64_bsp());
-#else
-    cont_restore_1(cont);
+#define cont_restore_0(cont, vp) register_stack_extend(cont, vp, (VALUE*)rb_ia64_bsp());
 #endif
-}
 
 /*
  *  Document-class: Continuation

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

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