Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct
Changeset: r80784:d8b23469f91f
Date: 2015-11-20 00:36 +0100
http://bitbucket.org/pypy/pypy/changeset/d8b23469f91f/
Log: reverse the logic to distinguish virtual arrays and strings, and
most importantly remove the weird ConstPtrInfo.is_array()==True
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
@@ -536,13 +536,12 @@
def optimize_GETARRAYITEM_GC_I(self, op):
# When using str_storage_getitem we op.getarg(0) is a string, NOT an
- # array. That's why we need to check for .is_array() before
- # remembering the reads. There is no point in remembering it, as the
- # box will be forced anyway by the optimizer
+ # array. In that case, we cannot cache the getarrayitem as if it were
+ # an array, obviously
arrayinfo = self.ensure_ptr_info_arg0(op)
indexb = self.getintbound(op.getarg(1))
cf = None
- if indexb.is_constant() and arrayinfo.is_array():
+ if indexb.is_constant() and not arrayinfo.is_vstring():
index = indexb.getint()
arrayinfo.getlenbound(None).make_gt_const(index)
# use the cache on (arraydescr, index), which is a constant
@@ -559,7 +558,7 @@
self.make_nonnull(op.getarg(0))
self.emit_operation(op)
# the remember the result of reading the array item
- if cf is not None and arrayinfo.is_array():
+ if cf is not None and not arrayinfo.is_vstring():
arrayinfo.setitem(op.getdescr(), indexb.getint(),
self.get_box_replacement(op.getarg(0)),
self.get_box_replacement(op), cf,
diff --git a/rpython/jit/metainterp/optimizeopt/info.py
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -24,6 +24,9 @@
def is_virtual(self):
return False
+ def is_vstring(self):
+ return False
+
def is_precise(self):
return False
@@ -49,9 +52,6 @@
def is_null(self):
return False
- def is_array(self):
- return False
-
def force_at_the_end_of_preamble(self, op, optforce, rec):
if not self.is_virtual():
return optforce.get_box_replacement(op)
@@ -481,9 +481,6 @@
self.lenbound = intutils.ConstIntBound(size)
self._clear = clear
- def is_array(self):
- return True
-
def getlenbound(self, mode):
from rpython.jit.metainterp.optimizeopt import intutils
@@ -722,9 +719,6 @@
def is_virtual(self):
return False
- def is_array(self):
- return True
-
def get_known_class(self, cpu):
if not self._const.nonnull():
return None
diff --git a/rpython/jit/metainterp/optimizeopt/virtualize.py
b/rpython/jit/metainterp/optimizeopt/virtualize.py
--- a/rpython/jit/metainterp/optimizeopt/virtualize.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualize.py
@@ -272,10 +272,9 @@
def optimize_GETARRAYITEM_GC_I(self, op):
# When using str_storage_getitem we op.getarg(0) is a string, NOT an
- # array, hence the check for is_array(). If it's a virtual but not an
- # array (i.e., if it's a string) it will be forced.
+ # array, hence the check. In that case, it will be forced
opinfo = self.getptrinfo(op.getarg(0))
- if opinfo and opinfo.is_virtual() and opinfo.is_array():
+ if opinfo and opinfo.is_virtual() and not opinfo.is_vstring():
indexbox = self.get_constant_box(op.getarg(1))
if indexbox is not None:
item = opinfo.getitem(op.getdescr(), indexbox.getint())
diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py
b/rpython/jit/metainterp/optimizeopt/vstring.py
--- a/rpython/jit/metainterp/optimizeopt/vstring.py
+++ b/rpython/jit/metainterp/optimizeopt/vstring.py
@@ -62,6 +62,9 @@
self.mode = mode
self.length = length
+ def is_vstring(self):
+ return True
+
def getlenbound(self, mode):
from rpython.jit.metainterp.optimizeopt import intutils
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit