[pypy-commit] pypy py3k: hg merge default
amauryfa
noreply at buildbot.pypy.org
Fri Nov 11 21:54:51 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r49348:8ca9a3739338
Date: 2011-11-11 21:54 +0100
http://bitbucket.org/pypy/pypy/changeset/8ca9a3739338/
Log: hg merge default
diff --git a/lib-python/2.7/test/test_os.py b/lib-python/2.7/test/test_os.py
--- a/lib-python/2.7/test/test_os.py
+++ b/lib-python/2.7/test/test_os.py
@@ -74,7 +74,8 @@
self.assertFalse(os.path.exists(name),
"file already exists for temporary file")
# make sure we can create the file
- open(name, "w")
+ f = open(name, "w")
+ f.close()
self.files.append(name)
def test_tempnam(self):
diff --git a/lib-python/2.7/pkgutil.py b/lib-python/modified-2.7/pkgutil.py
copy from lib-python/2.7/pkgutil.py
copy to lib-python/modified-2.7/pkgutil.py
--- a/lib-python/2.7/pkgutil.py
+++ b/lib-python/modified-2.7/pkgutil.py
@@ -244,7 +244,8 @@
return mod
def get_data(self, pathname):
- return open(pathname, "rb").read()
+ with open(pathname, "rb") as f:
+ return f.read()
def _reopen(self):
if self.file and self.file.closed:
diff --git a/lib-python/modified-2.7/test/test_import.py b/lib-python/modified-2.7/test/test_import.py
--- a/lib-python/modified-2.7/test/test_import.py
+++ b/lib-python/modified-2.7/test/test_import.py
@@ -64,6 +64,7 @@
except ImportError, err:
self.fail("import from %s failed: %s" % (ext, err))
else:
+ # XXX importing .pyw is missing on Windows
self.assertEqual(mod.a, a,
"module loaded (%s) but contents invalid" % mod)
self.assertEqual(mod.b, b,
diff --git a/lib-python/modified-2.7/test/test_repr.py b/lib-python/modified-2.7/test/test_repr.py
--- a/lib-python/modified-2.7/test/test_repr.py
+++ b/lib-python/modified-2.7/test/test_repr.py
@@ -254,8 +254,14 @@
eq = self.assertEqual
touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
- eq(repr(areallylongpackageandmodulenametotestreprtruncation),
- "<module '%s' from '%s'>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__))
+ # On PyPy, we use %r to format the file name; on CPython it is done
+ # with '%s'. It seems to me that %r is safer <arigo>.
+ if '__pypy__' in sys.builtin_module_names:
+ eq(repr(areallylongpackageandmodulenametotestreprtruncation),
+ "<module %r from %r>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__))
+ else:
+ eq(repr(areallylongpackageandmodulenametotestreprtruncation),
+ "<module '%s' from '%s'>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__))
eq(repr(sys), "<module 'sys' (built-in)>")
def test_type(self):
diff --git a/lib-python/2.7/test/test_subprocess.py b/lib-python/modified-2.7/test/test_subprocess.py
copy from lib-python/2.7/test/test_subprocess.py
copy to lib-python/modified-2.7/test/test_subprocess.py
--- a/lib-python/2.7/test/test_subprocess.py
+++ b/lib-python/modified-2.7/test/test_subprocess.py
@@ -16,11 +16,11 @@
# Depends on the following external programs: Python
#
-if mswindows:
- SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
- 'os.O_BINARY);')
-else:
- SETBINARY = ''
+#if mswindows:
+# SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
+# 'os.O_BINARY);')
+#else:
+# SETBINARY = ''
try:
@@ -420,8 +420,9 @@
self.assertStderrEqual(stderr, "")
def test_universal_newlines(self):
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
+ # NB. replaced SETBINARY with the -u flag
+ p = subprocess.Popen([sys.executable, "-u", "-c",
+ 'import sys,os;' + #SETBINARY +
'sys.stdout.write("line1\\n");'
'sys.stdout.flush();'
'sys.stdout.write("line2\\r");'
@@ -448,8 +449,9 @@
def test_universal_newlines_communicate(self):
# universal newlines through communicate()
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
+ # NB. replaced SETBINARY with the -u flag
+ p = subprocess.Popen([sys.executable, "-u", "-c",
+ 'import sys,os;' + #SETBINARY +
'sys.stdout.write("line1\\n");'
'sys.stdout.flush();'
'sys.stdout.write("line2\\r");'
diff --git a/pypy/interpreter/test/test_typedef.py b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -2,7 +2,7 @@
from pypy.interpreter import typedef
from pypy.tool.udir import udir
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import ObjSpace, interp2app
# this test isn't so much to test that the objspace interface *works*
# -- it's more to test that it's *there*
@@ -260,6 +260,50 @@
gc.collect(); gc.collect()
assert space.unwrap(w_seen) == [6, 2]
+ def test_multiple_inheritance(self):
+ class W_A(Wrappable):
+ a = 1
+ b = 2
+ class W_C(W_A):
+ b = 3
+ W_A.typedef = typedef.TypeDef("A",
+ a = typedef.interp_attrproperty("a", cls=W_A),
+ b = typedef.interp_attrproperty("b", cls=W_A),
+ )
+ class W_B(Wrappable):
+ pass
+ def standalone_method(space, w_obj):
+ if isinstance(w_obj, W_A):
+ return space.w_True
+ else:
+ return space.w_False
+ W_B.typedef = typedef.TypeDef("B",
+ c = interp2app(standalone_method)
+ )
+ W_C.typedef = typedef.TypeDef("C", (W_A.typedef, W_B.typedef,))
+
+ w_o1 = self.space.wrap(W_C())
+ w_o2 = self.space.wrap(W_B())
+ w_c = self.space.gettypefor(W_C)
+ w_b = self.space.gettypefor(W_B)
+ w_a = self.space.gettypefor(W_A)
+ assert w_c.mro_w == [
+ w_c,
+ w_a,
+ w_b,
+ self.space.w_object,
+ ]
+ for w_tp in w_c.mro_w:
+ assert self.space.isinstance_w(w_o1, w_tp)
+ def assert_attr(w_obj, name, value):
+ assert self.space.unwrap(self.space.getattr(w_obj, self.space.wrap(name))) == value
+ def assert_method(w_obj, name, value):
+ assert self.space.unwrap(self.space.call_method(w_obj, name)) == value
+ assert_attr(w_o1, "a", 1)
+ assert_attr(w_o1, "b", 3)
+ assert_method(w_o1, "c", True)
+ assert_method(w_o2, "c", False)
+
class AppTestTypeDef:
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -15,13 +15,19 @@
def __init__(self, __name, __base=None, **rawdict):
"NOT_RPYTHON: initialization-time only"
self.name = __name
- self.base = __base
+ if __base is None:
+ bases = []
+ elif isinstance(__base, tuple):
+ bases = list(__base)
+ else:
+ bases = [__base]
+ self.bases = bases
self.hasdict = '__dict__' in rawdict
self.weakrefable = '__weakref__' in rawdict
self.doc = rawdict.pop('__doc__', None)
- if __base is not None:
- self.hasdict |= __base.hasdict
- self.weakrefable |= __base.weakrefable
+ for base in bases:
+ self.hasdict |= base.hasdict
+ self.weakrefable |= base.weakrefable
self.rawdict = {}
self.acceptable_as_base_class = '__new__' in rawdict
self.applevel_subclasses_base = None
diff --git a/pypy/jit/backend/llsupport/descr.py b/pypy/jit/backend/llsupport/descr.py
--- a/pypy/jit/backend/llsupport/descr.py
+++ b/pypy/jit/backend/llsupport/descr.py
@@ -305,12 +305,16 @@
_clsname = ''
loop_token = None
arg_classes = '' # <-- annotation hack
- ffi_flags = 0
+ ffi_flags = 1
- def __init__(self, arg_classes, extrainfo=None, ffi_flags=0):
+ def __init__(self, arg_classes, extrainfo=None, ffi_flags=1):
self.arg_classes = arg_classes # string of "r" and "i" (ref/int)
self.extrainfo = extrainfo
self.ffi_flags = ffi_flags
+ # NB. the default ffi_flags is 1, meaning FUNCFLAG_CDECL, which
+ # makes sense on Windows as it's the one for all the C functions
+ # we are compiling together with the JIT. On non-Windows platforms
+ # it is just ignored anyway.
def __repr__(self):
res = '%s(%s)' % (self.__class__.__name__, self.arg_classes)
@@ -351,6 +355,10 @@
return False # unless overridden
def create_call_stub(self, rtyper, RESULT):
+ from pypy.rlib.clibffi import FFI_DEFAULT_ABI
+ assert self.get_call_conv() == FFI_DEFAULT_ABI, (
+ "%r: create_call_stub() with a non-default call ABI" % (self,))
+
def process(c):
if c == 'L':
assert longlong.supports_longlong
@@ -445,7 +453,7 @@
"""
_clsname = 'DynamicIntCallDescr'
- def __init__(self, arg_classes, result_size, result_sign, extrainfo=None, ffi_flags=0):
+ def __init__(self, arg_classes, result_size, result_sign, extrainfo, ffi_flags):
BaseIntCallDescr.__init__(self, arg_classes, extrainfo, ffi_flags)
assert isinstance(result_sign, bool)
self._result_size = chr(result_size)
diff --git a/pypy/jit/backend/llsupport/ffisupport.py b/pypy/jit/backend/llsupport/ffisupport.py
--- a/pypy/jit/backend/llsupport/ffisupport.py
+++ b/pypy/jit/backend/llsupport/ffisupport.py
@@ -8,7 +8,7 @@
class UnsupportedKind(Exception):
pass
-def get_call_descr_dynamic(cpu, ffi_args, ffi_result, extrainfo=None, ffi_flags=0):
+def get_call_descr_dynamic(cpu, ffi_args, ffi_result, extrainfo, ffi_flags):
"""Get a call descr: the types of result and args are represented by
rlib.libffi.types.*"""
try:
diff --git a/pypy/jit/backend/llsupport/test/test_ffisupport.py b/pypy/jit/backend/llsupport/test/test_ffisupport.py
--- a/pypy/jit/backend/llsupport/test/test_ffisupport.py
+++ b/pypy/jit/backend/llsupport/test/test_ffisupport.py
@@ -13,44 +13,46 @@
def test_call_descr_dynamic():
args = [types.sint, types.pointer]
- descr = get_call_descr_dynamic(FakeCPU(), args, types.sint, ffi_flags=42)
+ descr = get_call_descr_dynamic(FakeCPU(), args, types.sint, None,
+ ffi_flags=42)
assert isinstance(descr, DynamicIntCallDescr)
assert descr.arg_classes == 'ii'
assert descr.get_ffi_flags() == 42
args = [types.sint, types.double, types.pointer]
- descr = get_call_descr_dynamic(FakeCPU(), args, types.void)
+ descr = get_call_descr_dynamic(FakeCPU(), args, types.void, None, 42)
assert descr is None # missing floats
descr = get_call_descr_dynamic(FakeCPU(supports_floats=True),
- args, types.void, ffi_flags=43)
+ args, types.void, None, ffi_flags=43)
assert isinstance(descr, VoidCallDescr)
assert descr.arg_classes == 'ifi'
assert descr.get_ffi_flags() == 43
- descr = get_call_descr_dynamic(FakeCPU(), [], types.sint8)
+ descr = get_call_descr_dynamic(FakeCPU(), [], types.sint8, None, 42)
assert isinstance(descr, DynamicIntCallDescr)
assert descr.get_result_size(False) == 1
assert descr.is_result_signed() == True
- descr = get_call_descr_dynamic(FakeCPU(), [], types.uint8)
+ descr = get_call_descr_dynamic(FakeCPU(), [], types.uint8, None, 42)
assert isinstance(descr, DynamicIntCallDescr)
assert descr.get_result_size(False) == 1
assert descr.is_result_signed() == False
if not is_64_bit:
- descr = get_call_descr_dynamic(FakeCPU(), [], types.slonglong)
+ descr = get_call_descr_dynamic(FakeCPU(), [], types.slonglong,
+ None, 42)
assert descr is None # missing longlongs
descr = get_call_descr_dynamic(FakeCPU(supports_longlong=True),
- [], types.slonglong, ffi_flags=43)
+ [], types.slonglong, None, ffi_flags=43)
assert isinstance(descr, LongLongCallDescr)
assert descr.get_ffi_flags() == 43
else:
assert types.slonglong is types.slong
- descr = get_call_descr_dynamic(FakeCPU(), [], types.float)
+ descr = get_call_descr_dynamic(FakeCPU(), [], types.float, None, 42)
assert descr is None # missing singlefloats
descr = get_call_descr_dynamic(FakeCPU(supports_singlefloats=True),
- [], types.float, ffi_flags=44)
+ [], types.float, None, ffi_flags=44)
SingleFloatCallDescr = getCallDescrClass(rffi.FLOAT)
assert isinstance(descr, SingleFloatCallDescr)
assert descr.get_ffi_flags() == 44
diff --git a/pypy/jit/backend/x86/test/test_runner.py b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -455,6 +455,9 @@
EffectInfo.MOST_GENERAL,
ffi_flags=-1)
calldescr.get_call_conv = lambda: ffi # <==== hack
+ # ^^^ we patch get_call_conv() so that the test also makes sense
+ # on Linux, because clibffi.get_call_conv() would always
+ # return FFI_DEFAULT_ABI on non-Windows platforms.
funcbox = ConstInt(rawstart)
i1 = BoxInt()
i2 = BoxInt()
diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -212,7 +212,10 @@
elidable = False
loopinvariant = False
if op.opname == "direct_call":
- func = getattr(get_funcobj(op.args[0].value), '_callable', None)
+ funcobj = get_funcobj(op.args[0].value)
+ assert getattr(funcobj, 'calling_conv', 'c') == 'c', (
+ "%r: getcalldescr() with a non-default call ABI" % (op,))
+ func = getattr(funcobj, '_callable', None)
elidable = getattr(func, "_elidable_function_", False)
loopinvariant = getattr(func, "_jit_loop_invariant_", False)
if loopinvariant:
diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -78,6 +78,9 @@
#
OS_MATH_SQRT = 100
+ # for debugging:
+ _OS_CANRAISE = set([OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL])
+
def __new__(cls, readonly_descrs_fields, readonly_descrs_arrays,
write_descrs_fields, write_descrs_arrays,
extraeffect=EF_CAN_RAISE,
@@ -116,6 +119,8 @@
result.extraeffect = extraeffect
result.can_invalidate = can_invalidate
result.oopspecindex = oopspecindex
+ if result.check_can_raise():
+ assert oopspecindex in cls._OS_CANRAISE
cls._cache[key] = result
return result
@@ -125,6 +130,10 @@
def check_can_invalidate(self):
return self.can_invalidate
+ def check_is_elidable(self):
+ return (self.extraeffect == self.EF_ELIDABLE_CAN_RAISE or
+ self.extraeffect == self.EF_ELIDABLE_CANNOT_RAISE)
+
def check_forces_virtual_or_virtualizable(self):
return self.extraeffect >= self.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
diff --git a/pypy/jit/codewriter/test/test_flatten.py b/pypy/jit/codewriter/test/test_flatten.py
--- a/pypy/jit/codewriter/test/test_flatten.py
+++ b/pypy/jit/codewriter/test/test_flatten.py
@@ -5,7 +5,7 @@
from pypy.jit.codewriter.format import assert_format
from pypy.jit.codewriter import longlong
from pypy.jit.metainterp.history import AbstractDescr
-from pypy.rpython.lltypesystem import lltype, rclass, rstr
+from pypy.rpython.lltypesystem import lltype, rclass, rstr, rffi
from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
from pypy.translator.unsimplify import varoftype
from pypy.rlib.rarithmetic import ovfcheck, r_uint, r_longlong, r_ulonglong
@@ -743,7 +743,6 @@
""", transform=True)
def test_force_cast(self):
- from pypy.rpython.lltypesystem import rffi
# NB: we don't need to test for INT here, the logic in jtransform is
# general enough so that if we have the below cases it should
# generalize also to INT
@@ -849,7 +848,6 @@
transform=True)
def test_force_cast_pointer(self):
- from pypy.rpython.lltypesystem import rffi
def h(p):
return rffi.cast(rffi.VOIDP, p)
self.encoding_test(h, [lltype.nullptr(rffi.CCHARP.TO)], """
@@ -857,7 +855,6 @@
""", transform=True)
def test_force_cast_floats(self):
- from pypy.rpython.lltypesystem import rffi
# Caststs to lltype.Float
def f(n):
return rffi.cast(lltype.Float, n)
@@ -964,7 +961,6 @@
""", transform=True)
def test_direct_ptradd(self):
- from pypy.rpython.lltypesystem import rffi
def f(p, n):
return lltype.direct_ptradd(p, n)
self.encoding_test(f, [lltype.nullptr(rffi.CCHARP.TO), 123], """
@@ -975,7 +971,6 @@
def check_force_cast(FROM, TO, operations, value):
"""Check that the test is correctly written..."""
- from pypy.rpython.lltypesystem import rffi
import re
r = re.compile('(\w+) \%i\d, \$(-?\d+)')
#
diff --git a/pypy/jit/metainterp/optimizeopt/intutils.py b/pypy/jit/metainterp/optimizeopt/intutils.py
--- a/pypy/jit/metainterp/optimizeopt/intutils.py
+++ b/pypy/jit/metainterp/optimizeopt/intutils.py
@@ -1,4 +1,4 @@
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT
+from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT
from pypy.rlib.objectmodel import we_are_translated
from pypy.jit.metainterp.resoperation import rop, ResOperation
from pypy.jit.metainterp.history import BoxInt, ConstInt
@@ -174,10 +174,10 @@
other.known_ge(IntBound(0, 0)) and \
other.known_lt(IntBound(LONG_BIT, LONG_BIT)):
try:
- vals = (ovfcheck_lshift(self.upper, other.upper),
- ovfcheck_lshift(self.upper, other.lower),
- ovfcheck_lshift(self.lower, other.upper),
- ovfcheck_lshift(self.lower, other.lower))
+ vals = (ovfcheck(self.upper << other.upper),
+ ovfcheck(self.upper << other.lower),
+ ovfcheck(self.lower << other.upper),
+ ovfcheck(self.lower << other.lower))
return IntBound(min4(vals), max4(vals))
except (OverflowError, ValueError):
return IntUnbounded()
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -4999,6 +4999,34 @@
"""
self.optimize_loop(ops, expected)
+ def test_known_equal_ints(self):
+ py.test.skip("in-progress")
+ ops = """
+ [i0, i1, i2, p0]
+ i3 = int_eq(i0, i1)
+ guard_true(i3) []
+
+ i4 = int_lt(i2, i0)
+ guard_true(i4) []
+ i5 = int_lt(i2, i1)
+ guard_true(i5) []
+
+ i6 = getarrayitem_gc(p0, i2)
+ finish(i6)
+ """
+ expected = """
+ [i0, i1, i2, p0]
+ i3 = int_eq(i0, i1)
+ guard_true(i3) []
+
+ i4 = int_lt(i2, i0)
+ guard_true(i4) []
+
+ i6 = getarrayitem_gc(p0, i3)
+ finish(i6)
+ """
+ self.optimize_loop(ops, expected)
+
class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin):
pass
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -183,6 +183,7 @@
can_invalidate=True))
arraycopydescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
EffectInfo([], [arraydescr], [], [arraydescr],
+ EffectInfo.EF_CANNOT_RAISE,
oopspecindex=EffectInfo.OS_ARRAYCOPY))
@@ -212,12 +213,14 @@
_oopspecindex = getattr(EffectInfo, _os)
locals()[_name] = \
cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
- EffectInfo([], [], [], [], oopspecindex=_oopspecindex))
+ EffectInfo([], [], [], [], EffectInfo.EF_CANNOT_RAISE,
+ oopspecindex=_oopspecindex))
#
_oopspecindex = getattr(EffectInfo, _os.replace('STR', 'UNI'))
locals()[_name.replace('str', 'unicode')] = \
cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
- EffectInfo([], [], [], [], oopspecindex=_oopspecindex))
+ EffectInfo([], [], [], [], EffectInfo.EF_CANNOT_RAISE,
+ oopspecindex=_oopspecindex))
s2u_descr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
EffectInfo([], [], [], [], oopspecindex=EffectInfo.OS_STR2UNICODE))
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
@@ -1345,10 +1345,8 @@
if effect == effectinfo.EF_LOOPINVARIANT:
return self.execute_varargs(rop.CALL_LOOPINVARIANT, allboxes,
descr, False, False)
- exc = (effect != effectinfo.EF_CANNOT_RAISE and
- effect != effectinfo.EF_ELIDABLE_CANNOT_RAISE)
- pure = (effect == effectinfo.EF_ELIDABLE_CAN_RAISE or
- effect == effectinfo.EF_ELIDABLE_CANNOT_RAISE)
+ exc = effectinfo.check_can_raise()
+ pure = effectinfo.check_is_elidable()
return self.execute_varargs(rop.CALL, allboxes, descr, exc, pure)
def do_residual_or_indirect_call(self, funcbox, calldescr, argboxes):
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3678,3 +3678,16 @@
assert x == -42
x = self.interp_operations(f, [1000, 1], translationoptions=topt)
assert x == 999
+
+ def test_ll_arraycopy(self):
+ from pypy.rlib import rgc
+ A = lltype.GcArray(lltype.Char)
+ a = lltype.malloc(A, 10)
+ for i in range(10): a[i] = chr(i)
+ b = lltype.malloc(A, 10)
+ #
+ def f(c, d, e):
+ rgc.ll_arraycopy(a, b, c, d, e)
+ return 42
+ self.interp_operations(f, [1, 2, 3])
+ self.check_operations_history(call=1, guard_no_exception=0)
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -212,6 +212,8 @@
while count + basic_size <= total_size:
fieldtypes.append(basic_ffi_type)
count += basic_size
+ if basic_size == 0: # corner case. get out of this infinite
+ break # loop after 1 iteration ("why not")
self.ffi_struct = clibffi.make_struct_ffitype_e(self.size,
self.alignment,
fieldtypes)
diff --git a/pypy/module/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,7 +29,7 @@
#define PY_VERSION "2.7.1"
/* PyPy version as a string */
-#define PYPY_VERSION "1.6.1"
+#define PYPY_VERSION "1.7.1"
/* Subversion Revision number of this file (not of the repository).
* Empty since Mercurial migration. */
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -116,8 +116,8 @@
try:
return typedescr_cache[typedef]
except KeyError:
- if typedef.base is not None:
- return _get_typedescr_1(typedef.base)
+ if typedef.bases:
+ return _get_typedescr_1(typedef.bases[0])
return typedescr_cache[None]
def get_typedescr(typedef):
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -513,7 +513,7 @@
space.warn(msg, space.w_ImportWarning)
modtype, suffix, filemode = find_modtype(space, filepart)
try:
- if modtype in (PY_SOURCE, PY_COMPILED):
+ if modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION):
assert suffix is not None
filename = filepart + suffix
stream = streamio.open_file_as_stream(filename, filemode)
@@ -522,9 +522,6 @@
except:
stream.close()
raise
- if modtype == C_EXTENSION:
- filename = filepart + suffix
- return FindInfo(modtype, filename, None, suffix, filemode)
except StreamErrors:
pass # XXX! must not eat all exceptions, e.g.
# Out of file descriptors.
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -135,6 +135,8 @@
interpleveldefs['execve'] = 'interp_posix.execve'
if hasattr(posix, 'spawnv'):
interpleveldefs['spawnv'] = 'interp_posix.spawnv'
+ if hasattr(posix, 'spawnve'):
+ interpleveldefs['spawnve'] = 'interp_posix.spawnve'
if hasattr(os, 'uname'):
interpleveldefs['uname'] = 'interp_posix.uname'
if hasattr(os, 'sysconf'):
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -758,6 +758,14 @@
except OSError, e:
raise wrap_oserror(space, e)
+def _env2interp(space, w_env):
+ env = {}
+ w_keys = space.call_method(w_env, 'keys')
+ for w_key in space.unpackiterable(w_keys):
+ w_value = space.getitem(w_env, w_key)
+ env[space.str_w(w_key)] = space.str_w(w_value)
+ return env
+
def execve(space, w_command, w_args, w_env):
""" execve(path, args, env)
@@ -769,11 +777,7 @@
"""
command = fsencode_w(space, w_command)
args = [fsencode_w(space, w_arg) for w_arg in space.unpackiterable(w_args)]
- env = {}
- w_keys = space.call_method(w_env, 'keys')
- for w_key in space.unpackiterable(w_keys):
- w_value = space.getitem(w_env, w_key)
- env[space.str_w(w_key)] = space.str_w(w_value)
+ env = _env2interp(space, w_env)
try:
os.execve(command, args, env)
except OSError, e:
@@ -788,6 +792,16 @@
raise wrap_oserror(space, e)
return space.wrap(ret)
+ at unwrap_spec(mode=int, path=str)
+def spawnve(space, mode, path, w_args, w_env):
+ args = [space.str_w(w_arg) for w_arg in space.unpackiterable(w_args)]
+ env = _env2interp(space, w_env)
+ try:
+ ret = os.spawnve(mode, path, args, env)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.wrap(ret)
+
def utime(space, w_path, w_tuple):
""" utime(path, (atime, mtime))
utime(path, None)
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -471,6 +471,17 @@
['python', '-c', 'raise(SystemExit(42))'])
assert ret == 42
+ if hasattr(__import__(os.name), "spawnve"):
+ def test_spawnve(self):
+ os = self.posix
+ import sys
+ print self.python
+ ret = os.spawnve(os.P_WAIT, self.python,
+ ['python', '-c',
+ "raise(SystemExit(int(__import__('os').environ['FOOBAR'])))"],
+ {'FOOBAR': '42'})
+ assert ret == 42
+
def test_popen(self):
os = self.posix
for i in range(5):
diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -285,6 +285,11 @@
guard_false(ticker_cond1, descr=...)
"""
src = src.replace('--EXC-TICK--', exc_ticker_check)
+ #
+ # ISINF is done as a macro; fix it here
+ r = re.compile('(\w+) = --ISINF--[(](\w+)[)]')
+ src = r.sub(r'\2\B999 = float_add(\2, ...)\n\1 = float_eq(\2\B999, \2)',
+ src)
return src
@classmethod
diff --git a/pypy/module/pypyjit/test_pypy_c/test_math.py b/pypy/module/pypyjit/test_pypy_c/test_math.py
--- a/pypy/module/pypyjit/test_pypy_c/test_math.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_math.py
@@ -1,3 +1,4 @@
+import py
from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
@@ -49,10 +50,7 @@
guard_true(i2, descr=...)
guard_not_invalidated(descr=...)
f1 = cast_int_to_float(i0)
- i3 = float_eq(f1, inf)
- i4 = float_eq(f1, -inf)
- i5 = int_or(i3, i4)
- i6 = int_is_true(i5)
+ i6 = --ISINF--(f1)
guard_false(i6, descr=...)
f2 = call(ConstClass(sin), f1, descr=<FloatCallDescr>)
f3 = call(ConstClass(cos), f1, descr=<FloatCallDescr>)
@@ -64,6 +62,7 @@
""")
def test_fmod(self):
+ py.test.skip("test relies on the old and broken ll_math_fmod")
def main(n):
import math
@@ -90,4 +89,4 @@
i6 = int_sub(i0, 1)
--TICK--
jump(..., descr=)
- """)
\ No newline at end of file
+ """)
diff --git a/pypy/module/select/test/test_select.py b/pypy/module/select/test/test_select.py
--- a/pypy/module/select/test/test_select.py
+++ b/pypy/module/select/test/test_select.py
@@ -214,11 +214,15 @@
def test_poll(self):
import select
- class A(object):
- def __int__(self):
- return 3
-
- select.poll().poll(A()) # assert did not crash
+ readend, writeend = self.getpair()
+ try:
+ class A(object):
+ def __int__(self):
+ return readend.fileno()
+ select.poll().poll(A()) # assert did not crash
+ finally:
+ readend.close()
+ writeend.close()
class AppTestSelectWithPipes(_AppTestSelect):
"Use a pipe to get pairs of file descriptors"
diff --git a/pypy/module/signal/__init__.py b/pypy/module/signal/__init__.py
--- a/pypy/module/signal/__init__.py
+++ b/pypy/module/signal/__init__.py
@@ -20,7 +20,7 @@
interpleveldefs['pause'] = 'interp_signal.pause'
interpleveldefs['siginterrupt'] = 'interp_signal.siginterrupt'
- if hasattr(cpy_signal, 'setitimer'):
+ if os.name == 'posix':
interpleveldefs['setitimer'] = 'interp_signal.setitimer'
interpleveldefs['getitimer'] = 'interp_signal.getitimer'
for name in ['ITIMER_REAL', 'ITIMER_VIRTUAL', 'ITIMER_PROF']:
diff --git a/pypy/module/signal/test/test_signal.py b/pypy/module/signal/test/test_signal.py
--- a/pypy/module/signal/test/test_signal.py
+++ b/pypy/module/signal/test/test_signal.py
@@ -1,4 +1,4 @@
-import os, py
+import os, py, sys
import signal as cpy_signal
from pypy.conftest import gettestobjspace
@@ -264,6 +264,10 @@
class AppTestItimer:
spaceconfig = dict(usemodules=['signal'])
+ def setup_class(cls):
+ if sys.platform == 'win32':
+ py.test.skip("Unix only")
+
def test_itimer_real(self):
import signal
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -10,7 +10,7 @@
CPYTHON_VERSION = (3, 2, 2, "final", 0) #XXX # sync patchlevel.h
CPYTHON_API_VERSION = 1013 #XXX # sync with include/modsupport.h
-PYPY_VERSION = (1, 6, 1, "dev", 0) #XXX # sync patchlevel.h
+PYPY_VERSION = (1, 7, 1, "dev", 0) #XXX # sync patchlevel.h
if platform.name == 'msvc':
COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
diff --git a/pypy/objspace/flow/operation.py b/pypy/objspace/flow/operation.py
--- a/pypy/objspace/flow/operation.py
+++ b/pypy/objspace/flow/operation.py
@@ -11,7 +11,7 @@
from pypy.interpreter.baseobjspace import ObjSpace
from pypy.interpreter.error import OperationError
from pypy.tool.sourcetools import compile2
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
from pypy.objspace.flow import model
MethodTable = ObjSpace.MethodTable[:]
@@ -151,7 +151,7 @@
return ovfcheck(x % y)
def lshift_ovf(x, y):
- return ovfcheck_lshift(x, y)
+ return ovfcheck(x << y)
# slicing: operator.{get,set,del}slice() don't support b=None or c=None
def do_getslice(a, b, c):
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -225,15 +225,12 @@
def _to_bytes(space, w_bytearray):
return space.wrapbytes(''.join(w_bytearray.data))
-def _convert_idx_params(space, w_self, w_start, w_stop):
- length = len(w_self.data)
+def str_count__Bytearray_Int_ANY_ANY(space, w_bytearray, w_char, w_start, w_stop):
+ char = w_char.intval
+ bytearray = w_bytearray.data
+ length = len(bytearray)
start, stop = slicetype.unwrap_start_stop(
space, length, w_start, w_stop, False)
- return start, stop, length
-
-def str_count__Bytearray_Int_ANY_ANY(space, w_bytearray, w_char, w_start, w_stop):
- char = w_char.intval
- start, stop, length = _convert_idx_params(space, w_bytearray, w_start, w_stop)
count = 0
for i in range(start, min(stop, length)):
c = w_bytearray.data[i]
diff --git a/pypy/objspace/std/bytearraytype.py b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -119,10 +119,11 @@
return data
def descr_fromhex(space, w_type, w_hexstring):
- "bytearray.fromhex(string) -> bytearray\n\nCreate a bytearray object "
- "from a string of hexadecimal numbers.\nSpaces between two numbers are "
- "accepted.\nExample: bytearray.fromhex('B9 01EF') -> "
- "bytearray(b'\\xb9\\x01\\xef')."
+ "bytearray.fromhex(string) -> bytearray\n"
+ "\n"
+ "Create a bytearray object from a string of hexadecimal numbers.\n"
+ "Spaces between two numbers are accepted.\n"
+ "Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')."
if not space.is_w(space.type(w_hexstring), space.w_unicode):
raise OperationError(space.w_TypeError, space.wrap(
"must be str, not %s" % space.type(w_hexstring).name))
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -6,7 +6,7 @@
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.register_all import register_all
from pypy.rlib import jit
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT, r_uint
+from pypy.rlib.rarithmetic import ovfcheck, LONG_BIT, r_uint
from pypy.rlib.rbigint import rbigint
"""
@@ -245,7 +245,7 @@
b = w_int2.intval
if r_uint(b) < LONG_BIT: # 0 <= b < LONG_BIT
try:
- c = ovfcheck_lshift(a, b)
+ c = ovfcheck(a << b)
except OverflowError:
raise FailedToImplementArgs(space.w_OverflowError,
space.wrap("integer left shift"))
diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py
--- a/pypy/objspace/std/stdtypedef.py
+++ b/pypy/objspace/std/stdtypedef.py
@@ -32,11 +32,14 @@
from pypy.objspace.std.objecttype import object_typedef
if b is object_typedef:
return True
- while a is not b:
- if a is None:
- return False
- a = a.base
- return True
+ if a is None:
+ return False
+ if a is b:
+ return True
+ for a1 in a.bases:
+ if issubtypedef(a1, b):
+ return True
+ return False
std_dict_descr = GetSetProperty(descr_get_dict, descr_set_dict, descr_del_dict,
doc="dictionary for instance variables (if defined)")
@@ -75,8 +78,8 @@
if typedef is object_typedef:
bases_w = []
else:
- base = typedef.base or object_typedef
- bases_w = [space.gettypeobject(base)]
+ bases = typedef.bases or [object_typedef]
+ bases_w = [space.gettypeobject(base) for base in bases]
# wrap everything
dict_w = {}
diff --git a/pypy/objspace/std/test/test_bytes.py b/pypy/objspace/std/test/test_bytearrayobject.py
rename from pypy/objspace/std/test/test_bytes.py
rename to pypy/objspace/std/test/test_bytearrayobject.py
diff --git a/pypy/objspace/std/test/test_stdobjspace.py b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -1,5 +1,6 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import app2interp
+from pypy.conftest import gettestobjspace
class TestW_StdObjSpace:
@@ -60,3 +61,10 @@
typedef = None
assert space.isinstance_w(X(), space.w_str)
+
+ def test_withstrbuf_fastpath_isinstance(self):
+ from pypy.objspace.std.stringobject import W_StringObject
+
+ space = gettestobjspace(withstrbuf=True)
+ assert space._get_interplevel_cls(space.w_str) is W_StringObject
+
diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py
--- a/pypy/rlib/clibffi.py
+++ b/pypy/rlib/clibffi.py
@@ -30,6 +30,9 @@
_MAC_OS = platform.name == "darwin"
_FREEBSD_7 = platform.name == "freebsd7"
+_LITTLE_ENDIAN = sys.byteorder == 'little'
+_BIG_ENDIAN = sys.byteorder == 'big'
+
if _WIN32:
from pypy.rlib import rwin32
@@ -338,15 +341,38 @@
cast_type_to_ffitype._annspecialcase_ = 'specialize:memo'
def push_arg_as_ffiptr(ffitp, arg, ll_buf):
- # this is for primitive types. For structures and arrays
- # would be something different (more dynamic)
+ # This is for primitive types. Note that the exact type of 'arg' may be
+ # different from the expected 'c_size'. To cope with that, we fall back
+ # to a byte-by-byte copy.
TP = lltype.typeOf(arg)
TP_P = lltype.Ptr(rffi.CArray(TP))
- buf = rffi.cast(TP_P, ll_buf)
- buf[0] = arg
+ TP_size = rffi.sizeof(TP)
+ c_size = intmask(ffitp.c_size)
+ # if both types have the same size, we can directly write the
+ # value to the buffer
+ if c_size == TP_size:
+ buf = rffi.cast(TP_P, ll_buf)
+ buf[0] = arg
+ else:
+ # needs byte-by-byte copying. Make sure 'arg' is an integer type.
+ # Note that this won't work for rffi.FLOAT/rffi.DOUBLE.
+ assert TP is not rffi.FLOAT and TP is not rffi.DOUBLE
+ if TP_size <= rffi.sizeof(lltype.Signed):
+ arg = rffi.cast(lltype.Unsigned, arg)
+ else:
+ arg = rffi.cast(lltype.UnsignedLongLong, arg)
+ if _LITTLE_ENDIAN:
+ for i in range(c_size):
+ ll_buf[i] = chr(arg & 0xFF)
+ arg >>= 8
+ elif _BIG_ENDIAN:
+ for i in range(c_size-1, -1, -1):
+ ll_buf[i] = chr(arg & 0xFF)
+ arg >>= 8
+ else:
+ raise AssertionError
push_arg_as_ffiptr._annspecialcase_ = 'specialize:argtype(1)'
-
# type defs for callback and closure userdata
USERDATA_P = lltype.Ptr(lltype.ForwardReference())
CALLBACK_TP = lltype.Ptr(lltype.FuncType([rffi.VOIDPP, rffi.VOIDP, USERDATA_P],
diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -234,7 +234,7 @@
# It is important that there is no other operation in the middle, else
# the optimizer will fail to recognize the pattern and won't turn it
# into a fast CALL. Note that "arg = arg.next" is optimized away,
- # assuming that archain is completely virtual.
+ # assuming that argchain is completely virtual.
self = jit.promote(self)
if argchain.numargs != len(self.argtypes):
raise TypeError, 'Wrong number of arguments: %d expected, got %d' %\
diff --git a/pypy/rlib/listsort.py b/pypy/rlib/listsort.py
--- a/pypy/rlib/listsort.py
+++ b/pypy/rlib/listsort.py
@@ -1,4 +1,4 @@
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
## ------------------------------------------------------------------------
@@ -136,7 +136,7 @@
if lower(a.list[p + ofs], key):
lastofs = ofs
try:
- ofs = ovfcheck_lshift(ofs, 1)
+ ofs = ovfcheck(ofs << 1)
except OverflowError:
ofs = maxofs
else:
@@ -161,7 +161,7 @@
# key <= a[hint - ofs]
lastofs = ofs
try:
- ofs = ovfcheck_lshift(ofs, 1)
+ ofs = ovfcheck(ofs << 1)
except OverflowError:
ofs = maxofs
else:
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -12,9 +12,6 @@
back to a signed int value
ovfcheck check on CPython whether the result of a signed
integer operation did overflow
-ovfcheck_lshift
- << with oveflow checking
- catering to 2.3/2.4 differences about <<
ovfcheck_float_to_int
convert to an integer or raise OverflowError
r_longlong
@@ -111,18 +108,6 @@
raise OverflowError, "signed integer expression did overflow"
return r
-def _local_ovfcheck(r):
- # a copy of the above, because we cannot call ovfcheck
- # in a context where no primitiveoperator is involved.
- assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
- if isinstance(r, long):
- raise OverflowError, "signed integer expression did overflow"
- return r
-
-def ovfcheck_lshift(a, b):
- "NOT_RPYTHON"
- return _local_ovfcheck(int(long(a) << b))
-
# Strange things happening for float to int on 64 bit:
# int(float(i)) != i because of rounding issues.
# These are the minimum and maximum float value that can
diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -163,8 +163,10 @@
source_start, dest_start,
length):
# if the write barrier is not supported, copy by hand
- for i in range(length):
+ i = 0
+ while i < length:
dest[i + dest_start] = source[i + source_start]
+ i += 1
return
source_addr = llmemory.cast_ptr_to_adr(source)
dest_addr = llmemory.cast_ptr_to_adr(dest)
@@ -214,8 +216,8 @@
func._gc_no_collect_ = True
return func
-def is_light_finalizer(func):
- func._is_light_finalizer_ = True
+def must_be_light_finalizer(func):
+ func._must_be_light_finalizer_ = True
return func
# ____________________________________________________________
diff --git a/pypy/rlib/test/test_libffi.py b/pypy/rlib/test/test_libffi.py
--- a/pypy/rlib/test/test_libffi.py
+++ b/pypy/rlib/test/test_libffi.py
@@ -179,6 +179,17 @@
res = self.call(func, [chr(20), 22], rffi.LONG)
assert res == 42
+ def test_char_args(self):
+ """
+ char sum_args(char a, char b) {
+ return a + b;
+ }
+ """
+ libfoo = self.get_libfoo()
+ func = (libfoo, 'sum_args', [types.schar, types.schar], types.schar)
+ res = self.call(func, [123, 43], rffi.CHAR)
+ assert res == chr(166)
+
def test_unsigned_short_args(self):
"""
unsigned short sum_xy_us(unsigned short x, unsigned short y)
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -1,6 +1,6 @@
from pypy.objspace.flow.model import FunctionGraph, Constant, Variable, c_last_exception
from pypy.rlib.rarithmetic import intmask, r_uint, ovfcheck, r_longlong
-from pypy.rlib.rarithmetic import r_ulonglong, ovfcheck_lshift
+from pypy.rlib.rarithmetic import r_ulonglong
from pypy.rpython.lltypesystem import lltype, llmemory, lloperation, llheap
from pypy.rpython.lltypesystem import rclass
from pypy.rpython.ootypesystem import ootype
@@ -1035,7 +1035,7 @@
assert isinstance(x, int)
assert isinstance(y, int)
try:
- return ovfcheck_lshift(x, y)
+ return ovfcheck(x << y)
except OverflowError:
self.make_llexception()
diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py
--- a/pypy/rpython/lltypesystem/ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/ll2ctypes.py
@@ -1163,10 +1163,14 @@
value = value.adr
if isinstance(value, llmemory.fakeaddress):
value = value.ptr or 0
+ if isinstance(value, r_singlefloat):
+ value = float(value)
TYPE1 = lltype.typeOf(value)
cvalue = lltype2ctypes(value)
cresulttype = get_ctypes_type(RESTYPE)
- if isinstance(TYPE1, lltype.Ptr):
+ if RESTYPE == TYPE1:
+ return value
+ elif isinstance(TYPE1, lltype.Ptr):
if isinstance(RESTYPE, lltype.Ptr):
# shortcut: ptr->ptr cast
cptr = ctypes.cast(cvalue, cresulttype)
diff --git a/pypy/rpython/lltypesystem/module/ll_math.py b/pypy/rpython/lltypesystem/module/ll_math.py
--- a/pypy/rpython/lltypesystem/module/ll_math.py
+++ b/pypy/rpython/lltypesystem/module/ll_math.py
@@ -11,15 +11,17 @@
from pypy.translator.platform import platform
from pypy.rlib.rfloat import isfinite, isinf, isnan, INFINITY, NAN
+use_library_isinf_isnan = False
if sys.platform == "win32":
if platform.name == "msvc":
# When compiled with /O2 or /Oi (enable intrinsic functions)
# It's no more possible to take the address of some math functions.
# Ensure that the compiler chooses real functions instead.
eci = ExternalCompilationInfo(
- includes = ['math.h'],
+ includes = ['math.h', 'float.h'],
post_include_bits = ['#pragma function(floor)'],
)
+ use_library_isinf_isnan = True
else:
eci = ExternalCompilationInfo()
# Some math functions are C99 and not defined by the Microsoft compiler
@@ -108,18 +110,32 @@
#
# Custom implementations
+VERY_LARGE_FLOAT = 1.0
+while VERY_LARGE_FLOAT * 100.0 != INFINITY:
+ VERY_LARGE_FLOAT *= 64.0
+
+_lib_isnan = rffi.llexternal("_isnan", [lltype.Float], lltype.Signed,
+ compilation_info=eci)
+_lib_finite = rffi.llexternal("_finite", [lltype.Float], lltype.Signed,
+ compilation_info=eci)
+
def ll_math_isnan(y):
# By not calling into the external function the JIT can inline this.
# Floats are awesome.
+ if use_library_isinf_isnan and not jit.we_are_jitted():
+ return bool(_lib_isnan(y))
return y != y
def ll_math_isinf(y):
- # Use a bitwise OR so the JIT doesn't produce 2 different guards.
- return (y == INFINITY) | (y == -INFINITY)
+ if use_library_isinf_isnan and not jit.we_are_jitted():
+ return not _lib_finite(y) and not _lib_isnan(y)
+ return (y + VERY_LARGE_FLOAT) == y
def ll_math_isfinite(y):
# Use a custom hack that is reasonably well-suited to the JIT.
# Floats are awesome (bis).
+ if use_library_isinf_isnan and not jit.we_are_jitted():
+ return bool(_lib_finite(y))
z = 0.0 * y
return z == z # i.e.: z is not a NaN
@@ -136,10 +152,12 @@
Windows, FreeBSD and alpha Tru64 are amongst platforms that don't
always follow C99.
"""
- if isnan(x) or isnan(y):
+ if isnan(x):
return NAN
- if isinf(y):
+ if not isfinite(y):
+ if isnan(y):
+ return NAN
if isinf(x):
if math_copysign(1.0, x) == 1.0:
# atan2(+-inf, +inf) == +-pi/4
@@ -168,7 +186,7 @@
def ll_math_frexp(x):
# deal with special cases directly, to sidestep platform differences
- if isnan(x) or isinf(x) or not x:
+ if not isfinite(x) or not x:
mantissa = x
exponent = 0
else:
@@ -185,7 +203,7 @@
INT_MIN = int(-2**31)
def ll_math_ldexp(x, exp):
- if x == 0.0 or isinf(x) or isnan(x):
+ if x == 0.0 or not isfinite(x):
return x # NaNs, zeros and infinities are returned unchanged
if exp > INT_MAX:
# overflow (64-bit platforms only)
@@ -209,10 +227,11 @@
def ll_math_modf(x):
# some platforms don't do the right thing for NaNs and
# infinities, so we take care of special cases directly.
- if isinf(x):
- return (math_copysign(0.0, x), x)
- elif isnan(x):
- return (x, x)
+ if not isfinite(x):
+ if isnan(x):
+ return (x, x)
+ else: # isinf(x)
+ return (math_copysign(0.0, x), x)
intpart_p = lltype.malloc(rffi.DOUBLEP.TO, 1, flavor='raw')
try:
fracpart = math_modf(x, intpart_p)
@@ -223,13 +242,21 @@
def ll_math_fmod(x, y):
- if isinf(x) and not isnan(y):
- raise ValueError("math domain error")
+ # fmod(x, +/-Inf) returns x for finite x.
+ if isinf(y) and isfinite(x):
+ return x
- if y == 0:
- raise ValueError("math domain error")
-
- return math_fmod(x, y)
+ _error_reset()
+ r = math_fmod(x, y)
+ errno = rposix.get_errno()
+ if isnan(r):
+ if isnan(x) or isnan(y):
+ errno = 0
+ else:
+ errno = EDOM
+ if errno:
+ _likely_raise(errno, r)
+ return r
def ll_math_hypot(x, y):
@@ -242,16 +269,17 @@
_error_reset()
r = math_hypot(x, y)
errno = rposix.get_errno()
- if isnan(r):
- if isnan(x) or isnan(y):
- errno = 0
- else:
- errno = EDOM
- elif isinf(r):
- if isinf(x) or isnan(x) or isinf(y) or isnan(y):
- errno = 0
- else:
- errno = ERANGE
+ if not isfinite(r):
+ if isnan(r):
+ if isnan(x) or isnan(y):
+ errno = 0
+ else:
+ errno = EDOM
+ else: # isinf(r)
+ if isfinite(x) and isfinite(y):
+ errno = ERANGE
+ else:
+ errno = 0
if errno:
_likely_raise(errno, r)
return r
@@ -261,30 +289,30 @@
# deal directly with IEEE specials, to cope with problems on various
# platforms whose semantics don't exactly match C99
- if isnan(x):
- if y == 0.0:
- return 1.0 # NaN**0 = 1
- return x
-
- elif isnan(y):
+ if isnan(y):
if x == 1.0:
return 1.0 # 1**Nan = 1
return y
- elif isinf(x):
- odd_y = not isinf(y) and math_fmod(math_fabs(y), 2.0) == 1.0
- if y > 0.0:
- if odd_y:
- return x
- return math_fabs(x)
- elif y == 0.0:
- return 1.0
- else: # y < 0.0
- if odd_y:
- return math_copysign(0.0, x)
- return 0.0
+ if not isfinite(x):
+ if isnan(x):
+ if y == 0.0:
+ return 1.0 # NaN**0 = 1
+ return x
+ else: # isinf(x)
+ odd_y = not isinf(y) and math_fmod(math_fabs(y), 2.0) == 1.0
+ if y > 0.0:
+ if odd_y:
+ return x
+ return math_fabs(x)
+ elif y == 0.0:
+ return 1.0
+ else: # y < 0.0
+ if odd_y:
+ return math_copysign(0.0, x)
+ return 0.0
- elif isinf(y):
+ if isinf(y):
if math_fabs(x) == 1.0:
return 1.0
elif y > 0.0 and math_fabs(x) > 1.0:
@@ -299,17 +327,18 @@
_error_reset()
r = math_pow(x, y)
errno = rposix.get_errno()
- if isnan(r):
- # a NaN result should arise only from (-ve)**(finite non-integer)
- errno = EDOM
- elif isinf(r):
- # an infinite result here arises either from:
- # (A) (+/-0.)**negative (-> divide-by-zero)
- # (B) overflow of x**y with x and y finite
- if x == 0.0:
+ if not isfinite(r):
+ if isnan(r):
+ # a NaN result should arise only from (-ve)**(finite non-integer)
errno = EDOM
- else:
- errno = ERANGE
+ else: # isinf(r)
+ # an infinite result here arises either from:
+ # (A) (+/-0.)**negative (-> divide-by-zero)
+ # (B) overflow of x**y with x and y finite
+ if x == 0.0:
+ errno = EDOM
+ else:
+ errno = ERANGE
if errno:
_likely_raise(errno, r)
return r
@@ -358,18 +387,19 @@
r = c_func(x)
# Error checking fun. Copied from CPython 2.6
errno = rposix.get_errno()
- if isnan(r):
- if isnan(x):
- errno = 0
- else:
- errno = EDOM
- elif isinf(r):
- if isinf(x) or isnan(x):
- errno = 0
- elif can_overflow:
- errno = ERANGE
- else:
- errno = EDOM
+ if not isfinite(r):
+ if isnan(r):
+ if isnan(x):
+ errno = 0
+ else:
+ errno = EDOM
+ else: # isinf(r)
+ if not isfinite(x):
+ errno = 0
+ elif can_overflow:
+ errno = ERANGE
+ else:
+ errno = EDOM
if errno:
_likely_raise(errno, r)
return r
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -125,6 +125,7 @@
canraise=False,
random_effects_on_gcobjs=
random_effects_on_gcobjs,
+ calling_conv=calling_conv,
**kwds)
if isinstance(_callable, ll2ctypes.LL2CtypesCallable):
_callable.funcptr = funcptr
@@ -245,8 +246,14 @@
wrapper._always_inline_ = True
# for debugging, stick ll func ptr to that
wrapper._ptr = funcptr
+ wrapper = func_with_new_name(wrapper, name)
- return func_with_new_name(wrapper, name)
+ if calling_conv != "c":
+ from pypy.rlib.jit import dont_look_inside
+ wrapper = dont_look_inside(wrapper)
+
+ return wrapper
+
class CallbackHolder:
def __init__(self):
@@ -855,11 +862,12 @@
try:
unsigned = not tp._type.SIGNED
except AttributeError:
- if tp in [lltype.Char, lltype.Float, lltype.Signed] or\
- isinstance(tp, lltype.Ptr):
+ if (not isinstance(tp, lltype.Primitive) or
+ tp in (FLOAT, DOUBLE) or
+ cast(lltype.SignedLongLong, cast(tp, -1)) < 0):
unsigned = False
else:
- unsigned = False
+ unsigned = True
return size, unsigned
def sizeof(tp):
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -18,6 +18,7 @@
from pypy.conftest import option
from pypy.objspace.flow.model import summary
from pypy.translator.tool.cbuild import ExternalCompilationInfo
+from pypy.rlib.rarithmetic import r_singlefloat
class BaseTestRffi:
def test_basic(self):
@@ -704,6 +705,14 @@
res = cast(lltype.Signed, 42.5)
assert res == 42
+ res = cast(lltype.SingleFloat, 12.3)
+ assert res == r_singlefloat(12.3)
+ res = cast(lltype.SingleFloat, res)
+ assert res == r_singlefloat(12.3)
+
+ res = cast(lltype.Float, r_singlefloat(12.))
+ assert res == 12.
+
def test_rffi_sizeof(self):
try:
import ctypes
@@ -733,7 +742,7 @@
assert sizeof(ll) == ctypes.sizeof(ctp)
assert sizeof(lltype.Typedef(ll, 'test')) == sizeof(ll)
assert not size_and_sign(lltype.Signed)[1]
- assert not size_and_sign(lltype.Char)[1]
+ assert size_and_sign(lltype.Char) == (1, True)
assert not size_and_sign(lltype.UniChar)[1]
assert size_and_sign(UINT)[1]
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -356,6 +356,32 @@
return extdef([int, str, [str]], int, llimpl=spawnv_llimpl,
export_name="ll_os.ll_os_spawnv")
+ @registering_if(os, 'spawnve')
+ def register_os_spawnve(self):
+ os_spawnve = self.llexternal('spawnve',
+ [rffi.INT, rffi.CCHARP, rffi.CCHARPP,
+ rffi.CCHARPP],
+ rffi.INT)
+
+ def spawnve_llimpl(mode, path, args, env):
+ envstrs = []
+ for item in env.iteritems():
+ envstrs.append("%s=%s" % item)
+
+ mode = rffi.cast(rffi.INT, mode)
+ l_args = rffi.liststr2charpp(args)
+ l_env = rffi.liststr2charpp(envstrs)
+ childpid = os_spawnve(mode, path, l_args, l_env)
+ rffi.free_charpp(l_env)
+ rffi.free_charpp(l_args)
+ if childpid == -1:
+ raise OSError(rposix.get_errno(), "os_spawnve failed")
+ return rffi.cast(lltype.Signed, childpid)
+
+ return extdef([int, str, [str], {str: str}], int,
+ llimpl=spawnve_llimpl,
+ export_name="ll_os.ll_os_spawnve")
+
@registering(os.dup)
def register_os_dup(self):
os_dup = self.llexternal(underscore_on_windows+'dup', [rffi.INT], rffi.INT)
diff --git a/pypy/translator/backendopt/finalizer.py b/pypy/translator/backendopt/finalizer.py
--- a/pypy/translator/backendopt/finalizer.py
+++ b/pypy/translator/backendopt/finalizer.py
@@ -4,7 +4,7 @@
class FinalizerError(Exception):
""" __del__ marked as lightweight finalizer, but the analyzer did
- not agreed
+ not agree
"""
class FinalizerAnalyzer(graphanalyze.BoolGraphAnalyzer):
@@ -23,7 +23,7 @@
def analyze_light_finalizer(self, graph):
result = self.analyze_direct_call(graph)
if (result is self.top_result() and
- getattr(graph.func, '_is_light_finalizer_', False)):
+ getattr(graph.func, '_must_be_light_finalizer_', False)):
raise FinalizerError(FinalizerError.__doc__, graph)
return result
diff --git a/pypy/translator/backendopt/test/test_canraise.py b/pypy/translator/backendopt/test/test_canraise.py
--- a/pypy/translator/backendopt/test/test_canraise.py
+++ b/pypy/translator/backendopt/test/test_canraise.py
@@ -201,6 +201,16 @@
result = ra.can_raise(ggraph.startblock.operations[0])
assert result
+ def test_ll_arraycopy(self):
+ from pypy.rpython.lltypesystem import rffi
+ from pypy.rlib.rgc import ll_arraycopy
+ def f(a, b, c, d, e):
+ ll_arraycopy(a, b, c, d, e)
+ t, ra = self.translate(f, [rffi.CCHARP, rffi.CCHARP, int, int, int])
+ fgraph = graphof(t, f)
+ result = ra.can_raise(fgraph.startblock.operations[0])
+ assert not result
+
class TestOOType(OORtypeMixin, BaseTestCanRaise):
def test_can_raise_recursive(self):
diff --git a/pypy/translator/backendopt/test/test_finalizer.py b/pypy/translator/backendopt/test/test_finalizer.py
--- a/pypy/translator/backendopt/test/test_finalizer.py
+++ b/pypy/translator/backendopt/test/test_finalizer.py
@@ -126,13 +126,13 @@
r = self.analyze(f, [], A.__del__.im_func)
assert r
- def test_is_light_finalizer_decorator(self):
+ def test_must_be_light_finalizer_decorator(self):
S = lltype.GcStruct('S')
- @rgc.is_light_finalizer
+ @rgc.must_be_light_finalizer
def f():
lltype.malloc(S)
- @rgc.is_light_finalizer
+ @rgc.must_be_light_finalizer
def g():
pass
self.analyze(g, []) # did not explode
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -521,13 +521,13 @@
rules = [
('clean', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) $(ASMFILES) *.gc?? ../module_cache/*.gc??'),
('clean_noprof', '', 'rm -f $(OBJECTS) $(TARGET) $(GCMAPFILES) $(ASMFILES)'),
- ('debug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT" $(TARGET)'),
- ('debug_exc', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DDO_LOG_EXC" $(TARGET)'),
- ('debug_mem', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DTRIVIAL_MALLOC_DEBUG" $(TARGET)'),
+ ('debug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT" debug_target'),
+ ('debug_exc', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DDO_LOG_EXC" debug_target'),
+ ('debug_mem', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DTRIVIAL_MALLOC_DEBUG" debug_target'),
('no_obmalloc', '', '$(MAKE) CFLAGS="-g -O2 -DRPY_ASSERT -DNO_OBMALLOC" $(TARGET)'),
- ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" $(TARGET)'),
+ ('linuxmemchk', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DLINUXMEMCHK" debug_target'),
('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(TARGET)'),
- ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" $(TARGET)'),
+ ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'),
('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(TARGET)'),
]
if self.has_profopt():
@@ -554,7 +554,7 @@
mk.definition('ASMLBLFILES', lblsfiles)
mk.definition('GCMAPFILES', gcmapfiles)
if sys.platform == 'win32':
- mk.definition('DEBUGFLAGS', '/Zi')
+ mk.definition('DEBUGFLAGS', '/MD /Zi')
else:
mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
@@ -618,9 +618,13 @@
else:
if sys.platform == 'win32':
- mk.definition('DEBUGFLAGS', '/Zi')
+ mk.definition('DEBUGFLAGS', '/MD /Zi')
else:
mk.definition('DEBUGFLAGS', '-O1 -g')
+ if sys.platform == 'win32':
+ mk.rule('debug_target', 'debugmode_$(DEFAULT_TARGET)', 'rem')
+ else:
+ mk.rule('debug_target', '$(TARGET)', '#')
mk.write()
#self.translator.platform,
# ,
diff --git a/pypy/translator/c/test/test_extfunc.py b/pypy/translator/c/test/test_extfunc.py
--- a/pypy/translator/c/test/test_extfunc.py
+++ b/pypy/translator/c/test/test_extfunc.py
@@ -818,6 +818,24 @@
func()
assert open(filename).read() == "2"
+if hasattr(posix, 'spawnve'):
+ def test_spawnve():
+ filename = str(udir.join('test_spawnve.txt'))
+ progname = str(sys.executable)
+ scriptpath = udir.join('test_spawnve.py')
+ scriptpath.write('import os\n' +
+ 'f=open(%r,"w")\n' % filename +
+ 'f.write(os.environ["FOOBAR"])\n' +
+ 'f.close\n')
+ scriptname = str(scriptpath)
+ def does_stuff():
+ l = [progname, scriptname]
+ pid = os.spawnve(os.P_NOWAIT, progname, l, {'FOOBAR': '42'})
+ os.waitpid(pid, 0)
+ func = compile(does_stuff, [])
+ func()
+ assert open(filename).read() == "42"
+
def test_utime():
path = str(udir.ensure("test_utime.txt"))
from time import time, sleep
diff --git a/pypy/translator/cli/test/test_snippet.py b/pypy/translator/cli/test/test_snippet.py
--- a/pypy/translator/cli/test/test_snippet.py
+++ b/pypy/translator/cli/test/test_snippet.py
@@ -28,14 +28,14 @@
res = self.interpret(fn, [], backendopt=False)
def test_link_vars_overlapping(self):
- from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+ from pypy.rlib.rarithmetic import ovfcheck
def fn(maxofs):
lastofs = 0
ofs = 1
while ofs < maxofs:
lastofs = ofs
try:
- ofs = ovfcheck_lshift(ofs, 1)
+ ofs = ovfcheck(ofs << 1)
except OverflowError:
ofs = maxofs
else:
diff --git a/pypy/translator/platform/__init__.py b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -102,6 +102,8 @@
bits = [self.__class__.__name__, 'cc=%r' % self.cc]
for varname in self.relevant_environ:
bits.append('%s=%r' % (varname, os.environ.get(varname)))
+ # adding sys.maxint to disambiguate windows
+ bits.append('%s=%r' % ('sys.maxint', sys.maxint))
return ' '.join(bits)
# some helpers which seem to be cross-platform enough
@@ -238,10 +240,13 @@
else:
host_factory = Linux64
elif sys.platform == 'darwin':
- from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64
+ from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64, Darwin_PowerPC
import platform
- assert platform.machine() in ('i386', 'x86_64')
- if sys.maxint <= 2147483647:
+ assert platform.machine() in ('Power Macintosh', 'i386', 'x86_64')
+
+ if platform.machine() == 'Power Macintosh':
+ host_factory = Darwin_PowerPC
+ elif sys.maxint <= 2147483647:
host_factory = Darwin_i386
else:
host_factory = Darwin_x86_64
diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py
--- a/pypy/translator/platform/darwin.py
+++ b/pypy/translator/platform/darwin.py
@@ -71,6 +71,11 @@
link_flags = ('-arch', 'i386')
cflags = ('-arch', 'i386', '-O3', '-fomit-frame-pointer')
+class Darwin_PowerPC(Darwin):#xxx fixme, mwp
+ name = "darwin_powerpc"
+ link_flags = ()
+ cflags = ('-O3', '-fomit-frame-pointer')
+
class Darwin_x86_64(Darwin):
name = "darwin_x86_64"
link_flags = ('-arch', 'x86_64')
diff --git a/pypy/translator/platform/test/test_darwin.py b/pypy/translator/platform/test/test_darwin.py
--- a/pypy/translator/platform/test/test_darwin.py
+++ b/pypy/translator/platform/test/test_darwin.py
@@ -7,7 +7,7 @@
py.test.skip("Darwin only")
from pypy.tool.udir import udir
-from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64
+from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64, Darwin_PowerPC
from pypy.translator.platform.test.test_platform import TestPlatform as BasicTest
from pypy.translator.tool.cbuild import ExternalCompilationInfo
@@ -17,7 +17,7 @@
else:
host_factory = Darwin_x86_64
else:
- host_factory = Darwin
+ host_factory = Darwin_PowerPC
class TestDarwin(BasicTest):
platform = host_factory()
diff --git a/pypy/translator/platform/windows.py b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -294,6 +294,9 @@
['$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA) $(OBJECTS) $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS) /MANIFEST /MANIFESTFILE:$*.manifest',
'mt.exe -nologo -manifest $*.manifest -outputresource:$@;1',
])
+ m.rule('debugmode_$(TARGET)', '$(OBJECTS)',
+ ['$(CC_LINK) /nologo /DEBUG $(LDFLAGS) $(LDFLAGSEXTRA) $(OBJECTS) $(LINKFILES) /out:$@ $(LIBDIRS) $(LIBS)',
+ ])
if shared:
m.definition('SHARED_IMPORT_LIB', so_name.new(ext='lib').basename)
@@ -307,6 +310,9 @@
['$(CC_LINK) /nologo main.obj $(SHARED_IMPORT_LIB) /out:$@ /MANIFEST /MANIFESTFILE:$*.manifest',
'mt.exe -nologo -manifest $*.manifest -outputresource:$@;1',
])
+ m.rule('debugmode_$(DEFAULT_TARGET)', ['debugmode_$(TARGET)', 'main.obj'],
+ ['$(CC_LINK) /nologo /DEBUG main.obj $(SHARED_IMPORT_LIB) /out:$@'
+ ])
return m
diff --git a/pypy/translator/simplify.py b/pypy/translator/simplify.py
--- a/pypy/translator/simplify.py
+++ b/pypy/translator/simplify.py
@@ -111,16 +111,13 @@
# the while loop above will simplify recursively the new link
def transform_ovfcheck(graph):
- """The special function calls ovfcheck and ovfcheck_lshift need to
+ """The special function calls ovfcheck needs to
be translated into primitive operations. ovfcheck is called directly
after an operation that should be turned into an overflow-checked
version. It is considered a syntax error if the resulting <op>_ovf
is not defined in objspace/flow/objspace.py.
- ovfcheck_lshift is special because there is no preceding operation.
- Instead, it will be replaced by an OP_LSHIFT_OVF operation.
"""
covf = Constant(rarithmetic.ovfcheck)
- covfls = Constant(rarithmetic.ovfcheck_lshift)
def check_syntax(opname):
exlis = operation.implicit_exceptions.get("%s_ovf" % (opname,), [])
@@ -154,9 +151,6 @@
op1.opname += '_ovf'
del block.operations[i]
block.renamevariables({op.result: op1.result})
- elif op.args[0] == covfls:
- op.opname = 'lshift_ovf'
- del op.args[0]
def simplify_exceptions(graph):
"""The exception handling caused by non-implicit exceptions
diff --git a/pypy/translator/test/snippet.py b/pypy/translator/test/snippet.py
--- a/pypy/translator/test/snippet.py
+++ b/pypy/translator/test/snippet.py
@@ -1210,7 +1210,7 @@
return istk.top(), sstk.top()
-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck
def add_func(i=numtype):
try:
@@ -1253,7 +1253,7 @@
def lshift_func(i=numtype):
try:
hugo(2, 3, 5)
- return ovfcheck_lshift((-maxint-1), i)
+ return ovfcheck((-maxint-1) << i)
except (hugelmugel, OverflowError, StandardError, ValueError):
raise
diff --git a/pypy/translator/test/test_simplify.py b/pypy/translator/test/test_simplify.py
--- a/pypy/translator/test/test_simplify.py
+++ b/pypy/translator/test/test_simplify.py
@@ -42,24 +42,6 @@
assert graph.startblock.operations[0].opname == 'int_mul_ovf'
assert graph.startblock.operations[1].opname == 'int_sub'
-def test_remove_ovfcheck_lshift():
- # check that ovfcheck_lshift() is handled
- from pypy.rlib.rarithmetic import ovfcheck_lshift
- def f(x):
- try:
- return ovfcheck_lshift(x, 2)
- except OverflowError:
- return -42
- graph, _ = translate(f, [int])
- assert len(graph.startblock.operations) == 1
- assert graph.startblock.operations[0].opname == 'int_lshift_ovf'
- assert len(graph.startblock.operations[0].args) == 2
- assert len(graph.startblock.exits) == 2
- assert [link.exitcase for link in graph.startblock.exits] == \
- [None, OverflowError]
- assert [link.target.operations for link in graph.startblock.exits] == \
- [(), ()]
-
def test_remove_ovfcheck_floordiv():
# check that ovfcheck() is handled even if the operation raises
# and catches another exception too, here ZeroDivisionError
More information about the pypy-commit
mailing list