Commits

Maciej Fijalkowski  committed 4cdddd8

fixes and tests

  • Participants
  • Parent commits 3f25d53
  • Branches jitframe-on-heap

Comments (0)

Files changed (2)

File pypy/jit/backend/x86/assembler.py

         clt.allgcrefs = []
         clt.frame_info.jfi_frame_depth = 0 # for now
         looptoken.compiled_loop_token = clt
+        clt._debug_nbargs = len(inputargs)
         if not we_are_translated():
             # Arguments should be unique
             assert len(set(inputargs)) == len(inputargs)
         regalloc = RegAlloc(self, self.cpu.translate_support_code)
         #
         self._call_header_with_stack_check()
-        clt._debug_nbargs = len(inputargs)
         operations = regalloc.prepare_loop(inputargs, operations, looptoken,
                                            clt.allgcrefs)
         rgc._make_sure_does_not_move(clt.frame_info)
         frame_info_ofs = self.cpu.get_ofs_of_frame_field('jf_frame_info')
         jfi_gc_map_ofs = self.cpu.get_ofs_of_frame_field('jfi_gcmap')
         if IS_X86_32:
-            self.mc.MOV_bi(gcmap_ofs, frame_info_addr + jfi_gc_map_ofs)
             self.mc.MOV_bi(frame_info_ofs, frame_info_addr)
+            XXX
         else:
-            self.mc.MOV_ri(X86_64_SCRATCH_REG.value,
-                           frame_info_addr + jfi_gc_map_ofs)
-            self.mc.MOV_br(gcmap_ofs, X86_64_SCRATCH_REG.value)
             self.mc.MOV_ri(X86_64_SCRATCH_REG.value, frame_info_addr)
             self.mc.MOV_br(frame_info_ofs, X86_64_SCRATCH_REG.value)
+            self.mc.MOV_rm(X86_64_SCRATCH_REG.value,
+                           (X86_64_SCRATCH_REG.value,
+                            jfi_gc_map_ofs))
+            self.mc.MOV_br(gcmap_ofs, X86_64_SCRATCH_REG.value)
             
 
     def _patch_stackadjust(self, adr, allocated_depth):
                         op.getopname())
 
     def closing_jump(self, target_token):
-        # The backend's logic assumes that the target code is in a piece of
-        # assembler that was also called with the same number of arguments,
-        # so that the locations [ebp+8..] of the input arguments are valid
-        # stack locations both before and after the jump.
-        my_nbargs = self.current_clt._debug_nbargs
-        target_nbargs = target_token._x86_clt._debug_nbargs
-        assert my_nbargs == target_nbargs
-        #
         target = target_token._x86_loop_code
         if target_token in self.target_tokens_currently_compiling:
             curpos = self.mc.get_relative_pos() + 5

File pypy/jit/backend/x86/test/test_gc_integration.py

     ptr0 = struct_ref
 
     targettoken = TargetToken()
+    targettoken2 = TargetToken()
 
     namespace = locals().copy()
 
     def test_label(self):
         ops = '''
         [i0, p0, i1, p1]
-        label(i0, p0, i1, p1, descr=targettoken)
+        label(i0, p0, i1, p1, descr=targettoken2)
         p3 = getfield_gc(p0, descr=fielddescr)
         force_spill(p3)
         guard_true(i0) [p0, i1, p1, p3]
         s1 = lltype.malloc(self.S)
         s2 = lltype.malloc(self.S)
         s1.field = s2
-        loop = self.interpret(ops, [0, s1, 1, s2])
+        self.interpret(ops, [0, s1, 1, s2])
         ops2 = '''
         [p0]
-        jump(1, p0, 1, p0, descr=targettoken)
+        jump(1, p0, 1, p0, descr=targettoken2)
         '''
-        self.interpret(ops2)
-        xxx
+        self.interpret(ops2, [s1])
+        frame = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, self.deadframe)
+        assert len(frame.jf_gcmap) == 3
+        assert [frame.jf_gcmap[i] for i in range(3)] == [1, 3, 4]
 
     def test_rewrite_constptr(self):
         ops = '''