[pypy-svn] r79279 - pypy/branch/arm-backend/pypy/jit/backend/arm

david at codespeak.net david at codespeak.net
Fri Nov 19 17:04:10 CET 2010


Author: david
Date: Fri Nov 19 17:04:08 2010
New Revision: 79279

Modified:
   pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py
   pypy/branch/arm-backend/pypy/jit/backend/arm/opassembler.py
   pypy/branch/arm-backend/pypy/jit/backend/arm/runner.py
Log:
Merge int_mul_ovf and guard_(no_)overflow operations and remove the hack used in that case before

Modified: pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py
==============================================================================
--- pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py	(original)
+++ pypy/branch/arm-backend/pypy/jit/backend/arm/assembler.py	Fri Nov 19 17:04:08 2010
@@ -165,6 +165,7 @@
         location:
         \xFC = stack location
         \xFD = imm location
+        emtpy = reg location
         \xFE = Empty arg
         """
 
@@ -173,7 +174,7 @@
         reg = regalloc.force_allocate_reg(box)
         # XXX free this memory
         # XXX allocate correct amount of memory
-        mem = lltype.malloc(rffi.CArray(lltype.Char), (len(args)+5)*4, flavor='raw')
+        mem = lltype.malloc(rffi.CArray(lltype.Char), len(args)*6+9, flavor='raw')
         # Note, the actual frame depth is one less than the value stored in
         # regalloc.frame_manager.frame_depth
         self.encode32(mem, 0, regalloc.frame_manager.frame_depth - 1)
@@ -378,6 +379,10 @@
         if op.getopnum() == rop.CALL_MAY_FORCE or op.getopnum() == rop.CALL_ASSEMBLER:
             assert operations[i + 1].getopnum() == rop.GUARD_NOT_FORCED
             return True
+        if op.getopnum() == rop.INT_MUL_OVF:
+            opnum = operations[i + 1].getopnum()
+            assert opnum  == rop.GUARD_OVERFLOW or opnum == rop.GUARD_NO_OVERFLOW
+            return True
         return False
 
     def assemble_bridge(self, faildescr, inputargs, operations):

Modified: pypy/branch/arm-backend/pypy/jit/backend/arm/opassembler.py
==============================================================================
--- pypy/branch/arm-backend/pypy/jit/backend/arm/opassembler.py	(original)
+++ pypy/branch/arm-backend/pypy/jit/backend/arm/opassembler.py	Fri Nov 19 17:04:08 2010
@@ -92,7 +92,8 @@
         return fcond
 
     #ref: http://blogs.arm.com/software-enablement/detecting-overflow-from-mul/
-    def emit_op_int_mul_ovf(self, op, regalloc, fcond):
+    f = False
+    def emit_guard_int_mul_ovf(self, op, guard, regalloc, fcond):
         a0 = op.getarg(0)
         a1 = op.getarg(1)
         reg1 = regalloc.make_sure_var_in_reg(a0, imm_fine=False)
@@ -101,7 +102,10 @@
         self.mc.SMULL(res.value, r.ip.value, reg1.value, reg2.value, cond=fcond)
         self.mc.CMP_rr(r.ip.value, res.value, shifttype=shift.ASR, imm=31, cond=fcond)
         regalloc.possibly_free_vars_for_op(op)
-        return 0xF # XXX Remove: hack to show that the prev operation was  a mul_ovf
+        if guard.getopnum() == rop.GUARD_OVERFLOW:
+            return self._emit_guard(guard, regalloc, c.EQ)
+        else:
+            return self._emit_guard(guard, regalloc, c.NE)
 
     emit_op_int_floordiv = gen_emit_op_by_helper_call('DIV')
     emit_op_int_mod = gen_emit_op_by_helper_call('MOD')
@@ -165,6 +169,8 @@
     def _emit_guard(self, op, regalloc, fcond):
         descr = op.getdescr()
         assert isinstance(descr, BasicFailDescr)
+        if hasattr(op, 'getfailargs'):
+            print 'Failargs: ', op.getfailargs()
         descr._arm_guard_code = self.mc.curraddr()
         memaddr = self._gen_path_to_exit_path(op, op.getfailargs(), regalloc, fcond)
         descr._failure_recovery_code = memaddr
@@ -181,7 +187,6 @@
         return self._emit_guard(op, regalloc, c.EQ)
 
     def emit_op_guard_false(self, op, regalloc, fcond):
-        print 'Failargs: ', op.getfailargs()
         a0 = op.getarg(0)
         l0 = regalloc.make_sure_var_in_reg(a0, imm_fine=False)
         self.mc.CMP_ri(l0.value, 0)
@@ -204,13 +209,9 @@
     emit_op_guard_isnull = emit_op_guard_false
 
     def emit_op_guard_no_overflow(self, op, regalloc, fcond):
-        if fcond == 0xF: # XXX: hack to check if the prev op was a mul_ovf
-            return self._emit_guard(op, regalloc, c.NE)
         return self._emit_guard(op, regalloc, c.VS)
 
     def emit_op_guard_overflow(self, op, regalloc, fcond):
-        if fcond == 0xF: # XXX: hack to check if the prev op was a mul_ovf
-            return self._emit_guard(op, regalloc, c.EQ)
         return self._emit_guard(op, regalloc, c.VC)
 
 class OpAssembler(object):

Modified: pypy/branch/arm-backend/pypy/jit/backend/arm/runner.py
==============================================================================
--- pypy/branch/arm-backend/pypy/jit/backend/arm/runner.py	(original)
+++ pypy/branch/arm-backend/pypy/jit/backend/arm/runner.py	Fri Nov 19 17:04:08 2010
@@ -41,6 +41,8 @@
         pass
 
     def execute_token(self, executable_token):
+        i = [self.get_latest_value_int(x) for x in range(10)]
+        print 'Inputargs: ', i
         addr = executable_token._arm_bootstrap_code
         assert addr % 8 == 0
         func = rffi.cast(lltype.Ptr(self.BOOTSTRAP_TP), addr)



More information about the Pypy-commit mailing list