[pypy-svn] r66595 - in pypy/branch/pyjitpl5-optimize4/pypy/jit/backend: llvm test

arigo at codespeak.net arigo at codespeak.net
Fri Jul 24 16:45:47 CEST 2009


Author: arigo
Date: Fri Jul 24 16:45:46 2009
New Revision: 66595

Modified:
   pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/compile.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/test/runner_test.py
Log:
Partial fix of the llvm backend.
The next failure is Really Obscure(tm).


Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/compile.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/compile.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/compile.py	Fri Jul 24 16:45:46 2009
@@ -667,7 +667,9 @@
         self.vars[op.result] = res
 
     def generate_NEW_WITH_VTABLE(self, op):
-        self.generate_NEW(op)
+        sizedescr = self.cpu.class_sizes[op.args[0].getint()]
+        res = self._generate_new(self.cpu._make_const_int(sizedescr.size))
+        self.vars[op.result] = res
         loc = self._generate_field_gep(op.result, self.cpu.vtable_descr)
         value_ref = self.getintarg(op.args[0])
         llvm_rffi.LLVMBuildStore(self.builder, value_ref, loc, "")

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/llvm/runner.py	Fri Jul 24 16:45:46 2009
@@ -5,6 +5,7 @@
 from pypy.rlib import runicode
 from pypy.jit.metainterp.history import AbstractDescr, INT
 from pypy.jit.metainterp.history import BoxInt, BoxPtr
+from pypy.jit.backend.model import AbstractCPU
 from pypy.jit.backend.llvm import llvm_rffi
 from pypy.jit.metainterp import history
 from pypy.jit.metainterp.resoperation import rop, ResOperation
@@ -82,6 +83,9 @@
                                              _nowrapper=True)
         assert rffi.sizeof(rffi.SIZE_T) == self.size_of_int
 
+    def set_class_sizes(self, class_sizes):
+        self.class_sizes = class_sizes
+
     def setup_once(self):
         if not we_are_translated():
             llvm_rffi.teardown_now()
@@ -532,8 +536,9 @@
         res = self.malloc_fn_ptr(rffi.cast(rffi.SIZE_T, sizedescr.size))
         return BoxPtr(res)
 
-    def do_new_with_vtable(self, args, sizedescr):
-        assert isinstance(sizedescr, SizeDescr)
+    def do_new_with_vtable(self, args, descr=None):
+        assert descr is None
+        sizedescr = self.class_sizes[args[0].getint()]
         res = self.malloc_fn_ptr(rffi.cast(rffi.SIZE_T, sizedescr.size))
         self._do_setfield(res, args[0], self.vtable_descr)
         return BoxPtr(res)
@@ -692,6 +697,8 @@
     def __init__(self, offset, size_index):
         self.offset = offset
         self.size_index = size_index    # index in cpu.types_by_index
+    def is_pointer_field(self):
+        return self.size_index == LLVMCPU.SIZE_GCPTR
 
 class ArrayDescr(AbstractDescr):
     def __init__(self, itemsize, itemsize_index):

Modified: pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/pyjitpl5-optimize4/pypy/jit/backend/test/runner_test.py	Fri Jul 24 16:45:46 2009
@@ -274,6 +274,7 @@
     def test_field_basic(self):
         t_box, T_box = self.alloc_instance(self.T)
         fielddescr = self.cpu.fielddescrof(self.S, 'value')
+        assert not fielddescr.is_pointer_field()
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, BoxInt(39082)],
                                      'void', descr=fielddescr)
         assert res is None
@@ -296,6 +297,7 @@
         #
         u_box, U_box = self.alloc_instance(self.U)
         fielddescr2 = self.cpu.fielddescrof(self.S, 'next')
+        assert fielddescr2.is_pointer_field()
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, u_box],
                                      'void', descr=fielddescr2)
         assert res is None



More information about the Pypy-commit mailing list