Author: Armin Rigo <[email protected]>
Branch:
Changeset: r62891:5b34c642de6f
Date: 2013-03-30 16:28 +0100
http://bitbucket.org/pypy/pypy/changeset/5b34c642de6f/
Log: Don't import the stacklet C code if we're not translating with
"continuation".
diff --git a/rpython/memory/gctransform/framework.py
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -468,6 +468,7 @@
# thread support
if translator.config.translation.continuation:
+ root_walker.stacklet_support = True
root_walker.need_stacklet_support(self, getfn)
if translator.config.translation.thread:
root_walker.need_thread_support(self, getfn)
@@ -1275,6 +1276,7 @@
def __init__(self, gctransformer):
self.gcdata = gctransformer.gcdata
self.gc = self.gcdata.gc
+ self.stacklet_support = False
def _freeze_(self):
return True
diff --git a/rpython/memory/gctransform/shadowstack.py
b/rpython/memory/gctransform/shadowstack.py
--- a/rpython/memory/gctransform/shadowstack.py
+++ b/rpython/memory/gctransform/shadowstack.py
@@ -113,7 +113,7 @@
# gc_thread_run and gc_thread_die. See docstrings below.
shadow_stack_pool = self.shadow_stack_pool
- SHADOWSTACKREF = get_shadowstackref(gctransformer)
+ SHADOWSTACKREF = get_shadowstackref(self, gctransformer)
# this is a dict {tid: SHADOWSTACKREF}, where the tid for the
# current thread may be missing so far
@@ -217,7 +217,7 @@
def need_stacklet_support(self, gctransformer, getfn):
shadow_stack_pool = self.shadow_stack_pool
- SHADOWSTACKREF = get_shadowstackref(gctransformer)
+ SHADOWSTACKREF = get_shadowstackref(self, gctransformer)
def gc_shadowstackref_new():
ssref = shadow_stack_pool.allocate(SHADOWSTACKREF)
@@ -366,7 +366,7 @@
return result
-def get_shadowstackref(gctransformer):
+def get_shadowstackref(root_walker, gctransformer):
if hasattr(gctransformer, '_SHADOWSTACKREF'):
return gctransformer._SHADOWSTACKREF
@@ -394,16 +394,20 @@
customtraceptr = llhelper(lltype.Ptr(CUSTOMTRACEFUNC), customtrace)
def shadowstack_destructor(shadowstackref):
- from rpython.rlib import _rffi_stacklet as _c
- h = shadowstackref.context
- h = llmemory.cast_adr_to_ptr(h, _c.handle)
+ if root_walker.stacklet_support:
+ from rpython.rlib import _rffi_stacklet as _c
+ h = shadowstackref.context
+ h = llmemory.cast_adr_to_ptr(h, _c.handle)
+ shadowstackref.context = llmemory.NULL
+ #
base = shadowstackref.base
shadowstackref.base = llmemory.NULL
shadowstackref.top = llmemory.NULL
- shadowstackref.context = llmemory.NULL
llmemory.raw_free(base)
- if h:
- _c.destroy(h)
+ #
+ if root_walker.stacklet_support:
+ if h:
+ _c.destroy(h)
destrptr = gctransformer.annotate_helper(shadowstack_destructor,
[SHADOWSTACKREFPTR], lltype.Void)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit