[pypy-commit] pypy remove-getarrayitem-pure: Start removing getarrayitem_gc_pure ops
sbauman
pypy.commits at gmail.com
Sat Apr 2 16:11:23 EDT 2016
Author: Spenser Bauman <sabauma at gmail.com>
Branch: remove-getarrayitem-pure
Changeset: r83510:84f6ca586b1c
Date: 2016-04-02 14:59 -0400
http://bitbucket.org/pypy/pypy/changeset/84f6ca586b1c/
Log: Start removing getarrayitem_gc_pure ops
diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py
--- a/rpython/jit/backend/llsupport/descr.py
+++ b/rpython/jit/backend/llsupport/descr.py
@@ -360,7 +360,7 @@
else:
lendescr = get_field_arraylen_descr(gccache, ARRAY_OR_STRUCT)
flag = get_type_flag(ARRAY_INSIDE.OF)
- is_pure = bool(ARRAY_INSIDE._immutable_field(None))
+ is_pure = ARRAY_INSIDE._immutable_field(None) != False
arraydescr = ArrayDescr(basesize, itemsize, lendescr, flag, is_pure)
if ARRAY_INSIDE.OF is lltype.SingleFloat or \
ARRAY_INSIDE.OF is lltype.Float:
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
@@ -475,19 +475,50 @@
@arguments("box", "box", "descr")
def opimpl_getarrayitem_gc_i(self, arraybox, indexbox, arraydescr):
+ if (arraydescr.is_always_pure() and
+ isinstance(arraybox, ConstPtr) and
+ isinstance(indexbox, ConstInt)):
+ # if the arguments are directly constants, bypass the heapcache
+ # completely
+ val = executor.execute(self.metainterp.cpu, self.metainterp,
+ rop.GETARRAYITEM_GC_I, arraydescr,
+ arraybox, indexbox)
+ return executor.wrap_constant(val)
return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_I, arraybox,
indexbox, arraydescr)
@arguments("box", "box", "descr")
def opimpl_getarrayitem_gc_r(self, arraybox, indexbox, arraydescr):
+ if (arraydescr.is_always_pure() and
+ isinstance(arraybox, ConstPtr) and
+ isinstance(indexbox, ConstInt)):
+ # if the arguments are directly constants, bypass the heapcache
+ # completely
+ val = executor.execute(self.metainterp.cpu, self.metainterp,
+ rop.GETARRAYITEM_GC_R, arraydescr,
+ arraybox, indexbox)
+ return executor.wrap_constant(val)
return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_R, arraybox,
indexbox, arraydescr)
@arguments("box", "box", "descr")
def opimpl_getarrayitem_gc_f(self, arraybox, indexbox, arraydescr):
+ if (arraydescr.is_always_pure() and
+ isinstance(arraybox, ConstPtr) and
+ isinstance(indexbox, ConstInt)):
+ # if the arguments are directly constants, bypass the heapcache
+ # completely
+ val = executor.execute(self.metainterp.cpu, self.metainterp,
+ rop.GETARRAYITEM_GC_F, arraydescr,
+ arraybox, indexbox)
+ return executor.wrap_constant(val)
return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_F, arraybox,
indexbox, arraydescr)
+ opimpl_getarrayitem_gc_i_pure = opimpl_getarrayitem_gc_i
+ opimpl_getarrayitem_gc_r_pure = opimpl_getarrayitem_gc_r
+ opimpl_getarrayitem_gc_f_pure = opimpl_getarrayitem_gc_f
+
@arguments("box", "box", "descr")
def opimpl_getarrayitem_raw_i(self, arraybox, indexbox, arraydescr):
return self.execute_with_descr(rop.GETARRAYITEM_RAW_I,
@@ -498,42 +529,6 @@
return self.execute_with_descr(rop.GETARRAYITEM_RAW_F,
arraydescr, arraybox, indexbox)
- @arguments("box", "box", "descr")
- def opimpl_getarrayitem_gc_i_pure(self, arraybox, indexbox, arraydescr):
- if isinstance(arraybox, ConstPtr) and isinstance(indexbox, ConstInt):
- # if the arguments are directly constants, bypass the heapcache
- # completely
- val = executor.execute(self.metainterp.cpu, self.metainterp,
- rop.GETARRAYITEM_GC_PURE_I, arraydescr,
- arraybox, indexbox)
- return executor.wrap_constant(val)
- return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_PURE_I,
- arraybox, indexbox, arraydescr)
-
- @arguments("box", "box", "descr")
- def opimpl_getarrayitem_gc_f_pure(self, arraybox, indexbox, arraydescr):
- if isinstance(arraybox, ConstPtr) and isinstance(indexbox, ConstInt):
- # if the arguments are directly constants, bypass the heapcache
- # completely
- resval = executor.execute(self.metainterp.cpu, self.metainterp,
- rop.GETARRAYITEM_GC_PURE_F, arraydescr,
- arraybox, indexbox)
- return executor.wrap_constant(resval)
- return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_PURE_F,
- arraybox, indexbox, arraydescr)
-
- @arguments("box", "box", "descr")
- def opimpl_getarrayitem_gc_r_pure(self, arraybox, indexbox, arraydescr):
- if isinstance(arraybox, ConstPtr) and isinstance(indexbox, ConstInt):
- # if the arguments are directly constants, bypass the heapcache
- # completely
- val = executor.execute(self.metainterp.cpu, self.metainterp,
- rop.GETARRAYITEM_GC_PURE_R, arraydescr,
- arraybox, indexbox)
- return executor.wrap_constant(val)
- return self._do_getarrayitem_gc_any(rop.GETARRAYITEM_GC_PURE_R,
- arraybox, indexbox, arraydescr)
-
@arguments("box", "box", "box", "descr")
def _opimpl_setarrayitem_gc_any(self, arraybox, indexbox, itembox,
arraydescr):
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
@@ -1052,7 +1052,7 @@
'ARRAYLEN_GC/1d/i',
'STRLEN/1/i',
'STRGETITEM/2/i',
- 'GETARRAYITEM_GC_PURE/2d/rfi',
+ # 'GETARRAYITEM_GC_PURE/2d/rfi',
'UNICODELEN/1/i',
'UNICODEGETITEM/2/i',
#
@@ -1356,6 +1356,10 @@
opnum == rop.GETFIELD_GC_I or
opnum == rop.GETFIELD_GC_R or
opnum == rop.GETFIELD_GC_F or
+ opnum == rop.GETARRAYITEM_GC_I or
+ opnum == rop.GETARRAYITEM_GC_R or
+ opnum == rop.GETARRAYITEM_GC_F or
+ opnum == rop.ARRAYLEN_GC or
opnum == rop.GETARRAYITEM_RAW_I or
opnum == rop.GETARRAYITEM_RAW_F):
return descr.is_always_pure()
More information about the pypy-commit
mailing list