Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.4
Changeset: r63209:861f1f888ff9
Date: 2013-04-10 15:54 -0400
http://bitbucket.org/pypy/pypy/changeset/861f1f888ff9/
Log: merge default
diff --git a/lib_pypy/_functools.py b/lib_pypy/_functools.py
--- a/lib_pypy/_functools.py
+++ b/lib_pypy/_functools.py
@@ -20,3 +20,16 @@
if self.keywords is not None:
fkeywords = dict(self.keywords, **fkeywords)
return self.func(*(self.args + fargs), **fkeywords)
+
+ def __reduce__(self):
+ d = dict((k, v) for k, v in self.__dict__.iteritems() if k not in
+ ('func', 'args', 'keywords'))
+ if len(d) == 0:
+ d = None
+ return (type(self), (self.func,),
+ (self.func, self.args, self.keywords, d))
+
+ def __setstate__(self, state):
+ self.func, self.args, self.keywords, d = state
+ if d is not None:
+ self.__dict__.update(d)
diff --git a/pypy/interpreter/pyparser/parsestring.py
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -91,9 +91,9 @@
assert 0 <= bufp <= bufq
substr = buf[bufp:bufq]
if rawmode:
- v = unicodehelper.PyUnicode_DecodeRawUnicodeEscape(space, substr)
+ v = unicodehelper.decode_raw_unicode_escape(space, substr)
else:
- v = unicodehelper.PyUnicode_DecodeUnicodeEscape(space, substr)
+ v = unicodehelper.decode_unicode_escape(space, substr)
return space.wrap(v)
need_encoding = (encoding is not None and
@@ -103,8 +103,8 @@
substr = s[ps : q]
if rawmode or '\\' not in s[ps:]:
if need_encoding:
- w_u = space.wrap(unicodehelper.PyUnicode_DecodeUTF8(space, substr))
- w_v = unicodehelper.PyUnicode_AsEncodedString(space, w_u,
space.wrap(encoding))
+ w_u = space.wrap(unicodehelper.decode_utf8(space, substr))
+ w_v = unicodehelper.encode(space, w_u, encoding)
return w_v
else:
return space.wrap(substr)
@@ -219,8 +219,8 @@
# while (s < end && *s != '\\') s++; */ /* inefficient for u".."
while ps < end and ord(s[ps]) & 0x80:
ps += 1
- w_u = space.wrap(unicodehelper.PyUnicode_DecodeUTF8(space, s[pt:ps]))
- w_v = unicodehelper.PyUnicode_AsEncodedString(space, w_u,
space.wrap(encoding))
+ w_u = space.wrap(unicodehelper.decode_utf8(space, s[pt:ps]))
+ w_v = unicodehelper.encode(space, w_u, encoding)
v = space.str_w(w_v)
return v, ps
diff --git a/pypy/interpreter/unicodehelper.py
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -29,11 +29,12 @@
# ____________________________________________________________
-def PyUnicode_AsEncodedString(space, w_data, w_encoding):
- return interp_codecs.encode(space, w_data, w_encoding)
+def encode(space, w_data, encoding=None, errors='strict'):
+ from pypy.objspace.std.unicodetype import encode_object
+ return encode_object(space, w_data, encoding, errors)
# These functions take and return unwrapped rpython strings and unicodes
-def PyUnicode_DecodeUnicodeEscape(space, string):
+def decode_unicode_escape(space, string):
state = space.fromcache(interp_codecs.CodecState)
unicodedata_handler = state.get_unicodedata_handler(space)
result, consumed = runicode.str_decode_unicode_escape(
@@ -42,20 +43,20 @@
unicodedata_handler=unicodedata_handler)
return result
-def PyUnicode_DecodeRawUnicodeEscape(space, string):
+def decode_raw_unicode_escape(space, string):
result, consumed = runicode.str_decode_raw_unicode_escape(
string, len(string), "strict",
final=True, errorhandler=decode_error_handler(space))
return result
-def PyUnicode_DecodeUTF8(space, string):
+def decode_utf8(space, string):
result, consumed = runicode.str_decode_utf_8(
string, len(string), "strict",
final=True, errorhandler=decode_error_handler(space),
allow_surrogates=True)
return result
-def PyUnicode_EncodeUTF8(space, uni):
+def encode_utf8(space, uni):
return runicode.unicode_encode_utf_8(
uni, len(uni), "strict",
errorhandler=encode_error_handler(space),
diff --git a/pypy/module/_codecs/interp_codecs.py
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -1,10 +1,18 @@
+from rpython.rlib import jit
+from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.rstring import UnicodeBuilder
+
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-from rpython.rlib.rstring import UnicodeBuilder
-from rpython.rlib.objectmodel import we_are_translated
+
+
+class VersionTag(object):
+ pass
class CodecState(object):
+ _immutable_fields_ = ["version?"]
+
def __init__(self, space):
self.codec_search_path = []
self.codec_search_cache = {}
@@ -14,6 +22,7 @@
self.encode_error_handler = self.make_encode_errorhandler(space)
self.unicodedata_handler = None
+ self.modified()
def _make_errorhandler(self, space, decode):
def call_errorhandler(errors, encoding, reason, input, startpos,
@@ -86,9 +95,20 @@
self.unicodedata_handler = UnicodeData_Handler(space, w_getcode)
return self.unicodedata_handler
+ def modified(self):
+ self.version = VersionTag()
+
+ def get_codec_from_cache(self, key):
+ return self._get_codec_with_version(key, self.version)
+
+ @jit.elidable
+ def _get_codec_with_version(self, key, version):
+ return self.codec_search_cache.get(key, None)
+
def _cleanup_(self):
assert not self.codec_search_path
+
def register_codec(space, w_search_function):
"""register(search_function)
@@ -115,11 +135,12 @@
"lookup_codec() should not be called during translation"
state = space.fromcache(CodecState)
normalized_encoding = encoding.replace(" ", "-").lower()
- w_result = state.codec_search_cache.get(normalized_encoding, None)
+ w_result = state.get_codec_from_cache(normalized_encoding)
if w_result is not None:
return w_result
return _lookup_codec_loop(space, encoding, normalized_encoding)
+
def _lookup_codec_loop(space, encoding, normalized_encoding):
state = space.fromcache(CodecState)
if state.codec_need_encodings:
@@ -143,6 +164,7 @@
space.wrap("codec search functions must return 4-tuples"))
else:
state.codec_search_cache[normalized_encoding] = w_result
+ state.modified()
return w_result
raise operationerrfmt(
space.w_LookupError,
diff --git a/pypy/module/pyexpat/interp_pyexpat.py
b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -475,8 +475,8 @@
def w_convert(self, space, s):
if self.returns_unicode:
- from pypy.interpreter.unicodehelper import PyUnicode_DecodeUTF8
- return space.wrap(PyUnicode_DecodeUTF8(space, s))
+ from pypy.interpreter.unicodehelper import decode_utf8
+ return space.wrap(decode_utf8(space, s))
else:
return space.wrap(s)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -237,3 +237,15 @@
loops = log.loops_by_filename(self.filepath)
loop, = loops
loop.match_by_id('callone', '') # nothing
+
+ def test_lookup_codec(self):
+ log = self.run("""
+ import codecs
+
+ def main(n):
+ for i in xrange(n):
+ codecs.lookup('utf8') # ID: codecs
+ return i
+ """, [1000])
+ loop, = log.loops_by_filename(self.filepath)
+ loop.match_by_id('codecs', '')
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_function.py
b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_function.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_function.py
@@ -16,7 +16,7 @@
"""xxx limited to capture at most 512 bytes of output, according
to the Posix manual."""
- def __init__(self, capture_fd=1): # stdout, by default
+ def __init__(self, capture_fd):
self.capture_fd = capture_fd
def __enter__(self):
@@ -109,80 +109,66 @@
y = lib.TlsFree(x)
assert y != 0
- def test_puts(self):
+ def test_fputs(self):
+ if not sys.platform.startswith('linux'):
+ py.test.skip("probably no symbol 'stderr' in the lib")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- int puts(const char *);
- int fflush(void *);
+ int fputs(const char *, void *);
+ void *stderr;
""")
ffi.C = ffi.dlopen(None)
- ffi.C.puts # fetch before capturing, for easier debugging
- with FdWriteCapture() as fd:
- ffi.C.puts(b"hello")
- ffi.C.puts(b" world")
- ffi.C.fflush(ffi.NULL)
+ ffi.C.fputs # fetch before capturing, for easier debugging
+ with FdWriteCapture(2) as fd:
+ ffi.C.fputs(b"hello\n", ffi.C.stderr)
+ ffi.C.fputs(b" world\n", ffi.C.stderr)
res = fd.getvalue()
assert res == b'hello\n world\n'
- def test_puts_without_const(self):
+ def test_fputs_without_const(self):
+ if not sys.platform.startswith('linux'):
+ py.test.skip("probably no symbol 'stderr' in the lib")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- int puts(char *);
- int fflush(void *);
+ int fputs(char *, void *);
+ void *stderr;
""")
ffi.C = ffi.dlopen(None)
- ffi.C.puts # fetch before capturing, for easier debugging
- with FdWriteCapture() as fd:
- ffi.C.puts(b"hello")
- ffi.C.puts(b" world")
- ffi.C.fflush(ffi.NULL)
+ ffi.C.fputs # fetch before capturing, for easier debugging
+ with FdWriteCapture(2) as fd:
+ ffi.C.fputs(b"hello\n", ffi.C.stderr)
+ ffi.C.fputs(b" world\n", ffi.C.stderr)
res = fd.getvalue()
assert res == b'hello\n world\n'
- def test_fputs(self):
+ def test_vararg(self):
if not sys.platform.startswith('linux'):
- py.test.skip("probably no symbol 'stdout' in the lib")
+ py.test.skip("probably no symbol 'stderr' in the lib")
ffi = FFI(backend=self.Backend())
ffi.cdef("""
- int fputs(const char *, void *);
- void *stdout, *stderr;
+ int fprintf(void *, const char *format, ...);
+ void *stderr;
""")
ffi.C = ffi.dlopen(None)
with FdWriteCapture(2) as fd:
- ffi.C.fputs(b"hello from stderr\n", ffi.C.stderr)
+ ffi.C.fprintf(ffi.C.stderr, b"hello with no arguments\n")
+ ffi.C.fprintf(ffi.C.stderr,
+ b"hello, %s!\n", ffi.new("char[]", b"world"))
+ ffi.C.fprintf(ffi.C.stderr,
+ ffi.new("char[]", b"hello, %s!\n"),
+ ffi.new("char[]", b"world2"))
+ ffi.C.fprintf(ffi.C.stderr,
+ b"hello int %d long %ld long long %lld\n",
+ ffi.cast("int", 42),
+ ffi.cast("long", 84),
+ ffi.cast("long long", 168))
+ ffi.C.fprintf(ffi.C.stderr, b"hello %p\n", ffi.NULL)
res = fd.getvalue()
- assert res == b'hello from stderr\n'
-
- def test_vararg(self):
- ffi = FFI(backend=self.Backend())
- ffi.cdef("""
- int printf(const char *format, ...);
- int fflush(void *);
- """)
- ffi.C = ffi.dlopen(None)
- with FdWriteCapture() as fd:
- ffi.C.printf(b"hello with no arguments\n")
- ffi.C.printf(b"hello, %s!\n", ffi.new("char[]", b"world"))
- ffi.C.printf(ffi.new("char[]", b"hello, %s!\n"),
- ffi.new("char[]", b"world2"))
- ffi.C.printf(b"hello int %d long %ld long long %lld\n",
- ffi.cast("int", 42),
- ffi.cast("long", 84),
- ffi.cast("long long", 168))
- ffi.C.printf(b"hello %p\n", ffi.NULL)
- ffi.C.fflush(ffi.NULL)
- res = fd.getvalue()
- if sys.platform == 'win32':
- NIL = b"00000000"
- elif sys.platform.startswith(('linux', 'gnu')):
- NIL = b"(nil)"
- else:
- NIL = b"0x0" # OS/X at least
assert res == (b"hello with no arguments\n"
b"hello, world!\n"
b"hello, world2!\n"
b"hello int 42 long 84 long long 168\n"
- b"hello " + NIL + b"\n")
+ b"hello (nil)\n")
def test_must_specify_type_of_vararg(self):
ffi = FFI(backend=self.Backend())
@@ -216,17 +202,18 @@
res = fptr(b"Hello")
assert res == 42
#
+ if not sys.platform.startswith('linux'):
+ py.test.skip("probably no symbol 'stderr' in the lib")
ffi.cdef("""
- int puts(const char *);
- int fflush(void *);
+ int fputs(const char *, void *);
+ void *stderr;
""")
ffi.C = ffi.dlopen(None)
- fptr = ffi.cast("int(*)(const char *txt)", ffi.C.puts)
- assert fptr == ffi.C.puts
- assert repr(fptr).startswith("<cdata 'int(*)(char *)' 0x")
- with FdWriteCapture() as fd:
- fptr(b"world")
- ffi.C.fflush(ffi.NULL)
+ fptr = ffi.cast("int(*)(const char *txt, void *)", ffi.C.fputs)
+ assert fptr == ffi.C.fputs
+ assert repr(fptr).startswith("<cdata 'int(*)(char *, void *)' 0x")
+ with FdWriteCapture(2) as fd:
+ fptr(b"world\n", ffi.C.stderr)
res = fd.getvalue()
assert res == b'world\n'
diff --git a/pypy/module/test_lib_pypy/test_functools.py
b/pypy/module/test_lib_pypy/test_functools.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/test_functools.py
@@ -0,0 +1,19 @@
+from lib_pypy import _functools
+
+def test_partial_reduce():
+ partial = _functools.partial(test_partial_reduce)
+ state = partial.__reduce__()
+ assert state == (type(partial), (test_partial_reduce,),
+ (test_partial_reduce, (), None, None))
+
+def test_partial_setstate():
+ partial = _functools.partial(object)
+ partial.__setstate__([test_partial_setstate, (), None, None])
+ assert partial.func == test_partial_setstate
+
+def test_partial_pickle():
+ import pickle
+ partial1 = _functools.partial(test_partial_pickle)
+ string = pickle.dumps(partial1)
+ partial2 = pickle.loads(string)
+ assert partial1.func == partial2.func
diff --git a/pypy/objspace/std/marshal_impl.py
b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -405,11 +405,11 @@
register(TYPE_CODE, unmarshal_pycode)
def marshal_w__Unicode(space, w_unicode, m):
- s = unicodehelper.PyUnicode_EncodeUTF8(space, space.unicode_w(w_unicode))
+ s = unicodehelper.encode_utf8(space, space.unicode_w(w_unicode))
m.atom_str(TYPE_UNICODE, s)
def unmarshal_Unicode(space, u, tc):
- return space.wrap(unicodehelper.PyUnicode_DecodeUTF8(space, u.get_str()))
+ return space.wrap(unicodehelper.decode_utf8(space, u.get_str()))
register(TYPE_UNICODE, unmarshal_Unicode)
app = gateway.applevel(r'''
diff --git a/rpython/jit/backend/arm/assembler.py
b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -30,6 +30,7 @@
class AssemblerARM(ResOpAssembler):
debug = False
+ DEBUG_FRAME_DEPTH = False
def __init__(self, cpu, translate_support_code=False):
ResOpAssembler.__init__(self, cpu, translate_support_code)
@@ -67,6 +68,7 @@
allblocks)
self.mc.datablockwrapper = self.datablockwrapper
self.target_tokens_currently_compiling = {}
+ self.frame_depth_to_patch = []
def teardown(self):
self.current_clt = None
@@ -597,6 +599,7 @@
'e', looptoken.number)
self._call_header_with_stack_check()
+ self._check_frame_depth_debug(self.mc)
regalloc = Regalloc(assembler=self)
operations = regalloc.prepare_loop(inputargs, operations, looptoken,
@@ -670,8 +673,7 @@
self.current_clt.allgcrefs,
self.current_clt.frame_info)
- stack_check_patch_ofs = self._check_frame_depth(self.mc,
- regalloc.get_gcmap())
+ self._check_frame_depth(self.mc, regalloc.get_gcmap())
frame_depth_no_fixed_size = self._assemble(regalloc, inputargs,
operations)
@@ -687,6 +689,8 @@
self.patch_trace(faildescr, original_loop_token,
rawstart, regalloc)
+ self.patch_stack_checks(frame_depth_no_fixed_size +
JITFRAME_FIXED_SIZE,
+ rawstart)
if not we_are_translated():
if log:
self.mc._dump_trace(rawstart, 'bridge.asm')
@@ -695,7 +699,6 @@
frame_depth = max(self.current_clt.frame_info.jfi_frame_depth,
frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE)
self.fixup_target_tokens(rawstart)
- self._patch_stackadjust(stack_check_patch_ofs + rawstart, frame_depth)
self.update_frame_depth(frame_depth)
self.teardown()
@@ -719,6 +722,11 @@
self._check_frame_depth(self.mc, self._regalloc.get_gcmap(),
expected_size=expected_size)
+ def _patch_frame_depth(self, adr, allocated_depth):
+ mc = InstrBuilder(self.cpu.arch_version)
+ mc.gen_load_int(r.lr.value, allocated_depth)
+ mc.copy_to_raw_memory(adr)
+
def _check_frame_depth(self, mc, gcmap, expected_size=-1):
""" check if the frame is of enough depth to follow this bridge.
Otherwise reallocate the frame in a helper.
@@ -751,7 +759,35 @@
pmc = OverwritingBuilder(mc, jg_location, WORD)
pmc.B_offs(currpos, c.GE)
- return stack_check_cmp_ofs
+ self.frame_depth_to_patch.append(stack_check_cmp_ofs)
+
+ def _check_frame_depth_debug(self, mc):
+ """ double check the depth size. It prints the error (and potentially
+ segfaults later)
+ """
+ if not self.DEBUG_FRAME_DEPTH:
+ return
+ descrs = self.cpu.gc_ll_descr.getframedescrs(self.cpu)
+ ofs = self.cpu.unpack_fielddescr(descrs.arraydescr.lendescr)
+ mc.LDR_ri(r.ip.value, r.fp.value, imm=ofs)
+ stack_check_cmp_ofs = mc.currpos()
+ for _ in range(mc.get_max_size_of_gen_load_int()):
+ mc.NOP()
+ mc.CMP_rr(r.ip.value, r.lr.value)
+
+ jg_location = mc.currpos()
+ mc.BKPT()
+
+ mc.MOV_rr(r.r0.value, r.fp.value)
+ mc.MOV_ri(r.r1.value, r.lr.value)
+
+ self.mc.BL(self.cpu.realloc_frame_crash)
+ # patch the JG above
+ currpos = self.mc.currpos()
+ pmc = OverwritingBuilder(mc, jg_location, WORD)
+ pmc.B_offs(currpos, c.GE)
+
+ self.frame_depth_to_patch.append(stack_check_cmp_ofs)
def build_frame_realloc_slowpath(self):
# this code should do the following steps
@@ -827,6 +863,10 @@
mc.gen_load_int(r.lr.value, allocated_depth)
mc.copy_to_raw_memory(adr)
+ def patch_stack_checks(self, framedepth, rawstart):
+ for ofs in self.frame_depth_to_patch:
+ self._patch_frame_depth(ofs + rawstart, framedepth)
+
def target_arglocs(self, loop_token):
return loop_token._arm_arglocs
diff --git a/rpython/jit/backend/arm/opassembler.py
b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -298,6 +298,10 @@
return self._emit_guard(op, locs, fcond, save_exc=False,
is_guard_not_invalidated=True)
+ def emit_op_label(self, op, arglocs, regalloc, fcond):
+ self._check_frame_depth_debug(self.mc)
+ return fcond
+
def emit_op_jump(self, op, arglocs, regalloc, fcond):
target_token = op.getdescr()
assert isinstance(target_token, TargetToken)
diff --git a/rpython/jit/backend/arm/regalloc.py
b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -1091,6 +1091,7 @@
#jump_op = self.final_jump_op
#if jump_op is not None and jump_op.getdescr() is descr:
# self._compute_hint_frame_locations_from_descr(descr)
+ return []
def prepare_guard_call_may_force(self, op, guard_op, fcond):
args = self._prepare_call(op, save_all_regs=True)
diff --git a/rpython/jit/backend/arm/test/test_regalloc_mov.py
b/rpython/jit/backend/arm/test/test_regalloc_mov.py
--- a/rpython/jit/backend/arm/test/test_regalloc_mov.py
+++ b/rpython/jit/backend/arm/test/test_regalloc_mov.py
@@ -174,8 +174,11 @@
s = stack(8191)
r6 = r(6)
expected = [
- mi('gen_load_int', 'helper', s.value, cond=AL),
- mi('LDR_rr', r6.value, fp.value, 'helper', cond=AL)]
+ mi('PUSH', [lr.value], cond=AL),
+ mi('gen_load_int', lr.value, 32940, cond=AL),
+ mi('LDR_rr', r6.value, fp.value, lr.value, cond=AL),
+ mi('POP', [lr.value], cond=AL),
+ ]
self.mov(s, r6, expected)
def test_mov_float_imm_to_vfp_reg(self):
@@ -422,8 +425,11 @@
def test_push_big_stack(self):
s = stack(1025)
- e = [mi('gen_load_int', 'helper', s.value, cond=AL),
- mi('LDR_rr', ip.value, fp.value, 'helper', cond=AL),
+ e = [
+ mi('PUSH', [lr.value], cond=AL),
+ mi('gen_load_int', lr.value, s.value, cond=AL),
+ mi('LDR_rr', ip.value, fp.value, lr.value, cond=AL),
+ mi('POP', [lr.value], cond=AL),
mi('PUSH', [ip.value], cond=AL)
]
self.push(s, e)
@@ -444,9 +450,11 @@
def test_push_large_stackfloat(self):
sf = stack_float(100)
e = [
- mi('gen_load_int', 'helper', sf.value, cond=AL),
- mi('ADD_rr', 'helper', fp.value, 'helper', cond=AL),
- mi('VLDR', vfp_ip.value, 'helper', cond=AL),
+ mi('PUSH', [ip.value], cond=AL),
+ mi('gen_load_int', ip.value, sf.value, cond=AL),
+ mi('ADD_rr', ip.value, fp.value, ip.value, cond=AL),
+ mi('VLDR', vfp_ip.value, ip.value, cond=AL),
+ mi('POP', [ip.value], cond=AL),
mi('VPUSH', [vfp_ip.value], cond=AL),
]
self.push(sf, e)
diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -346,7 +346,7 @@
])
CConfig.WSAPROTOCOL_INFO = platform.Struct(
- 'WSAPROTOCOL_INFO',
+ 'WSAPROTOCOL_INFOA',
[]) # Struct is just passed between functions
CConfig.FROM_PROTOCOL_INFO = platform.DefinedConstantInteger(
'FROM_PROTOCOL_INFO')
@@ -612,11 +612,11 @@
WSAPROTOCOL_INFO = cConfig.WSAPROTOCOL_INFO
FROM_PROTOCOL_INFO = cConfig.FROM_PROTOCOL_INFO
- WSADuplicateSocket = external('WSADuplicateSocket',
+ WSADuplicateSocket = external('WSADuplicateSocketA',
[socketfd_type, rwin32.DWORD,
lltype.Ptr(WSAPROTOCOL_INFO)],
rffi.INT)
- WSASocket = external('WSASocket',
+ WSASocket = external('WSASocketA',
[rffi.INT, rffi.INT, rffi.INT,
lltype.Ptr(WSAPROTOCOL_INFO),
rwin32.DWORD, rwin32.DWORD],
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -1053,7 +1053,7 @@
if _c.WIN32:
def dup(fd):
- with lltype.scoped_alloc(_c.WSAData, zero=True) as info:
+ with lltype.scoped_alloc(_c.WSAPROTOCOL_INFO, zero=True) as info:
if _c.WSADuplicateSocket(fd, rwin32.GetCurrentProcessId(), info):
raise last_error()
result = _c.WSASocket(
diff --git a/rpython/translator/c/gcc/instruction.py
b/rpython/translator/c/gcc/instruction.py
--- a/rpython/translator/c/gcc/instruction.py
+++ b/rpython/translator/c/gcc/instruction.py
@@ -57,11 +57,11 @@
def getlocation(self, framesize, uses_frame_pointer, wordsize):
if (self.hint == 'esp' or not uses_frame_pointer
- or self.ofs_from_frame_end % 2 != 0):
+ or self.ofs_from_frame_end % 1 != 0):
# try to use esp-relative addressing
ofs_from_esp = framesize + self.ofs_from_frame_end
- if ofs_from_esp % 2 == 0:
- return frameloc_esp(ofs_from_esp, wordsize)
+ if ofs_from_esp % 1 == 0:
+ return frameloc_esp(int(ofs_from_esp), wordsize)
# we can get an odd value if the framesize is marked as bogus
# by visit_andl()
assert uses_frame_pointer
@@ -177,12 +177,12 @@
class InsnStackAdjust(Insn):
_args_ = ['delta']
def __init__(self, delta):
- assert delta % 2 == 0 # should be "% 4", but there is the special
- self.delta = delta # case of 'pushw' to handle
+ #assert delta % 4 == 0 --- but not really, gcc generates strange code
+ self.delta = delta
class InsnCannotFollowEsp(InsnStackAdjust):
def __init__(self):
- self.delta = -7 # use an odd value as marker
+ self.delta = -7.25 # use this non-integer value as a marker
class InsnStop(Insn):
_args_ = ['reason']
diff --git a/rpython/translator/c/gcc/test/elf/track_odd_esp.s
b/rpython/translator/c/gcc/test/elf/track_odd_esp.s
new file mode 100644
--- /dev/null
+++ b/rpython/translator/c/gcc/test/elf/track_odd_esp.s
@@ -0,0 +1,97 @@
+ .type pypy_g_copy_flags_from_bases, @function
+pypy_g_copy_flags_from_bases:
+.LFB188:
+ .cfi_startproc
+ pushl %ebp
+ .cfi_def_cfa_offset 8
+ .cfi_offset 5, -8
+ xorl %edx, %edx
+ pushl %edi
+ .cfi_def_cfa_offset 12
+ .cfi_offset 7, -12
+ pushl %esi
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ pushl %ebx
+ .cfi_def_cfa_offset 20
+ .cfi_offset 3, -20
+ subl $1, %esp
+ .cfi_def_cfa_offset 21
+ movl 21(%esp), %ebx
+ movb $0, (%esp)
+ movl 16(%ebx), %ebp
+ movl 4(%ebp), %edi
+ .p2align 4,,7
+ .p2align 3
+.L572:
+ cmpl %edi, %edx
+ jge .L573
+.L590:
+.L574:
+ addl $1, %edx
+ movl 4(%ebp,%edx,4), %ecx
+ testl %ecx, %ecx
+ je .L585
+.L576:
+ movl 4(%ecx), %esi
+ movl (%esi), %esi
+ subl $404, %esi
+ cmpl $10, %esi
+ ja .L585
+.L577:
+ cmpb $0, 443(%ebx)
+ movl $1, %esi
+ jne .L578
+.L579:
+ movzbl 443(%ecx), %esi
+.L578:
+ cmpb $0, 444(%ebx)
+ movl %esi, %eax
+ movb %al, 443(%ebx)
+ movl $1, %esi
+ jne .L580
+.L581:
+ movzbl 444(%ecx), %esi
+.L580:
+ cmpb $0, 446(%ebx)
+ movl %esi, %eax
+ movb %al, 444(%ebx)
+ movl $1, %esi
+ jne .L582
+.L583:
+ movzbl 446(%ecx), %esi
+.L582:
+ movl %esi, %eax
+ cmpl %edi, %edx
+ movb %al, 446(%ebx)
+ jl .L590
+.L573:
+ movl 25(%esp), %edx
+ movzbl (%esp), %eax
+ movl 420(%edx), %edx
+ movl %edx, 420(%ebx)
+ addl $1, %esp
+ .cfi_remember_state
+ .cfi_def_cfa_offset 20
+ popl %ebx
+ .cfi_restore 3
+ .cfi_def_cfa_offset 16
+ popl %esi
+ .cfi_restore 6
+ .cfi_def_cfa_offset 12
+ popl %edi
+ .cfi_restore 7
+ .cfi_def_cfa_offset 8
+ popl %ebp
+ .cfi_restore 5
+ .cfi_def_cfa_offset 4
+ ret
+ .p2align 4,,7
+ .p2align 3
+.L585:
+ .cfi_restore_state
+ movb $1, (%esp)
+ jmp .L572
+ .cfi_endproc
+.LFE188:
+ .size pypy_g_copy_flags_from_bases, .-pypy_g_copy_flags_from_bases
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit