[pypy-svn] r62643 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph backend/llgraph/test metainterp

arigo at codespeak.net arigo at codespeak.net
Fri Mar 6 14:35:16 CET 2009


Author: arigo
Date: Fri Mar  6 14:35:15 2009
New Revision: 62643

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
Kill execute_operation() in the llgraph backend.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	Fri Mar  6 14:35:15 2009
@@ -102,14 +102,13 @@
             llimpl.compile_from_guard(c, from_guard._compiled,
                                          from_guard._opindex)
 
-    def execute_operations_in_new_frame(self, name, merge_point, valueboxes,
-                                        result_type=None):
+    def execute_operations_in_new_frame(self, name, operations, valueboxes):
         """Perform a 'call' to the given merge point, i.e. create
         a new CPU frame and use it to execute the operations that
         follow the merge point.
         """
-        assert result_type is None or isinstance(result_type, str)
         frame = llimpl.new_frame(self.memo_cast)
+        merge_point = operations[0]
         llimpl.frame_clear(frame, merge_point._compiled, merge_point._opindex)
         for box in valueboxes:
             if isinstance(box, history.BoxInt):
@@ -124,73 +123,6 @@
                 raise Exception("bad box in valueboxes: %r" % (box,))
         return self.loop(frame)
 
-    def execute_operation(self, opnum, valueboxes, result_type):
-        """Execute a single operation, returning the result.
-        Mostly a hack: falls back to interpreting a complete bridge
-        containing the operation.
-        """
-        #if opname[0] == '#':
-        #    return None
-        c = self.get_compiled_single_op(opnum, valueboxes, result_type)
-        frame = llimpl.new_frame(self.memo_cast)
-        llimpl.frame_clear(frame, c, 0)
-        for box in valueboxes:
-            if box.type == 'int':
-                llimpl.frame_add_int(frame, box.getint())
-            elif box.type == 'ptr':
-                llimpl.frame_add_ptr(frame, box.getptr_base())
-            else:
-                raise Exception("bad box in valueboxes: %r" % (box,))
-        res = llimpl.frame_execute(frame)
-        assert res == -1
-        if result_type == 'int':
-            return history.BoxInt(llimpl.frame_int_getresult(frame))
-        elif result_type == 'ptr':
-            return history.BoxPtr(llimpl.frame_ptr_getresult(frame))
-        else:
-            return None
-
-    def get_compiled_single_op(self, opnum, valueboxes, result_type):
-        assert isinstance(opnum, int)
-        keylist = self.compiled_single_ops.setdefault((opnum, result_type),
-                                                      [])
-        types = [valuebox.type for valuebox in valueboxes]
-        for key, impl in keylist:
-            if len(key) == len(types):
-                for i in range(len(key)):
-                    if key[i] is not types[i]:
-                        break
-                else:
-                    return impl
-        valueboxes = []
-        for type in types:
-            if type == 'int':
-                valueboxes.append(history.BoxInt())
-            elif type == 'ptr':
-                valueboxes.append(history.BoxPtr())
-            else:
-                raise AssertionError('valuebox type=%s' % (type,))
-        if result_type == 'void':
-            resbox = None
-        elif result_type == 'int':
-            resbox = history.BoxInt()
-        elif result_type == 'ptr':
-            resbox = history.BoxPtr()
-        else:
-            raise AssertionError(result_type)
-        resboxes = []
-        if resbox is not None:
-            resboxes.append(resbox)
-        operations = [
-            ResOperation(rop.MERGE_POINT, valueboxes, None),
-            ResOperation(opnum, valueboxes, resbox),
-            ResOperation(rop.RETURN, resboxes, None),
-            ]
-        self.compile_operations(operations)
-        impl = operations[0]._compiled
-        keylist.append((types, impl))
-        return impl
-
     def loop(self, frame):
         """Execute a loop.  When the loop fails, ask the metainterp for more.
         """

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py	Fri Mar  6 14:35:15 2009
@@ -5,7 +5,7 @@
 
 from pypy.jit.metainterp.history import BoxInt, BoxPtr, Const, ConstInt
 from pypy.jit.metainterp.resoperation import ResOperation, rop
-from pypy.jit.metainterp.executor import get_execute_function
+from pypy.jit.metainterp.executor import execute
 from pypy.jit.backend.llgraph.runner import CPU, GuardFailed
 
 
@@ -44,30 +44,6 @@
                     assert getattr(res, key) == value
         interpret(main, [])
 
-    def test_simple(self):
-        cpu = CPU(None)
-        box = cpu.execute_operation(rop.INT_SUB, [BoxInt(10), BoxInt(2)],
-                                    "int")
-        assert isinstance(box, BoxInt)
-        assert box.value == 8
-
-    def test_execute_operation(self):
-        cpu = CPU(None)
-        node = lltype.malloc(NODE)
-        node_value = cpu.fielddescrof(NODE, 'value')
-        nodeadr = lltype.cast_opaque_ptr(llmemory.GCREF, node)
-        box = cpu.execute_operation(rop.SETFIELD_GC, [BoxPtr(nodeadr),
-                                                      ConstInt(node_value),
-                                                      BoxInt(3)],
-                                    'void')
-        assert box is None
-        assert node.value == 3
-
-        box = cpu.execute_operation(rop.GETFIELD_GC, [BoxPtr(nodeadr),
-                                                      ConstInt(node_value)],
-                                    'int')
-        assert box.value == 3
-
     def test_execute_operations_in_env(self):
         cpu = CPU(None)
         cpu.set_meta_interp(FakeMetaInterp(cpu))
@@ -85,10 +61,9 @@
             ResOperation(rop.JUMP, [z, t], None),
             ]
         operations[-2].liveboxes = [t, z]
-        startmp = operations[0]
-        operations[-1].jump_target = startmp
+        operations[-1].jump_target = operations[0]
         cpu.compile_operations(operations)
-        res = cpu.execute_operations_in_new_frame('foo', startmp,
+        res = cpu.execute_operations_in_new_frame('foo', operations,
                                                   [BoxInt(0), BoxInt(10)])
         assert res.value == 42
         gf = cpu.metainterp.gf
@@ -129,9 +104,8 @@
                 ResOperation(opnum, args, []),
                 ResOperation(rop.VOID_RETURN, [], []),
                 ]
-            startmp = operations[0]
             cpu.compile_operations(operations)
-            res = cpu.execute_operations_in_new_frame('foo', startmp, args)
+            res = cpu.execute_operations_in_new_frame('foo', operations, args)
             assert res.value == 42
 
     def test_cast_adr_to_int_and_back(self):
@@ -304,8 +278,7 @@
 
     def test_executor(self):
         cpu = CPU(None)
-        fn = get_execute_function(cpu, rop.INT_ADD)
-        assert fn(cpu, [BoxInt(100), ConstInt(42)]).value == 142
-        fn = get_execute_function(cpu, rop.NEWSTR)
-        s = fn(cpu, [BoxInt(8)])
+        x = execute(cpu, rop.INT_ADD, [BoxInt(100), ConstInt(42)])
+        assert x.value == 142
+        s = execute(cpu, rop.NEWSTR, [BoxInt(8)])
         assert len(s.getptr(lltype.Ptr(rstr.STR)).chars) == 8

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/resoperation.py	Fri Mar  6 14:35:15 2009
@@ -72,7 +72,6 @@
     MERGE_POINT            = 1
     CATCH                  = 2
     JUMP                   = 3
-    RETURN                 = 4
     _SPECIAL_LAST = 9
 
     _GUARD_FIRST = 10 # ----- start of guard operations -----

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	Fri Mar  6 14:35:15 2009
@@ -485,10 +485,9 @@
             loop, boxes = warmrunnerdesc.metainterp.compile_and_run(*args)
             if loop:
                 cpu = warmrunnerdesc.metainterp.cpu
-                mp = loop.operations[0]
+                operations = loop.operations
                 box = cpu.execute_operations_in_new_frame('run_this_loop',
-                                                          mp, boxes,
-                                                          "int")
+                                                          operations, boxes)
                 raise warmrunnerdesc.DoneWithThisFrame(box)
 
         def must_compile_from_failure(self, guard_failure):



More information about the Pypy-commit mailing list