[pypy-svn] r23357 - in pypy/dist/pypy/translator: backendopt c c/test

ericvrp at codespeak.net ericvrp at codespeak.net
Wed Feb 15 14:14:35 CET 2006


Author: ericvrp
Date: Wed Feb 15 14:14:34 2006
New Revision: 23357

Modified:
   pypy/dist/pypy/translator/backendopt/stackless.py
   pypy/dist/pypy/translator/c/genc.py
   pypy/dist/pypy/translator/c/node.py
   pypy/dist/pypy/translator/c/test/test_stackless.py
Log:
First step towards removing SlpFunctionCodeGenerator from genc by making
the stackless transformation coexist with the code generator.


Modified: pypy/dist/pypy/translator/backendopt/stackless.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/stackless.py	(original)
+++ pypy/dist/pypy/translator/backendopt/stackless.py	Wed Feb 15 14:14:34 2006
@@ -1,12 +1,28 @@
 """This produces a graph in the style that was manually experimented
 with in http://codespeak.net/svn/user/arigo/hack/misc/stackless.c
 And is meant to replace stackless support in the PyPy backends.
+
+Stackless transformation workplan.
+====================================
+
+Currently genc has stackless support mostly spread over two files. (c/stackless.py & c/src/ll_stackless.h)
+In addition some files are generated by genc (in the tmp directory):
+    - slp_defs.h (frame structures and prototype of functions for initialization)
+    - slp_signatures.h (resume function calls, one per function signature id)
+    - slp_state_decoding.h (table for finding resume function (including signature id))
+    - slp_imp.c (actual frame initializers)
+
+Objective is to get rid of 'hardcoded; stackless support in genc (c/stackless.py) as well as the handwritten code in c/src/ll_stackless.h
+
+This is done by first creating a transformation (backendopt/stackless.py) that does basically the same as SlpFunctionCodeGenerator in c/stackless.py . The four slp_* files would be stored in graph structures and arrays. This process should leave the old code working and unchanged as much as possible! This step alone would make stackless work in genllvm.
+
+A second step would be to rewrite c/src/ll_stackless.h in RPython. This would allow backendopt transformations to be more effective but yields not additional advantage to PyPy's current backends (genjs has handwritten stackless support) and other backends are probably too experimental at this stage to benefit from stackless support.
 """
 
 from pypy.translator.backendopt.support import log, all_operations, annotate
 log = log.stackless
 
-def stackless(translator):
+def stackless(translator, stacklessdata):
     log('starting')
     seen = {}
     for op in all_operations(translator):

Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py	(original)
+++ pypy/dist/pypy/translator/c/genc.py	Wed Feb 15 14:14:34 2006
@@ -19,6 +19,7 @@
     _compiled = False
     symboltable = None
     stackless = False
+    use_stackless_transformation = False
     
     def __init__(self, translator, entrypoint, gcpolicy=None, libraries=None, thread_enabled=False):
         self.translator = translator
@@ -38,6 +39,7 @@
         if self.stackless:
             from pypy.translator.c.stackless import StacklessData
             db.stacklessdata = StacklessData(db)
+            db.use_stackless_transformation = self.use_stackless_transformation
 
         # we need a concrete gcpolicy to do this
         self.libraries += db.gcpolicy.gc_libraries()
@@ -74,6 +76,10 @@
         else:
             if self.stackless:
                 defines['USE_STACKLESS'] = '1'
+                if self.use_stackless_transformation: #set in test_stackless.py
+                    from pypy.translator.backendopt.stackless import stackless
+                    from pypy.translator.c.stackless import StacklessData
+                    stackless(translator, StacklessData(db))
             cfile, extra = gen_source_standalone(db, modulename, targetdir,
                                                  entrypointname = pfname,
                                                  defines = defines)

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Wed Feb 15 14:14:34 2006
@@ -547,7 +547,7 @@
             fnobj._callable,)
     elif hasattr(fnobj, 'graph'):
         cpython_exc = getattr(fnobj, 'exception_policy', None) == "CPython"
-        if hasattr(db, 'stacklessdata'):
+        if hasattr(db, 'stacklessdata') and not db.use_stackless_transformation:
             from pypy.translator.c.stackless import SlpFunctionCodeGenerator
             gencls = SlpFunctionCodeGenerator
         else:

Modified: pypy/dist/pypy/translator/c/test/test_stackless.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_stackless.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_stackless.py	Wed Feb 15 14:14:34 2006
@@ -19,6 +19,7 @@
 
     cbuilder = CStandaloneBuilder(t, entry_point)
     cbuilder.stackless = True
+    #cbuilder.use_stackless_transformation = True
     cbuilder.generate_source()
     cbuilder.compile()
     return cbuilder.cmdexec('')



More information about the Pypy-commit mailing list