[pypy-commit] pypy cleanup-llgraph-backend: progress

fijal noreply at buildbot.pypy.org
Tue Oct 16 21:31:52 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: cleanup-llgraph-backend
Changeset: r58147:038b7419f1b2
Date: 2012-10-16 21:31 +0200
http://bitbucket.org/pypy/pypy/changeset/038b7419f1b2/

Log:	progress

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
@@ -33,11 +33,17 @@
         self.known_labels = WeakKeyDictionary()
 
     def compile_loop(self, inputargs, operations, looptoken, log=True, name=''):
+        self.total_compiled_loops += 1
         for i, op in enumerate(operations):
             if op.getopnum() == rop.LABEL:
                 self.known_labels[op.getdescr()] = (operations, i)
         looptoken._llgraph_loop = LLLoop(inputargs, operations)
 
+    def compile_bridge(self, faildescr, inputargs, operations,
+                       original_loop_token):
+        faildescr._llgraph_bridge = LLLoop(inputargs, operations)
+        self.total_compiled_bridges += 1
+
     def make_execute_token(self, *argtypes):
         return self._execute_token
 
@@ -58,6 +64,12 @@
         return self.latest_values[index]
     get_latest_value_float = get_latest_value_int
 
+    def get_latest_value_count(self):
+        return len(self.latest_values)
+
+    def clear_latest_values(self, count):
+        del self.latest_values
+
 class LLFrame(object):
     def __init__(self, cpu, argboxes, args):
         self.env = {}
@@ -86,6 +98,16 @@
                 self.do_renaming(label_op.getarglist(), j.args)
                 i += 1
                 continue
+            except GuardFailed, gf:
+                if hasattr(gf.descr, '_llgraph_bridge'):
+                    i = 0
+                    bridge = gf.descr._llgraph_bridge
+                    operations = bridge.operations
+                    newargs = [self.env[arg] for arg in
+                               self.current_op.getfailargs() if arg is not None]
+                    self.do_renaming(bridge.inputargs, newargs)
+                    continue
+                raise
             if op.result is not None:
                 assert resval is not None
                 self.env[op.result] = resval
@@ -111,6 +133,9 @@
 
     # -----------------------------------------------------
 
+    def fail_guard(self, descr):
+        raise GuardFailed(self._getfailargs(), descr)
+
     def execute_finish(self, descr, arg=None):
         raise ExecutionFinished(descr, arg)
 
@@ -120,7 +145,11 @@
 
     def execute_guard_true(self, descr, arg):
         if not arg:
-            raise GuardFailed(self._getfailargs(), descr)
+            self.fail_guard(descr)
+
+    def execute_guard_false(self, descr, arg):
+        if arg:
+            self.fail_guard(descr)    
 
     def execute_jump(self, descr, *args):
         raise Jump(descr, args)
diff --git a/pypy/jit/backend/llgraph/test/test_llgraph.py b/pypy/jit/backend/llgraph/test/test_llgraph.py
--- a/pypy/jit/backend/llgraph/test/test_llgraph.py
+++ b/pypy/jit/backend/llgraph/test/test_llgraph.py
@@ -1,12 +1,6 @@
 import py
-from pypy.rpython.lltypesystem import lltype, llmemory, rstr, rclass
-from pypy.rpython.test.test_llinterp import interpret
-from pypy.rlib.unroll import unrolling_iterable
+from pypy.rpython.lltypesystem import lltype, llmemory
 
-from pypy.jit.metainterp.history import BoxInt, BoxPtr, Const, ConstInt,\
-     TreeLoop
-from pypy.jit.metainterp.resoperation import ResOperation, rop
-from pypy.jit.metainterp.executor import execute
 from pypy.jit.codewriter import heaptracker
 from pypy.jit.backend.test.runner_test import LLtypeBackendTest
 
@@ -19,6 +13,9 @@
     def setup_method(self, _):
         self.cpu = self.cpu_type(None)
 
+    def test_backends_dont_keep_loops_alive(self):
+        py.test.skip("does not make much sense on the llgraph backend")
+
     def test_memoryerror(self):
         py.test.skip("does not make much sense on the llgraph backend")
 
@@ -34,18 +31,3 @@
     assert llmemory.cast_adr_to_ptr(a2, lltype.Ptr(X)) == x
     assert heaptracker.adr2int(llmemory.NULL) == 0
     assert heaptracker.int2adr(0) == llmemory.NULL
-
-## these tests never worked
-## class TestOOTypeLLGraph(LLGraphTest):
-##     from pypy.jit.backend.llgraph.runner import OOtypeCPU as cpu_type
-
-def test_fielddescr_ootype():
-    py.test.skip("ootype tests skipped")
-    from pypy.rpython.ootypesystem import ootype
-    from pypy.jit.backend.llgraph.runner import OOtypeCPU
-    A = ootype.Instance("A", ootype.ROOT, {"foo": ootype.Signed})
-    B = ootype.Instance("B", A)
-    cpu = OOtypeCPU(None)
-    descr1 = cpu.fielddescrof(A, "foo")
-    descr2 = cpu.fielddescrof(B, "foo")
-    assert descr1 is descr2


More information about the pypy-commit mailing list