Author: Spenser Bauman <[email protected]>
Branch: remove-getfield-pure
Changeset: r81886:3a92e4541f68
Date: 2016-01-21 14:13 -0500
http://bitbucket.org/pypy/pypy/changeset/3a92e4541f68/
Log: Cleanup based on suggestions from fijal
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
@@ -5,7 +5,7 @@
ConstIntBound, MININT, MAXINT, IntUnbounded
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
from rpython.jit.metainterp.resoperation import rop, AbstractResOp,
GuardResOp,\
- OpHelpers, ResOperation, is_pure_getfield
+ OpHelpers, ResOperation
from rpython.jit.metainterp.optimizeopt import info
from rpython.jit.metainterp.typesystem import llhelper
from rpython.rlib.objectmodel import specialize, we_are_translated
@@ -756,7 +756,7 @@
opnum = op.getopnum()
cpu = self.cpu
- if is_pure_getfield(opnum, op.getdescr()):
+ if OpHelpers.is_pure_getfield(opnum, op.getdescr()):
fielddescr = op.getdescr()
ref = self.get_constant_box(op.getarg(0)).getref_base()
cpu.protect_speculative_field(ref, fielddescr)
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
@@ -2095,21 +2095,7 @@
profiler = self.staticdata.profiler
profiler.count_ops(opnum)
resvalue = executor.execute(self.cpu, self, opnum, descr, *argboxes)
- #
- is_pure = rop._ALWAYS_PURE_FIRST <= opnum <= rop._ALWAYS_PURE_LAST
- if not is_pure:
- # TODO Don't base purity of an operation solely on opnum
- if (opnum == rop.GETFIELD_RAW_I or
- opnum == rop.GETFIELD_RAW_R or
- opnum == rop.GETFIELD_RAW_F or
- opnum == rop.GETFIELD_GC_I or
- opnum == rop.GETFIELD_GC_R or
- opnum == rop.GETFIELD_GC_F or
- opnum == rop.GETARRAYITEM_RAW_I or
- opnum == rop.GETARRAYITEM_RAW_F):
- is_pure = descr.is_always_pure()
- #
- if is_pure:
+ if OpHelpers.is_pure_with_descr(opnum, descr):
return self._record_helper_pure(opnum, resvalue, descr, *argboxes)
if rop._OVF_FIRST <= opnum <= rop._OVF_LAST:
return self._record_helper_ovf(opnum, resvalue, descr, *argboxes)
diff --git a/rpython/jit/metainterp/resoperation.py
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -246,11 +246,6 @@
def forget_value(self):
pass
-def is_pure_getfield(opnum, descr):
- if opnum not in (rop.GETFIELD_GC_I, rop.GETFIELD_GC_F, rop.GETFIELD_GC_R):
- return False
- return descr is not None and descr.is_always_pure()
-
class AbstractResOp(AbstractResOpOrInputArg):
"""The central ResOperation class, representing one operation."""
@@ -1757,4 +1752,26 @@
opnum = rop.VEC_UNPACK_F
return VecOperationNew(opnum, args, datatype, bytesize, signed, count)
+ @staticmethod
+ def is_pure_getfield(opnum, descr):
+ if (opnum == rop.GETFIELD_GC_I or
+ opnum == rop.GETFIELD_GC_F or
+ opnum == rop.GETFIELD_GC_R):
+ return descr is not None and descr.is_always_pure()
+ return False
+ @staticmethod
+ def is_pure_with_descr(opnum, descr):
+ is_pure = rop._ALWAYS_PURE_FIRST <= opnum <= rop._ALWAYS_PURE_LAST
+ if not is_pure:
+ if (opnum == rop.GETFIELD_RAW_I or
+ opnum == rop.GETFIELD_RAW_R or
+ opnum == rop.GETFIELD_RAW_F or
+ opnum == rop.GETFIELD_GC_I or
+ opnum == rop.GETFIELD_GC_R or
+ opnum == rop.GETFIELD_GC_F or
+ opnum == rop.GETARRAYITEM_RAW_I or
+ opnum == rop.GETARRAYITEM_RAW_F):
+ is_pure = descr.is_always_pure()
+ return is_pure
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit