summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-06 10:09:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-06 10:09:54 +0000
commit53716bfce783666039c53da88a02c5f1a9045205 (patch)
treec10fb2a7a27796c96b6935a234009201c5130d17
parent1fffe3d399433d43ffa213c5ca20c5cea2c5d163 (diff)
* cont.c (cont_restore_0): streamlined to ensure O(1) time. based on
a patch by Brent Roman <brent AT mbari.org>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--cont.c46
2 files changed, 33 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index adabbd6bc9..1dcf7a17b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 6 19:09:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@fsij.org>
* io.c (rb_close_before_exec): more heuristics to detect maximum fd.
diff --git a/cont.c b/cont.c
index c0db5083a8..f7292b5b88 100644
--- a/cont.c
+++ b/cont.c
@@ -371,10 +371,13 @@ static volatile int C(a), C(b), C(c), C(d), C(e);
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 @@ register_stack_extend(rb_context_t *cont, VALUE *curr_bsp)
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 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
#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
}
-#ifdef __ia64
- register_stack_extend(cont, (VALUE*)rb_ia64_bsp());
-#else
cont_restore_1(cont);
-#endif
}
+#ifdef __ia64
+#define cont_restore_0(cont, vp) register_stack_extend(cont, vp, (VALUE*)rb_ia64_bsp());
+#endif
/*
* Document-class: Continuation