Commits

Maciej Fijalkowski committed a57b539

finish the test and fix the code

Comments (0)

Files changed (2)

rpython/jit/backend/x86/assembler.py

         # first, close the stack in the sense of the asmgcc GC root tracker
         gcrootmap = self.cpu.gc_ll_descr.gcrootmap
         if gcrootmap:
-            raise NotImplementedError # we need tests
-            xxx
             self.call_release_gil(gcrootmap, arglocs)
         # do the call
         self._store_force_index(guard_op)
         self.genop_call(op, arglocs, result_loc)
         # then reopen the stack
         if gcrootmap:
-            raise NotImplementedError # we need tests
-            xxx
             self.call_reacquire_gil(gcrootmap, result_loc)
         # finally, the guard_not_forced
         self._emit_guard_not_forced(guard_token)
             if reg in save_registers:
                 self.mc.MOV_rs(reg.value, p)
                 p += WORD
-        self._regalloc.needed_extra_stack_locations(p//WORD)
 
     def call_reacquire_gil(self, gcrootmap, save_loc):
         # save the previous result (eax/xmm0) into the stack temporarily.
         if gcrootmap.is_shadow_stack:
             args = []
         else:
+            xxx
             assert self.gcrootmap_retaddr_forced == -1, (
                       "missing mark_gc_roots() in CALL_RELEASE_GIL")
             self.gcrootmap_retaddr_forced = 0
         # restore the result from the stack
         if isinstance(save_loc, RegLoc) and not save_loc.is_xmm:
             self.mc.MOV_rs(save_loc.value, WORD)
-            self._regalloc.needed_extra_stack_locations(2)
 
     def genop_guard_call_assembler(self, op, guard_op, guard_token,
                                    arglocs, result_loc):

rpython/jit/backend/x86/test/test_gc_integration.py

 from rpython.rtyper.annlowlevel import llhelper, llhelper_args
 
 from rpython.jit.backend.x86.test.test_regalloc import BaseTestRegalloc
-from rpython.jit.backend.x86.regalloc import gpr_reg_mgr_cls
 from rpython.jit.codewriter.effectinfo import EffectInfo
-from rpython.rtyper.memory.gcheader import GCHeaderBuilder
+from rpython.rlib.objectmodel import invoke_around_extcall
 
 CPU = getcpuclass()
 
     ('hdr', lltype.Signed),
     ('jf_frame_info', lltype.Ptr(jitframe.JITFRAMEINFO)),
     ('jf_descr', llmemory.GCREF),
+    ('jf_force_descr', llmemory.GCREF),
     ('jf_guard_exc', llmemory.GCREF),
     ('jf_gcmap', lltype.Ptr(jitframe.GCMAP)),
     ('jf_gc_trace_state', lltype.Signed),
     def getframedescrs(self, cpu):
         descrs = JitFrameDescrs()
         descrs.arraydescr = cpu.arraydescrof(JITFRAME)
-        for name in ['jf_descr', 'jf_guard_exc',
+        for name in ['jf_descr', 'jf_guard_exc', 'jf_force_descr',
                      'jf_frame_info', 'jf_gcmap']:
             setattr(descrs, name, cpu.fielddescrof(JITFRAME, name))
         descrs.jfi_frame_depth = cpu.fielddescrof(jitframe.JITFRAMEINFO,
         assert rffi.cast(JITFRAMEPTR, cpu.gc_ll_descr.write_barrier_on_frame_called) == frame
 
     def test_call_release_gil(self):
+        # note that we can't test floats here because when untranslated
+        # people actually wreck xmm registers
         cpu = self.cpu
+        l = []
+
+        def before():
+            l.append("before")
+
+        def after():
+            l.append("after")
+
+        invoke_around_extcall(before, after)
 
         def f(x):
-            import pdb
-            pdb.set_trace()
-
-        FUNC = lltype.FuncType([lltype.Float], lltype.Float)
+            assert x == 1
+            return 2
+        
+        FUNC = lltype.FuncType([lltype.Signed], lltype.Signed)
         fptr = llhelper(lltype.Ptr(FUNC), f)
         calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
                                     EffectInfo.MOST_GENERAL)        
         loop = self.parse("""
-        [f0]
-        f1 = call_release_gil(ConstClass(fptr), f0, descr=calldescr)
+        [i0]
+        i1 = call_release_gil(ConstClass(fptr), i0, descr=calldescr)
         guard_not_forced(descr=faildescr) []
-        finish(f1)
+        finish(i1, descr=finaldescr)
         """, namespace={'fptr': fptr, 'calldescr':calldescr,
-                        'faildescr': BasicFailDescr()})
+                        'faildescr': BasicFailDescr(),
+                        'finaldescr': BasicFinalDescr()})
         token = JitCellToken()
         cpu.gc_ll_descr.init_nursery(100)
         cpu.setup_once()
         cpu.compile_loop(loop.inputargs, loop.operations, token)
-        cpu.execute_token(token, 1.3)
+        frame = cpu.execute_token(token, 1)
+        frame = rffi.cast(JITFRAMEPTR, frame)
+        assert frame.jf_frame[0] == 2
+        assert l == ['before', 'after']