Author: Maciej Fijalkowski <fij...@gmail.com> Branch: ffi-backend Changeset: r55813:e2cc0a942e8f Date: 2012-06-24 22:19 +0200 http://bitbucket.org/pypy/pypy/changeset/e2cc0a942e8f/
Log: a bit of missing boilerplate diff --git a/pypy/jit/backend/llgraph/runner.py b/pypy/jit/backend/llgraph/runner.py --- a/pypy/jit/backend/llgraph/runner.py +++ b/pypy/jit/backend/llgraph/runner.py @@ -485,9 +485,15 @@ def bh_raw_store_i(self, struct, offset, descr, newvalue): assert isinstance(descr, Descr) return llimpl.do_raw_store_int(struct, offset, descr.ofs, newvalue) + def bh_raw_store_f(self, struct, offset, descr, newvalue): + assert isinstance(descr, Descr) + return llimpl.do_raw_store_float(struct, offset, descr.ofs, newvalue) def bh_raw_load_i(self, struct, offset, descr): assert isinstance(descr, Descr) return llimpl.do_raw_load_int(struct, offset, descr.ofs) + def bh_raw_load_f(self, struct, offset, descr): + assert isinstance(descr, Descr) + return llimpl.do_raw_load_float(struct, offset, descr.ofs) def bh_new(self, sizedescr): assert isinstance(sizedescr, Descr) diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py --- a/pypy/jit/codewriter/jtransform.py +++ b/pypy/jit/codewriter/jtransform.py @@ -856,6 +856,7 @@ def rewrite_op_raw_store(self, op): T = op.args[2].concretetype kind = getkind(T)[0] + assert kind != 'r' descr = self.cpu.arraydescrof(rffi.CArray(T)) return SpaceOperation('raw_store_%s' % kind, [op.args[0], op.args[1], descr, op.args[2]], @@ -864,6 +865,7 @@ def rewrite_op_raw_load(self, op): T = op.result.concretetype kind = getkind(T)[0] + assert kind != 'r' descr = self.cpu.arraydescrof(rffi.CArray(T)) return SpaceOperation('raw_load_%s' % kind, [op.args[0], op.args[1], descr], op.result) diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py --- a/pypy/jit/metainterp/blackhole.py +++ b/pypy/jit/metainterp/blackhole.py @@ -1272,10 +1272,16 @@ @arguments("cpu", "i", "i", "d", "i") def bhimpl_raw_store_i(cpu, addr, offset, arraydescr, newvalue): cpu.bh_raw_store_i(addr, offset, arraydescr, newvalue) + @arguments("cpu", "i", "i", "d", "f") + def bhimpl_raw_store_f(cpu, addr, offset, arraydescr, newvalue): + cpu.bh_raw_store_f(addr, offset, arraydescr, newvalue) @arguments("cpu", "i", "i", "d", returns="i") def bhimpl_raw_load_i(cpu, addr, offset, arraydescr): return cpu.bh_raw_load_i(addr, offset, arraydescr) + @arguments("cpu", "i", "i", "d", returns="f") + def bhimpl_raw_load_f(cpu, addr, offset, arraydescr): + return cpu.bh_raw_load_f(addr, offset, arraydescr) @arguments("r", "d", "d") def bhimpl_record_quasiimmut_field(struct, fielddescr, mutatefielddescr): diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py --- a/pypy/jit/metainterp/executor.py +++ b/pypy/jit/metainterp/executor.py @@ -184,9 +184,9 @@ addr = addrbox.getint() offset = offsetbox.getint() if arraydescr.is_array_of_pointers(): - xxx + raise AssertionError("cannot store GC pointers in raw store") elif arraydescr.is_array_of_floats(): - xxx + cpu.bh_raw_store_f(addr, offset, arraydescr, valuebox.getfloat()) else: cpu.bh_raw_store_i(addr, offset, arraydescr, valuebox.getint()) @@ -194,9 +194,9 @@ addr = addrbox.getint() offset = offsetbox.getint() if arraydescr.is_array_of_pointers(): - xxx + raise AssertionError("cannot store GC pointers in raw store") elif arraydescr.is_array_of_floats(): - xxx + return BoxFloat(cpu.bh_raw_load_f(addr, offset, arraydescr)) else: return BoxInt(cpu.bh_raw_load_i(addr, offset, arraydescr)) diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -654,12 +654,14 @@ self.execute_with_descr(rop.RAW_STORE, arraydescr, addrbox, offsetbox, valuebox) opimpl_raw_store_i = _opimpl_raw_store + opimpl_raw_store_f = _opimpl_raw_store @arguments("box", "box", "descr") def _opimpl_raw_load(self, addrbox, offsetbox, arraydescr): return self.execute_with_descr(rop.RAW_LOAD, arraydescr, addrbox, offsetbox) opimpl_raw_load_i = _opimpl_raw_load + opimpl_raw_load_f = _opimpl_raw_load @arguments("box", "descr", "descr", "orgpc") def opimpl_record_quasiimmut_field(self, box, fielddescr, diff --git a/pypy/jit/metainterp/test/test_rawmem.py b/pypy/jit/metainterp/test/test_rawmem.py --- a/pypy/jit/metainterp/test/test_rawmem.py +++ b/pypy/jit/metainterp/test/test_rawmem.py @@ -44,3 +44,16 @@ self.check_operations_history({'call': 2, 'guard_no_exception': 1, 'raw_store': 1, 'raw_load': 1, 'finish': 1}) + + def test_raw_storage_float(self): + def f(): + p = alloc_raw_storage(15) + raw_storage_setitem(p, 3, 2.4e15) + res = raw_storage_getitem(lltype.Float, p, 3) + free_raw_storage(p) + return res + res = self.interp_operations(f, []) + assert res == 2.4e15 + self.check_operations_history({'call': 2, 'guard_no_exception': 1, + 'raw_store': 1, 'raw_load': 1, + 'finish': 1}) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit