[pypy-svn] r66573 - in pypy/branch/pyjitpl5-optimize4/pypy/jit: backend/llgraph metainterp

arigo at codespeak.net arigo at codespeak.net
Fri Jul 24 12:52:42 CEST 2009


Author: arigo
Date: Fri Jul 24 12:52:41 2009
New Revision: 66573

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/pyjitpl.py
Log:
Fix the llgraph backend for NEW_WITH_VTABLE not receiving a descr any more.


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/llimpl.py	Fri Jul 24 12:52:41 2009
@@ -624,8 +624,10 @@
     def op_new(self, size):
         return do_new(size.ofs)
 
-    def op_new_with_vtable(self, size, vtable):
-        result = do_new(size.ofs)
+    def op_new_with_vtable(self, descr, vtable):
+        assert descr is None
+        size = get_class_size(self.memocast, vtable)
+        result = do_new(size)
         value = lltype.cast_opaque_ptr(rclass.OBJECTPTR, result)
         value.typeptr = cast_from_int(rclass.CLASSTYPE, vtable, self.memocast)
         return result
@@ -685,8 +687,9 @@
 
     OPHANDLERS = [None] * (rop._LAST+1)
     
-    def op_new_with_vtable(self, typedescr, vtable):
-        from pypy.jit.backend.llgraph import runner
+    def op_new_with_vtable(self, descr, vtable):
+        assert descr is None
+        typedescr = get_class_size(self.memocast, vtable)
         return ootype.cast_to_object(ootype.new(typedescr.TYPE))
 
     def op_new_array(self, typedescr, count):
@@ -916,6 +919,7 @@
     def __init__(self):
         self.addresses = [llmemory.NULL]
         self.rev_cache = {}
+        self.vtable_to_size = {}
 
 def new_memo_cast():
     memocast = MemoCast()
@@ -938,6 +942,14 @@
     assert 0 <= int < len(memocast.addresses)
     return memocast.addresses[int]
 
+def get_class_size(memocast, vtable):
+    memocast = _from_opaque(memocast)
+    return memocast.vtable_to_size[vtable]
+
+def set_class_size(memocast, vtable, size):
+    memocast = _from_opaque(memocast)
+    memocast.vtable_to_size[vtable] = size
+
 class GuardFailed(Exception):
     pass
 
@@ -1234,6 +1246,7 @@
 setannotation(new_memo_cast, s_MemoCast)
 setannotation(cast_adr_to_int, annmodel.SomeInteger())
 setannotation(cast_int_to_adr, annmodel.SomeAddress())
+setannotation(set_class_size, annmodel.s_None)
 
 setannotation(do_arraylen_gc, annmodel.SomeInteger())
 setannotation(do_strlen, annmodel.SomeInteger())

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llgraph/runner.py	Fri Jul 24 12:52:41 2009
@@ -91,6 +91,13 @@
         assert self.translate_support_code
         return False
 
+    def set_class_sizes(self, class_sizes):
+        self.class_sizes = class_sizes
+        for vtable, size in class_sizes.items():
+            if not self.is_oo:
+                size = size.ofs
+            llimpl.set_class_size(self.memo_cast, vtable, size)
+
     def compile_operations(self, loop, bridge=None):
         """In a real assembler backend, this should assemble the given
         list of operations.  Here we just generate a similar CompiledLoop
@@ -326,7 +333,7 @@
     def do_new_with_vtable(self, args, descr=None):
         assert descr is None
         vtable = args[0].getint()
-        size = self.class_sizes[vtable]    # attribute set by codewriter.py
+        size = self.class_sizes[vtable]
         result = llimpl.do_new(size.ofs)
         llimpl.do_setfield_gc_int(result, self.fielddescrof_vtable.ofs,
                                   vtable, self.memo_cast)

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/metainterp/pyjitpl.py	Fri Jul 24 12:52:41 2009
@@ -983,7 +983,7 @@
             self.globaldata.initialized = True
 
     def _setup_class_sizes(self):
-        self.cpu.class_sizes = class_sizes = {}
+        class_sizes = {}
         for vtable, sizedescr in self._class_sizes:
             if not self.cpu.is_oo:
                 vtable = llmemory.cast_ptr_to_adr(vtable)
@@ -991,6 +991,7 @@
             else:
                 vtable = ootype.cast_to_object(vtable)
             class_sizes[vtable] = sizedescr
+        self.cpu.set_class_sizes(class_sizes)
 
     def generate_bytecode(self, policy, ts):
         self._codewriter = codewriter.CodeWriter(self, policy, ts)



More information about the Pypy-commit mailing list