Author: Spenser Andrew Bauman <[email protected]>
Branch: remove-getfield-pure
Changeset: r81515:7d8cd001c720
Date: 2015-12-31 14:31 -0500
http://bitbucket.org/pypy/pypy/changeset/7d8cd001c720/
Log: More precise logic for constant folding
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -493,7 +493,7 @@
return pendingfields
def optimize_GETFIELD_GC_I(self, op):
- if op.is_always_pure() and self.get_constant_box(op.getarg(0)):
+ if op.is_always_pure() and self.get_constant_box(op.getarg(0)) is not
None:
resbox = self.optimizer.constant_fold(op)
self.optimizer.make_constant(op, resbox)
return
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -375,6 +375,7 @@
if (box.type == 'i' and box.get_forwarded() and
box.get_forwarded().is_constant()):
return ConstInt(box.get_forwarded().getint())
+ return None
#self.ensure_imported(value)
def get_newoperations(self):
diff --git a/rpython/jit/metainterp/pyjitpl.py
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -666,7 +666,7 @@
if fielddescr.is_always_pure() != False and isinstance(box, ConstPtr):
# if 'box' is directly a ConstPtr, bypass the heapcache completely
resvalue = executor.execute(self.metainterp.cpu, self.metainterp,
- rop.GETFIELD_GC_F, fielddescr, box)
+ rop.GETFIELD_GC_F, fielddescr, box)
return ConstFloat(resvalue)
return self._opimpl_getfield_gc_any_pureornot(
rop.GETFIELD_GC_F, box, fielddescr, 'f')
@@ -676,7 +676,7 @@
if fielddescr.is_always_pure() != False and isinstance(box, ConstPtr):
# if 'box' is directly a ConstPtr, bypass the heapcache completely
val = executor.execute(self.metainterp.cpu, self.metainterp,
- rop.GETFIELD_GC_R, fielddescr, box)
+ rop.GETFIELD_GC_R, fielddescr, box)
return ConstPtr(val)
return self._opimpl_getfield_gc_any_pureornot(
rop.GETFIELD_GC_R, box, fielddescr, 'r')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit