[pypy-commit] pypy win64-stage1: Merge with default
ctismer
noreply at buildbot.pypy.org
Thu Mar 15 23:30:47 CET 2012
Author: Christian Tismer <tismer at stackless.com>
Branch: win64-stage1
Changeset: r53709:e5b7cd3f019a
Date: 2012-03-15 14:55 -0700
http://bitbucket.org/pypy/pypy/changeset/e5b7cd3f019a/
Log: Merge with default
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -47,6 +47,11 @@
def async(self, space):
"Check if this is an exception that should better not be caught."
+ if not space.full_exceptions:
+ # flow objspace does not support such exceptions and more
+ # importantly, raises KeyboardInterrupt if you try to access
+ # space.w_KeyboardInterrupt
+ return False
return (self.match(space, space.w_SystemExit) or
self.match(space, space.w_KeyboardInterrupt))
diff --git a/pypy/jit/backend/llsupport/regalloc.py b/pypy/jit/backend/llsupport/regalloc.py
--- a/pypy/jit/backend/llsupport/regalloc.py
+++ b/pypy/jit/backend/llsupport/regalloc.py
@@ -321,7 +321,7 @@
except KeyError:
pass # 'var' is already not in a register
- def loc(self, box):
+ def loc(self, box, must_exist=False):
""" Return the location of 'box'.
"""
self._check_type(box)
@@ -332,6 +332,8 @@
except KeyError:
if box in self.bindings_to_frame_reg:
return self.frame_reg
+ if must_exist:
+ return self.frame_manager.bindings[box]
return self.frame_manager.loc(box)
def return_constant(self, v, forbidden_vars=[], selected_reg=None):
@@ -360,7 +362,7 @@
self._check_type(v)
if isinstance(v, Const):
return self.return_constant(v, forbidden_vars, selected_reg)
- prev_loc = self.loc(v)
+ prev_loc = self.loc(v, must_exist=True)
if prev_loc is self.frame_reg and selected_reg is None:
return prev_loc
loc = self.force_allocate_reg(v, forbidden_vars, selected_reg,
diff --git a/pypy/jit/backend/llsupport/test/test_regalloc.py b/pypy/jit/backend/llsupport/test/test_regalloc.py
--- a/pypy/jit/backend/llsupport/test/test_regalloc.py
+++ b/pypy/jit/backend/llsupport/test/test_regalloc.py
@@ -1,4 +1,4 @@
-
+import py
from pypy.jit.metainterp.history import BoxInt, ConstInt, BoxFloat, INT, FLOAT
from pypy.jit.backend.llsupport.regalloc import FrameManager
from pypy.jit.backend.llsupport.regalloc import RegisterManager as BaseRegMan
@@ -236,6 +236,16 @@
assert isinstance(loc, FakeFramePos)
assert len(asm.moves) == 1
+ def test_bogus_make_sure_var_in_reg(self):
+ b0, = newboxes(0)
+ longevity = {b0: (0, 1)}
+ fm = TFrameManager()
+ asm = MockAsm()
+ rm = RegisterManager(longevity, frame_manager=fm, assembler=asm)
+ rm.next_instruction()
+ # invalid call to make_sure_var_in_reg(): box unknown so far
+ py.test.raises(KeyError, rm.make_sure_var_in_reg, b0)
+
def test_return_constant(self):
asm = MockAsm()
boxes, longevity = boxes_and_longevity(5)
diff --git a/pypy/jit/backend/x86/support.py b/pypy/jit/backend/x86/support.py
--- a/pypy/jit/backend/x86/support.py
+++ b/pypy/jit/backend/x86/support.py
@@ -36,15 +36,15 @@
# ____________________________________________________________
-if sys.platform == 'win32':
- ensure_sse2_floats = lambda : None
- # XXX check for SSE2 on win32 too
+if WORD == 4:
+ extra = ['-DPYPY_X86_CHECK_SSE2']
else:
- if WORD == 4:
- extra = ['-DPYPY_X86_CHECK_SSE2']
- else:
- extra = []
- ensure_sse2_floats = rffi.llexternal_use_eci(ExternalCompilationInfo(
- compile_extra = ['-msse2', '-mfpmath=sse',
- '-DPYPY_CPU_HAS_STANDARD_PRECISION'] + extra,
- ))
+ extra = []
+
+if sys.platform != 'win32':
+ extra = ['-msse2', '-mfpmath=sse',
+ '-DPYPY_CPU_HAS_STANDARD_PRECISION'] + extra
+
+ensure_sse2_floats = rffi.llexternal_use_eci(ExternalCompilationInfo(
+ compile_extra = extra,
+))
diff --git a/pypy/jit/backend/x86/test/test_zmath.py b/pypy/jit/backend/x86/test/test_zmath.py
--- a/pypy/jit/backend/x86/test/test_zmath.py
+++ b/pypy/jit/backend/x86/test/test_zmath.py
@@ -6,6 +6,8 @@
from pypy.translator.c.test.test_genc import compile
from pypy.jit.backend.x86.support import ensure_sse2_floats
from pypy.rlib import rfloat
+from pypy.rlib.unroll import unrolling_iterable
+from pypy.rlib.debug import debug_print
def get_test_case((fnname, args, expected)):
@@ -16,16 +18,32 @@
expect_valueerror = (expected == ValueError)
expect_overflowerror = (expected == OverflowError)
check = test_direct.get_tester(expected)
+ unroll_args = unrolling_iterable(args)
#
def testfn():
+ debug_print('calling', fnname, 'with arguments:')
+ for arg in unroll_args:
+ debug_print('\t', arg)
try:
got = fn(*args)
except ValueError:
- return expect_valueerror
+ if expect_valueerror:
+ return True
+ else:
+ debug_print('unexpected ValueError!')
+ return False
except OverflowError:
- return expect_overflowerror
+ if expect_overflowerror:
+ return True
+ else:
+ debug_print('unexpected OverflowError!')
+ return False
else:
- return check(got)
+ if check(got):
+ return True
+ else:
+ debug_print('unexpected result:', got)
+ return False
#
testfn.func_name = 'test_' + fnname
return testfn
diff --git a/pypy/module/math/test/test_direct.py b/pypy/module/math/test/test_direct.py
--- a/pypy/module/math/test/test_direct.py
+++ b/pypy/module/math/test/test_direct.py
@@ -59,6 +59,9 @@
('copysign', (1.5, -0.0), -1.5),
('copysign', (1.5, INFINITY), 1.5),
('copysign', (1.5, -INFINITY), -1.5),
+ ]
+ if sys.platform != 'win32': # all NaNs seem to be negative there...?
+ IRREGCASES += [
('copysign', (1.5, NAN), 1.5),
('copysign', (1.75, -NAN), -1.75), # special case for -NAN here
]
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -117,7 +117,7 @@
else:
return Constant(tuple(content))
- def newlist(self, args_w):
+ def newlist(self, args_w, sizehint=None):
if self.concrete_mode:
content = [self.unwrap(w_arg) for w_arg in args_w]
return Constant(content)
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -849,16 +849,25 @@
c.co_filename, c.co_name, c.co_firstlineno,
c.co_lnotab)
+ def patch_opcodes(self, *opcodes):
+ flow_meth_names = flowcontext.FlowSpaceFrame.opcode_method_names
+ pyframe_meth_names = PyFrame.opcode_method_names
+ for name in opcodes:
+ num = bytecode_spec.opmap[name]
+ setattr(self, 'old_' + name, flow_meth_names[num])
+ flow_meth_names[num] = pyframe_meth_names[num]
+
+ def unpatch_opcodes(self, *opcodes):
+ flow_meth_names = flowcontext.FlowSpaceFrame.opcode_method_names
+ for name in opcodes:
+ num = bytecode_spec.opmap[name]
+ flow_meth_names[num] = getattr(self, 'old_' + name)
+
def test_callmethod_opcode(self):
""" Tests code generated by pypy-c compiled with CALL_METHOD
bytecode
"""
- flow_meth_names = flowcontext.FlowSpaceFrame.opcode_method_names
- pyframe_meth_names = PyFrame.opcode_method_names
- for name in ['CALL_METHOD', 'LOOKUP_METHOD']:
- num = bytecode_spec.opmap[name]
- locals()['old_' + name] = flow_meth_names[num]
- flow_meth_names[num] = pyframe_meth_names[num]
+ self.patch_opcodes('CALL_METHOD', 'LOOKUP_METHOD')
try:
class X:
def m(self):
@@ -878,9 +887,29 @@
assert all_ops['simple_call'] == 2
assert all_ops['getattr'] == 1
finally:
- for name in ['CALL_METHOD', 'LOOKUP_METHOD']:
- num = bytecode_spec.opmap[name]
- flow_meth_names[num] = locals()['old_' + name]
+ self.unpatch_opcodes('CALL_METHOD', 'LOOKUP_METHOD')
+
+ def test_build_list_from_arg_opcode(self):
+ """ Tests code generated by pypy-c compiled with BUILD_LIST_FROM_ARG
+ bytecode
+ """
+ self.patch_opcodes('BUILD_LIST_FROM_ARG')
+ try:
+ def f():
+ return [i for i in "abc"]
+
+ # this code is generated by pypy-c when compiling above f
+ pypy_code = 'd\x01\x00\xcb\x00\x00D]\x0c\x00}\x00\x00|\x00\x00^\x02\x00q\x07\x00S'
+ new_c = self.monkey_patch_code(f.func_code, 3, 67, pypy_code, (),
+ ('i',))
+ f2 = new.function(new_c, locals(), 'f')
+
+ graph = self.codetest(f2)
+ all_ops = self.all_operations(graph)
+ assert all_ops == {'newlist': 1, 'getattr': 1, 'simple_call': 1,
+ 'iter': 1, 'next': 1}
+ finally:
+ self.unpatch_opcodes('BUILD_LIST_FROM_ARG')
def test_dont_capture_RuntimeError(self):
class Foo:
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -469,9 +469,6 @@
r_longlong = build_int('r_longlong', True, 64)
r_ulonglong = build_int('r_ulonglong', False, 64)
-r_long = build_int('r_long', True, 32)
-r_ulong = build_int('r_ulong', False, 32)
-
longlongmax = r_longlong(LONGLONG_TEST - 1)
if r_longlong is not r_int:
@@ -480,10 +477,7 @@
r_int64 = int
# needed for ll_os_stat.time_t_to_FILE_TIME in the 64 bit case
-if r_long is not r_int:
- r_uint32 = r_ulong
-else:
- r_uint32 = r_uint
+r_uint32 = build_int('r_uint32', False, 32)
# needed for ll_time.time_sleep_llimpl
maxint32 = int((1 << 31) -1)
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
@@ -84,14 +84,14 @@
else:
PIECESIZE = 0x08000000
PIECES = 10
- flags = 0
+ flags = (0,)
if _LINUX:
flags = (rmmap.MAP_PRIVATE|rmmap.MAP_ANONYMOUS|rmmap.MAP_NORESERVE,
rmmap.PROT_READ|rmmap.PROT_WRITE)
if _MS_WINDOWS:
- flags = rmmap.MEM_RESERVE
+ flags = (rmmap.MEM_RESERVE,)
# XXX seems not to work
- m = rmmap.mmap(-1, PIECES * PIECESIZE, flags)
+ m = rmmap.mmap(-1, PIECES * PIECESIZE, *flags)
m.close = lambda : None # leak instead of giving a spurious
# error at CPython's shutdown
m._ll2ctypes_pieces = []
diff --git a/pypy/translator/c/src/asm.h b/pypy/translator/c/src/asm.h
--- a/pypy/translator/c/src/asm.h
+++ b/pypy/translator/c/src/asm.h
@@ -14,4 +14,8 @@
# include "src/asm_ppc.h"
#endif
+#if defined(MS_WINDOWS) && defined(_MSC_VER)
+# include "src/asm_msvc.h"
+#endif
+
#endif /* _PYPY_ASM_H */
diff --git a/pypy/translator/c/src/asm_msvc.h b/pypy/translator/c/src/asm_msvc.h
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/src/asm_msvc.h
@@ -0,0 +1,31 @@
+
+#ifdef PYPY_X86_CHECK_SSE2
+#define PYPY_X86_CHECK_SSE2_DEFINED
+extern void pypy_x86_check_sse2(void);
+#endif
+
+
+/* implementations */
+
+#ifndef PYPY_NOT_MAIN_FILE
+#ifdef PYPY_X86_CHECK_SSE2
+#include <intrin.h>
+void pypy_x86_check_sse2(void)
+{
+ int features;
+ int CPUInfo[4];
+ CPUInfo[3] = 0;
+ __cpuid(CPUInfo, 1);
+ features = CPUInfo[3];
+
+ //Check bits 25 and 26, this indicates SSE2 support
+ if (((features & (1 << 25)) == 0) || ((features & (1 << 26)) == 0))
+ {
+ fprintf(stderr, "Old CPU with no SSE2 support, cannot continue.\n"
+ "You need to re-translate with "
+ "'--jit-backend=x86-without-sse2'\n");
+ abort();
+ }
+}
+#endif
+#endif
More information about the pypy-commit
mailing list