Author: Antonio Cuni <anto.c...@gmail.com> Branch: faster-rstruct-2 Changeset: r91265:d5941a454db5 Date: 2017-05-12 16:02 +0200 http://bitbucket.org/pypy/pypy/changeset/d5941a454db5/
Log: shuffle the order of arguments of llop.gc_store_indexed to match the existing rop.GC_STORE_INDEXED diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -747,29 +747,29 @@ return llop.gc_load_indexed(longlong.FLOATSTORAGE, struct, index, scale, base_ofs) - def bh_gc_store_indexed_i(self, struct, index, scale, base_ofs, val, bytes, + def bh_gc_store_indexed_i(self, struct, index, val, scale, base_ofs, bytes, descr): T = self._get_int_type_from_size(bytes) val = lltype.cast_primitive(T, val) if descr.A.OF == lltype.SingleFloat: val = longlong.int2singlefloat(val) - llop.gc_store_indexed(lltype.Void, struct, index, scale, base_ofs, val) + llop.gc_store_indexed(lltype.Void, struct, index, val, scale, base_ofs) - def bh_gc_store_indexed_f(self, struct, index, scale, base_ofs, val, bytes, + def bh_gc_store_indexed_f(self, struct, index, val, scale, base_ofs, bytes, descr): if bytes != 8: raise Exception("gc_store_indexed_f is only for 'double'!") val = longlong.getrealfloat(val) - llop.gc_store_indexed(lltype.Void, struct, index, scale, base_ofs, val) + llop.gc_store_indexed(lltype.Void, struct, index, val, scale, base_ofs) - def bh_gc_store_indexed(self, struct, index, scale, base_ofs, val, bytes, + def bh_gc_store_indexed(self, struct, index, val, scale, base_ofs, bytes, descr): if descr.A.OF == lltype.Float: - self.bh_gc_store_indexed_f(struct, index, scale, base_ofs, - val, bytes, descr) + self.bh_gc_store_indexed_f(struct, index, val, scale, base_ofs, + bytes, descr) else: - self.bh_gc_store_indexed_i(struct, index, scale, base_ofs, - val, bytes, descr) + self.bh_gc_store_indexed_i(struct, index, val, scale, base_ofs, + bytes, descr) def bh_increment_debug_counter(self, addr): p = rffi.cast(rffi.CArrayPtr(lltype.Signed), addr) diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py --- a/rpython/jit/codewriter/jtransform.py +++ b/rpython/jit/codewriter/jtransform.py @@ -1132,19 +1132,18 @@ op.args[2], op.args[3], c_bytes], op.result) def rewrite_op_gc_store_indexed(self, op): - T = op.args[4].concretetype + T = op.args[2].concretetype kind = getkind(T)[0] assert kind != 'r' descr = self.cpu.arraydescrof(rffi.CArray(T)) - if (not isinstance(op.args[2], Constant) or - not isinstance(op.args[3], Constant)): + if (not isinstance(op.args[3], Constant) or + not isinstance(op.args[4], Constant)): raise NotImplementedError("gc_store_indexed: 'scale' and 'base_ofs'" " should be constants") - # xxx hard-code the size in bytes at translation time, which is - # probably fine and avoids lots of issues later + # According to the comment in resoperation.py, "itemsize is not signed + # (always > 0)", so we don't need the "bytes = -bytes" line which is + # in rewrite_op_gc_load_indexed bytes = descr.get_item_size_in_bytes() - if descr.is_item_signed(): - bytes = -bytes c_bytes = Constant(bytes, lltype.Signed) return SpaceOperation('gc_store_indexed_%s' % kind, [op.args[0], op.args[1], op.args[2], diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py --- a/rpython/jit/metainterp/blackhole.py +++ b/rpython/jit/metainterp/blackhole.py @@ -1479,11 +1479,11 @@ return cpu.bh_gc_load_indexed_f(addr, index,scale,base_ofs, bytes) @arguments("cpu", "r", "i", "i", "i", "i", "i") - def bhimpl_gc_store_indexed_i(cpu, addr, index, scale, base_ofs, val, bytes): - return cpu.bh_gc_store_indexed_i(addr, index,scale,base_ofs, val, bytes) - @arguments("cpu", "r", "i", "i", "i", "f", "i") - def bhimpl_gc_store_indexed_f(cpu, addr, index, scale, base_ofs, val, bytes): - return cpu.bh_gc_store_indexed_f(addr, index,scale,base_ofs, val, bytes) + def bhimpl_gc_store_indexed_i(cpu, addr, index, val, scale, base_ofs, bytes): + return cpu.bh_gc_store_indexed_i(addr, index, val, scale,base_ofs, bytes) + @arguments("cpu", "r", "i", "f", "i", "i", "i") + def bhimpl_gc_store_indexed_f(cpu, addr, index, val, scale, base_ofs, bytes): + return cpu.bh_gc_store_indexed_f(addr, index, val, scale,base_ofs, bytes) @arguments("r", "d", "d") def bhimpl_record_quasiimmut_field(struct, fielddescr, mutatefielddescr): diff --git a/rpython/jit/metainterp/executor.py b/rpython/jit/metainterp/executor.py --- a/rpython/jit/metainterp/executor.py +++ b/rpython/jit/metainterp/executor.py @@ -251,8 +251,8 @@ else: return BoxInt(cpu.bh_raw_load_i(addr, offset, arraydescr)) -def do_gc_store_indexed(cpu, _, addrbox, indexbox, scalebox, - base_ofsbox, valuebox, bytesbox, arraydescr): +def do_gc_store_indexed(cpu, _, addrbox, indexbox, valuebox, scalebox, + base_ofsbox, bytesbox, arraydescr): addr = addrbox.getref_base() index = indexbox.getint() scale = scalebox.getint() @@ -262,11 +262,11 @@ raise AssertionError("cannot store GC pointers in gc_store_indexed for now") elif arraydescr.is_array_of_floats(): floatval = valuebox.getfloat() - cpu.bh_gc_store_indexed_i(addr, index, scale, base_ofs, floatval, bytes, + cpu.bh_gc_store_indexed_i(addr, index, floatval, scale, base_ofs, bytes, arraydescr) else: intval = valuebox.getint() - cpu.bh_gc_store_indexed_i(addr, index, scale, base_ofs, intval, bytes, + cpu.bh_gc_store_indexed_i(addr, index, intval, scale, base_ofs, bytes, arraydescr) 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 @@ -828,16 +828,16 @@ self._remove_symbolics(baseofsbox), bytesbox) @arguments("box", "box", "box", "box", "box", "box", "descr") - def _opimpl_gc_store_indexed(self, addrbox, indexbox, - scalebox, baseofsbox, valuebox, bytesbox, + def _opimpl_gc_store_indexed(self, addrbox, indexbox, valuebox, + scalebox, baseofsbox, bytesbox, arraydescr): return self.execute_with_descr(rop.GC_STORE_INDEXED, arraydescr, addrbox, indexbox, + valuebox, self._remove_symbolics(scalebox), self._remove_symbolics(baseofsbox), - valuebox, bytesbox) opimpl_gc_store_indexed_i = _opimpl_gc_store_indexed opimpl_gc_store_indexed_f = _opimpl_gc_store_indexed diff --git a/rpython/rtyper/lltypesystem/opimpl.py b/rpython/rtyper/lltypesystem/opimpl.py --- a/rpython/rtyper/lltypesystem/opimpl.py +++ b/rpython/rtyper/lltypesystem/opimpl.py @@ -728,7 +728,7 @@ return p[0] op_gc_load_indexed.need_result_type = True -def op_gc_store_indexed(p, index, scale, base_ofs, newvalue): +def op_gc_store_indexed(p, index, newvalue, scale, base_ofs): # 'base_ofs' should be a CompositeOffset(..., ArrayItemsOffset). # 'scale' should be a llmemory.sizeof(). from rpython.rtyper.lltypesystem import rffi diff --git a/rpython/rtyper/test/test_llop.py b/rpython/rtyper/test/test_llop.py --- a/rpython/rtyper/test/test_llop.py +++ b/rpython/rtyper/test/test_llop.py @@ -28,7 +28,7 @@ scale_factor = llmemory.sizeof(lltype.Char) value = lltype.cast_primitive(TYPE, value) llop.gc_store_indexed(lltype.Void, ll_items, 0, - scale_factor, base_ofs, value) + value, scale_factor, base_ofs) return lst diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py --- a/rpython/translator/c/funcgen.py +++ b/rpython/translator/c/funcgen.py @@ -731,10 +731,10 @@ def OP_GC_STORE_INDEXED(self, op): addr = self.expr(op.args[0]) index = self.expr(op.args[1]) - scale = self.expr(op.args[2]) - base_ofs = self.expr(op.args[3]) - value = self.expr(op.args[4]) - TYPE = op.args[4].concretetype + value = self.expr(op.args[2]) + scale = self.expr(op.args[3]) + base_ofs = self.expr(op.args[4]) + TYPE = op.args[2].concretetype typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') return ( "((%(typename)s) (((char *)%(addr)s) + " _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit