Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: regalloc-playground
Changeset: r92336:364d9e356958
Date: 2017-09-06 18:08 +0200
http://bitbucket.org/pypy/pypy/changeset/364d9e356958/

Log:    some cleanup in the call hinting implementation, a longer test with
        two calls

diff --git a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py 
b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
--- a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
+++ b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
@@ -71,19 +71,34 @@
         assert len(args) == 10
         return sum(args)
 
+    def fgcref(x):
+        return 17
+
+    def fppii(x, y, i, j):
+        return 19
+
     F1PTR = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed))
     F2PTR = lltype.Ptr(lltype.FuncType([lltype.Signed]*2, lltype.Signed))
     F10PTR = lltype.Ptr(lltype.FuncType([lltype.Signed]*10, lltype.Signed))
+    FGCREFPTR = lltype.Ptr(lltype.FuncType([llmemory.GCREF], lltype.Signed))
+    FPPIIPTR = lltype.Ptr(lltype.FuncType([llmemory.GCREF, llmemory.GCREF, 
lltype.Signed, lltype.Signed], lltype.Signed))
+
     f1ptr = llhelper(F1PTR, f1)
     f2ptr = llhelper(F2PTR, f2)
     f10ptr = llhelper(F10PTR, f10)
+    fgcrefptr = llhelper(FGCREFPTR, fgcref)
+    fppiiptr = llhelper(FPPIIPTR, fppii)
 
     f1_calldescr = cpu.calldescrof(F1PTR.TO, F1PTR.TO.ARGS, F1PTR.TO.RESULT,
                                    EffectInfo.MOST_GENERAL)
     f2_calldescr = cpu.calldescrof(F2PTR.TO, F2PTR.TO.ARGS, F2PTR.TO.RESULT,
                                    EffectInfo.MOST_GENERAL)
-    f10_calldescr= cpu.calldescrof(F10PTR.TO, F10PTR.TO.ARGS, F10PTR.TO.RESULT,
-                                   EffectInfo.MOST_GENERAL)
+    f10_calldescr = cpu.calldescrof(F10PTR.TO, F10PTR.TO.ARGS, 
F10PTR.TO.RESULT,
+                                    EffectInfo.MOST_GENERAL)
+    fgcref_calldescr = cpu.calldescrof(FGCREFPTR.TO, FGCREFPTR.TO.ARGS, 
FGCREFPTR.TO.RESULT,
+                                       EffectInfo.MOST_GENERAL)
+    fppii_calldescr = cpu.calldescrof(FPPIIPTR.TO, FPPIIPTR.TO.ARGS, 
FPPIIPTR.TO.RESULT,
+                                      EffectInfo.MOST_GENERAL)
 
     namespace = locals().copy()
 
diff --git a/rpython/jit/backend/x86/reghint.py 
b/rpython/jit/backend/x86/reghint.py
--- a/rpython/jit/backend/x86/reghint.py
+++ b/rpython/jit/backend/x86/reghint.py
@@ -101,11 +101,6 @@
     consider_call_malloc_nursery_varsize = consider_call_malloc_nursery
     consider_call_malloc_nursery_varsize_frame = consider_call_malloc_nursery
 
-
-    def _call(self, op, position, args, save_all_regs=False):
-        # XXX fish for correct argtypes
-        CallHints64(self.longevity).hint(position, args, [], save_all_regs)
-
     def _consider_call(self, op, position, guard_not_forced=False, 
first_arg_index=1):
         calldescr = op.getdescr()
         assert isinstance(calldescr, CallDescr)
@@ -117,8 +112,9 @@
             gc_level = 1
         else:
             gc_level = 0
-        self._call(op, position, op.getarglist()[first_arg_index:],
-                   save_all_regs=gc_level)
+        args = op.getarglist()[first_arg_index:]
+        argtypes = calldescr.get_arg_types()
+        CallHints64(self.longevity).hint(position, args, argtypes, gc_level)
 
     def _consider_real_call(self, op, position):
         effectinfo = op.getdescr().get_extra_info()
@@ -148,10 +144,7 @@
 
     ARGUMENTS_GPR = [edi, esi, edx, ecx, r8, r9]
     ARGUMENTS_XMM = [xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7]
-    _ALL_CALLEE_SAVE_GPR = [ebx, r12, r13, r14, r15]
 
-    next_arg_gpr = 0
-    next_arg_xmm = 0
 
     def __init__(self, longevity):
         self.longevity = longevity
@@ -177,27 +170,26 @@
         hinted_xmm = []
         hinted_gpr = []
         hinted_args = []
+        next_arg_gpr = 0
+        next_arg_xmm = 0
         for i in range(len(args)):
             arg = args[i]
-            if arg.type == "f":
-                tgt = self._unused_xmm()
-                if tgt is not None and not arg.is_constant() and arg not in 
hinted_args:
-                    self.longevity.fixed_register(position, tgt, arg)
-                    hinted_xmm.append(tgt)
-                    hinted_args.append(arg)
-            elif i < len(argtypes) and argtypes[i] == 'S':
-                # Singlefloat argument
-                tgt = self._unused_xmm()
-                if tgt is not None and not arg.is_constant() and arg not in 
hinted_args:
-                    self.longevity.fixed_register(position, tgt, arg)
-                    hinted_xmm.append(tgt)
-                    hinted_args.append(arg)
+            if arg.type == "f" or (i < len(argtypes) and argtypes[i] == 'S'):
+                if next_arg_xmm < len(self.ARGUMENTS_XMM):
+                    tgt = self.ARGUMENTS_XMM[next_arg_xmm]
+                    if not arg.is_constant() and arg not in hinted_args:
+                        self.longevity.fixed_register(position, tgt, arg)
+                        hinted_xmm.append(tgt)
+                        hinted_args.append(arg)
+                    next_arg_xmm += 1
             else:
-                tgt = self._unused_gpr()
-                if tgt is not None and not arg.is_constant() and arg not in 
hinted_args:
-                    self.longevity.fixed_register(position, tgt, arg)
-                    hinted_gpr.append(tgt)
-                    hinted_args.append(arg)
+                if next_arg_gpr < len(self.ARGUMENTS_GPR):
+                    tgt = self.ARGUMENTS_GPR[next_arg_gpr]
+                    if not arg.is_constant() and arg not in hinted_args:
+                        self.longevity.fixed_register(position, tgt, arg)
+                        hinted_gpr.append(tgt)
+                        hinted_args.append(arg)
+                    next_arg_gpr += 1
         # block all remaining registers that are not caller save
         # XXX the case save_all_regs == 1 (save callee-save regs + gc ptrs) is
         # no expressible atm
diff --git a/rpython/jit/backend/x86/test/test_regalloc.py 
b/rpython/jit/backend/x86/test/test_regalloc.py
--- a/rpython/jit/backend/x86/test/test_regalloc.py
+++ b/rpython/jit/backend/x86/test/test_regalloc.py
@@ -49,7 +49,7 @@
                 arglocs, resloc, frame_depth)
 
     def malloc_cond(self, nursery_free_adr, nursery_top_adr, size, gcmap):
-        self._log("malloc_cond", size) # always uses edx and ecx
+        self._log("malloc_cond", size, "ecx") # always uses edx and ecx
 
 
 class TestCheckRegistersExplicitly(test_regalloc_integration.BaseTestRegalloc):
@@ -259,3 +259,51 @@
         self.interpret(ops, [0], run=False)
         # 4 moves, three for args, one for result
         assert len(self.filter_log_moves()) == 4
+
+    def test_dict_lookup(self, monkeypatch):
+        monkeypatch.setattr(self.cpu.gc_ll_descr, "get_nursery_top_addr", 
lambda: 61)
+        monkeypatch.setattr(self.cpu.gc_ll_descr, "get_nursery_free_addr", 
lambda: 68)
+        # real trace for a dict lookup
+        ops = """
+        [i172, i182, i201, p209, p0, p219]
+        i184 = int_lt(i172, 0)
+        guard_false(i184) []
+        i185 = int_ge(i172, i182)
+        guard_false(i185) []
+        i187 = int_add(i172, 1)
+        i202 = uint_ge(i172, i201)
+        guard_false(i202) [i172]
+        i221 = int_xor(i172, 3430008)
+        i223 = int_mul(i221, 1000003)
+        i230 = call_i(ConstClass(fgcrefptr), p209, descr=fgcref_calldescr)
+        guard_no_exception() [p209, i230, i172]
+        i232 = int_eq(i230, -1)
+        i233 = int_sub(i230, i232)
+        i234 = int_xor(i223, i233)
+        i236 = int_mul(i234, 1082525)
+        i238 = int_add(i236, 97531)
+        i240 = int_eq(i238, -1)
+        i241 = int_sub(i238, i240)
+        p242 = force_token()
+        p244 = call_malloc_nursery(40)
+        gc_store(p244, 0, 83568, 8)
+        p249 = nursery_ptr_increment(p244, 24)
+        gc_store(p249, 0, 4656, 8)
+        gc_store(p249, 8, i172, 8)
+        #cond_call_gc_wb(p0)
+        gc_store(p0, 8, p242, 8)
+        i263 = call_may_force_i(ConstClass(fppiiptr), p219, p244, i241, 0, 
descr=fppii_calldescr)
+        guard_not_forced() [p0, p249, p244, i263, p219]
+        guard_no_exception() [p0, p249, p244, i263, p219]
+        i265 = int_lt(i263, 0)
+        guard_true(i265) [p0, p249, p244, i263, p219]
+        finish(i263)
+        """
+        self.interpret(ops, [0], run=False)
+        # the moves are:
+        # 5 arguments
+        # 1 result
+        # 1 because lifetime of i172 does not end at the int_xor
+        # 1 ptr to save before call
+        # 3 for argument shuffling
+        assert len(self.filter_log_moves()) == 11
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to