[pypy-svn] r28243 - in pypy/dist/pypy: rpython translator/stackless

mwh at codespeak.net mwh at codespeak.net
Sun Jun 4 12:53:26 CEST 2006


Author: mwh
Date: Sun Jun  4 12:53:25 2006
New Revision: 28243

Modified:
   pypy/dist/pypy/rpython/rstack.py
   pypy/dist/pypy/translator/stackless/code.py
   pypy/dist/pypy/translator/stackless/transform.py
Log:
(mwh, pedronis)
have resume_state_create etc deal in the same state types as
yield_current_frame_to_caller and friends.


Modified: pypy/dist/pypy/rpython/rstack.py
==============================================================================
--- pypy/dist/pypy/rpython/rstack.py	(original)
+++ pypy/dist/pypy/rpython/rstack.py	Sun Jun  4 12:53:25 2006
@@ -70,9 +70,6 @@
         return hop.genop('resume_point', [c_label, v_return] + args_v,
                          hop.r_result)
 
-class ResumeState(object):
-    pass
-
 def resume_state_create(prevstate, label, *args):
     raise RuntimeError("cannot resume states in non-translated versions")
 
@@ -91,7 +88,7 @@
 
     def compute_result_annotation(self, s_prevstate, s_label, *args_s):
         from pypy.annotation import model as annmodel
-        return annmodel.SomeExternalObject(ResumeState)
+        return annmodel.SomeExternalObject(frame_stack_top)
 
     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
@@ -111,15 +108,6 @@
         return hop.genop('resume_state_create', [v_state, c_label] + args_v,
                          hop.r_result)
 
-class ResumeStateEntry(ExtRegistryEntry):
-    _type_ = ResumeState
-
-    def get_repr(self, rtyper, s_state):
-        from pypy.rpython.rmodel import SimplePointerRepr
-        from pypy.translator.stackless.frame import STATE_HEADER
-        from pypy.rpython.lltypesystem import lltype
-        return SimplePointerRepr(lltype.Ptr(STATE_HEADER))
-
 def resume_state_invoke(type, state, **kwds):
     raise NotImplementedError("only works in translated versions")
 

Modified: pypy/dist/pypy/translator/stackless/code.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/code.py	(original)
+++ pypy/dist/pypy/translator/stackless/code.py	Sun Jun  4 12:53:25 2006
@@ -191,7 +191,7 @@
         u = UnwindException()
         s = lltype.malloc(RESUME_AFTER_STATE)
         s.header.f_restart = INDEX_RESUME_AFTER_VOID
-        s.c = state
+        s.c = lltype.cast_opaque_ptr(lltype.Ptr(STATE_HEADER), state)
         add_frame_state(u, s.header)
         raise u
     elif global_state.restart_substate == 0:
@@ -223,7 +223,7 @@
         u = UnwindException()
         s = lltype.malloc(RESUME_AFTER_STATE)
         s.header.f_restart = INDEX_RESUME_AFTER_RAISING
-        s.c = state
+        s.c = lltype.cast_opaque_ptr(lltype.Ptr(STATE_HEADER), state)
         add_frame_state(u, s.header)
         global_state.exception = exception
         raise u
@@ -256,7 +256,7 @@
         u = UnwindException()
         s = lltype.malloc(RESUME_AFTER_STATE)
         s.header.f_restart = INDEX_RESUME_AFTER_%(TYPENAME)s
-        s.c = state
+        s.c = lltype.cast_opaque_ptr(lltype.Ptr(STATE_HEADER), state)
         global_state.retval_%(typename)s = retvalue
         add_frame_state(u, s.header)
         raise u

Modified: pypy/dist/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/transform.py	(original)
+++ pypy/dist/pypy/translator/stackless/transform.py	Sun Jun  4 12:53:25 2006
@@ -237,33 +237,33 @@
         self.resume_afters = {
             lltype.Void: mixlevelannotator.constfunc(
                 code.resume_after_void,
-                [s_hdrptr, annmodel.s_None],
+                [s_StatePtr, annmodel.s_None],
                 annmodel.s_None),
             lltype.Signed: mixlevelannotator.constfunc(
                 code.resume_after_long,
-                [s_hdrptr, annmodel.SomeInteger()],
+                [s_StatePtr, annmodel.SomeInteger()],
                 annmodel.s_None),
             lltype.SignedLongLong: mixlevelannotator.constfunc(
                 code.resume_after_longlong,
-                [s_hdrptr, annmodel.SomeInteger(knowntype=rarithmetic.r_longlong)],
+                [s_StatePtr, annmodel.SomeInteger(knowntype=rarithmetic.r_longlong)],
                 annmodel.s_None),
             lltype.Float: mixlevelannotator.constfunc(
                 code.resume_after_float,
-                [s_hdrptr, annmodel.SomeFloat()],
+                [s_StatePtr, annmodel.SomeFloat()],
                 annmodel.s_None),
             llmemory.Address: mixlevelannotator.constfunc(
                 code.resume_after_addr,
-                [s_hdrptr, annmodel.SomeAddress()],
+                [s_StatePtr, annmodel.SomeAddress()],
                 annmodel.s_None),
             SAVED_REFERENCE: mixlevelannotator.constfunc(
                 code.resume_after_ref,
-                [s_hdrptr, annmodel.SomePtr(SAVED_REFERENCE)],
+                [s_StatePtr, annmodel.SomePtr(SAVED_REFERENCE)],
                 annmodel.s_None),
             }
         exception_def = bk.getuniqueclassdef(Exception)
         self.resume_after_raising_ptr = mixlevelannotator.constfunc(
             code.resume_after_raising,
-            [s_hdrptr, annmodel.SomeInstance(exception_def)],
+            [s_StatePtr, annmodel.SomeInstance(exception_def)],
             annmodel.s_None)
         self.exception_type = getinstancerepr(
             self.translator.rtyper, exception_def).lowleveltype
@@ -534,10 +534,12 @@
         llops.genop('setfield', [v_state,
                                  model.Constant('f_restart', lltype.Void),
                                  model.Constant(symb, lltype.Signed)])
+        v_prevstate = llops.genop('cast_opaque_ptr', [op.args[0]],
+                                  resulttype=lltype.Ptr(frame.STATE_HEADER))
         llops.genop('setfield', [v_state,
                                  model.Constant('f_back', lltype.Void),
-                                 op.args[0]])
-        llops.append(model.SpaceOperation('same_as', [v_state], op.result))
+                                 v_prevstate])
+        llops.append(model.SpaceOperation('cast_opaque_ptr', [v_state], op.result))
         block.operations[i:i+1] = llops
 
     def handle_resume_state_invoke(self, block):



More information about the Pypy-commit mailing list