[pypy-svn] r65667 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86: . test

arigo at codespeak.net arigo at codespeak.net
Mon Jun 8 19:05:35 CEST 2009


Author: arigo
Date: Mon Jun  8 19:05:33 2009
New Revision: 65667

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/symbolic.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py
Log:
Fix for the offset of lengths of arrays, which is not 0 with
our GCs.  Similarly, use vtable_offset instead of 0 in guard_class.


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	Mon Jun  8 19:05:33 2009
@@ -587,8 +587,9 @@
         self.mc.MOV(resloc, addr_add_const(base_loc, ofs_length))
 
     def genop_arraylen_gc(self, op, arglocs, resloc):
+        ofs = self.cpu.gc_ll_descr.array_length_ofs
         base_loc, ofs_loc = arglocs
-        self.mc.MOV(resloc, addr_add_const(base_loc, 0))     # XXX fix this 0
+        self.mc.MOV(resloc, addr_add_const(base_loc, ofs))
 
     def genop_strgetitem(self, op, arglocs, resloc):
         base_loc, ofs_loc = arglocs
@@ -679,7 +680,7 @@
         self.implement_guard(addr, op, self.mc.JNE)
 
     def genop_guard_guard_class(self, op, ign_1, addr, locs, ign_2):
-        offset = 0    # XXX for now, the vtable ptr is at the start of the obj
+        offset = self.cpu.vtable_offset
         self.mc.CMP(mem(locs[0], offset), locs[1])
         self.implement_guard(addr, op, self.mc.JNE)
 

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py	Mon Jun  8 19:05:33 2009
@@ -26,6 +26,7 @@
 class GcLLDescr_boehm(GcLLDescription):
     moving_gc = False
     gcrootmap = None
+    array_length_ofs = 0
 
     def __init__(self, gcdescr, cpu):
         # grab a pointer to the Boehm 'malloc' function
@@ -292,7 +293,7 @@
         self.moving_gc = self.GCClass.moving_gc
         self.HDRPTR = lltype.Ptr(self.GCClass.HDR)
         self.fielddescr_tid = cpu.fielddescrof(self.GCClass.HDR, 'tid')
-        self._array_length_ofs = -1
+        self.array_length_ofs = -1
 
         # make a malloc function, with three arguments
         def malloc_basic(size, type_id, has_finalizer):
@@ -312,7 +313,7 @@
             return llop.do_malloc_varsize_clear(
                 llmemory.GCREF,
                 type_id, num_elem, basesize, itemsize,
-                self._array_length_ofs, True, False)
+                self.array_length_ofs, True, False)
         self.malloc_array = malloc_array
         self.GC_MALLOC_ARRAY = lltype.Ptr(lltype.FuncType(
             [lltype.Signed] * 4, llmemory.GCREF))
@@ -354,10 +355,10 @@
         assert translate_support_code, "required with the framework GC"
         basesize, itemsize, ofs_length = symbolic.get_array_token(A, True)
         assert rffi.sizeof(A.OF) in [1, 2, WORD]
-        if self._array_length_ofs == -1:
-            self._array_length_ofs = ofs_length
+        if self.array_length_ofs == -1:
+            self.array_length_ofs = ofs_length
         else:
-            assert self._array_length_ofs == ofs_length    # all the same
+            assert self.array_length_ofs == ofs_length    # all the same
         if isinstance(A.OF, lltype.Ptr) and A.OF.TO._gckind == 'gc':
             ptr = True
         else:

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py	Mon Jun  8 19:05:33 2009
@@ -406,8 +406,10 @@
     # ------------------- backend-specific ops ------------------------
 
     def do_arraylen_gc(self, args, arraydescr):
+        ofs = self.gc_ll_descr.array_length_ofs
         gcref = args[0].getptr(llmemory.GCREF)
-        return BoxInt(rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)[0])
+        length = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref)[ofs/WORD]
+        return BoxInt(length)
 
     def do_getarrayitem_gc(self, args, arraydescr):
         field = args[1].getint()

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/symbolic.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/symbolic.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/symbolic.py	Mon Jun  8 19:05:33 2009
@@ -26,11 +26,13 @@
     if translate_support_code:
         basesize = llmemory.sizeof(T, 0)
         if isinstance(T, lltype.Struct):
-            itemsize = llmemory.sizeof(getattr(T, T._arrayfld).OF)
-            ofs_length = llmemory.offsetof(T, T._arrayfld)
+            SUBARRAY = getattr(T, T._arrayfld)
+            itemsize = llmemory.sizeof(SUBARRAY.OF)
+            ofs_length = (llmemory.offsetof(T, T._arrayfld) +
+                          llmemory.ArrayLengthOffset(SUBARRAY))
         else:
             itemsize = llmemory.sizeof(T.OF)
-            ofs_length = 0
+            ofs_length = llmemory.ArrayLengthOffset(T)
     else:
         if isinstance(T, lltype.Struct):
             assert T._arrayfld is not None, "%r is not variable-sized" % (T,)

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py	Mon Jun  8 19:05:33 2009
@@ -231,7 +231,13 @@
         while n > 0:
             myjitdriver.can_enter_jit(n=n, x=x, l=l)
             myjitdriver.jit_merge_point(n=n, x=x, l=l)
-            l = [n, n, n]
+            if n < 200:
+                l = [n, n, n]
+            if n < 100:
+                assert len(l) == 3
+                assert l[0] == n
+                assert l[1] == n
+                assert l[2] == n
             n -= x.foo
         assert len(l) == 3
         assert l[0] == 2



More information about the Pypy-commit mailing list