Author: Armin Rigo <[email protected]>
Branch: stacklet
Changeset: r46331:45a9786afee3
Date: 2011-08-06 19:54 +0200
http://bitbucket.org/pypy/pypy/changeset/45a9786afee3/
Log: Improve the tests. They fail. Stacklet bug. Argh. :-(
diff --git a/pypy/translator/c/src/stacklet/Makefile
b/pypy/translator/c/src/stacklet/Makefile
--- a/pypy/translator/c/src/stacklet/Makefile
+++ b/pypy/translator/c/src/stacklet/Makefile
@@ -12,7 +12,7 @@
rm -fr run_tests_*_[go]
-DEBUG = #-DDEBUG_DUMP
+DEBUG = -DDEBUG_DUMP
tests: clean
make -j1 run-all-tests
diff --git a/pypy/translator/c/src/stacklet/stacklet.c
b/pypy/translator/c/src/stacklet/stacklet.c
--- a/pypy/translator/c/src/stacklet/stacklet.c
+++ b/pypy/translator/c/src/stacklet/stacklet.c
@@ -69,7 +69,11 @@
/***************************************************************/
-static void g_save(struct stacklet_s* g, char* stop)
+static void g_save(struct stacklet_s* g, char* stop
+#ifdef DEBUG_DUMP
+ , int overwrite_stack_for_debug
+#endif
+ )
{
/* Save more of g's stack into the heap -- at least up to 'stop'
@@ -96,6 +100,10 @@
char *c = (char *)(g + 1);
#if STACK_DIRECTION == 0
memcpy(c+sz1, g->stack_start+sz1, sz2-sz1);
+# ifdef DEBUG_DUMP
+ if (overwrite_stack_for_debug)
+ memset(g->stack_start+sz1, 0xdb, sz2-sz1);
+# endif
#else
xxx;
#endif
@@ -139,13 +147,21 @@
while (current != NULL && current->stack_stop <= target_stop) {
struct stacklet_s *prev = current->stack_prev;
current->stack_prev = NULL;
- g_save(current, current->stack_stop);
+ g_save(current, current->stack_stop
+#ifdef DEBUG_DUMP
+ , 1
+#endif
+ );
current = prev;
}
/* save a partial stack */
if (current != NULL && current->stack_start < target_stop)
- g_save(current, target_stop);
+ g_save(current, target_stop
+#ifdef DEBUG_DUMP
+ , 1
+#endif
+ );
thrd->g_stack_chain_head = current;
}
@@ -170,7 +186,11 @@
{
struct stacklet_thread_s *thrd = (struct stacklet_thread_s *)rawthrd;
if (g_allocate_source_stacklet(old_stack_pointer, thrd) == 0)
- g_save(thrd->g_source, thrd->g_current_stack_marker);
+ g_save(thrd->g_source, thrd->g_current_stack_marker
+#ifdef DEBUG_DUMP
+ , 0
+#endif
+ );
return NULL;
}
diff --git a/pypy/translator/c/src/stacklet/tests.c
b/pypy/translator/c/src/stacklet/tests.c
--- a/pypy/translator/c/src/stacklet/tests.c
+++ b/pypy/translator/c/src/stacklet/tests.c
@@ -94,11 +94,35 @@
return h;
}
+typedef struct foo_s {
+ int self;
+ float d;
+ struct foo_s *next;
+} foo_t;
+
int withdepth(int self, float d)
{
int res = 0;
if (d > 0.0)
- res = withdepth(self, d - 1.1);
+ {
+ foo_t *foo = malloc(sizeof(foo_t));
+ foo_t *foo2 = malloc(sizeof(foo_t));
+ foo->self = self;
+ foo->d = d;
+ foo->next = foo2;
+ foo2->self = self + 100;
+ foo2->d = d;
+ foo2->next = NULL;
+ res = withdepth(self, d - 1.1);
+ assert(foo->self == self);
+ assert(foo->d == d);
+ assert(foo->next == foo2);
+ assert(foo2->self == self + 100);
+ assert(foo2->d == d);
+ assert(foo2->next == NULL);
+ free(foo2);
+ free(foo);
+ }
else
{
stacklet_handle h;
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit