[pypy-commit] pypy default: Fix this skipped test by moving the logic from rewrite.py to pure.py,
arigo
noreply at buildbot.pypy.org
Wed Apr 30 21:13:11 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r71102:3f8b9a32c444
Date: 2014-04-30 21:12 +0200
http://bitbucket.org/pypy/pypy/changeset/3f8b9a32c444/
Log: Fix this skipped test by moving the logic from rewrite.py to
pure.py, which runs after vstring.py.
diff --git a/rpython/jit/metainterp/optimizeopt/pure.py b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -57,6 +57,28 @@
self.emit_operation(nextop)
def optimize_CALL_PURE(self, op):
+ # Step 1: check if all arguments are constant
+ arg_consts = []
+ for i in range(op.numargs()):
+ arg = op.getarg(i)
+ const = self.get_constant_box(arg)
+ if const is None:
+ break
+ arg_consts.append(const)
+ else:
+ # all constant arguments: check if we already know the result
+ try:
+ result = self.optimizer.call_pure_results[arg_consts]
+ except KeyError:
+ pass
+ else:
+ # this removes a CALL_PURE with all constant arguments.
+ self.make_constant(op.result, result)
+ self.last_emitted_operation = REMOVED
+ return
+
+ # Step 2: check if all arguments are the same as a previous
+ # CALL_PURE.
args = self.optimizer.make_args_key(op)
oldop = self.pure_operations.get(args, None)
if oldop is not None and oldop.getdescr() is op.getdescr():
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -515,30 +515,9 @@
return True # 0-length arraycopy
return False
- def optimize_CALL_PURE(self, op):
- arg_consts = []
- for i in range(op.numargs()):
- arg = op.getarg(i)
- const = self.get_constant_box(arg)
- if const is None:
- break
- arg_consts.append(const)
- else:
- # all constant arguments: check if we already know the result
- try:
- result = self.optimizer.call_pure_results[arg_consts]
- except KeyError:
- pass
- else:
- # this removes a CALL_PURE with all constant arguments.
- self.make_constant(op.result, result)
- self.last_emitted_operation = REMOVED
- return
- self.emit_operation(op)
-
def optimize_GUARD_NO_EXCEPTION(self, op):
if self.last_emitted_operation is REMOVED:
- # it was a CALL_PURE or a CALL_LOOPINVARIANT that was killed;
+ # it was a CALL_LOOPINVARIANT that was killed;
# so we also kill the following GUARD_NO_EXCEPTION
return
self.emit_operation(op)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -5164,7 +5164,6 @@
self.optimize_strunicode_loop(ops, expected)
def test_call_pure_vstring_const(self):
- py.test.skip("implement me")
ops = """
[]
p0 = newstr(3)
More information about the pypy-commit
mailing list