1. Pypy
  2. Untitled project
  3. pypy

Commits

Maciej Fijalkowski  committed cf9ed33

a test and a fix

  • Participants
  • Parent commits 297a8f9
  • Branches jitframe-on-heap

Comments (0)

Files changed (3)

File rpython/jit/backend/llsupport/jitframe.py

View file
         i += 1
     return frame
 
-JITFRAME = lltype.GcStruct(
+def jitframe_resolve(frame):
+    while frame.jf_forward:
+        frame = frame.jf_forward
+    return frame
+
+JITFRAME = lltype.GcForwardReference()
+
+JITFRAME.become(lltype.GcStruct(
     'JITFRAME',
     ('jf_frame_info', lltype.Ptr(JITFRAMEINFO)),
     # Once the execute_token() returns, the field 'jf_descr' stores the
     # RPython code that finishes the function with an exception, the
     # exception is not stored there, but is simply kept as a variable there)
     ('jf_guard_exc', llmemory.GCREF),
+    # in case the frame got reallocated, we have to forward it somewhere
+    ('jf_forward', lltype.Ptr(JITFRAME)),
     # absolutely useless field used to make up for tracing hooks inflexibilities
     ('jf_gc_trace_state', lltype.Signed),
     # the actual frame
     # about GCrefs here and not in frame info which might change
     adtmeths = {
         'allocate': jitframe_allocate,
+        'resolve': jitframe_resolve,
     },
     rtti = True,
-)
+))
 
 @specialize.memo()
 def getofs(name):

File rpython/jit/backend/llsupport/llmodel.py

View file
                     frame.jf_frame_info.set_frame_depth(base_ofs, size)
                 new_frame = jitframe.JITFRAME.allocate(frame.jf_frame_info,
                                                        self.JITFRAME_FIXED_SIZE)
+                frame.jf_forward = new_frame
                 i = 0
                 while i < len(frame.jf_frame):
                     new_frame.jf_frame[i] = frame.jf_frame[i]
 
     def force(self, addr_of_force_token):
         frame = rffi.cast(jitframe.JITFRAMEPTR, addr_of_force_token)
+        frame = frame.resolve()
         frame.jf_descr = frame.jf_force_descr
         return lltype.cast_opaque_ptr(llmemory.GCREF, frame)
 

File rpython/jit/backend/test/runner_test.py

View file
     def test_compile_bridge_while_running(self):        
         def func():
             bridge = parse("""
-            [i1, i2]
+            [i1, i2, px]
             i3 = int_add(i1, i2)
             i4 = int_add(i1, i3)
             i5 = int_add(i1, i4)
             force_spill(i8)
             force_spill(i9)
             call(ConstClass(func2_ptr), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, descr=calldescr2)
-            guard_true(i1, descr=guarddescr) [i1, i2, i3, i4, i5, i6, i7, i8, i9]
+            guard_true(i1, descr=guarddescr) [i1, i2, i3, i4, i5, i6, i7, i8, i9, px]
             finish(i1, descr=finaldescr)
             """, namespace={'finaldescr': finaldescr, 'calldescr2': calldescr2,
                             'guarddescr': guarddescr, 'func2_ptr': func2_ptr})
         loop = parse("""
         [i0, i1, i2]
         call(ConstClass(func_ptr), descr=calldescr)
-        guard_true(i0, descr=faildescr) [i1, i2]
+        px = force_token()
+        guard_true(i0, descr=faildescr) [i1, i2, px]
         finish(i2, descr=finaldescr2)
         """, namespace=locals())
         self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
             
         frame = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, frame)
         assert len(frame.jf_frame) == frame.jf_frame_info.jfi_frame_depth
+        ref = self.cpu.get_ref_value(frame, 9)
+        token = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, ref)
+        assert token != frame
+        token = token.resolve()
+        assert token == frame
 
     def test_compile_bridge_while_running_guard_no_exc(self):
         xtp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)