[pypy-commit] pypy faster-rstruct: fix runpack('d') on win32 and 32bit ARM. I tried to keep the fix and the implementation as least invasive as possible, because it will go away as soon as we have gc_load; but in the meantime, this fixes it with reasonable performance
antocuni
noreply at buildbot.pypy.org
Mon Nov 23 15:36:58 EST 2015
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct
Changeset: r80871:59a4b706d487
Date: 2015-11-23 21:37 +0100
http://bitbucket.org/pypy/pypy/changeset/59a4b706d487/
Log: fix runpack('d') on win32 and 32bit ARM. I tried to keep the fix and
the implementation as least invasive as possible, because it will go
away as soon as we have gc_load; but in the meantime, this fixes it
with reasonable performance
diff --git a/rpython/rlib/rstruct/standardfmttable.py b/rpython/rlib/rstruct/standardfmttable.py
--- a/rpython/rlib/rstruct/standardfmttable.py
+++ b/rpython/rlib/rstruct/standardfmttable.py
@@ -185,6 +185,13 @@
data = fmtiter.read(size)
fmtiter.appendobj(ieee.unpack_float(data, fmtiter.bigendian))
return
+ if not str_storage_supported(TYPE):
+ # this happens e.g. on win32 and ARM32: we cannot read the string
+ # content as an array of doubles because it's not properly
+ # aligned. But we can read a longlong and convert to float
+ assert TYPE == rffi.DOUBLE
+ assert rffi.sizeof(TYPE) == 8
+ return unpack_longlong2float(fmtiter)
try:
# fast path
val = unpack_fastpath(TYPE)(fmtiter)
@@ -195,6 +202,16 @@
fmtiter.appendobj(float(val))
return unpack_ieee
+ at specialize.argtype(0)
+def unpack_longlong2float(fmtiter):
+ from rpython.rlib.rstruct.runpack import runpack
+ from rpython.rlib.longlong2float import longlong2float
+ s = fmtiter.read(8)
+ llval = runpack('q', s) # this is a bit recursive, I know
+ doubleval = longlong2float(llval)
+ fmtiter.appendobj(doubleval)
+
+
unpack_double = make_ieee_unpacker(rffi.DOUBLE)
unpack_float = make_ieee_unpacker(rffi.FLOAT)
More information about the pypy-commit
mailing list