Author: Maciej Fijalkowski <fij...@gmail.com> Branch: optresult-unroll Changeset: r79146:7d5e249ccc68 Date: 2015-08-23 10:04 +0200 http://bitbucket.org/pypy/pypy/changeset/7d5e249ccc68/
Log: clenaup input arguments and fix some tests 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 @@ -573,7 +573,7 @@ cf = None if indexb.is_constant(): index = indexb.getint() - arrayinfo.getlenbound().make_gt_const(index) + arrayinfo.getlenbound(None).make_gt_const(index) # use the cache on (arraydescr, index), which is a constant cf = self.arrayitem_cache(op.getdescr(), index) field = cf.getfield_from_cache(self, arrayinfo, op.getdescr()) @@ -602,7 +602,7 @@ cf = None if indexb.is_constant(): index = indexb.getint() - arrayinfo.getlenbound().make_gt_const(index) + arrayinfo.getlenbound(None).make_gt_const(index) # use the cache on (arraydescr, index), which is a constant cf = self.arrayitem_cache(op.getdescr(), index) fieldvalue = cf.getfield_from_cache(self, arrayinfo, op.getdescr()) @@ -631,7 +631,7 @@ if indexb.is_constant(): arrayinfo = self.ensure_ptr_info_arg0(op) # arraybound - arrayinfo.getlenbound().make_gt_const(indexb.getint()) + arrayinfo.getlenbound(None).make_gt_const(indexb.getint()) cf = self.arrayitem_cache(op.getdescr(), indexb.getint()) cf.do_setfield(self, op) else: 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 @@ -38,7 +38,7 @@ def get_known_class(self, cpu): return None - def getlenbound(self): + def getlenbound(self, mode): return None def getnullness(self): @@ -331,9 +331,10 @@ self.lenbound = intutils.ConstIntBound(size) self._clear = clear - def getlenbound(self): + def getlenbound(self, mode): from rpython.jit.metainterp.optimizeopt import intutils - + + assert mode is None if self.lenbound is None: assert self.length == -1 self.lenbound = intutils.IntLowerBound(0) @@ -518,9 +519,9 @@ info = self._get_array_info(optheap) return info.getitem(index) - def setitem(self, index, op, cf=None, optheap=None): + def setitem(self, index, struct, op, cf=None, optheap=None): info = self._get_array_info(optheap) - info.setitem(index, op, cf) + info.setitem(index, struct, op, cf) def setfield(self, descr, struct, op, optheap=None, cf=None): info = self._get_info(optheap) @@ -563,9 +564,13 @@ return self._unpack_str(mode) def getlenbound(self, mode): - from rpython.jit.metainterp.optimizeopt.intutils import ConstIntBound - - return ConstIntBound(self.getstrlen(None, None, mode).getint()) + from rpython.jit.metainterp.optimizeopt.intutils import ConstIntBound,\ + IntLowerBound + + if mode is None: + return IntLowerBound(0) + else: + return ConstIntBound(self.getstrlen(None, None, mode).getint()) def getstrlen(self, op, string_optimizer, mode, create_ops=True): from rpython.jit.metainterp.optimizeopt import vstring diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -411,7 +411,7 @@ def optimize_ARRAYLEN_GC(self, op): array = self.ensure_ptr_info_arg0(op) self.emit_operation(op) - self.optimizer.setintbound(op, array.getlenbound()) + self.optimizer.setintbound(op, array.getlenbound(None)) def optimize_STRLEN(self, op): self.emit_operation(op) diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py --- a/rpython/jit/metainterp/optimizeopt/unroll.py +++ b/rpython/jit/metainterp/optimizeopt/unroll.py @@ -219,9 +219,6 @@ def export_state(self, start_label, original_label_args, renamed_inputargs): end_args = [self.get_box_replacement(a) for a in original_label_args] virtual_state = self.get_virtual_state(end_args) - inparg_mapping = [(start_label.getarg(i), end_args[i]) - for i in range(len(end_args)) if - start_label.getarg(i) is not end_args[i]] infos = {} for arg in end_args: infos[arg] = self.optimizer.getinfo(arg) @@ -240,15 +237,16 @@ infos[op] = self.optimizer.getinfo(op) self.optimizer._clean_optimization_info(end_args) self.optimizer._clean_optimization_info(start_label.getarglist()) - return ExportedState(label_args, inparg_mapping, virtual_state, infos, + return ExportedState(label_args, end_args, virtual_state, infos, short_boxes, renamed_inputargs, short_inputargs) def import_state(self, targetop, exported_state): # the mapping between input args (from old label) and what we need # to actually emit. Update the info - assert len(exported_state.inputarg_mapping) == len(targetop.getarglist()) - for i, (s, target) in enumerate(exported_state.inputarg_mapping): + assert (len(exported_state.next_iteration_args) == + len(targetop.getarglist())) + for i, target in enumerate(exported_state.next_iteration_args): source = targetop.getarg(i) assert source is not target source.set_forwarded(target) @@ -296,9 +294,7 @@ class ExportedState(LoopInfo): """ Exported state consists of a few pieces of information: - * inputarg_mapping - a list of tuples with original inputarg box - as the first element and the second element being - what it maps to (potentially const) + * next_iteration_args - starting arguments for next iteration * exported_infos - a mapping from ops to infos, including inputargs * end_args - arguments that end up in the label leading to the next iteration @@ -309,11 +305,11 @@ * short_inputargs - the renamed inputargs for short preamble """ - def __init__(self, end_args, inputarg_mapping, virtual_state, + def __init__(self, end_args, next_iteration_args, virtual_state, exported_infos, short_boxes, renamed_inputargs, short_inputargs): self.end_args = end_args - self.inputarg_mapping = inputarg_mapping + self.next_iteration_args = next_iteration_args self.virtual_state = virtual_state self.exported_infos = exported_infos self.short_boxes = short_boxes diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -319,7 +319,8 @@ self.level = LEVEL_KNOWNCLASS elif info.is_nonnull(): self.level = LEVEL_NONNULL - self.lenbound = info.getlenbound() + # XXX strings? + self.lenbound = info.getlenbound(None) elif type == 'i': self.intbound = info diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py --- a/rpython/jit/metainterp/test/test_ajit.py +++ b/rpython/jit/metainterp/test/test_ajit.py @@ -914,7 +914,7 @@ return n res = self.meta_interp(f, [20, 1, 2]) assert res == 0 - self.check_resops(call=0) + self.check_resops(call_i=0, call_r=0) def test_abs(self): myjitdriver = JitDriver(greens = [], reds = ['i', 't']) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit