[pypy-svn] r18416 - in pypy/dist/pypy/translator/c: . src test

ale at codespeak.net ale at codespeak.net
Tue Oct 11 17:19:53 CEST 2005


Author: ale
Date: Tue Oct 11 17:19:49 2005
New Revision: 18416

Modified:
   pypy/dist/pypy/translator/c/extfunc.py
   pypy/dist/pypy/translator/c/src/ll_stackless.h
   pypy/dist/pypy/translator/c/stackless.py
   pypy/dist/pypy/translator/c/test/test_standalone.py
Log:
(tismer, ale)
adding the stack_unwind function


Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/extfunc.py	Tue Oct 11 17:19:49 2005
@@ -50,6 +50,7 @@
     ll_thread.ll_thread_start:     'LL_thread_start',
     ll_thread.ll_thread_get_ident: 'LL_thread_get_ident',
     ll_stackless.ll_stackless_stack_frames_depth: 'LL_stackless_stack_frames_depth',
+    ll_stackless.ll_stackless_stack_unwind: 'LL_stackless_stack_unwind',
     ll_stackless.ll_stackless_stack_too_big: 'LL_stackless_stack_too_big',
     }
 

Modified: pypy/dist/pypy/translator/c/src/ll_stackless.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_stackless.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_stackless.h	Tue Oct 11 17:19:49 2005
@@ -87,6 +87,19 @@
     }
 }
 
+void LL_stackless_stack_unwind(void)
+{
+    if (slp_frame_stack_top)
+        goto resume;
+
+    slp_frame_stack_top = slp_frame_stack_bottom =
+        slp_new_frame(sizeof(slp_frame_t), 0);
+    return ;
+
+ resume:
+    slp_frame_stack_top = NULL;
+}
+
 char LL_stackless_stack_too_big(void)
 {
   char local;
@@ -166,3 +179,4 @@
 #endif /* PYPY_NOT_MAIN_FILE */
 
 #endif USE_STACKLESS
+

Modified: pypy/dist/pypy/translator/c/stackless.py
==============================================================================
--- pypy/dist/pypy/translator/c/stackless.py	(original)
+++ pypy/dist/pypy/translator/c/stackless.py	Tue Oct 11 17:19:49 2005
@@ -21,10 +21,13 @@
         self.decode_table = []
         # start the decoding table with entries for the functions that
         # are written manually in ll_stackless.h
+
+        self.registerunwindable('LL_stackless_stack_unwind',
+                                lltype.FuncType([], lltype.Void),
+                                resume_points=1)
         self.registerunwindable('LL_stackless_stack_frames_depth',
                                 lltype.FuncType([], lltype.Signed),
                                 resume_points=1)
-
     def registerunwindable(self, functionname, FUNC, resume_points):
         if resume_points >= 1:
             try:

Modified: pypy/dist/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_standalone.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_standalone.py	Tue Oct 11 17:19:49 2005
@@ -2,7 +2,7 @@
 from pypy.translator.tool.cbuild import build_executable 
 from pypy.annotation.model import SomeList, SomeString
 from pypy.annotation.listdef import ListDef
-from pypy.rpython.objectmodel import stack_frames_depth, stack_too_big
+from pypy.rpython.objectmodel import stack_unwind, stack_frames_depth, stack_too_big
 import os
 
 
@@ -26,7 +26,7 @@
     assert data.startswith('''hello world\nargument count: 2\n   'hi'\n   'there'\n''')
 
 
-def test_stack_unwind():
+def test_stack_depth():
     def g1():
         "just to check Void special cases around the code"
     def g2(ignored):
@@ -124,4 +124,21 @@
     cbuilder.stackless = True
     cbuilder.generate_source()
     cbuilder.compile() 
+    data = cbuilder.cmdexec('')
+    assert data.strip() == '10'
+
+def test_stack_unwind():
+    def entry_point(argv):
+        stack_unwind()
+        return 0
+
+    t = Translator(entry_point)
+    s_list_of_strings = SomeList(ListDef(None, SomeString()))
+    t.annotate([s_list_of_strings])
+    t.specialize()
+    cbuilder = t.cbuilder(standalone=True)
+    cbuilder.stackless = True
+    cbuilder.generate_source()
+    cbuilder.compile()
+    data = cbuilder.cmdexec('')
     return cbuilder.cmdexec('')



More information about the Pypy-commit mailing list