Commits

Armin Rigo  committed d1db1d3

Try to be more careful: the jit backend must now emit GETFIELD_GC with
a SEGC7 prefix, but not GETFIELD_RAW.

  • Participants
  • Parent commits c851d68
  • Branches stmgc-c7

Comments (0)

Files changed (5)

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

         descrs = self.gc_ll_descr.getframedescrs(self.cpu)
         if self.gc_ll_descr.kind == 'boehm':
             size_box = history.BoxInt()
-            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
+            op0 = ResOperation(rop.GETFIELD_RAW,[history.ConstInt(frame_info)],
                                size_box,
                                descr=descrs.jfi_frame_depth)
             self.newops.append(op0)
         elif not self.gc_ll_descr.stm:
             # we read size in bytes here, not the length
             size_box = history.BoxInt()
-            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
+            op0 = ResOperation(rop.GETFIELD_RAW,[history.ConstInt(frame_info)],
                                size_box,
                                descr=descrs.jfi_frame_size)
             self.newops.append(op0)
             self.gen_malloc_nursery_varsize_frame(size_box, frame)
             self.gen_initialize_tid(frame, descrs.arraydescr.tid)
             length_box = history.BoxInt()
-            op1 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
+            op1 = ResOperation(rop.GETFIELD_RAW,[history.ConstInt(frame_info)],
                                length_box,
                                descr=descrs.jfi_frame_depth)
             self.newops.append(op1)
         else:
             # jfi_frame_size not set in STM!
             length_box = history.BoxInt()
-            op0 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
+            op0 = ResOperation(rop.GETFIELD_RAW,[history.ConstInt(frame_info)],
                                length_box,
                                descr=descrs.jfi_frame_depth)
             self.newops.append(op0)
         val = op.getarg(0)
         if self.must_apply_write_barrier(val, op.getarg(1)):
             self.gen_write_barrier(val)
-            #op = op.copy_and_change(rop.SETFIELD_RAW)
         self.newops.append(op)
 
     def handle_write_barrier_setinteriorfield(self, op):
         val = op.getarg(0)
         if self.must_apply_write_barrier(val, op.getarg(2)):
             self.gen_write_barrier(val)
-            #op = op.copy_and_change(rop.SETINTERIORFIELD_RAW)
         self.newops.append(op)
 
     def handle_write_barrier_setarrayitem(self, op):
         val = op.getarg(0)
         if self.must_apply_write_barrier(val, op.getarg(2)):
             self.gen_write_barrier_array(val, op.getarg(1))
-            #op = op.copy_and_change(rop.SETARRAYITEM_RAW)
         self.newops.append(op)
 
     def gen_write_barrier(self, v_base):

File rpython/jit/backend/llsupport/test/test_rewrite.py

         i2 = call_assembler(i0, f0, descr=casmdescr)
         """, """
         [i0, f0]
-        i1 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_size)
+        i1 = getfield_raw(ConstClass(frame_info), descr=jfi_frame_size)
         p1 = call_malloc_nursery_varsize_frame(i1)
         setfield_gc(p1, 0, descr=tiddescr)
-        i2 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_depth)
+        i2 = getfield_raw(ConstClass(frame_info), descr=jfi_frame_depth)
         setfield_gc(p1, i2, descr=framelendescr)
         setfield_gc(p1, ConstClass(frame_info), descr=jf_frame_info)
         setarrayitem_gc(p1, 0, i0, descr=signedframedescr)

File rpython/jit/backend/llsupport/test/test_stmrewrite.py

         guard_not_forced()[] 
         """, """
         [i0, f0]
-        i1 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_depth)
+        i1 = getfield_raw(ConstClass(frame_info), descr=jfi_frame_depth)
         p1 = call_malloc_nursery_varsize_frame(i1)
         setfield_gc(p1, 0, descr=tiddescr)
         setfield_gc(p1, i1, descr=framelendescr)

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

 
     # ----------
 
-    def load_from_mem(self, resloc, source_addr, size_loc, sign_loc):
+    def load_from_mem(self, resloc, source_addr, size_loc, sign_loc, op):
         assert isinstance(resloc, RegLoc)
         size = size_loc.value
         sign = sign_loc.value
+        self.mc.SEGC7_if_gc(op)
         if resloc.is_xmm:
             self.mc.MOVSD(resloc, source_addr)
         elif size == WORD:
 
     def save_into_mem(self, dest_addr, value_loc, size_loc):
         size = size_loc.value
+        self.mc.SEGC7_if_gc(op)
         if isinstance(value_loc, RegLoc) and value_loc.is_xmm:
             self.mc.MOVSD(dest_addr, value_loc)
         elif size == 1:
             else:
                 assert isinstance(value_loc, FloatImmedLoc)
                 self.mc.MOV(dest_addr, value_loc.low_part_loc())
+                self.mc.SEGC7_if_gc(op)
                 self.mc.MOV(dest_addr.add_offset(4), value_loc.high_part_loc())
         else:
             not_implemented("save_into_mem size = %d" % size)
         base_loc, ofs_loc, size_loc, sign_loc = arglocs
         assert isinstance(size_loc, ImmedLoc)
         source_addr = AddressLoc(base_loc, ofs_loc)
-        self.load_from_mem(resloc, source_addr, size_loc, sign_loc)
+        self.load_from_mem(resloc, source_addr, size_loc, sign_loc, op)
 
     genop_getfield_raw = genop_getfield_gc
     genop_getfield_raw_pure = genop_getfield_gc
         assert isinstance(size_loc, ImmedLoc)
         scale = get_scale(size_loc.value)
         src_addr = addr_add(base_loc, ofs_loc, ofs.value, scale)
-        self.load_from_mem(resloc, src_addr, size_loc, sign_loc)
+        self.load_from_mem(resloc, src_addr, size_loc, sign_loc, op)
 
     genop_getarrayitem_gc_pure = genop_getarrayitem_gc
     genop_getarrayitem_raw = genop_getarrayitem_gc
         base_loc, ofs_loc, size_loc, ofs, sign_loc = arglocs
         assert isinstance(ofs, ImmedLoc)
         src_addr = addr_add(base_loc, ofs_loc, ofs.value, 0)
-        self.load_from_mem(resloc, src_addr, size_loc, sign_loc)
+        self.load_from_mem(resloc, src_addr, size_loc, sign_loc, op)
 
     def _imul_const_scaled(self, mc, targetreg, sourcereg, itemsize):
         """Produce one operation to do roughly
         src_addr = self._get_interiorfield_addr(temp_loc, index_loc,
                                                 itemsize_loc, base_loc,
                                                 ofs_loc)
-        self.load_from_mem(resloc, src_addr, fieldsize_loc, sign_loc)
+        self.load_from_mem(resloc, src_addr, fieldsize_loc, sign_loc, op)
 
     def genop_discard_increment_debug_counter(self, op, arglocs):
         # The argument should be an immediate address.  This should
         base_loc, ofs_loc, size_loc, value_loc = arglocs
         assert isinstance(size_loc, ImmedLoc)
         dest_addr = AddressLoc(base_loc, ofs_loc)
-        self.save_into_mem(dest_addr, value_loc, size_loc)
+        self.save_into_mem(dest_addr, value_loc, size_loc, op)
 
     def genop_discard_setinteriorfield_gc(self, op, arglocs):
         (base_loc, ofs_loc, itemsize_loc, fieldsize_loc,
         dest_addr = self._get_interiorfield_addr(temp_loc, index_loc,
                                                  itemsize_loc, base_loc,
                                                  ofs_loc)
-        self.save_into_mem(dest_addr, value_loc, fieldsize_loc)
+        self.save_into_mem(dest_addr, value_loc, fieldsize_loc, op)
 
     genop_discard_setinteriorfield_raw = genop_discard_setinteriorfield_gc
 
         assert isinstance(size_loc, ImmedLoc)
         scale = get_scale(size_loc.value)
         dest_addr = AddressLoc(base_loc, ofs_loc, scale, baseofs.value)
-        self.save_into_mem(dest_addr, value_loc, size_loc)
+        self.save_into_mem(dest_addr, value_loc, size_loc, op)
 
     def genop_discard_raw_store(self, op, arglocs):
         base_loc, ofs_loc, value_loc, size_loc, baseofs = arglocs
         assert isinstance(baseofs, ImmedLoc)
         dest_addr = AddressLoc(base_loc, ofs_loc, 0, baseofs.value)
-        self.save_into_mem(dest_addr, value_loc, size_loc)
+        self.save_into_mem(dest_addr, value_loc, size_loc, op)
 
     def genop_discard_strsetitem(self, op, arglocs):
         base_loc, ofs_loc, val_loc = arglocs
                 size = WORD * 2
             else:
                 size = WORD
-            self.save_into_mem(raw_stack(base_ofs), return_val, imm(size))
+            self.save_into_mem(raw_stack(base_ofs), return_val, imm(size), op)
         else:
             [fail_descr_loc] = arglocs
         ofs = self.cpu.get_ofs_of_frame_field('jf_descr')

File rpython/jit/backend/x86/codebuf.py

         if self.stm and we_are_translated():
             from rpython.jit.backend.x86 import stmtlocal
             stmtlocal.c7_segment_prefix(self)
+
+    def SEGC7_if_gc(self, op):
+        if self.stm and we_are_translated():
+            from rpython.jit.backend.x86 import stmtlocal
+            from rpython.jit.metainterp.resoperation import rop
+            #
+            opnum = op.getopnum()
+            if opnum in (rop.GETFIELD_GC,
+                         rop.GETFIELD_GC_PURE,
+                         rop.GETARRAYITEM_GC,
+                         rop.GETARRAYITEM_GC_PURE,
+                         rop.GETINTERIORFIELD_GC,
+                         rop.SETFIELD_GC,
+                         rop.SETARRAYITEM_GC,
+                         rop.SETINTERIORFIELD_GC,
+                         ):
+                stmtlocal.c7_segment_prefix(self)