[pypy-commit] pypy tealet: General support for tealet.
arigo
noreply at buildbot.pypy.org
Wed Jul 6 20:28:38 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: tealet
Changeset: r45377:4a707bc5ac9a
Date: 2011-06-11 16:15 +0200
http://bitbucket.org/pypy/pypy/changeset/4a707bc5ac9a/
Log: General support for tealet.
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -28,6 +28,11 @@
default=False, cmdline="--stackless",
requires=[("translation.type_system", "lltype"),
("translation.gcremovetypeptr", False)]), # XXX?
+ BoolOption("tealet", "enable stackless features via tealets",
+ default=False, cmdline="--tealet",
+ requires=[("translation.type_system", "lltype"),
+ ("translation.gctransformer", "framework"),
+ ("translation.thread", False)]), # XXX temporary
ChoiceOption("type_system", "Type system to use when RTyping",
["lltype", "ootype"], cmdline=None, default="lltype",
requires={
diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -483,6 +483,9 @@
'gc_dump_rpy_heap' : LLOp(),
'gc_typeids_z' : LLOp(),
+ 'gc_walk_stack_roots' : LLOp(), # for tealet support
+ 'gc_set_stack_roots_count': LLOp(), # "
+
# ------- JIT & GC interaction, only for some GCs ----------
'gc_adr_of_nursery_free' : LLOp(),
diff --git a/pypy/rpython/memory/gctransform/framework.py b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -491,9 +491,11 @@
annmodel.s_None,
minimal_transform = False)
- # thread support
+ # thread & tealet support
if translator.config.translation.thread:
root_walker.need_thread_support(self, getfn)
+ if translator.config.translation.tealet:
+ root_walker.need_tealet_support(self, getfn)
self.layoutbuilder.encode_type_shapes_now()
@@ -1004,6 +1006,19 @@
hop.genop("direct_call", [self.root_walker.thread_after_fork_ptr]
+ hop.spaceop.args)
+ def gct_gc_walk_stack_roots(self, hop):
+ # only available if tealet support is enabled
+ assert self.translator.config.translation.tealet
+ hop.genop("direct_call", [self.root_walker.ll_walk_stack_roots_ptr]
+ + hop.spaceop.args)
+
+ def gct_gc_set_stack_roots_count(self, hop):
+ assert self.translator.config.translation.tealet
+ if hasattr(self.root_walker, 'set_stack_roots_count_ptr'):
+ hop.genop("direct_call",
+ [self.root_walker.set_stack_roots_count_ptr]
+ + hop.spaceop.args)
+
def gct_gc_get_type_info_group(self, hop):
return hop.cast_result(self.c_type_info_group)
@@ -1327,6 +1342,22 @@
raise Exception("%s does not support threads" % (
self.__class__.__name__,))
+ def need_tealet_support(self, gctransformer, getfn):
+ #
+ def ll_walk_stack_roots(fnptr_stack_root):
+ gcdata = self.gcdata
+ gcdata._fnptr_stack_root = fnptr_stack_root
+ self.walk_stack_roots(_ll_collect)
+ #
+ def _ll_collect(gc, root):
+ gcdata = self.gcdata
+ gcdata._fnptr_stack_root(root)
+ #
+ FUNCPTR = lltype.Ptr(lltype.FuncType([llmemory.Address], lltype.Void))
+ s_FuncPtr = annmodel.SomePtr(FUNCPTR)
+ self.ll_walk_stack_roots_ptr = getfn(ll_walk_stack_roots,
+ [s_FuncPtr], annmodel.s_None)
+
class ShadowStackRootWalker(BaseRootWalker):
need_root_stack = True
@@ -1387,6 +1418,17 @@
if self.collect_stacks_from_other_threads is not None:
self.collect_stacks_from_other_threads(collect_stack_root)
+ def need_tealet_support(self, gctransformer, getfn):
+ super(ShadowStackRootWalker, self).need_tealet_support(gctransformer,
+ getfn)
+ gcdata = self.gcdata
+ def set_stack_roots_count(count):
+ bytes = count * llmemory.sizeof(llmemory.Address)
+ gcdata.root_stack_top = gcdata.root_stack_base + bytes
+ self.set_stack_roots_count_ptr = getfn(set_stack_roots_count,
+ [annmodel.SomeInteger()],
+ annmodel.s_None)
+
def need_thread_support(self, gctransformer, getfn):
from pypy.module.thread import ll_thread # xxx fish
from pypy.rpython.memory.support import AddressDict
More information about the pypy-commit
mailing list