Author: Richard Plangger <planri...@gmail.com> Branch: ppc-vsx-support Changeset: r86000:8ec827c25980 Date: 2016-08-02 09:29 +0200 http://bitbucket.org/pypy/pypy/changeset/8ec827c25980/
Log: merge default diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -101,3 +101,11 @@ .. branch: jitlog-32bit Resolve issues to use the new logging facility on a 32bit system + +.. branch: ep2016sprint + +Trying harder to make hash(-1) return -2, like it does on CPython + +.. branch: jitlog-exact-source-lines + +Log exact line positions in debug merge points. diff --git a/pypy/module/_jitlog/test/test__jitlog.py b/pypy/module/_jitlog/test/test__jitlog.py --- a/pypy/module/_jitlog/test/test__jitlog.py +++ b/pypy/module/_jitlog/test/test__jitlog.py @@ -1,8 +1,9 @@ - import sys +import platform from rpython.tool.udir import udir from pypy.tool.pytest.objspace import gettestobjspace from rpython.rlib.rjitlog import rjitlog as jl +from rpython.jit.metainterp.resoperation import opname class AppTestJitLog(object): spaceconfig = {'usemodules': ['_jitlog', 'struct']} @@ -12,6 +13,11 @@ cls.w_mark_header = cls.space.wrap(jl.MARK_JITLOG_HEADER) cls.w_version = cls.space.wrap(jl.JITLOG_VERSION_16BIT_LE) cls.w_is_32bit = cls.space.wrap(sys.maxint == 2**31-1) + cls.w_machine = cls.space.wrap(platform.machine()) + cls.w_resops = cls.space.newdict() + space = cls.space + for key, value in opname.items(): + space.setitem(cls.w_resops, space.wrap(key), space.wrap(value)) def test_enable(self): import _jitlog, struct @@ -25,8 +31,22 @@ assert fd.read(1) == self.mark_header assert fd.read(2) == self.version assert bool(ord(fd.read(1))) == self.is_32bit + strcount, = struct.unpack('<i', fd.read(4)) + machine = fd.read(strcount) + assert machine == self.machine + # resoperations count, = struct.unpack('<h', fd.read(2)) + opnames = set() for i in range(count): opnum = struct.unpack('<h', fd.read(2)) - strcount = struct.unpack('<i', fd.read(4)) - fd.read(strcount) + strcount, = struct.unpack('<i', fd.read(4)) + opname = fd.read(strcount) + opnames.append((opnum, opname)) + + for opnum, opname in opnames: + # must be known resoperation + assert opnum in self.resops + # the name must equal + assert self.resops[opnum] == opname + + diff --git a/pypy/module/cpyext/include/pyport.h b/pypy/module/cpyext/include/pyport.h --- a/pypy/module/cpyext/include/pyport.h +++ b/pypy/module/cpyext/include/pyport.h @@ -64,13 +64,6 @@ # error "Python needs a typedef for Py_uintptr_t in pyport.h." #endif /* HAVE_UINTPTR_T */ -/* Py_hash_t is the same size as a pointer. */ -#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T -typedef Py_ssize_t Py_hash_t; -/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */ -#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T -typedef size_t Py_uhash_t; - /******************************* * stat() and fstat() fiddling * diff --git a/pypy/module/cpyext/number.py b/pypy/module/cpyext/number.py --- a/pypy/module/cpyext/number.py +++ b/pypy/module/cpyext/number.py @@ -20,16 +20,12 @@ def PyNumber_Check(space, w_obj): """Returns 1 if the object o provides numeric protocols, and false otherwise. This function always succeeds.""" - try: - space.float_w(w_obj) + # According to CPython, this means: w_obj is not None, and + # the type of w_obj has got a method __int__ or __float__. + if w_obj is None: + return 0 + if space.lookup(w_obj, '__int__') or space.lookup(w_obj, '__float__'): return 1 - except OperationError: - pass - try: - space.int_w(w_obj) - return 1 - except OperationError: - pass return 0 @cpython_api([PyObject, PyObject], Py_ssize_t, error=-1) diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -381,6 +381,7 @@ ('tp_as_number.c_nb_invert', '__invert__'), ('tp_as_number.c_nb_index', '__index__'), ('tp_as_number.c_nb_hex', '__hex__'), + ('tp_as_number.c_nb_oct', '__oct__'), ('tp_str', '__str__'), ('tp_repr', '__repr__'), ('tp_iter', '__iter__'), diff --git a/pypy/module/cpyext/test/test_longobject.py b/pypy/module/cpyext/test/test_longobject.py --- a/pypy/module/cpyext/test/test_longobject.py +++ b/pypy/module/cpyext/test/test_longobject.py @@ -259,8 +259,19 @@ ret = PyLong_FromLong(-1); Py_DECREF(obj); return ret; + """), + ("has_oct", "METH_NOARGS", + """ + PyObject *ret, *obj = PyLong_FromLong(42); + if (obj->ob_type->tp_as_number->nb_oct) + ret = obj->ob_type->tp_as_number->nb_oct(obj); + else + ret = PyLong_FromLong(-1); + Py_DECREF(obj); + return ret; """)]) assert module.has_sub() == 0 assert module.has_pow() == 0 assert module.has_hex() == '0x2aL' + assert module.has_oct() == '052L' diff --git a/pypy/module/cpyext/test/test_number.py b/pypy/module/cpyext/test/test_number.py --- a/pypy/module/cpyext/test/test_number.py +++ b/pypy/module/cpyext/test/test_number.py @@ -15,7 +15,7 @@ assert api.PyNumber_Check(space.wraplong(-12L)) assert api.PyNumber_Check(space.wrap(12.1)) assert not api.PyNumber_Check(space.wrap('12')) - assert not api.PyNumber_Check(space.wrap(1+3j)) + assert api.PyNumber_Check(space.wrap(1+3j)) def test_number_long(self, space, api): w_l = api.PyNumber_Long(space.wrap(123)) @@ -151,7 +151,6 @@ ''' PyObject *obj = PyTuple_GET_ITEM(args, 0); int val = PyNumber_Check(obj); - Py_DECREF(obj); return PyInt_FromLong(val); ''')]) val = mod.test_PyNumber_Check(10) diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -800,7 +800,7 @@ IntLike_Type.tp_as_number = &intlike_as_number; intlike_as_number.nb_nonzero = intlike_nb_nonzero; intlike_as_number.nb_int = intlike_nb_int; - if (PyType_Ready(&IntLike_Type) < 0) return NULL; + PyType_Ready(&IntLike_Type); """) assert not bool(module.newInt(0)) assert bool(module.newInt(1)) diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -46,6 +46,7 @@ jl.MP_SCOPE, jl.MP_INDEX, jl.MP_OPCODE) def get_location(next_instr, is_being_profiled, bytecode): from pypy.tool.stdlib_opcode import opcode_method_names + from rpython.tool.error import offset2lineno bcindex = ord(bytecode.co_code[next_instr]) opname = "" if 0 <= bcindex < len(opcode_method_names): @@ -53,7 +54,8 @@ name = bytecode.co_name if not name: name = "" - return (bytecode.co_filename, bytecode.co_firstlineno, + line = offset2lineno(bytecode, intmask(next_instr)) + return (bytecode.co_filename, line, name, intmask(next_instr), opname) def should_unroll_one_iteration(next_instr, is_being_profiled, bytecode): diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py --- a/pypy/module/thread/os_lock.py +++ b/pypy/module/thread/os_lock.py @@ -26,8 +26,7 @@ elif timeout == -1.0: microseconds = -1 else: - # 0.0 => 0.0, but otherwise tends to round up - timeout = timeout * 1e6 + 0.999 + timeout *= 1e6 try: microseconds = ovfcheck_float_to_longlong(timeout) except OverflowError: diff --git a/pypy/module/thread/test/test_lock.py b/pypy/module/thread/test/test_lock.py --- a/pypy/module/thread/test/test_lock.py +++ b/pypy/module/thread/test/test_lock.py @@ -81,7 +81,7 @@ else: got_ovf = False lock.release() - assert (i, got_ovf) == (i, int(timeout * 1e6 + 0.999) > maxint) + assert (i, got_ovf) == (i, int(timeout * 1e6) > maxint) @py.test.mark.xfail(machine()=='s390x', reason='may fail under heavy load') def test_ping_pong(self): diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -424,29 +424,20 @@ raise oefmt(space.w_TypeError, "'%T' objects are unhashable", w_obj) w_result = space.get_and_call_function(w_hash, w_obj) - w_resulttype = space.type(w_result) # issue 2346 : returns now -2 for hashing -1 like cpython - if space.is_w(w_resulttype, space.w_int): - if space.int_w(w_result) == -1: - return space.wrap(-2) - return w_result - elif space.isinstance_w(w_result, space.w_int): - # be careful about subclasses of 'int'... - int_result = space.int_w(w_result) - if int_result == -1: - int_result == -2 - return space.wrap(int_result) + if space.isinstance_w(w_result, space.w_int): + h = space.int_w(w_result) elif space.isinstance_w(w_result, space.w_long): - # be careful about subclasses of 'long'... bigint = space.bigint_w(w_result) h = bigint.hash() - if h == -1: - h = -2 - return space.wrap(h) else: raise oefmt(space.w_TypeError, "__hash__() should return an int or long") + # turn -1 into -2 without using a condition, which would + # create a potential bridge in the JIT + h -= (h == -1) + return space.wrap(h) def cmp(space, w_v, w_w): 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 @@ -66,17 +66,18 @@ def test_wrap_various_unsigned_types(self): import sys + from rpython.rlib.rarithmetic import r_uint from rpython.rtyper.lltypesystem import lltype, rffi space = self.space value = sys.maxint * 2 - x = rffi.cast(lltype.Unsigned, value) + x = r_uint(value) assert space.eq_w(space.wrap(value), space.wrap(x)) - x = rffi.cast(rffi.UINTPTR_T, value) + x = rffi.cast(rffi.UINTPTR_T, r_uint(value)) assert x > 0 assert space.eq_w(space.wrap(value), space.wrap(x)) value = 60000 - x = rffi.cast(rffi.USHORT, value) + x = rffi.cast(rffi.USHORT, r_uint(value)) assert space.eq_w(space.wrap(value), space.wrap(x)) value = 200 - x = rffi.cast(rffi.UCHAR, value) + x = rffi.cast(rffi.UCHAR, r_uint(value)) assert space.eq_w(space.wrap(value), space.wrap(x)) diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py --- a/pypy/tool/pytest/objspace.py +++ b/pypy/tool/pytest/objspace.py @@ -128,3 +128,5 @@ def is_w(self, obj1, obj2): return obj1 is obj2 + def setitem(self, obj, key, value): + obj[key] = value diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py --- a/rpython/annotator/binaryop.py +++ b/rpython/annotator/binaryop.py @@ -401,6 +401,9 @@ class __extend__(pairtype(SomeString, SomeTuple), pairtype(SomeUnicodeString, SomeTuple)): def mod((s_string, s_tuple)): + if not s_string.is_constant(): + raise AnnotatorError("string formatting requires a constant " + "string/unicode on the left of '%'") is_string = isinstance(s_string, SomeString) is_unicode = isinstance(s_string, SomeUnicodeString) assert is_string or is_unicode diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/test_annrpython.py @@ -4623,6 +4623,14 @@ a = self.RPythonAnnotator() a.build_types(main, [int]) + def test_string_mod_nonconstant(self): + def f(x): + return x % 5 + a = self.RPythonAnnotator() + e = py.test.raises(AnnotatorError, a.build_types, f, [str]) + assert ('string formatting requires a constant string/unicode' + in str(e.value)) + def g(n): return [0, 1, 2, n] diff --git a/rpython/jit/backend/x86/test/test_regloc.py b/rpython/jit/backend/x86/test/test_regloc.py --- a/rpython/jit/backend/x86/test/test_regloc.py +++ b/rpython/jit/backend/x86/test/test_regloc.py @@ -147,7 +147,7 @@ py.test.skip() def test_reuse_scratch_register(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.begin_reuse_scratch_register() cb.MOV(ecx, heap(base_addr)) @@ -167,7 +167,7 @@ # ------------------------------------------------------------ def test_64bit_address_1(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.CMP(ecx, AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr)) # this case is a CMP_rj @@ -181,7 +181,7 @@ assert cb.getvalue() == expected_instructions def test_64bit_address_2(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(ecx, AddressLoc(ImmedLoc(0), edx, 3, base_addr)) # this case is a CMP_ra @@ -195,7 +195,7 @@ assert cb.getvalue() == expected_instructions def test_64bit_address_3(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(ecx, AddressLoc(edx, ImmedLoc(0), 0, base_addr)) # this case is a CMP_rm @@ -211,7 +211,7 @@ assert cb.getvalue() == expected_instructions def test_64bit_address_4(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.begin_reuse_scratch_register() assert cb._reuse_scratch_register is True @@ -234,7 +234,7 @@ # ------------------------------------------------------------ def test_MOV_64bit_constant_into_r11(self): - base_constant = 0xFEDCBA9876543210 + base_constant = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(r11, imm(base_constant)) @@ -245,7 +245,7 @@ assert cb.getvalue() == expected_instructions def test_MOV_64bit_constant_into_rax(self): - base_constant = 0xFEDCBA9876543210 + base_constant = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(eax, imm(base_constant)) @@ -256,7 +256,7 @@ assert cb.getvalue() == expected_instructions def test_MOV_64bit_address_into_r11(self): - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(r11, heap(base_addr)) @@ -270,7 +270,7 @@ def test_MOV_immed32_into_64bit_address_1(self): immed = -0x01234567 - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr), ImmedLoc(immed)) @@ -286,7 +286,7 @@ def test_MOV_immed32_into_64bit_address_2(self): immed = -0x01234567 - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr), ImmedLoc(immed)) @@ -302,7 +302,7 @@ def test_MOV_immed32_into_64bit_address_3(self): immed = -0x01234567 - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(edx, ImmedLoc(0), 0, base_addr), ImmedLoc(immed)) @@ -320,7 +320,7 @@ def test_MOV_immed32_into_64bit_address_4(self): immed = -0x01234567 - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(edx, esi, 2, base_addr), ImmedLoc(immed)) # this case is a MOV_ai @@ -339,7 +339,7 @@ def test_MOV_immed64_into_64bit_address_1(self): immed = 0x0123456789ABCDEF - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr), ImmedLoc(immed)) @@ -361,7 +361,7 @@ def test_MOV_immed64_into_64bit_address_2(self): immed = 0x0123456789ABCDEF - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr), ImmedLoc(immed)) @@ -383,7 +383,7 @@ def test_MOV_immed64_into_64bit_address_3(self): immed = 0x0123456789ABCDEF - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(eax, ImmedLoc(0), 0, base_addr), ImmedLoc(immed)) @@ -407,7 +407,7 @@ def test_MOV_immed64_into_64bit_address_4(self): immed = 0x0123456789ABCDEF - base_addr = 0xFEDCBA9876543210 + base_addr = intmask(0xFEDCBA9876543210) cb = LocationCodeBuilder64() cb.MOV(AddressLoc(edx, eax, 2, base_addr), ImmedLoc(immed)) # this case is a MOV_ai diff --git a/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py b/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py --- a/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py +++ b/rpython/jit/backend/x86/test/test_ztranslation_call_assembler.py @@ -4,6 +4,16 @@ from rpython.jit.backend.x86.arch import WORD import sys + +# On Windows, this test crashes obscurely, but only if compiled with +# Boehm, not if run with no GC at all. So for now we'll assume it is +# really a Boehm bug, or maybe a Boehm-on-Windows-specific issue, and +# skip. +if sys.platform == 'win32': + import py + py.test.skip("crashes on Windows (Boehm issue?)") + + class TestTranslationCallAssemblerX86(TranslationTestCallAssembler): def _check_cbuilder(self, cbuilder): #We assume here that we have sse2. If not, the CPUClass diff --git a/rpython/jit/backend/zarch/test/test_assembler.py b/rpython/jit/backend/zarch/test/test_assembler.py --- a/rpython/jit/backend/zarch/test/test_assembler.py +++ b/rpython/jit/backend/zarch/test/test_assembler.py @@ -21,6 +21,7 @@ from rpython.rlib.debug import ll_assert from rpython.rlib.longlong2float import (float2longlong, DOUBLE_ARRAY_PTR, singlefloat2uint_emulator) +from rpython.rlib.rarithmetic import r_uint, intmask import ctypes CPU = getcpuclass() @@ -168,7 +169,7 @@ def test_load_byte_zero_extend(self): adr = self.a.datablockwrapper.malloc_aligned(16, 16) data = rffi.cast(rffi.CArrayPtr(rffi.ULONG), adr) - data[0] = rffi.cast(rffi.ULONG,0xffffFFFFffffFF02) + data[0] = rffi.cast(rffi.ULONG, intmask(0xffffFFFFffffFF02)) self.a.mc.load_imm(r.r3, adr+7) self.a.mc.LLGC(r.r2, loc.addr(0,r.r3)) self.a.mc.BCR(con.ANY, r.r14) @@ -177,7 +178,7 @@ def test_load_byte_and_imm(self): adr = self.a.datablockwrapper.malloc_aligned(16, 16) data = rffi.cast(rffi.CArrayPtr(rffi.ULONG), adr) - data[0] = rffi.cast(rffi.ULONG,0xffffFFFFffff0001) + data[0] = rffi.cast(rffi.ULONG, intmask(0xffffFFFFffff0001)) self.a.mc.load_imm(r.r3, adr) self.a.mc.LG(r.r2, loc.addr(0,r.r3)) self.a.mc.LLGC(r.r2, loc.addr(7,r.r3)) diff --git a/rpython/jit/metainterp/test/test_fficall.py b/rpython/jit/metainterp/test/test_fficall.py --- a/rpython/jit/metainterp/test/test_fficall.py +++ b/rpython/jit/metainterp/test/test_fficall.py @@ -11,7 +11,7 @@ from rpython.rlib.jit_libffi import (types, CIF_DESCRIPTION, FFI_TYPE_PP, jit_ffi_call) from rpython.rlib.unroll import unrolling_iterable -from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat +from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat, r_uint from rpython.rlib.longlong2float import float2longlong def get_description(atypes, rtype): @@ -230,8 +230,8 @@ def test_handle_unsigned(self): self._run([types.ulong], types.ulong, - [rffi.cast(rffi.ULONG, sys.maxint + 91348)], - rffi.cast(rffi.ULONG, sys.maxint + 4242)) + [rffi.cast(rffi.ULONG, r_uint(sys.maxint + 91348))], + rffi.cast(rffi.ULONG, r_uint(sys.maxint + 4242))) def test_handle_unsignedchar(self): self._run([types.uint8], types.uint8, diff --git a/rpython/jit/metainterp/test/test_memmgr.py b/rpython/jit/metainterp/test/test_memmgr.py --- a/rpython/jit/metainterp/test/test_memmgr.py +++ b/rpython/jit/metainterp/test/test_memmgr.py @@ -248,8 +248,8 @@ tokens = [t() for t in get_stats().jitcell_token_wrefs] # Some loops have been freed assert None in tokens - # Loop with number 0, h(), has not been freed - assert 0 in [t.number for t in tokens if t] + # Loop with number 1, h(), has not been freed + assert 1 in [t.number for t in tokens if t] # ____________________________________________________________ diff --git a/rpython/jit/tl/tla/targettla.py b/rpython/jit/tl/tla/targettla.py --- a/rpython/jit/tl/tla/targettla.py +++ b/rpython/jit/tl/tla/targettla.py @@ -4,9 +4,16 @@ def entry_point(args): - """Main entry point of the stand-alone executable: - takes a list of strings and returns the exit code. - """ + for i in range(len(argv)): + if argv[i] == "--jit": + if len(argv) == i + 1: + print "missing argument after --jit" + return 2 + jitarg = argv[i + 1] + del argv[i:i+2] + jit.set_user_param(jitdriver, jitarg) + break + if len(args) < 3: print "Usage: %s filename x" % (args[0],) return 2 @@ -26,7 +33,7 @@ return bytecode def target(driver, args): - return entry_point, None + return entry_point # ____________________________________________________________ diff --git a/rpython/jit/tl/tla/tla.py b/rpython/jit/tl/tla/tla.py --- a/rpython/jit/tl/tla/tla.py +++ b/rpython/jit/tl/tla/tla.py @@ -60,19 +60,34 @@ # ____________________________________________________________ -CONST_INT = 1 -POP = 2 -ADD = 3 -RETURN = 4 -JUMP_IF = 5 -DUP = 6 -SUB = 7 -NEWSTR = 8 +OPNAMES = [] +HASARG = [] + +def define_op(name, has_arg=False): + globals()[name] = len(OPNAMES) + OPNAMES.append(name) + HASARG.append(has_arg) + +define_op("CONST_INT", True) +define_op("POP") +define_op("ADD") +define_op("RETURN") +define_op("JUMP_IF", True) +define_op("DUP") +define_op("SUB") +define_op("NEWSTR", True) + # ____________________________________________________________ def get_printable_location(pc, bytecode): - return str(pc) + op = ord(bytecode[pc]) + name = OPNAMES[op] + if HASARG[op]: + arg = str(ord(bytecode[pc + 1])) + else: + arg = '' + return "%s: %s %s" % (pc, name, arg) jitdriver = JitDriver(greens=['pc', 'bytecode'], reds=['self'], diff --git a/rpython/rlib/rjitlog/rjitlog.py b/rpython/rlib/rjitlog/rjitlog.py --- a/rpython/rlib/rjitlog/rjitlog.py +++ b/rpython/rlib/rjitlog/rjitlog.py @@ -3,6 +3,7 @@ import weakref import struct import os +import platform from rpython.rlib import jit from rpython.tool.udir import udir from rpython.tool.version import rpythonroot @@ -282,14 +283,16 @@ IS_32_BIT = sys.maxint == 2**31-1 +MACHINE_NAME = platform.machine() + def assemble_header(): version = JITLOG_VERSION_16BIT_LE count = len(resoperations.opname) is_32bit = chr(0x1) if not IS_32_BIT: is_32bit = chr(0x0) - content = [version, is_32bit, MARK_RESOP_META, - encode_le_16bit(count)] + content = [version, is_32bit, encode_str(MACHINE_NAME), + MARK_RESOP_META, encode_le_16bit(count)] for opnum, opname in resoperations.opname.items(): content.append(encode_le_16bit(opnum)) content.append(encode_str(opname.lower())) diff --git a/rpython/rlib/test/test_rarithmetic.py b/rpython/rlib/test/test_rarithmetic.py --- a/rpython/rlib/test/test_rarithmetic.py +++ b/rpython/rlib/test/test_rarithmetic.py @@ -404,6 +404,8 @@ def test_int_c_div_mod(x, y): assert int_c_div(~x, y) == -(abs(~x) // y) assert int_c_div( x,-y) == -(x // y) + if (x, y) == (sys.maxint, 1): + py.test.skip("would overflow") assert int_c_div(~x,-y) == +(abs(~x) // y) for x1 in [x, ~x]: for y1 in [y, -y]: diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py --- a/rpython/rtyper/lltypesystem/lltype.py +++ b/rpython/rtyper/lltypesystem/lltype.py @@ -812,8 +812,10 @@ if tp is long: if -maxint-1 <= val <= maxint: return Signed + elif longlongmask(val) == val: + return SignedLongLong else: - return SignedLongLong + raise OverflowError("integer %r is out of bounds" % (val,)) if tp is bool: return Bool if issubclass(tp, base_int): diff --git a/rpython/rtyper/rrange.py b/rpython/rtyper/rrange.py --- a/rpython/rtyper/rrange.py +++ b/rpython/rtyper/rrange.py @@ -199,8 +199,11 @@ self.r_baseiter = r_baseiter self.lowleveltype = r_baseiter.lowleveltype # only supports for now enumerate() on sequence types whose iterators - # have a method ll_getnextindex. It's easy to add one for most - # iterator types, but I didn't do it so far. + # have a method ll_getnextindex. It could be added for most + # iterator types, but it's a bit messy for no clear benefit. + if not hasattr(r_baseiter, 'll_getnextindex'): + raise TyperError("not implemented for now: enumerate(x) where x " + "is not a regular list (got %r)" % (r_baseiter,)) self.ll_getnextindex = r_baseiter.ll_getnextindex def rtype_next(self, hop): diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py --- a/rpython/rtyper/rstr.py +++ b/rpython/rtyper/rstr.py @@ -591,7 +591,9 @@ class __extend__(pairtype(IntegerRepr, AbstractStringRepr)): def rtype_mul((r_int, r_str), hop): - return pair(r_str, r_int).rtype_mul(hop) + str_repr = r_str.repr + v_int, v_str = hop.inputargs(Signed, str_repr) + return hop.gendirectcall(r_str.ll.ll_str_mul, v_str, v_int) rtype_inplace_mul = rtype_mul diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py --- a/rpython/rtyper/test/test_rstr.py +++ b/rpython/rtyper/test/test_rstr.py @@ -220,11 +220,12 @@ const = self.const def fn(i, mul): s = ["", "a", "aba"][i] - return s * mul + return s * mul + mul * s for i in xrange(3): for m in [0, 1, 4]: + res1 = fn(i, m) res = self.interpret(fn, [i, m]) - assert self.ll_to_string(res) == fn(i, m) + assert self.ll_to_string(res) == res1 def test_is_none(self): const = self.const diff --git a/rpython/tool/error.py b/rpython/tool/error.py --- a/rpython/tool/error.py +++ b/rpython/tool/error.py @@ -158,6 +158,8 @@ @jit.elidable def offset2lineno(c, stopat): + # even position in lnotab denote byte increments, odd line increments. + # see dis.findlinestarts in the python std. library for more details tab = c.co_lnotab line = c.co_firstlineno addr = 0 diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -422,14 +422,11 @@ mk.definition('PROFOPT', profopt) rules = [ - ('clean', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) $(GCMAPFILES) $(ASMFILES) *.gc?? ../module_cache/*.gc??'), - ('clean_noprof', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) $(GCMAPFILES) $(ASMFILES)'), ('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 -DPYPY_USE_TRIVIAL_MALLOC" debug_target'), ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(DEFAULT_TARGET)'), ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'), - ('lldebug0','', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -O0 -DMAX_STACK_SIZE=8192000 -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'), ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(DEFAULT_TARGET)'), ] if self.has_profopt(): @@ -443,6 +440,17 @@ for rule in rules: mk.rule(*rule) + if self.translator.platform.name == 'msvc': + mk.rule('lldebug0','', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -Od -DMAX_STACK_SIZE=8192000 -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'), + wildcards = '..\*.obj ..\*.pdb ..\*.lib ..\*.dll ..\*.manifest ..\*.exp *.pch' + cmd = r'del /s %s $(DEFAULT_TARGET) $(TARGET) $(GCMAPFILES) $(ASMFILES)' % wildcards + mk.rule('clean', '', cmd + ' *.gc?? ..\module_cache\*.gc??') + mk.rule('clean_noprof', '', cmd) + else: + mk.rule('lldebug0','', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -O0 -DMAX_STACK_SIZE=8192000 -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'), + mk.rule('clean', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) $(GCMAPFILES) $(ASMFILES) *.gc?? ../module_cache/*.gc??') + mk.rule('clean_noprof', '', 'rm -f $(OBJECTS) $(DEFAULT_TARGET) $(TARGET) $(GCMAPFILES) $(ASMFILES)') + #XXX: this conditional part is not tested at all if self.config.translation.gcrootfinder == 'asmgcc': if self.translator.platform.name == 'msvc': @@ -507,7 +515,7 @@ else: mk.definition('DEBUGFLAGS', '-O1 -g') if self.translator.platform.name == 'msvc': - mk.rule('debug_target', '$(DEFAULT_TARGET)', 'rem') + mk.rule('debug_target', '$(DEFAULT_TARGET) $(WTARGET)', 'rem') else: mk.rule('debug_target', '$(DEFAULT_TARGET)', '#') mk.write() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit