Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct-2
Changeset: r91263:84c40c5d2545
Date: 2017-05-12 01:14 +0200
http://bitbucket.org/pypy/pypy/changeset/84c40c5d2545/
Log: add JIT support for gc_store_indexed of floats
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
@@ -753,11 +753,18 @@
val = lltype.cast_primitive(T, val)
llop.gc_store_indexed(lltype.Void, struct, index, scale, base_ofs, val)
+ def bh_gc_store_indexed_f(self, struct, index, scale, base_ofs, val, 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)
+
def bh_gc_store_indexed(self, struct, index, scale, base_ofs, val, bytes,
descr):
if descr.A.OF == lltype.Float:
- XXX
- self.bh_raw_store_f(struct, offset, newvalue, descr)
+ self.bh_gc_store_indexed_f(struct, index, scale, base_ofs,
+ val, bytes, descr)
else:
self.bh_gc_store_indexed_i(struct, index, scale, base_ofs,
val, bytes, descr)
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
@@ -261,7 +261,9 @@
if arraydescr.is_array_of_pointers():
raise AssertionError("cannot store GC pointers in gc_store_indexed for
now")
elif arraydescr.is_array_of_floats():
- import pdb;pdb.set_trace()
+ floatval = valuebox.getfloat()
+ cpu.bh_gc_store_indexed_i(addr, index, scale, base_ofs, floatval,
bytes,
+ arraydescr)
else:
intval = valuebox.getint()
cpu.bh_gc_store_indexed_i(addr, index, scale, base_ofs, intval, bytes,
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,9 +828,9 @@
self._remove_symbolics(baseofsbox), bytesbox)
@arguments("box", "box", "box", "box", "box", "box", "descr")
- def opimpl_gc_store_indexed_i(self, addrbox, indexbox,
- scalebox, baseofsbox, valuebox, bytesbox,
- arraydescr):
+ def _opimpl_gc_store_indexed(self, addrbox, indexbox,
+ scalebox, baseofsbox, valuebox, bytesbox,
+ arraydescr):
return self.execute_with_descr(rop.GC_STORE_INDEXED,
arraydescr,
addrbox,
@@ -839,6 +839,8 @@
self._remove_symbolics(baseofsbox),
valuebox,
bytesbox)
+ opimpl_gc_store_indexed_i = _opimpl_gc_store_indexed
+ opimpl_gc_store_indexed_f = _opimpl_gc_store_indexed
@arguments("box")
def opimpl_hint_force_virtualizable(self, box):
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
@@ -46,10 +46,14 @@
val = self.gc_load_from_string(rffi.INT, buf, 12)
assert val == 0x12345678
- def test_gc_store_indexed(self):
+ def test_gc_store_indexed_int(self):
expected = struct.pack('i', 0x12345678)
self.newlist_and_gc_store(rffi.INT, 0x12345678, expected)
+ def test_gc_store_indexed_double(self):
+ expected = struct.pack('d', 123.456)
+ self.newlist_and_gc_store(rffi.DOUBLE, 123.456, expected)
+
class TestDirect(BaseLLOpTest):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit