Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r1316:e85ce411f190
Date: 2014-08-18 10:10 +0200
http://bitbucket.org/pypy/stmgc/changeset/e85ce411f190/

Log:    Avoid one word here with the jit

diff --git a/c7/stm/rewind_setjmp.c b/c7/stm/rewind_setjmp.c
--- a/c7/stm/rewind_setjmp.c
+++ b/c7/stm/rewind_setjmp.c
@@ -37,8 +37,17 @@
     size_t stack_size, ssstack_size;
 
     assert(rjthread->head != NULL);
-    stop = rjthread->head->frame_base;
     ssstop = rjthread->head->shadowstack_base;
+    if (((long)ssstop) & 1) {
+        /* PyPy's JIT: 'head->frame_base' is missing; use directly 'head',
+           which should be at the end of the frame (and doesn't need itself
+           to be copied because it contains immutable data only) */
+        ssstop = ((char *)ssstop) - 1;
+        stop = (char *)rjthread->head;
+    }
+    else {
+        stop = rjthread->head->frame_base;
+    }
     assert(stop >= base);
     assert(ssstop <= ssbase);
     stack_size = stop - base;
diff --git a/c7/stm/rewind_setjmp.h b/c7/stm/rewind_setjmp.h
--- a/c7/stm/rewind_setjmp.h
+++ b/c7/stm/rewind_setjmp.h
@@ -53,9 +53,12 @@
 ************************************************************/
 
 typedef struct _rewind_jmp_buf {
-    char *frame_base;
     char *shadowstack_base;
     struct _rewind_jmp_buf *prev;
+    char *frame_base;
+    /* NB: PyPy's JIT has got details of this structure hard-coded,
+       as follows: it uses 2 words only (so frame_base is invalid)
+       and sets the lowest bit of 'shadowstack_base' to tell this */
 } rewind_jmp_buf;
 
 typedef struct {
@@ -71,6 +74,7 @@
 
 /* remember the current stack and ss_stack positions */
 #define rewind_jmp_enterframe(rjthread, rjbuf, ss)   do {  \
+    assert((((long)(ss)) & 1) == 0);                       \
     (rjbuf)->frame_base = __builtin_frame_address(0);      \
     (rjbuf)->shadowstack_base = (char *)(ss);              \
     (rjbuf)->prev = (rjthread)->head;                      \
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to