Author: David Schneider <david.schnei...@picle.org>
Branch: jitframe-on-heap
Changeset: r60683:59d2f0246fa5
Date: 2013-01-29 15:13 +0100
http://bitbucket.org/pypy/pypy/changeset/59d2f0246fa5/

Log:    merge heads

diff --git a/rpython/jit/backend/arm/assembler.py 
b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -756,14 +756,6 @@
 
     def update_frame_depth(self, frame_depth):
         self.current_clt.frame_info.jfi_frame_depth = frame_depth
-        new_jumping_to = []
-        for wref in self.current_clt.jumping_to:
-            clt = wref()
-            if clt is not None:
-                clt.frame_info.jfi_frame_depth = max(frame_depth,
-                    clt.frame_info.jfi_frame_depth)
-                new_jumping_to.append(weakref.ref(clt))
-        self.current_clt.jumping_to = new_jumping_to
 
     def write_pending_failure_recoveries(self):
         for tok in self.pending_guards:
diff --git a/rpython/jit/backend/llsupport/jitframe.py 
b/rpython/jit/backend/llsupport/jitframe.py
--- a/rpython/jit/backend/llsupport/jitframe.py
+++ b/rpython/jit/backend/llsupport/jitframe.py
@@ -2,6 +2,7 @@
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rlib.objectmodel import specialize
 from rpython.rlib.debug import ll_assert
+from rpython.rlib.objectmodel import enforceargs
 
 SIZEOFSIGNED = rffi.sizeof(lltype.Signed)
 IS_32BIT = (SIZEOFSIGNED == 2 ** 31 - 1)
@@ -10,14 +11,17 @@
 # compiled loop token (in fact we could use this as a compiled loop token
 # XXX do this
 
-GCMAP = lltype.GcArray(lltype.Unsigned)
+GCMAP = lltype.Array(lltype.Unsigned)
 NULLGCMAP = lltype.nullptr(GCMAP)
 
+@enforceargs(None, int, int)
 def jitframeinfo_set_depth(jfi, base_ofs, new_depth):
     jfi.jfi_frame_depth = new_depth
     jfi.jfi_frame_size = base_ofs + new_depth * SIZEOFSIGNED
 
-JITFRAMEINFO = lltype.GcStruct(
+JITFRAMEINFO_SIZE = 2 * SIZEOFSIGNED # make sure this stays correct
+
+JITFRAMEINFO = lltype.Struct(
     'JITFRAMEINFO',
     # the depth of the frame
     ('jfi_frame_depth', lltype.Signed),
@@ -29,6 +33,7 @@
 )
 
 NULLFRAMEINFO = lltype.nullptr(JITFRAMEINFO)
+JITFRAMEINFOPTR = lltype.Ptr(JITFRAMEINFO)
 
 # the JITFRAME that's stored on the heap. See backend/<backend>/arch.py for
 # detailed explanation how it is on your architecture
@@ -82,25 +87,19 @@
 def jitframe_trace(obj_addr, prev):
     if prev == llmemory.NULL:
         (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 0
-        return obj_addr + getofs('jf_frame_info')
+        return obj_addr + getofs('jf_descr')
     fld = (obj_addr + getofs('jf_gc_trace_state')).signed[0]
     state = fld & 0x7 # 3bits of possible states
     if state == 0:
         (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 1
-        return obj_addr + getofs('jf_descr')
+        return obj_addr + getofs('jf_force_descr')
     elif state == 1:
         (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 2
-        return obj_addr + getofs('jf_force_descr')
+        return obj_addr + getofs('jf_savedata')
     elif state == 2:
         (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 3
-        return obj_addr + getofs('jf_gcmap')
-    elif state == 3:
-        (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 4
-        return obj_addr + getofs('jf_savedata')
-    elif state == 4:
-        (obj_addr + getofs('jf_gc_trace_state')).signed[0] = 5
         return obj_addr + getofs('jf_guard_exc')
-    ll_assert(state == 5, "invalid state")
+    ll_assert(state == 3, "invalid state")
     # bit pattern
     # decode the pattern
     if IS_32BIT:
@@ -125,9 +124,9 @@
             # found it
             # save new state
             if IS_32BIT:
-                new_state = 5 | ((state + 1) << 3) | (no << 8)
+                new_state = 3 | ((state + 1) << 3) | (no << 8)
             else:
-                new_state = 5 | ((state + 1) << 3) | (no << 9)
+                new_state = 3 | ((state + 1) << 3) | (no << 9)
             (obj_addr + getofs('jf_gc_trace_state')).signed[0] = new_state
             return (obj_addr + getofs('jf_frame') + BASEITEMOFS + SIGN_SIZE *
                     (no * SIZEOFSIGNED * 8 + state))
diff --git a/rpython/jit/backend/llsupport/llmodel.py 
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -54,10 +54,14 @@
     def _setup_frame_realloc(self, translate_support_code):
         FUNC_TP = lltype.Ptr(lltype.FuncType([llmemory.GCREF, lltype.Signed],
                                              llmemory.GCREF))
+        base_ofs = self.get_baseofs_of_frame_field()
 
         def realloc_frame(frame, size):
             frame = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, frame)
-            assert size <= frame.jf_frame_info.jfi_frame_depth
+            if size > frame.jf_frame_info.jfi_frame_depth:
+                # update the frame_info size, which is for whatever reason
+                # not up to date
+                frame.jf_frame_info.set_frame_depth(base_ofs, size)
             new_frame = jitframe.JITFRAME.allocate(frame.jf_frame_info)
             i = 0
             while i < len(frame.jf_frame):
diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -1,5 +1,4 @@
 from rpython.rlib.rarithmetic import ovfcheck
-from rpython.rlib import rgc
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.jit.metainterp import history
 from rpython.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
@@ -140,7 +139,7 @@
     def gen_malloc_frame(self, frame_info, frame, size_box):
         descrs = self.gc_ll_descr.getframedescrs(self.cpu)
         if self.gc_ll_descr.kind == 'boehm':
-            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstPtr(frame_info)],
+            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
                                size_box,
                                descr=descrs.jfi_frame_depth)
             self.newops.append(op0)
@@ -149,14 +148,14 @@
             self.handle_new_array(descrs.arraydescr, op1)
         else:
             # we read size in bytes here, not the length
-            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstPtr(frame_info)],
+            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
                                size_box,
                                descr=descrs.jfi_frame_size)
             self.newops.append(op0)
             self.gen_malloc_nursery_varsize(size_box, frame, is_small=True)
             self.gen_initialize_tid(frame, descrs.arraydescr.tid)
             length_box = history.BoxInt()
-            op1 = ResOperation(rop.GETFIELD_GC, [history.ConstPtr(frame_info)],
+            op1 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
                                length_box,
                                descr=descrs.jfi_frame_depth)
             self.newops.append(op1)
@@ -168,12 +167,11 @@
         loop_token = op.getdescr()
         assert isinstance(loop_token, history.JitCellToken)
         jfi = loop_token.compiled_loop_token.frame_info
-        llref = lltype.cast_opaque_ptr(llmemory.GCREF, jfi)
-        rgc._make_sure_does_not_move(llref)
+        llfi = heaptracker.adr2int(llmemory.cast_ptr_to_adr(jfi))
         size_box = history.BoxInt()
         frame = history.BoxPtr()
-        self.gen_malloc_frame(llref, frame, size_box)
-        op2 = ResOperation(rop.SETFIELD_GC, [frame, history.ConstPtr(llref)],
+        self.gen_malloc_frame(llfi, frame, size_box)
+        op2 = ResOperation(rop.SETFIELD_GC, [frame, history.ConstInt(llfi)],
                            None, descr=descrs.jf_frame_info)
         self.newops.append(op2)
         arglist = op.getarglist()
diff --git a/rpython/jit/backend/llsupport/test/test_gc.py 
b/rpython/jit/backend/llsupport/test/test_gc.py
--- a/rpython/jit/backend/llsupport/test/test_gc.py
+++ b/rpython/jit/backend/llsupport/test/test_gc.py
@@ -271,10 +271,10 @@
         return (frame_adr + jitframe.getofs('jf_frame') +
                 jitframe.BASEITEMOFS + jitframe.SIGN_SIZE * no)
     
-    frame_info = lltype.malloc(jitframe.JITFRAMEINFO, zero=True)
+    frame_info = lltype.malloc(jitframe.JITFRAMEINFO, zero=True, flavor='raw')
     frame = lltype.malloc(jitframe.JITFRAME, 15, zero=True)
     frame.jf_frame_info = frame_info
-    frame.jf_gcmap = lltype.malloc(jitframe.GCMAP, 2)
+    frame.jf_gcmap = lltype.malloc(jitframe.GCMAP, 2, flavor='raw')
     if sys.maxint == 2**31 - 1:
         max = r_uint(2 ** 31)
     else:
@@ -290,18 +290,20 @@
     counter = 0
     for name in jitframe.JITFRAME._names:
         TP = getattr(jitframe.JITFRAME, name)
-        if isinstance(TP, lltype.Ptr): # only GC pointers
+        if isinstance(TP, lltype.Ptr) and TP.TO._gckind == 'gc': 
             assert all_addrs[counter] == frame_adr + jitframe.getofs(name)
             counter += 1
     # gcpattern
-    assert all_addrs[6] == indexof(0)
-    assert all_addrs[7] == indexof(1)
-    assert all_addrs[8] == indexof(3)
-    assert all_addrs[9] == indexof(5)
-    assert all_addrs[10] == indexof(7)
-    assert all_addrs[11] == indexof(63)
+    assert all_addrs[4] == indexof(0)
+    assert all_addrs[5] == indexof(1)
+    assert all_addrs[6] == indexof(3)
+    assert all_addrs[7] == indexof(5)
+    assert all_addrs[8] == indexof(7)
+    assert all_addrs[9] == indexof(63)
     # XXX 32bit
-    assert all_addrs[12] == indexof(65)
+    assert all_addrs[10] == indexof(65)
 
-    assert len(all_addrs) == 6 + 6 + 4
-    # 6 static fields, 4 addresses from gcmap, 2 from gcpattern
+    assert len(all_addrs) == 4 + 6 + 4
+    # 4 static fields, 4 addresses from gcmap, 2 from gcpattern
+    lltype.free(frame_info, flavor='raw')
+    lltype.free(frame.jf_gcmap, flavor='raw')
diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py 
b/rpython/jit/backend/llsupport/test/test_rewrite.py
--- a/rpython/jit/backend/llsupport/test/test_rewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_rewrite.py
@@ -9,7 +9,7 @@
 from rpython.jit.metainterp.optimizeopt.util import equaloplists
 from rpython.jit.codewriter.heaptracker import register_known_gctype
 from rpython.jit.metainterp.history import JitCellToken, FLOAT
-from rpython.rtyper.lltypesystem import lltype, rclass, llmemory
+from rpython.rtyper.lltypesystem import lltype, rclass, rffi
 from rpython.jit.backend.x86.arch import WORD
 
 class Evaluator(object):
@@ -72,8 +72,7 @@
 
         casmdescr = JitCellToken()
         clt = FakeLoopToken()
-        frame_info = lltype.malloc(jitframe.JITFRAMEINFO)
-        ll_frame_info = lltype.cast_opaque_ptr(llmemory.GCREF, frame_info)
+        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
         clt.frame_info = frame_info
         frame_info.jfi_frame_depth = 13
         frame_info.jfi_frame_size = 255
@@ -100,6 +99,7 @@
                                                         ops.operations,
                                                         [])
         equaloplists(operations, expected.operations)
+        lltype.free(frame_info, flavor='raw')
 
 class FakeTracker(object):
     pass
@@ -740,12 +740,12 @@
         i2 = call_assembler(i0, f0, descr=casmdescr)
         """, """
         [i0, f0]
-        i1 = getfield_gc(ConstPtr(ll_frame_info), descr=jfi_frame_size)
+        i1 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_size)
         p1 = call_malloc_nursery_varsize_small(i1)
         setfield_gc(p1, 0, descr=tiddescr)
-        i2 = getfield_gc(ConstPtr(ll_frame_info), descr=jfi_frame_depth)
+        i2 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_depth)
         setfield_gc(p1, i2, descr=framelendescr)
-        setfield_gc(p1, ConstPtr(ll_frame_info), descr=jf_frame_info)
+        setfield_gc(p1, ConstClass(frame_info), descr=jf_frame_info)
         setarrayitem_gc(p1, 0, i0, descr=signedframedescr)
         setarrayitem_gc(p1, 1, f0, descr=floatframedescr)
         i3 = call_assembler(p1, descr=casmdescr)
diff --git a/rpython/jit/backend/model.py b/rpython/jit/backend/model.py
--- a/rpython/jit/backend/model.py
+++ b/rpython/jit/backend/model.py
@@ -288,14 +288,11 @@
     asmmemmgr_blocks = None
     asmmemmgr_gcroots = 0
 
-    frame_depth = 0
-
     def __init__(self, cpu, number):
         cpu.tracker.total_compiled_loops += 1
         self.cpu = cpu
         self.number = number
         self.bridges_count = 0
-        self.jumping_to = [] # a list of weakrefs who jump here
         # This growing list gives the 'descr_number' of all fail descrs
         # that belong to this loop or to a bridge attached to it.
         # Filled by the frontend calling record_faildescr_index().
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -44,23 +44,21 @@
 
 
 class GuardToken(object):
-    def __init__(self, faildescr, failargs, fail_locs, exc, frame_depth,
-                 is_guard_not_invalidated, is_guard_not_forced):
+    def __init__(self, gcmap, faildescr, failargs, fail_locs, exc,
+                 frame_depth, is_guard_not_invalidated, is_guard_not_forced):
         self.faildescr = faildescr
         self.failargs = failargs
         self.fail_locs = fail_locs
-        self.gcmap = self.compute_gcmap(failargs, fail_locs, frame_depth)
+        self.gcmap = self.compute_gcmap(gcmap, failargs,
+                                        fail_locs, frame_depth)
         self.exc = exc
         self.is_guard_not_invalidated = is_guard_not_invalidated
         self.is_guard_not_forced = is_guard_not_forced
 
-    def compute_gcmap(self, failargs, fail_locs, frame_depth):
+    def compute_gcmap(self, gcmap, failargs, fail_locs, frame_depth):
         # note that regalloc has a very similar compute, but
         # one that does iteration over all bindings, so slightly different,
         # eh
-        size = frame_depth + JITFRAME_FIXED_SIZE
-        gcmap = lltype.malloc(jitframe.GCMAP, size // WORD // 8 + 1,
-                              zero=True)
         input_i = 0
         for i in range(len(failargs)):
             arg = failargs[i]
@@ -143,7 +141,8 @@
             self.set_debug(have_debug_prints())
             debug_stop('jit-backend-counts')
         # when finishing, we only have one value at [0], the rest dies
-        self.gcmap_for_finish = lltype.malloc(jitframe.GCMAP, 1, zero=True)
+        self.gcmap_for_finish = lltype.malloc(jitframe.GCMAP, 1, zero=True,
+                                              flavor='raw', immortal=True)
         self.gcmap_for_finish[0] = r_uint(1)
 
     def setup(self, looptoken):
@@ -505,9 +504,6 @@
         # about not storing on 'self' attributes that will live only
         # for the duration of compiling one loop or a one bridge.
         clt = CompiledLoopToken(self.cpu, looptoken.number)
-        clt.frame_info = lltype.malloc(jitframe.JITFRAMEINFO)
-        clt.allgcrefs = []
-        clt.frame_info.set_frame_depth(0, 0) # for now
         looptoken.compiled_loop_token = clt
         clt._debug_nbargs = len(inputargs)
         if not we_are_translated():
@@ -515,6 +511,13 @@
             assert len(set(inputargs)) == len(inputargs)
 
         self.setup(looptoken)
+
+        frame_info = self.datablockwrapper.malloc_aligned(
+            jitframe.JITFRAMEINFO_SIZE, alignment=WORD)
+        clt.frame_info = rffi.cast(jitframe.JITFRAMEINFOPTR, frame_info)
+        clt.allgcrefs = []
+        clt.frame_info.set_frame_depth(0, 0) # for now
+
         if log:
             operations = self._inject_debugging_code(looptoken, operations,
                                                      'e', looptoken.number)
@@ -524,8 +527,6 @@
         self._call_header_with_stack_check()
         operations = regalloc.prepare_loop(inputargs, operations, looptoken,
                                            clt.allgcrefs)
-        rgc._make_sure_does_not_move(lltype.cast_opaque_ptr(llmemory.GCREF,
-                                                            clt.frame_info))
         looppos = self.mc.get_relative_pos()
         frame_depth = self._assemble(regalloc, inputargs, operations)
         self.update_frame_depth(frame_depth + JITFRAME_FIXED_SIZE)
@@ -595,9 +596,6 @@
                     (descr_number, rawstart, rawstart + codeendpos))
         debug_stop("jit-backend-addr")
         self.patch_pending_failure_recoveries(rawstart)
-        if not we_are_translated():
-            # for the benefit of tests
-            faildescr._x86_bridge_frame_depth = frame_depth
         # patch the jump from original guard
         self.patch_jump_for_descr(faildescr, rawstart)
         ops_offset = self.mc.ops_offset
@@ -668,16 +666,8 @@
     def update_frame_depth(self, frame_depth):
         baseofs = self.cpu.get_baseofs_of_frame_field()
         self.current_clt.frame_info.set_frame_depth(baseofs, frame_depth)
-        new_jumping_to = []
-        for wref in self.current_clt.jumping_to:
-            clt = wref()
-            if clt is not None:
-                clt.frame_info.set_frame_depth(baseofs, max(frame_depth,
-                    clt.frame_info.jfi_frame_depth))
-                new_jumping_to.append(weakref.ref(clt))
-        self.current_clt.jumping_to = new_jumping_to
 
-    def _check_frame_depth(self, mc, gcmap):
+    def _check_frame_depth(self, mc, gcmap, expected_size=-1):
         """ check if the frame is of enough depth to follow this bridge.
         Otherwise reallocate the frame in a helper.
         There are other potential solutions
@@ -686,12 +676,18 @@
         descrs = self.cpu.gc_ll_descr.getframedescrs(self.cpu)
         ofs = self.cpu.unpack_fielddescr(descrs.arraydescr.lendescr)
         base_ofs = self.cpu.get_baseofs_of_frame_field()
-        mc.CMP_bi(ofs - base_ofs, 0xffffff)
+        if expected_size == -1:
+            mc.CMP_bi(ofs - base_ofs, 0xffffff)
+        else:
+            mc.CMP_bi(ofs - base_ofs, expected_size)
         stack_check_cmp_ofs = mc.get_relative_pos() - 4
         assert not IS_X86_32
         mc.J_il8(rx86.Conditions['GE'], 0)
         jg_location = mc.get_relative_pos()
-        mc.MOV_si(WORD, 0xffffff)
+        if expected_size == -1:
+            mc.MOV_si(WORD, 0xffffff)
+        else:
+            mc.MOV_si(WORD, expected_size)            
         ofs2 = mc.get_relative_pos() - 4
         self.push_gcmap(mc, gcmap, mov=True)
         mc.CALL(imm(self._stack_check_failure))
@@ -1850,9 +1846,24 @@
                guard_opnum == rop.GUARD_NOT_FORCED)
         is_guard_not_invalidated = guard_opnum == rop.GUARD_NOT_INVALIDATED
         is_guard_not_forced = guard_opnum == rop.GUARD_NOT_FORCED
-        return GuardToken(faildescr, failargs, fail_locs, exc, frame_depth,
+        gcmap = self.allocate_gcmap(frame_depth)
+        return GuardToken(gcmap, faildescr, failargs,
+                          fail_locs, exc, frame_depth,
                           is_guard_not_invalidated, is_guard_not_forced)
 
+    def allocate_gcmap(self, frame_depth):
+        size = frame_depth + JITFRAME_FIXED_SIZE
+        malloc_size = (size // WORD // 8 + 1) + 1
+        rawgcmap = self.datablockwrapper.malloc_aligned(WORD * malloc_size,
+                                                        WORD)
+        # set the length field
+        rffi.cast(rffi.CArrayPtr(lltype.Signed), rawgcmap)[0] = malloc_size - 1
+        gcmap = rffi.cast(lltype.Ptr(jitframe.GCMAP), rawgcmap)
+        # zero the area
+        for i in range(malloc_size - 1):
+            gcmap[i] = r_uint(0)
+        return gcmap
+
     def generate_propagate_error_64(self):
         assert WORD == 8
         startpos = self.mc.get_relative_pos()
@@ -1890,6 +1901,8 @@
                 positions[i] = v * WORD
         # write down the positions of locs
         guardtok.faildescr.rd_locs = positions
+        # we want the descr to keep alive
+        guardtok.faildescr.rd_loop_token = self.current_clt
         #if WORD == 4:
         #    mc.PUSH(imm(fail_descr))
         #    mc.PUSH(imm(gcpattern))
@@ -1901,19 +1914,15 @@
         return startpos
 
     def push_gcmap(self, mc, gcmap, push=False, mov=False, store=False):
-        gcmapref = lltype.cast_opaque_ptr(llmemory.GCREF, gcmap)
-        # keep the ref alive
-        self.current_clt.allgcrefs.append(gcmapref)
-        rgc._make_sure_does_not_move(gcmapref)
         if push:
-            mc.PUSH(imm(rffi.cast(lltype.Signed, gcmapref)))
+            mc.PUSH(imm(rffi.cast(lltype.Signed, gcmap)))
         elif mov:
             mc.MOV(RawEspLoc(0, REF),
-                   imm(rffi.cast(lltype.Signed, gcmapref)))
+                   imm(rffi.cast(lltype.Signed, gcmap)))
         else:
             assert store
             ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap')
-            mc.MOV(raw_stack(ofs), imm(rffi.cast(lltype.Signed, gcmapref)))
+            mc.MOV(raw_stack(ofs), imm(rffi.cast(lltype.Signed, gcmap)))
 
     def pop_gcmap(self, mc):
         ofs = self.cpu.get_ofs_of_frame_field('jf_gcmap')
@@ -2468,10 +2477,13 @@
             curpos = self.mc.get_relative_pos() + 5
             self.mc.JMP_l(target - curpos)
         else:
-            clt = self.current_clt
-            assert clt is not None
-            target_token._x86_clt.jumping_to.append(
-                weakref.ref(clt))
+            if target_token._x86_clt is not self.current_clt:
+                # We can have a frame coming from god knows where that's
+                # passed to a jump to another loop. Make sure it has the
+                # correct depth
+                expected_size = 
target_token._x86_clt.frame_info.jfi_frame_depth
+                self._check_frame_depth(self.mc, self._regalloc.get_gcmap(),
+                                        expected_size=expected_size)
             self.mc.JMP(imm(target))
 
     def malloc_cond(self, nursery_free_adr, nursery_top_adr, size, gcmap):
diff --git a/rpython/jit/backend/x86/regalloc.py 
b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -896,9 +896,7 @@
 
     def get_gcmap(self, forbidden_regs=[]):
         frame_depth = self.fm.get_frame_depth()
-        size = frame_depth + JITFRAME_FIXED_SIZE
-        gcmap = lltype.malloc(GCMAP, size // WORD // 8 + 1,
-                              zero=True)
+        gcmap = self.assembler.allocate_gcmap(frame_depth)
         for box, loc in self.rm.reg_bindings.iteritems():
             if loc in forbidden_regs:
                 continue
@@ -1334,6 +1332,7 @@
         #jump_op = self.final_jump_op
         #if jump_op is not None and jump_op.getdescr() is descr:
         #    self._compute_hint_frame_locations_from_descr(descr)
+        
 
     def consider_keepalive(self, op):
         pass
diff --git a/rpython/jit/backend/x86/test/test_recompilation.py 
b/rpython/jit/backend/x86/test/test_recompilation.py
--- a/rpython/jit/backend/x86/test/test_recompilation.py
+++ b/rpython/jit/backend/x86/test/test_recompilation.py
@@ -33,7 +33,7 @@
         jump(i1, descr=targettoken)
         '''
         loop = self.interpret(ops, [0])
-        previous = loop._jitcelltoken.compiled_loop_token.frame_depth
+        previous = 
loop._jitcelltoken.compiled_loop_token.frame_info.jfi_frame_depth
         assert self.getint(0) == 20
         ops = '''
         [i1]
@@ -43,14 +43,15 @@
         i6 = int_add(i5, 1)
         i7 = int_add(i5, i4)
         force_spill(i5)
+        force_spill(i6)
+        force_spill(i7)
         i8 = int_add(i7, 1)
         i9 = int_add(i8, 1)
         guard_false(i3, descr=fdescr2) [i3, i4, i5, i6, i7, i8, i9]
         finish()
         '''
-        bridge = self.attach_bridge(ops, loop, -2)
-        descr = loop.operations[3].getdescr()
-        new = descr._x86_bridge_frame_depth
+        self.attach_bridge(ops, loop, -2)
+        new = loop._jitcelltoken.compiled_loop_token.frame_info.jfi_frame_depth
         # the force_spill() forces the stack to grow
         assert new > previous
         fail = self.run(loop, 0)
@@ -103,20 +104,32 @@
         [i97, i3]
         i10 = int_mul(i3, 2)
         i8 = int_add(i3, 1)
+        i15 = int_add(i3, 1)
+        i16 = int_add(i3, 1)
+        i17 = int_add(i3, 1)
+        i18 = int_add(i3, 1)
         i6 = int_add(i8, i10)
         i7 = int_add(i3, i6)
         force_spill(i6)
         force_spill(i7)
         force_spill(i8)
+        force_spill(i10)
         i12 = int_add(i7, i8)
         i11 = int_add(i12, i6)
+        force_spill(i11)
+        force_spill(i12)
+        force_spill(i15)
+        force_spill(i16)
+        force_spill(i17)
+        force_spill(i18)
+        guard_true(i18) [i3, i12, i11, i10, i6, i7, i18, i17, i16]
         jump(i3, i12, i11, i10, i6, i7, descr=targettoken)
         '''
-        loop_frame_depth = loop._jitcelltoken.compiled_loop_token.frame_depth
+        loop_frame_depth = 
loop._jitcelltoken.compiled_loop_token.frame_info.jfi_frame_depth
         bridge = self.attach_bridge(ops, loop, 6)
-        guard_op = loop.operations[6]
         # the force_spill() forces the stack to grow
-        assert guard_op.getdescr()._x86_bridge_frame_depth > loop_frame_depth
+        bridge_frame_depth = 
loop._jitcelltoken.compiled_loop_token.frame_info.jfi_frame_depth
+        assert bridge_frame_depth > loop_frame_depth
         self.run(loop, 0, 0, 0, 0, 0, 0)
         assert self.getint(0) == 1
         assert self.getint(1) == 20
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to