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

antocuni at codespeak.net antocuni at codespeak.net
Thu Apr 23 14:05:07 CEST 2009


Author: antocuni
Date: Thu Apr 23 14:05:07 2009
New Revision: 64588

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/heaptracker.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/optimize.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_exception.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
Log:
emit ootype's new as NEW_WITH_VTABLE, so that optimize.py can correctly
recognize it. This fixes a few tests in test_send and test_exception



Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	Thu Apr 23 14:05:07 2009
@@ -696,7 +696,7 @@
 
     OPHANDLERS = [None] * (rop._LAST+1)
     
-    def op_new(self, typedescr):
+    def op_new_with_vtable(self, typedescr, vtable):
         from pypy.jit.backend.llgraph import runner
         return ootype.cast_to_object(ootype.new(typedescr.TYPE))
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	Thu Apr 23 14:05:07 2009
@@ -431,8 +431,9 @@
         else:
             return ootype.NULL
 
-    def do_new(self, args, typedescr):
+    def do_new_with_vtable(self, args, typedescr):
         assert isinstance(typedescr, TypeDescr)
+        assert len(args) == 1 # but we don't need it, so ignore
         return typedescr.create()
 
     def do_runtimenew(self, args, descr):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	Thu Apr 23 14:05:07 2009
@@ -644,7 +644,10 @@
 
     def serialize_op_new(self, op):
         TYPE = op.args[0].value
-        self.emit('new', self.get_position(self.cpu.typedescrof(TYPE)))
+        cls = ootype.runtimeClass(TYPE)
+        self.emit('new_with_vtable',
+                  self.get_position(self.cpu.typedescrof(TYPE)),
+                  self.const_position(cls))
         self.register_var(op.result)
 
     def serialize_op_zero_gc_pointers_inside(self, op):

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/heaptracker.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/heaptracker.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/heaptracker.py	Thu Apr 23 14:05:07 2009
@@ -1,5 +1,6 @@
 import re
 from pypy.rpython.lltypesystem import lltype, llmemory, lloperation
+from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.lltypesystem import rclass
 from pypy.tool.pairtype import pair, pairtype
 from pypy.rlib.objectmodel import we_are_translated
@@ -71,7 +72,7 @@
     for graph in graphs:
         for block in graph.iterblocks():
             for op in block.operations:
-                if op.opname == 'malloc':
+                if not cpu.is_oo and op.opname == 'malloc':
                     STRUCT = op.args[0].value
                     if isinstance(STRUCT, lltype.GcStruct):
                         vtable = get_vtable_for_gcstruct(cpu, STRUCT)
@@ -83,6 +84,14 @@
                             else:
                                 vt = llmemory.cast_ptr_to_adr(vtable)
                                 cache.append((vt, cpu.sizeof(STRUCT)))
+                elif cpu.is_oo and op.opname == 'new':
+                    TYPE = op.args[0].value
+                    cls = ootype.cast_to_object(ootype.runtimeClass(TYPE))
+                    typedescr = cpu.typedescrof(TYPE)
+                    if not cpu.translate_support_code:
+                        cache[cls] = typedescr
+                    else:
+                        cache.append((cls, typedescr))
     return cache
 
 testing_gcstruct2vtable = {}

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/optimize.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/optimize.py	Thu Apr 23 14:05:07 2009
@@ -1,7 +1,8 @@
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.history import (Box, Const, ConstInt, BoxInt, BoxPtr,
                                          ResOperation, AbstractDescr,
-                                         Options, AbstractValue, ConstPtr)
+                                         Options, AbstractValue, ConstPtr,
+                                         ConstObj)
 from pypy.jit.metainterp.specnode import (FixedClassSpecNode,
    VirtualInstanceSpecNode, VirtualizableSpecNode, NotSpecNode,
    VirtualFixedListSpecNode, VirtualizableListSpecNode,
@@ -9,6 +10,7 @@
 from pypy.jit.metainterp import executor
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.ootypesystem import ootype
 from pypy.rlib.objectmodel import r_dict
 
 class FixedList(AbstractValue):
@@ -471,7 +473,14 @@
                 sizebox = ConstInt(instnode.cursize)
                 op = ResOperation(rop.NEW_ARRAY, [sizebox], box,
                                   descr=ad)
+            elif self.cpu.is_oo and isinstance(ld, ConstObj):
+                # it's probably a ootype new
+                cls = ld.getobj()
+                typedescr = self.cpu.class_sizes[cls] # XXX this is probably not rpython
+                op = ResOperation(rop.NEW_WITH_VTABLE, [ld], box,
+                                  descr=typedescr)
             else:
+                assert not self.cpu.is_oo
                 vtable = ld.getint()
                 if self.cpu.translate_support_code:
                     vtable_addr = self.cpu.cast_int_to_adr(vtable)

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_exception.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_exception.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_exception.py	Thu Apr 23 14:05:07 2009
@@ -35,8 +35,6 @@
             return n
         res = self.meta_interp(f, [10])
         assert res == 0
-        if self.type_system == 'ootype':
-            py.test.skip('problem in optimize.py')
         self.check_loops({'jump': 1,
                           'int_gt': 1, 'guard_true': 1,
                           'int_sub': 1})

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py	Thu Apr 23 14:05:07 2009
@@ -134,8 +134,6 @@
         assert res == 17
         res = self.meta_interp(f, [4, 14])
         assert res == 1404
-        if self.type_system == 'ootype':
-            py.test.skip('problem in optimize.py')
         self.check_loops(guard_class=0, new_with_vtable=0, new=0)
 
     def test_three_receivers(self):
@@ -286,8 +284,6 @@
         # However, this doesn't match the initial value of 'w'.
         # XXX This not completely easy to check...
         self.check_loop_count(1)
-        if self.type_system == 'ootype':
-            py.test.skip('problem in optimize.py')
         self.check_loops(int_add=0, int_mul=1, guard_class=0,
                          new_with_vtable=0, new=0)
 



More information about the Pypy-commit mailing list