[pypy-svn] r75323 - pypy/branch/multijit-4/pypy/jit/metainterp

arigo at codespeak.net arigo at codespeak.net
Sat Jun 12 12:55:23 CEST 2010


Author: arigo
Date: Sat Jun 12 12:55:22 2010
New Revision: 75323

Modified:
   pypy/branch/multijit-4/pypy/jit/metainterp/compile.py
   pypy/branch/multijit-4/pypy/jit/metainterp/history.py
   pypy/branch/multijit-4/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/multijit-4/pypy/jit/metainterp/resoperation.py
   pypy/branch/multijit-4/pypy/jit/metainterp/resume.py
Log:
test_virtualizable passes again.


Modified: pypy/branch/multijit-4/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/metainterp/compile.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/metainterp/compile.py	Sat Jun 12 12:55:22 2010
@@ -212,8 +212,6 @@
 class ResumeDescr(AbstractFailDescr):
     def __init__(self, original_greenkey):
         self.original_greenkey = original_greenkey
-    def _clone_if_mutable(self):
-        raise NotImplementedError
 
 class ResumeGuardDescr(ResumeDescr):
     _counter = 0        # if < 0, there is one counter per value;
@@ -327,8 +325,7 @@
         send_bridge_to_backend(metainterp.staticdata, self, inputargs,
                                new_loop.operations)
 
-    def _clone_if_mutable(self):
-        res = self.__class__(self.metainterp_sd, self.original_greenkey)
+    def copy_all_attrbutes_into(self, res):
         # XXX a bit ugly to have to list them all here
         res.rd_snapshot = self.rd_snapshot
         res.rd_frame_info_list = self.rd_frame_info_list
@@ -336,10 +333,18 @@
         res.rd_consts = self.rd_consts
         res.rd_virtuals = self.rd_virtuals
         res.rd_pendingfields = self.rd_pendingfields
+
+    def _clone_if_mutable(self):
+        res = ResumeGuardDescr(self.metainterp_sd, self.original_greenkey)
+        self.copy_all_attrbutes_into(res)
         return res
 
 class ResumeGuardForcedDescr(ResumeGuardDescr):
 
+    def __init__(self, metainterp_sd, original_greenkey, jitdriver_sd):
+        ResumeGuardDescr.__init__(self, metainterp_sd, original_greenkey)
+        self.jitdriver_sd = jitdriver_sd
+
     def handle_fail(self, metainterp_sd, jitdriver_sd):
         # Failures of a GUARD_NOT_FORCED are never compiled, but
         # always just blackholed.  First fish for the data saved when
@@ -350,6 +355,7 @@
         all_virtuals = self.fetch_data(token)
         if all_virtuals is None:
             all_virtuals = []
+        assert jitdriver_sd is self.jitdriver_sd
         resume_in_blackhole(metainterp_sd, jitdriver_sd, self, all_virtuals)
         assert 0, "unreachable"
 
@@ -365,7 +371,8 @@
     def handle_async_forcing(self, force_token):
         from pypy.jit.metainterp.resume import force_from_resumedata
         metainterp_sd = self.metainterp_sd
-        all_virtuals = force_from_resumedata(metainterp_sd, self)
+        vinfo = self.jitdriver_sd.virtualizable_info
+        all_virtuals = force_from_resumedata(metainterp_sd, self, vinfo)
         # The virtualizable data was stored on the real virtualizable above.
         # Handle all_virtuals: keep them for later blackholing from the
         # future failure of the GUARD_NOT_FORCED
@@ -399,6 +406,13 @@
                 assert 0, "not found: %r" % (key,)
         return data
 
+    def _clone_if_mutable(self):
+        res = ResumeGuardForcedDescr(self.metainterp_sd,
+                                     self.original_greenkey,
+                                     self.jitdriver_sd)
+        self.copy_all_attrbutes_into(res)
+        return res
+
 
 class AbstractResumeGuardCounters(object):
     # Completely custom algorithm for now: keep 5 pairs (value, counter),

Modified: pypy/branch/multijit-4/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/metainterp/history.py	Sat Jun 12 12:55:22 2010
@@ -125,9 +125,6 @@
     def repr_of_descr(self):
         return '%r' % (self,)
 
-    def _clone_if_mutable(self):
-        return self
-
     def get_arg_types(self):
         """ Implement in call descr.
         Must return a string of INT, REF and FLOAT ('i', 'r', 'f').
@@ -171,6 +168,14 @@
         """
         raise NotImplementedError
 
+    def _clone_if_mutable(self):
+        return self
+    def clone_if_mutable(self):
+        clone = self._clone_if_mutable()
+        if not we_are_translated():
+            assert clone.__class__ is self.__class__
+        return clone
+
 class AbstractFailDescr(AbstractDescr):
     index = -1
 

Modified: pypy/branch/multijit-4/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/metainterp/pyjitpl.py	Sat Jun 12 12:55:22 2010
@@ -939,7 +939,8 @@
         original_greenkey = metainterp.resumekey.original_greenkey
         if opnum == rop.GUARD_NOT_FORCED:
             resumedescr = compile.ResumeGuardForcedDescr(metainterp_sd,
-                                                         original_greenkey)
+                                                   original_greenkey,
+                                                   metainterp.jitdriver_sd)
         else:
             resumedescr = compile.ResumeGuardDescr(metainterp_sd,
                                                    original_greenkey)

Modified: pypy/branch/multijit-4/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/metainterp/resoperation.py	Sat Jun 12 12:55:22 2010
@@ -34,7 +34,7 @@
     def clone(self):
         descr = self.descr
         if descr is not None:
-            descr = descr._clone_if_mutable()
+            descr = descr.clone_if_mutable()
         op = ResOperation(self.opnum, self.args, self.result, descr)
         op.fail_args = self.fail_args
         if not we_are_translated():

Modified: pypy/branch/multijit-4/pypy/jit/metainterp/resume.py
==============================================================================
--- pypy/branch/multijit-4/pypy/jit/metainterp/resume.py	(original)
+++ pypy/branch/multijit-4/pypy/jit/metainterp/resume.py	Sat Jun 12 12:55:22 2010
@@ -745,10 +745,9 @@
     resumereader.done()
     return firstbh
 
-def force_from_resumedata(metainterp_sd, storage):
+def force_from_resumedata(metainterp_sd, storage, vinfo=None):
     resumereader = ResumeDataDirectReader(metainterp_sd.cpu, storage)
     resumereader.handling_async_forcing()
-    vinfo = metainterp_sd.virtualizable_info
     vrefinfo = metainterp_sd.virtualref_info
     resumereader.consume_vref_and_vable(vrefinfo, vinfo)
     return resumereader.virtuals



More information about the Pypy-commit mailing list