Author: Armin Rigo <[email protected]>
Branch: nogil-unsafe-2
Changeset: r92158:13c93572cf88
Date: 2017-08-16 10:03 +0400
http://bitbucket.org/pypy/pypy/changeset/13c93572cf88/
Log: Make the current stack limits a thread-local, too
diff --git a/rpython/translator/c/src/stack.c b/rpython/translator/c/src/stack.c
--- a/rpython/translator/c/src/stack.c
+++ b/rpython/translator/c/src/stack.c
@@ -10,16 +10,15 @@
stack that grows downward here. */
/* (stored in a struct to ensure that stack_end and stack_length are
- close together; used e.g. by the ppc jit backend) */
-rpy_stacktoobig_t rpy_stacktoobig = {
- NULL, /* stack_end */
- MAX_STACK_SIZE, /* stack_length */
- 1 /* report_error */
-};
+ close together; used e.g. by the ppc jit backend)
+ XXX this is no longer the case in the nogil-unsafe-2 branch */
+__thread rpy_stacktoobig_t rpy_stacktoobig;
+long rpy_stack_length = MAX_STACK_SIZE;
+
void LL_stack_set_length_fraction(double fraction)
{
- rpy_stacktoobig.stack_length = (long)(MAX_STACK_SIZE * fraction);
+ rpy_stack_length = (long)(MAX_STACK_SIZE * fraction);
}
char LL_stack_too_big_slowpath(long current)
@@ -33,12 +32,14 @@
if it is still 0 or if we later find a 'curptr' position
that is above it. The real stack_end pointer is stored in
thread-local storage, but we try to minimize its overhead by
- keeping a local copy in rpy_stacktoobig.stack_end. */
+ keeping a local copy in rpy_stacktoobig.stack_end.
+
+ XXX no point in having another thread-local copy */
OP_THREADLOCALREF_ADDR(tl);
tl1 = (struct pypy_threadlocal_s *)tl;
baseptr = tl1->stack_end;
- max_stack_size = rpy_stacktoobig.stack_length;
+ max_stack_size = rpy_stack_length;
if (baseptr == NULL) {
/* first time we see this thread */
}
@@ -54,7 +55,7 @@
the stack base must be revised */
}
else { /* stack overflow (probably) */
- return rpy_stacktoobig.report_error;
+ return !rpy_stacktoobig.dont_report_error;
}
}
diff --git a/rpython/translator/c/src/stack.h b/rpython/translator/c/src/stack.h
--- a/rpython/translator/c/src/stack.h
+++ b/rpython/translator/c/src/stack.h
@@ -22,11 +22,11 @@
typedef struct {
char *stack_end;
- long stack_length;
- char report_error;
+ char dont_report_error;
} rpy_stacktoobig_t;
-RPY_EXTERN rpy_stacktoobig_t rpy_stacktoobig;
+RPY_EXTERN __thread rpy_stacktoobig_t rpy_stacktoobig;
+RPY_EXTERN long rpy_stack_length;
RPY_EXTERN
char LL_stack_too_big_slowpath(long); /* returns 0 (ok) or 1 (too big) */
@@ -35,12 +35,12 @@
/* some macros referenced from rpython.rlib.rstack */
#define LL_stack_get_end() ((long)rpy_stacktoobig.stack_end)
-#define LL_stack_get_length() rpy_stacktoobig.stack_length
-#define LL_stack_get_end_adr() ((long)&rpy_stacktoobig.stack_end) /* JIT
*/
-#define LL_stack_get_length_adr() ((long)&rpy_stacktoobig.stack_length)/* JIT
*/
+#define LL_stack_get_length() rpy_stack_length
+#define LL_stack_get_end_adr() FIXME ((long)&rpy_stacktoobig.stack_end)
/* JIT */
+#define LL_stack_get_length_adr() ((long)&rpy_stack_length) /* JIT */
-#define LL_stack_criticalcode_start() (rpy_stacktoobig.report_error = 0)
-#define LL_stack_criticalcode_stop() (rpy_stacktoobig.report_error = 1)
+#define LL_stack_criticalcode_start() (rpy_stacktoobig.dont_report_error = 1)
+#define LL_stack_criticalcode_stop() (rpy_stacktoobig.dont_report_error = 0)
#ifdef __GNUC__
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit