Commits

Maciej Fijalkowski committed ef194d2

uh, fix the bug

Comments (0)

Files changed (3)

 
 * 32bit x86
 * ARM
-* shadowstack + asmgcc
+* shadowstack + asmgcc (shadowstack needs reloading of ebp after frame
+  got potentially moved, which is after each potentially collecting call
+  or slowpath malloc)
 * kill jit2gc on translator
 * fix test_singlefloats in test_calling_conventions

rpython/jit/backend/llsupport/rewrite.py

 from rpython.rlib.rarithmetic import ovfcheck
+from rpython.rlib import rgc
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.jit.metainterp import history
 from rpython.jit.metainterp.history import ConstInt, BoxPtr, ConstPtr
         lgt_box = history.BoxInt()
         frame = history.BoxPtr()
         jfi = loop_token.compiled_loop_token.frame_info
+        rgc._make_sure_does_not_move(jfi)
         llref = lltype.cast_opaque_ptr(llmemory.GCREF, jfi)
         op0 = ResOperation(rop.GETFIELD_GC, [history.ConstPtr(llref)], lgt_box,
                            descr=descrs.jfi_frame_depth)
         op2 = ResOperation(rop.SETFIELD_GC, [frame, history.ConstPtr(llref)],
                            None, descr=descrs.jf_frame_info)
         self.newops.append(op2)
+        llref = lltype.cast_opaque_ptr(llmemory.GCREF, jfi.jfi_gcmap)
+        op3 = ResOperation(rop.SETFIELD_GC, [frame, history.ConstPtr(llref)],
+                           None, descr=descrs.jf_gcmap)
+        self.newops.append(op3)
         for i, arg in enumerate(op.getarglist()):
             index, descr = self.cpu.getarraydescr_for_frame(arg.type, i)
             self.newops.append(ResOperation(rop.SETARRAYITEM_GC,

rpython/jit/backend/x86/assembler.py

                                              operations,
                                              self.current_clt.allgcrefs,
                                              self.current_clt.frame_info)
-        stack_check_patch_ofs = self._check_frame_depth()
+        stack_check_patch_ofs = self._check_frame_depth(self.mc)
         frame_depth = self._assemble(regalloc, inputargs, operations)
         codeendpos = self.mc.get_relative_pos()
         self.write_pending_failure_recoveries()
                 mc.writeimm32(self.error_trampoline_64 - pos_after_jz)
                 mc.copy_to_raw_memory(rawstart + pos_after_jz - 4)
 
-    def _check_frame_depth(self):
+    def _check_frame_depth(self, mc):
         """ check if the frame is of enough depth to follow this bridge.
         Otherwise reallocate the frame in a helper.
         There are other potential solutions
         descrs = self.cpu.gc_ll_descr.getframedescrs(self.cpu)
         ofs = self.cpu.unpack_fielddescr(descrs.arraydescr.lendescr)
         base_ofs = self.cpu.get_baseofs_of_frame_field()
-        self.mc.CMP_bi(ofs - base_ofs, 0xffffff)
-        stack_check_cmp_ofs = self.mc.get_relative_pos() - 4
+        mc.CMP_bi(ofs - base_ofs, 0xffffff)
+        stack_check_cmp_ofs = mc.get_relative_pos() - 4
         assert not IS_X86_32
-        self.mc.J_il8(rx86.Conditions['GE'], 0)
-        jg_location = self.mc.get_relative_pos()
-        self.mc.CALL(imm(self._stack_check_failure))
+        mc.J_il8(rx86.Conditions['GE'], 0)
+        jg_location = mc.get_relative_pos()
+        mc.CALL(imm(self._stack_check_failure))
         # patch the JG above
-        offset = self.mc.get_relative_pos() - jg_location
+        offset = mc.get_relative_pos() - jg_location
         assert 0 < offset <= 127
-        self.mc.overwrite(jg_location-1, chr(offset))
+        mc.overwrite(jg_location-1, chr(offset))
         return stack_check_cmp_ofs
 
     def _insert_frame_adjustment(self, frame_info):
         # Ideally we should rather patch all existing CALLs, but well.
         oldadr = oldlooptoken._x86_function_addr
         target = newlooptoken._x86_function_addr
+        # copy frame-info data
+        old_fi = oldlooptoken.compiled_loop_token.frame_info
+        new_fi = newlooptoken.compiled_loop_token.frame_info
+        old_fi.jfi_frame_depth = new_fi.jfi_frame_depth
+        old_fi.jfi_gcmap = new_fi.jfi_gcmap
         mc = codebuf.MachineCodeBlockWrapper()
         mc.JMP(imm(target))
         if WORD == 4:         # keep in sync with prepare_loop()
         if WORD == 4:
             mc.PUSH(imm(fail_descr))
             mc.PUSH(imm(gcpattern))
-            mc.JMP(imm(target))
+            mc.CALL(imm(target))
         else:
             mc.MOV_ri64(X86_64_SCRATCH_REG.value, target)
             mc.PUSH(imm(fail_descr))
             mc.PUSH(imm(gcpattern))
-            mc.JMP_r(X86_64_SCRATCH_REG.value)
+            self.mc.JMP_r(X86_64_SCRATCH_REG.value)
         return startpos
 
     def rebuild_faillocs_from_descr(self, descr, inputargs):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.