[pypy-commit] pypy arm64: guard_not_invalidated

fijal pypy.commits at gmail.com
Tue Jun 25 07:13:30 EDT 2019


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: arm64
Changeset: r96852:caa3d6c5a7fe
Date: 2019-06-24 08:36 +0000
http://bitbucket.org/pypy/pypy/changeset/caa3d6c5a7fe/

Log:	guard_not_invalidated

diff --git a/rpython/jit/backend/aarch64/assembler.py b/rpython/jit/backend/aarch64/assembler.py
--- a/rpython/jit/backend/aarch64/assembler.py
+++ b/rpython/jit/backend/aarch64/assembler.py
@@ -710,7 +710,6 @@
                 mc.B_ofs_cond(relative_offset, c.get_opposite_of(tok.fcond))
                 mc.copy_to_raw_memory(guard_pos)
             else:
-                XX
                 clt.invalidate_positions.append((guard_pos, relative_offset))
 
     def fixup_target_tokens(self, rawstart):
@@ -895,8 +894,13 @@
             XXX
 
     def _mov_imm_to_loc(self, prev_loc, loc):
-        assert loc.is_core_reg()
-        self.mc.gen_load_int(loc.value, prev_loc.value)
+        if loc.is_core_reg():
+            self.mc.gen_load_int(loc.value, prev_loc.value)
+        elif loc.is_stack():
+            self.mc.gen_load_int(r.ip0.value, prev_loc.value)
+            self.mc.STR_ri(r.ip0.value, r.fp.value, loc.value)
+        else:
+            assert False
 
     def new_stack_loc(self, i, tp):
         base_ofs = self.cpu.get_baseofs_of_frame_field()
diff --git a/rpython/jit/backend/aarch64/opassembler.py b/rpython/jit/backend/aarch64/opassembler.py
--- a/rpython/jit/backend/aarch64/opassembler.py
+++ b/rpython/jit/backend/aarch64/opassembler.py
@@ -502,6 +502,8 @@
         self._emit_guard(guard_op, c.get_opposite_of(fcond), arglocs)
     emit_guard_op_guard_overflow = emit_guard_op_guard_false
 
+    def emit_op_guard_not_invalidated(self, op, arglocs):
+        self._emit_guard(op, 0, arglocs, True)
 
     def load_condition_into_cc(self, loc):
         if not loc.is_core_reg():
diff --git a/rpython/jit/backend/aarch64/regalloc.py b/rpython/jit/backend/aarch64/regalloc.py
--- a/rpython/jit/backend/aarch64/regalloc.py
+++ b/rpython/jit/backend/aarch64/regalloc.py
@@ -817,6 +817,9 @@
     prepare_op_guard_gc_type = prepare_op_guard_class
     prepare_op_guard_subclass = prepare_op_guard_class
 
+    def prepare_op_guard_not_invalidated(self, op):
+        return self._guard_impl(op)
+
     def prepare_op_guard_exception(self, op):
         boxes = op.getarglist()
         arg0 = ConstInt(rffi.cast(lltype.Signed, op.getarg(0).getint()))
diff --git a/rpython/jit/backend/aarch64/runner.py b/rpython/jit/backend/aarch64/runner.py
--- a/rpython/jit/backend/aarch64/runner.py
+++ b/rpython/jit/backend/aarch64/runner.py
@@ -4,6 +4,7 @@
 from rpython.jit.backend.aarch64 import registers as r
 from rpython.jit.backend.aarch64.regalloc import VFPRegisterManager
 from rpython.jit.backend.llsupport.llmodel import AbstractLLCPU
+from rpython.jit.backend.aarch64.codebuilder import InstrBuilder
 
 class CPU_ARM64(AbstractLLCPU):
     """ARM 64"""
@@ -40,6 +41,21 @@
     def redirect_call_assembler(self, oldlooptoken, newlooptoken):
         self.assembler.redirect_call_assembler(oldlooptoken, newlooptoken)
 
+    def invalidate_loop(self, looptoken):
+        """Activate all GUARD_NOT_INVALIDATED in the loop and its attached
+        bridges.  Before this call, all GUARD_NOT_INVALIDATED do nothing;
+        after this call, they all fail.  Note that afterwards, if one such
+        guard fails often enough, it has a bridge attached to it; it is
+        possible then to re-call invalidate_loop() on the same looptoken,
+        which must invalidate all newer GUARD_NOT_INVALIDATED, but not the
+        old one that already has a bridge attached to it."""
+        for jmp, tgt in looptoken.compiled_loop_token.invalidate_positions:
+            mc = InstrBuilder()
+            mc.B_ofs(tgt)
+            mc.copy_to_raw_memory(jmp)
+        # positions invalidated
+        looptoken.compiled_loop_token.invalidate_positions = []
+
     def cast_ptr_to_int(x):
         adr = llmemory.cast_ptr_to_adr(x)
         return CPU_ARM64.cast_adr_to_int(adr)


More information about the pypy-commit mailing list