Author: Maciej Fijalkowski <[email protected]>
Branch: jitframe-on-heap
Changeset: r60413:1f9aea6048aa
Date: 2013-01-24 10:10 +0200
http://bitbucket.org/pypy/pypy/changeset/1f9aea6048aa/

Log:    finish the test and make it pass

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
@@ -30,12 +30,6 @@
     frame.jf_frame_info = frame_info
     return frame
 
-def jitframe_copy(frame):
-    frame_info = frame.jf_frame_info
-    new_frame = lltype.malloc(JITFRAME, frame_info.jfi_frame_depth, zero=True)
-    new_frame.jf_frame_info = frame_info
-    return new_frame
-
 JITFRAME = lltype.GcStruct(
     'JITFRAME',
     ('jf_frame_info', lltype.Ptr(JITFRAMEINFO)),
@@ -63,7 +57,6 @@
     # about GCrefs here and not in frame info which might change
     adtmeths = {
         'allocate': jitframe_allocate,
-        'copy': jitframe_copy,
     },
     rtti = True,
 )
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
@@ -140,6 +140,9 @@
             debug_start('jit-backend-counts')
             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[0] = r_uint(1)
 
     def setup(self, looptoken):
         assert self.memcpy_addr != 0, "setup_once() not called?"
@@ -2006,7 +2009,7 @@
         ofs = self.cpu.get_ofs_of_frame_field('jf_descr')
         base_ofs = self.cpu.get_baseofs_of_frame_field()
         self.mov(fail_descr_loc, RawStackLoc(ofs))
-        gcmap = self._regalloc.get_gcmap()
+        gcmap = self.gcmap_for_finish
         self.push_gcmap(self.mc, gcmap, store=True)
         self.mc.LEA_rb(eax.value, -base_ofs)
         # exit function
diff --git a/rpython/jit/backend/x86/test/test_gc_integration.py 
b/rpython/jit/backend/x86/test/test_gc_integration.py
--- a/rpython/jit/backend/x86/test/test_gc_integration.py
+++ b/rpython/jit/backend/x86/test/test_gc_integration.py
@@ -366,27 +366,31 @@
             assert len(frame.jf_frame) == JITFRAME_FIXED_SIZE + 4
             # we "collect"
             frames.append(frame)
-            new_frame = frame.copy()
+            new_frame = jitframe.JITFRAME.allocate(frame.jf_frame_info)
+            gcmap = unpack_gcmap(frame)
+            assert gcmap == [28, 29, 30]
+            for item, s in zip(gcmap, new_items):
+                new_frame.jf_frame[item] = rffi.cast(lltype.Signed, s)
             assert self.cpu.gc_ll_descr.gcrootmap.stack[0] == 
rffi.cast(lltype.Signed, frame)
             hdrbuilder.new_header(new_frame)
-            #gc_ll_descr.gcrootmap.stack[0] = rffi.cast(lltype.Signed, 
new_frame)
+            gc_ll_descr.gcrootmap.stack[0] = rffi.cast(lltype.Signed, 
new_frame)
             frames.append(new_frame)
-            assert unpack_gcmap(frame) == [28, 29, 30]
 
         def check2(i):
             assert self.cpu.gc_ll_descr.gcrootmap.stack[0] == i - ofs
             frame = rffi.cast(jitframe.JITFRAMEPTR, i - ofs)
-            #assert frame == frames[1]
-            #assert frame != frames[0]
+            assert frame == frames[1]
+            assert frame != frames[0]
 
         CHECK = lltype.FuncType([lltype.Signed], lltype.Void)
         checkptr = llhelper(lltype.Ptr(CHECK), check)
         check2ptr = llhelper(lltype.Ptr(CHECK), check2)
         checkdescr = self.cpu.calldescrof(CHECK, CHECK.ARGS, CHECK.RESULT,
                                           EffectInfo.MOST_GENERAL)
-        
-        S = lltype.GcStruct('S',
-                            ('x', lltype.Ptr(lltype.GcArray(lltype.Signed))))
+
+        S = lltype.GcForwardReference()
+        S.become(lltype.GcStruct('S',
+                                 ('x', lltype.Ptr(S))))
         loop = self.parse("""
         [p0, p1, p2]
         i0 = force_token() # this is a bit below the frame
@@ -412,9 +416,15 @@
         p0 = lltype.malloc(S, zero=True)
         p1 = lltype.malloc(S)
         p2 = lltype.malloc(S)
+        new_items = [lltype.malloc(S), lltype.malloc(S), lltype.malloc(S)]
+        new_items[0].x = new_items[2]
         hdrbuilder.new_header(p0)
         hdrbuilder.new_header(p1)
         hdrbuilder.new_header(p2)
         frame = self.cpu.execute_token(token, p0, p1, p2)
+        frame = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, frame)
         gcmap = unpack_gcmap(lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, 
frame))
-        assert gcmap == [11]
+        assert len(gcmap) == 1
+        assert gcmap[0] < 29
+        item = rffi.cast(lltype.Ptr(S), frame.jf_frame[gcmap[0]])
+        assert item == new_items[2]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to