Author: Armin Rigo <[email protected]>
Branch: continulet-jit-3
Changeset: r58732:4716f62e7156
Date: 2012-11-05 03:28 +0100
http://bitbucket.org/pypy/pypy/changeset/4716f62e7156/

Log:    Tweak tweak.

diff --git a/pypy/jit/backend/llgraph/runner.py 
b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -201,7 +201,6 @@
         class MiniStats:
             pass
         self.stats = stats or MiniStats()
-        self.TOKEN_TRACING_RESCALL = NotAFrame()
 
     def compile_loop(self, inputargs, operations, looptoken, log=True, 
name=''):
         clt = model.CompiledLoopToken(self, looptoken.number)
@@ -420,9 +419,11 @@
 
     def bh_getfield_gc(self, p, descr):
         if isinstance(descr, JFDescrDescr):
-            result = p.latest_descr
+            frame = p._obj.llframe
+            result = frame.latest_descr
             if result is None:
-                return lltype.nullptr(llmemory.GCREF.TO)
+                #return lltype.nullptr(llmemory.GCREF.TO)
+                raise AssertionError("latest_descr is None")
             # <XXX> HACK
             result._TYPE = llmemory.GCREF
             result._identityhash = lambda: hash(result)   # for rd_hash()
@@ -491,8 +492,8 @@
 
     def bh_getinteriorfield_gc(self, a, index, descr):
         if isinstance(descr, JFValueDescr):
-            assert isinstance(a, LLFrame)
-            return a.latest_values[index]
+            frame = a._obj.llframe
+            return frame.latest_values[index]
         array = a._obj.container
         return support.cast_result(descr.FIELD,
                           getattr(array.getitem(index), descr.fieldname))
@@ -610,16 +611,6 @@
     def bh_read_timestamp(self):
         return read_timestamp()
 
-class NotAFrame(object):
-    _TYPE = llmemory.GCREF
-
-    class latest_descr:
-        pass
-
-    def __eq__(self, other):
-        return isinstance(other, NotAFrame)
-    def __ne__(self, other):
-        return not (self == other)
 
 class LLFrame(object):
     _forced = False
diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -238,8 +238,8 @@
         raise NotImplementedError
 
     def jitframe_get_jfdescr_descr(self):
-        """ Return a descr that can be used to read the XXX field
-        """
+        """Return a descr that can be used to read the field normally
+        returned by get_latest_descr(jitframe)."""
         raise NotImplementedError
 
     # ---------- the backend-dependent operations ----------
diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -628,10 +628,10 @@
         # an inconsistent state
         rstack._stack_criticalcode_start()
         try:
-            cpu.force(jitframetoken)
-            faildescr = cpu.get_latest_descr(jitframetoken)
+            jitframe = cpu.force(jitframetoken)
+            faildescr = cpu.get_latest_descr(jitframe)
             assert isinstance(faildescr, ResumeGuardForcedDescr)
-            faildescr.handle_async_forcing(jitframetoken)
+            faildescr.handle_async_forcing(jitframe)
         finally:
             rstack._stack_criticalcode_stop()
 
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -10,7 +10,7 @@
 from pypy.jit.metainterp.history import Const, ConstInt, ConstPtr, ConstFloat
 from pypy.jit.metainterp.history import Box, TargetToken
 from pypy.jit.metainterp.resoperation import rop
-from pypy.jit.metainterp import executor
+from pypy.jit.metainterp import executor, jitframe
 from pypy.jit.metainterp.logger import Logger
 from pypy.jit.metainterp.jitprof import EmptyProfiler
 from pypy.rlib.jit import Counters
@@ -748,17 +748,23 @@
         if not self._establish_nullity(jfbox, orgpc):
             return      # jfbox is NULL
         cpu = self.metainterp.cpu
-        if jfbox.getref_base() == cpu.TOKEN_TRACING_RESCALL:
+        if jfbox.getref_base() == jitframe.TOKEN_TRACING_RESCALL:
             # we're trying to force a virtualizable that is being traced,
             # abort as bad loop
             raise SwitchToBlackhole(Counters.ABORT_BAD_LOOP)
+        from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
         descr = cpu.jitframe_get_jfdescr_descr()
         jfdescrbox = self._opimpl_getfield_gc_any(jfbox, descr)
         jfdescrbox = self.implement_guard_value(orgpc, jfdescrbox)
         jfdescr = jfdescrbox.getref_base()
-        descr = cpu.jitframe_cast_jfdescr_to_descr(jfdescr)
-        if not descr:
+        if not jfdescr:
             raise Exception("descr should not be none while inside a recursive 
call")
+        if we_are_translated():
+            jfdescr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, jfdescr)
+            descr = cast_base_ptr_to_instance(compile.ResumeDescr, jfdescr)
+        else:
+            assert isinstance(jfdescr, compile.ResumeDescr)
+            descr = jfdescr
         resume.rebuild_virtualizable_from_resumedata(self.metainterp, descr,
                                                      vinfo, box, jfbox)
         self._opimpl_setfield_gc_any(box, vinfo.jit_frame_descr,
diff --git a/pypy/jit/metainterp/virtualizable.py 
b/pypy/jit/metainterp/virtualizable.py
--- a/pypy/jit/metainterp/virtualizable.py
+++ b/pypy/jit/metainterp/virtualizable.py
@@ -16,7 +16,6 @@
     def __init__(self, warmrunnerdesc, VTYPEPTR):
         self.warmrunnerdesc = warmrunnerdesc
         cpu = warmrunnerdesc.cpu
-        self.TOKEN_TRACING_RESCALL = cpu.TOKEN_TRACING_RESCALL
         if cpu.ts.name == 'ootype':
             import py
             py.test.skip("ootype: fix virtualizables")
@@ -231,7 +230,7 @@
         def tracing_before_residual_call(virtualizable):
             virtualizable = cast_gcref_to_vtype(virtualizable)
             assert virtualizable.jit_frame == jitframe.TOKEN_NONE
-            virtualizable.jit_frame = self.TOKEN_TRACING_RESCALL
+            virtualizable.jit_frame = jitframe.TOKEN_TRACING_RESCALL
         self.tracing_before_residual_call = tracing_before_residual_call
 
         def tracing_after_residual_call(virtualizable):
@@ -239,7 +238,7 @@
             if virtualizable.jit_frame != jitframe.TOKEN_NONE:
                 # not modified by the residual call; assert that it is still
                 # set to TOKEN_TRACING_RESCALL and clear it.
-                assert virtualizable.jit_frame == self.TOKEN_TRACING_RESCALL
+                assert virtualizable.jit_frame== jitframe.TOKEN_TRACING_RESCALL
                 virtualizable.jit_frame = jitframe.TOKEN_NONE
                 return False
             else:
@@ -249,7 +248,7 @@
 
         def force_now(virtualizable):
             token = virtualizable.jit_frame
-            if token == self.TOKEN_TRACING_RESCALL:
+            if token == jitframe.TOKEN_TRACING_RESCALL:
                 # The values in the virtualizable are always correct during
                 # tracing.  We only need to reset jit_frame to TOKEN_NONE
                 # as a marker for the tracing, to tell it that this
diff --git a/pypy/jit/metainterp/virtualref.py 
b/pypy/jit/metainterp/virtualref.py
--- a/pypy/jit/metainterp/virtualref.py
+++ b/pypy/jit/metainterp/virtualref.py
@@ -9,7 +9,6 @@
     def __init__(self, warmrunnerdesc):
         self.warmrunnerdesc = warmrunnerdesc
         self.cpu = warmrunnerdesc.cpu
-        self.TOKEN_TRACING_RESCALL = self.cpu.TOKEN_TRACING_RESCALL
         # we make the low-level type of an RPython class directly
         self.JIT_VIRTUAL_REF = lltype.GcStruct('JitVirtualRef',
             ('super', rclass.OBJECT),
@@ -87,7 +86,7 @@
             return
         vref = lltype.cast_opaque_ptr(lltype.Ptr(self.JIT_VIRTUAL_REF), gcref)
         assert vref.jit_frame == jitframe.TOKEN_NONE
-        vref.jit_frame = self.TOKEN_TRACING_RESCALL
+        vref.jit_frame = jitframe.TOKEN_TRACING_RESCALL
 
     def tracing_after_residual_call(self, gcref):
         if not self.is_virtual_ref(gcref):
@@ -97,7 +96,7 @@
         if vref.jit_frame != jitframe.TOKEN_NONE:
             # not modified by the residual call; assert that it is still
             # set to TOKEN_TRACING_RESCALL and clear it.
-            assert vref.jit_frame == self.TOKEN_TRACING_RESCALL
+            assert vref.jit_frame == jitframe.TOKEN_TRACING_RESCALL
             vref.jit_frame = jitframe.TOKEN_NONE
             return False
         else:
@@ -109,7 +108,7 @@
             return
         assert real_object
         vref = lltype.cast_opaque_ptr(lltype.Ptr(self.JIT_VIRTUAL_REF), gcref)
-        assert vref.jit_frame != self.TOKEN_TRACING_RESCALL
+        assert vref.jit_frame != jitframe.TOKEN_TRACING_RESCALL
         vref.jit_frame = jitframe.TOKEN_NONE
         vref.forced = lltype.cast_opaque_ptr(rclass.OBJECTPTR, real_object)
 
@@ -143,7 +142,7 @@
         vref = lltype.cast_pointer(lltype.Ptr(self.JIT_VIRTUAL_REF), inst)
         token = vref.jit_frame
         if token != jitframe.TOKEN_NONE:
-            if token == self.TOKEN_TRACING_RESCALL:
+            if token == jitframe.TOKEN_TRACING_RESCALL:
                 # The "virtual" is not a virtual at all during tracing.
                 # We only need to reset jit_frame to TOKEN_NONE
                 # as a marker for the tracing, to tell it that this
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -553,7 +553,7 @@
         else:
             assert False
         (_, jd._PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(
-            [llmemory.GCREF], ASMRESTYPE)
+            [self.cpu.JITFRAMEPTR], ASMRESTYPE)
 
     def rewrite_can_enter_jits(self):
         sublists = {}
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to