[pypy-svn] r78474 - pypy/trunk/pypy/jit/metainterp/optimizeopt

arigo at codespeak.net arigo at codespeak.net
Fri Oct 29 16:23:29 CEST 2010


Author: arigo
Date: Fri Oct 29 16:23:27 2010
New Revision: 78474

Modified:
   pypy/trunk/pypy/jit/metainterp/optimizeopt/rewrite.py
Log:
Simplify the logic and stick to the invariant
"getint() must *never* be called on a BoxInt, only on a ConstInt"


Modified: pypy/trunk/pypy/jit/metainterp/optimizeopt/rewrite.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/optimizeopt/rewrite.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/optimizeopt/rewrite.py	Fri Oct 29 16:23:27 2010
@@ -244,14 +244,11 @@
         self.optimizer.exception_might_have_happened = False
 
     def optimize_CALL_LOOPINVARIANT(self, op):
-        funcvalue = self.getvalue(op.getarg(0))
-        if not funcvalue.is_constant():
-            # XXX this code path is never executed in tests nor in production.
-            # in fact, it can't even happen since residual_call in codewriter
-            # expects a compile-time constant
-            self.emit_operation(op)
-            return
-        key = make_hashable_int(op.getarg(0).getint())
+        arg = op.getarg(0)
+        # 'arg' must be a Const, because residual_call in codewriter
+        # expects a compile-time constant
+        assert isinstance(arg, Const)
+        key = make_hashable_int(arg.getint())
         resvalue = self.optimizer.loop_invariant_results.get(key, None)
         if resvalue is not None:
             self.make_equal_to(op.result, resvalue)



More information about the Pypy-commit mailing list