[pypy-commit] pypy py3k: attempt to adapt missing parts of 29d14733e007 to cffi
Author: Philip JenveyBranch: py3k Changeset: r87301:16035fa70024 Date: 2016-09-21 20:00 -0700 http://bitbucket.org/pypy/pypy/changeset/16035fa70024/ Log:attempt to adapt missing parts of 29d14733e007 to cffi diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py --- a/lib_pypy/_pypy_winbase_build.py +++ b/lib_pypy/_pypy_winbase_build.py @@ -83,6 +83,7 @@ BOOL WINAPI GetExitCodeProcess(HANDLE, LPDWORD); BOOL WINAPI TerminateProcess(HANDLE, UINT); HANDLE WINAPI GetStdHandle(DWORD); +DWORD WINAPI GetModuleFileNameW(HANDLE, wchar_t *, DWORD); """) # diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py --- a/lib_pypy/_winapi.py +++ b/lib_pypy/_winapi.py @@ -162,18 +162,19 @@ return int(_ffi.cast("intptr_t", res)) def CloseHandle(handle): -res = _CloseHandle(handle) +res = _kernel32.CloseHandle(_ffi.cast("HANDLE", handle)) if not res: raise _WinError() def GetModuleFileName(module): -buf = ctypes.create_unicode_buffer(_MAX_PATH) -res = _GetModuleFileNameW(module, buf, _MAX_PATH) +buf = _ffi.new("wchar_t[]", _MAX_PATH) +res = _kernel32.GetModuleFileNameW(_ffi.cast("HANDLE", module), + buf, _MAX_PATH) if not res: raise _WinError() -return buf.value +return _ffi.string(buf) STD_INPUT_HANDLE = -10 STD_OUTPUT_HANDLE = -11 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix many tests in module/_ssl
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87300:d58ded0f71fb Date: 2016-09-22 03:08 +0200 http://bitbucket.org/pypy/pypy/changeset/d58ded0f71fb/ Log:Fix many tests in module/_ssl diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py --- a/pypy/module/_ssl/interp_ssl.py +++ b/pypy/module/_ssl/interp_ssl.py @@ -311,7 +311,8 @@ class SSLSocket(W_Root): -def __init__(self, space): +def __init__(self, space, w_ctx): +self.w_ctx = w_ctx self.w_socket = None self.ssl = lltype.nullptr(SSL.TO) self.peer_cert = lltype.nullptr(X509.TO) @@ -691,6 +692,16 @@ self.w_ctx = w_ctx libssl_SSL_set_SSL_CTX(self.ssl, ctx.ctx) +def descr_get_owner(self, space): +if self.w_owner: +w_owner = self.w_owner() +if w_owner: +return w_owner +return space.w_None + +def descr_set_owner(self, space, w_owner): +self.w_owner = weakref.ref(w_owner) + SSLSocket.typedef = TypeDef("_ssl._SSLSocket", write = interp2app(SSLSocket.write), @@ -707,6 +718,8 @@ tls_unique_cb = interp2app(SSLSocket.tls_unique_cb_w), context=GetSetProperty(SSLSocket.descr_get_context, SSLSocket.descr_set_context), +owner=GetSetProperty(SSLSocket.descr_get_owner, + SSLSocket.descr_set_owner), ) def _certificate_to_der(space, certificate): @@ -999,14 +1012,14 @@ libssl_sk_DIST_POINT_free(dps) return space.newtuple(cdp_w[:]) -def new_sslobject(space, ctx, w_sock, side, server_hostname): -ss = SSLSocket(space) +def new_sslobject(space, w_ctx, w_sock, side, server_hostname): +ss = SSLSocket(space, w_ctx) sock_fd = space.int_w(space.call_method(w_sock, "fileno")) w_timeout = space.call_method(w_sock, "gettimeout") has_timeout = not space.is_none(w_timeout) -ss.ssl = libssl_SSL_new(ctx) # new ssl struct +ss.ssl = libssl_SSL_new(w_ctx.ctx) # new ssl struct libssl_SSL_set_fd(ss.ssl, sock_fd) # set the socket for SSL # The ACCEPT_MOVING_WRITE_BUFFER flag is necessary because the address # of a str object may be changed by the garbage collector. @@ -1261,7 +1274,20 @@ index = rffi.cast(lltype.Signed, libssl_SSL_get_app_data(ssl)) w_ssl = SOCKET_STORAGE.get(index) assert isinstance(w_ssl, SSLSocket) -w_ssl_socket = w_ssl # So far. Need to change in 3.3. +# The servername callback expects an argument that represents the current +# SSL connection and that has a .context attribute that can be changed to +# identify the requested hostname. Since the official API is the Python +# level API we want to pass the callback a Python level object rather than +# a _ssl.SSLSocket instance. If there's an "owner" (typically an +# SSLObject) that will be passed. Otherwise if there's a socket then that +# will be passed. If both do not exist only then the C-level object is +# passed. +if w_ssl.w_owner: +w_ssl_socket = w_ssl.w_owner() +elif w_ssl.w_socket: +w_ssl_socket = w_ssl.w_socket() +else: +w_ssl_socket = w_ssl if space.is_none(w_ssl_socket): ad[0] = rffi.cast(rffi.INT, SSL_AD_INTERNAL_ERROR) return rffi.cast(rffi.INT, SSL_TLSEXT_ERR_ALERT_FATAL) @@ -1392,7 +1418,7 @@ "server_hostname is not supported by your OpenSSL " "library") -return new_sslobject(space, self.ctx, w_sock, server_side, hostname) +return new_sslobject(space, self, w_sock, server_side, hostname) def session_stats_w(self, space): w_stats = space.newdict() @@ -1796,9 +1822,8 @@ SSLContext.descr_set_verify_mode), verify_flags=GetSetProperty(SSLContext.descr_get_verify_flags, SSLContext.descr_set_verify_flags), -# XXX: For use by 3.4 ssl.py only -#check_hostname=GetSetProperty(SSLContext.descr_get_check_hostname, -# SSLContext.descr_set_check_hostname), +check_hostname=GetSetProperty(SSLContext.descr_get_check_hostname, + SSLContext.descr_set_check_hostname), ) diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py --- a/pypy/module/_ssl/test/test_ssl.py +++ b/pypy/module/_ssl/test/test_ssl.py @@ -428,7 +428,7 @@ class AppTestSSLError: spaceconfig = dict(usemodules=('_ssl', '_socket', 'binascii', 'thread', - 'struct')) + 'struct', 'select')) def setup_class(cls): tmpfile = udir / "tmpfile.pem" ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Add a minimal _ssl.MemoryBIO to allow "import ssl"
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87299:3c1b46d02aad Date: 2016-09-22 02:41 +0200 http://bitbucket.org/pypy/pypy/changeset/3c1b46d02aad/ Log:Add a minimal _ssl.MemoryBIO to allow "import ssl" diff --git a/pypy/module/_ssl/__init__.py b/pypy/module/_ssl/__init__.py --- a/pypy/module/_ssl/__init__.py +++ b/pypy/module/_ssl/__init__.py @@ -22,6 +22,7 @@ '_SSLSocket': 'interp_ssl.SSLSocket', '_SSLContext': 'interp_ssl.SSLContext', +'MemoryBIO': 'interp_ssl.MemoryBIO', } if sys.platform == 'win32': diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py --- a/pypy/module/_ssl/interp_ssl.py +++ b/pypy/module/_ssl/interp_ssl.py @@ -1858,3 +1858,10 @@ w_convert_path(space, libssl_X509_get_default_cert_dir_env()), w_convert_path(space, libssl_X509_get_default_cert_dir()), ]) + + +class MemoryBIO(W_Root): +pass +MemoryBIO.typedef = TypeDef( +"_ssl.MemoryBIO", +) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: socket.py now depends on the 'select' module.
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87298:09b437dc07a9 Date: 2016-09-22 02:35 +0200 http://bitbucket.org/pypy/pypy/changeset/09b437dc07a9/ Log:socket.py now depends on the 'select' module. diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py --- a/pypy/module/_socket/test/test_sock_app.py +++ b/pypy/module/_socket/test/test_sock_app.py @@ -300,7 +300,7 @@ class AppTestSocket: -spaceconfig = dict(usemodules=['_socket', '_weakref', 'struct']) +spaceconfig = dict(usemodules=['_socket', '_weakref', 'struct', 'select']) def setup_class(cls): cls.space = space @@ -726,7 +726,7 @@ class AppTestSocketTCP: HOST = 'localhost' -spaceconfig = {'usemodules': ['_socket', 'array']} +spaceconfig = {'usemodules': ['_socket', 'array', 'select']} def setup_method(self, method): w_HOST = self.space.wrap(self.HOST) @@ -870,7 +870,7 @@ class AppTestErrno: -spaceconfig = {'usemodules': ['_socket']} +spaceconfig = {'usemodules': ['_socket', 'select']} def test_errno(self): from socket import socket, AF_INET, SOCK_STREAM, error diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py --- a/pypy/module/_ssl/test/test_ssl.py +++ b/pypy/module/_ssl/test/test_ssl.py @@ -2,7 +2,8 @@ import os class AppTestSSL: -spaceconfig = dict(usemodules=('_ssl', '_socket', 'struct', 'binascii', 'thread')) +spaceconfig = dict(usemodules=('_ssl', '_socket', 'select', 'struct', + 'binascii', 'thread')) def setup_class(cls): cls.w_nullbytecert = cls.space.wrap(os.path.join( @@ -154,7 +155,7 @@ class AppTestConnectedSSL: spaceconfig = { "usemodules": ['_ssl', '_socket', 'struct', 'array', 'binascii', - 'unicodedata'], + 'unicodedata', 'select'], } def setup_method(self, method): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Add memoryview.nbytes.
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87297:0dd312748a34 Date: 2016-09-22 02:23 +0200 http://bitbucket.org/pypy/pypy/changeset/0dd312748a34/ Log:Add memoryview.nbytes. diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py --- a/pypy/objspace/std/memoryobject.py +++ b/pypy/objspace/std/memoryobject.py @@ -387,6 +387,10 @@ self._check_released(space) return space.wrap(self.getlength()) +def w_get_nbytes(self, space): +self._check_released(space) +return space.wrap(self.buf.getlength()) + def w_get_format(self, space): self._check_released(space) return space.wrap(self.getformat()) @@ -684,6 +688,7 @@ format = GetSetProperty(W_MemoryView.w_get_format), itemsize= GetSetProperty(W_MemoryView.w_get_itemsize), ndim= GetSetProperty(W_MemoryView.w_get_ndim), +nbytes= GetSetProperty(W_MemoryView.w_get_nbytes), readonly= GetSetProperty(W_MemoryView.w_is_readonly), shape = GetSetProperty(W_MemoryView.w_get_shape), strides = GetSetProperty(W_MemoryView.w_get_strides), diff --git a/pypy/objspace/std/test/test_memoryobject.py b/pypy/objspace/std/test/test_memoryobject.py --- a/pypy/objspace/std/test/test_memoryobject.py +++ b/pypy/objspace/std/test/test_memoryobject.py @@ -55,6 +55,7 @@ assert v.shape == (100,) assert v.ndim == 1 assert v.strides == (1,) +assert v.nbytes == 100 def test_suboffsets(self): v = memoryview(b"a"*100) @@ -127,6 +128,7 @@ raises(ValueError, "v[0]") raises(ValueError, "v[0] = b'a'") raises(ValueError, "v.format") +raises(ValueError, "v.nbytes") raises(ValueError, "v.itemsize") raises(ValueError, "v.ndim") raises(ValueError, "v.readonly") @@ -155,6 +157,7 @@ assert len(m) == 10 assert m.shape == (10,) assert len(m.tobytes()) == 40 +assert m.nbytes == 40 assert m[0] == 0 m[0] = 1 assert m[0] == 1 @@ -167,6 +170,7 @@ assert slice.itemsize == 4 assert len(slice) == 6 assert len(slice.tobytes()) == 24 +assert slice.nbytes == 24 assert slice[0] == 2 slice[0] = 1 assert slice[0] == 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix tests for audioop.byteswap(), and test_wave passes.
Author: Amaury Forgeot d'ArcBranch: py3.5 Changeset: r87296:f7828bc4b08d Date: 2016-09-22 01:38 +0200 http://bitbucket.org/pypy/pypy/changeset/f7828bc4b08d/ Log:Fix tests for audioop.byteswap(), and test_wave passes. diff --git a/lib_pypy/audioop.py b/lib_pypy/audioop.py --- a/lib_pypy/audioop.py +++ b/lib_pypy/audioop.py @@ -592,4 +592,5 @@ rv[i] = cp[base] if base == next_bump: base += bump +next_bump += size return ffi.buffer(rv)[:] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Add some missing _immutable_fields_ annotations for BuiltinCode objects
Author: Spenser BaumanBranch: value-classes Changeset: r87295:659c9d93b42d Date: 2016-09-21 18:26 -0400 http://bitbucket.org/pypy/pypy/changeset/659c9d93b42d/ Log:Add some missing _immutable_fields_ annotations for BuiltinCode objects diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -786,6 +786,8 @@ class BuiltinCode1(BuiltinCode): fast_natural_arity = 1 +_immutable_fields_ = ['fastfunc_1'] + def fastcall_1(self, space, w_func, w1): try: w_result = self.fastfunc_1(space, w1) @@ -805,6 +807,8 @@ class BuiltinCode2(BuiltinCode): fast_natural_arity = 2 +_immutable_fields_ = ['fastfunc_2'] + def fastcall_2(self, space, w_func, w1, w2): try: w_result = self.fastfunc_2(space, w1, w2) @@ -824,6 +828,8 @@ class BuiltinCode3(BuiltinCode): fast_natural_arity = 3 +_immutable_fields_ = ['fastfunc_3'] + def fastcall_3(self, space, func, w1, w2, w3): try: w_result = self.fastfunc_3(space, w1, w2, w3) @@ -843,6 +849,8 @@ class BuiltinCode4(BuiltinCode): fast_natural_arity = 4 +_immutable_fields_ = ['fastfunc_4'] + def fastcall_4(self, space, func, w1, w2, w3, w4): try: w_result = self.fastfunc_4(space, w1, w2, w3, w4) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Remove again unused import
Author: Armin RigoBranch: Changeset: r87294:b96f8757abef Date: 2016-09-21 22:33 +0200 http://bitbucket.org/pypy/pypy/changeset/b96f8757abef/ Log:Remove again unused import diff --git a/rpython/jit/backend/test/zll_stress.py b/rpython/jit/backend/test/zll_stress.py --- a/rpython/jit/backend/test/zll_stress.py +++ b/rpython/jit/backend/test/zll_stress.py @@ -1,7 +1,6 @@ from rpython.jit.backend.test.test_random import check_random_function, Random from rpython.jit.backend.test.test_ll_random import LLtypeOperationBuilder from rpython.jit.backend.detect_cpu import getcpuclass -from rpython.jit.metainterp.resoperation import rop import platform CPU = getcpuclass() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Armin RigoBranch: py3k Changeset: r87293:f854ee56f616 Date: 2016-09-21 22:33 +0200 http://bitbucket.org/pypy/pypy/changeset/f854ee56f616/ Log:hg merge default diff --git a/rpython/doc/jit/backend.rst b/rpython/doc/jit/backend.rst new file mode 100644 --- /dev/null +++ b/rpython/doc/jit/backend.rst @@ -0,0 +1,263 @@ += +PyPy's assembler backends += + +Draft notes about the organization of assembler backends in the PyPy JIT, in 2016 += + + +input: linear sequence of instructions, called a "trace". + +A trace is a sequence of instructions in SSA form. Most instructions +correspond to one or a few CPU-level instructions. There are a few +meta-instructions like `label` and debugging stuff. All branching is +done with guards, which are instructions that check that a condition is +true and exit the trace if not. A failing guard can have a new trace +added to it later, called a "bridge". A patched guard becomes a direct +`Jcond` instruction going to the bridge, with no indirection, no +register spilling, etc. + +A trace ends with either a `return` or a `jump to label`. The target +label is either inside the same trace, or in some older one. For +historical reasons we call a "loop" a trace that is not a bridge. The +machine code that we generate is organized as a forest of trees; the +trunk of the tree is a "loop", and the branches are all bridges +(branching off the trunk or off another branch). + +* every trunk or branch that ends in a `jump to label` can target a + label from a different tree, too. + +* the whole process of assembling a loop or a branch is basically + single-threaded, so no synchronization issue there (including to patch + older generated instructions). + +* the generated assembler has got a "frame" in %rbp, which is actually + not on the stack at all, but is a GC object (called a "jitframe"). + Spilling goes there. + +* the guards are `Jcond` to a very small piece of generated code, which + is basically pushing a couple of constants on the stack and then + jumping to the general guard-recovery code. That code will save the + registers into the jitframe and then exit the whole generated + function. The caller of that generated function checks how it + finished: if it finished by hitting a guard, then the caller is + responsible for calling the "blackhole interpreter". This is the part + of the front-end that recovers from failing guards and finishes + running the frame (including, possibly, by jumping again into + generated assembler). + + +Details about the JITting process: + +* front-end and optimization pass + +* rewrite (includes gc related transformation as well as simplifactions) + +* assembler generation + + +Front-end and optimization pass +--- + +Not discussed here in detail. This produces loops and bridges using an +instruction set that is "high-level" in some sense: it contains +intructions like "new"/"new_array", and +"setfield"/"setarrayitem"/"setinteriorfield" which describe the action +of storing a value in a precise field of the structure or array. For +example, the "setfield" action might require implicitly a GC write +barrier. This is the high-level trace that we send to the following +step. + + +Rewrite +--- + +A mostly but not completely CPU-independent phase: lowers some +instructions. For example, the variants of "new" are lowered to +"malloc" and a few "gc_store": it bumps the pointer of the GC and then +sets a few fields explicitly in the newly allocated structure. The +"setfield" is replaced with a "cond_gc_wb_call" (conditional call to the +write barrier) if needed, followed by a "gc_store". + +The "gc_store" instruction can be encoded in a single MOV assembler +instruction, but is not as flexible as a MOV. The address is always +specified as "some GC pointer + an offset". We don't have the notion of +interior pointer for GC objects. + +A different instruction, "gc_store_indexed", offers additional operands, +which can be mapped to a single MOV instruction using forms like +`[rax+8*rcx+24]`. + +Some other complex instructions pass through to the backend, which must +deal with them: for example, "card marking" in the GC. (Writing an +object pointer inside an array would require walking the whole array +later to find "young" references. Instead of that, we flip a bit for +every range of 128 entries. This is a common GC optimization.) Setting +the card bit of a GC object requires a sequence of assembler +instructions that depends too much on the target CPU to be expressed +explicitly here (moreover, it contains a few branches, which are hard to +express at this level). + + +Assembly + + +No fancy code generation technique, but greedy forward pass that tries +to avoid some pitfalls + + +Handling instructions +~ + +* One
[pypy-commit] pypy default: Check in extradoc/talk/bucharest2016/jit-backend-8vhY1ArTsh.txt in the
Author: Armin RigoBranch: Changeset: r87292:1e5c1b905a1c Date: 2016-09-21 22:24 +0200 http://bitbucket.org/pypy/pypy/changeset/1e5c1b905a1c/ Log:Check in extradoc/talk/bucharest2016/jit-backend-8vhY1ArTsh.txt in the docs, as a draft description of our low-level JIT assembler backends diff --git a/rpython/doc/jit/backend.rst b/rpython/doc/jit/backend.rst new file mode 100644 --- /dev/null +++ b/rpython/doc/jit/backend.rst @@ -0,0 +1,263 @@ += +PyPy's assembler backends += + +Draft notes about the organization of assembler backends in the PyPy JIT, in 2016 += + + +input: linear sequence of instructions, called a "trace". + +A trace is a sequence of instructions in SSA form. Most instructions +correspond to one or a few CPU-level instructions. There are a few +meta-instructions like `label` and debugging stuff. All branching is +done with guards, which are instructions that check that a condition is +true and exit the trace if not. A failing guard can have a new trace +added to it later, called a "bridge". A patched guard becomes a direct +`Jcond` instruction going to the bridge, with no indirection, no +register spilling, etc. + +A trace ends with either a `return` or a `jump to label`. The target +label is either inside the same trace, or in some older one. For +historical reasons we call a "loop" a trace that is not a bridge. The +machine code that we generate is organized as a forest of trees; the +trunk of the tree is a "loop", and the branches are all bridges +(branching off the trunk or off another branch). + +* every trunk or branch that ends in a `jump to label` can target a + label from a different tree, too. + +* the whole process of assembling a loop or a branch is basically + single-threaded, so no synchronization issue there (including to patch + older generated instructions). + +* the generated assembler has got a "frame" in %rbp, which is actually + not on the stack at all, but is a GC object (called a "jitframe"). + Spilling goes there. + +* the guards are `Jcond` to a very small piece of generated code, which + is basically pushing a couple of constants on the stack and then + jumping to the general guard-recovery code. That code will save the + registers into the jitframe and then exit the whole generated + function. The caller of that generated function checks how it + finished: if it finished by hitting a guard, then the caller is + responsible for calling the "blackhole interpreter". This is the part + of the front-end that recovers from failing guards and finishes + running the frame (including, possibly, by jumping again into + generated assembler). + + +Details about the JITting process: + +* front-end and optimization pass + +* rewrite (includes gc related transformation as well as simplifactions) + +* assembler generation + + +Front-end and optimization pass +--- + +Not discussed here in detail. This produces loops and bridges using an +instruction set that is "high-level" in some sense: it contains +intructions like "new"/"new_array", and +"setfield"/"setarrayitem"/"setinteriorfield" which describe the action +of storing a value in a precise field of the structure or array. For +example, the "setfield" action might require implicitly a GC write +barrier. This is the high-level trace that we send to the following +step. + + +Rewrite +--- + +A mostly but not completely CPU-independent phase: lowers some +instructions. For example, the variants of "new" are lowered to +"malloc" and a few "gc_store": it bumps the pointer of the GC and then +sets a few fields explicitly in the newly allocated structure. The +"setfield" is replaced with a "cond_gc_wb_call" (conditional call to the +write barrier) if needed, followed by a "gc_store". + +The "gc_store" instruction can be encoded in a single MOV assembler +instruction, but is not as flexible as a MOV. The address is always +specified as "some GC pointer + an offset". We don't have the notion of +interior pointer for GC objects. + +A different instruction, "gc_store_indexed", offers additional operands, +which can be mapped to a single MOV instruction using forms like +`[rax+8*rcx+24]`. + +Some other complex instructions pass through to the backend, which must +deal with them: for example, "card marking" in the GC. (Writing an +object pointer inside an array would require walking the whole array +later to find "young" references. Instead of that, we flip a bit for +every range of 128 entries. This is a common GC optimization.) Setting +the card bit of a GC object requires a sequence of assembler +instructions that depends too much on the target CPU to be expressed +explicitly here (moreover, it contains a few branches, which are hard to +express at this level). + + +Assembly + + +No fancy code
[pypy-commit] pypy default: replace a number of _annspecialcase_ by @specialize in rlib/
Author: Carl Friedrich BolzBranch: Changeset: r87291:f4db251591bc Date: 2016-09-21 22:13 +0200 http://bitbucket.org/pypy/pypy/changeset/f4db251591bc/ Log:replace a number of _annspecialcase_ by @specialize in rlib/ diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py --- a/rpython/rlib/clibffi.py +++ b/rpython/rlib/clibffi.py @@ -359,12 +359,13 @@ tpe.members[n] = lltype.nullptr(FFI_TYPE_P.TO) return tpe +@specialize.memo() def cast_type_to_ffitype(tp): """ This function returns ffi representation of rpython type tp """ return TYPE_MAP[tp] -cast_type_to_ffitype._annspecialcase_ = 'specialize:memo' +@specialize.argtype(1) def push_arg_as_ffiptr(ffitp, arg, ll_buf): # 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 @@ -396,7 +397,6 @@ arg >>= 8 else: raise AssertionError -push_arg_as_ffiptr._annspecialcase_ = 'specialize:argtype(1)' # type defs for callback and closure userdata @@ -470,12 +470,12 @@ FUNCFLAG_USE_ERRNO = 8 FUNCFLAG_USE_LASTERROR = 16 +@specialize.arg(1) # hack :-/ def get_call_conv(flags, from_jit): if _WIN32 and not _WIN64 and (flags & FUNCFLAG_CDECL == 0): return FFI_STDCALL else: return FFI_DEFAULT_ABI -get_call_conv._annspecialcase_ = 'specialize:arg(1)' # hack :-/ class AbstractFuncPtr(object): @@ -599,6 +599,7 @@ else: self.restype_size = -1 +@specialize.argtype(1) def push_arg(self, value): #if self.pushed_args == self.argnum: #raise TypeError("Too many arguments, eats %d, pushed %d" % @@ -618,7 +619,6 @@ push_arg_as_ffiptr(self.argtypes[self.pushed_args], value, self.ll_args[self.pushed_args]) self.pushed_args += 1 -push_arg._annspecialcase_ = 'specialize:argtype(1)' def _check_args(self): if self.pushed_args < self.argnum: @@ -627,6 +627,7 @@ def _clean_args(self): self.pushed_args = 0 +@specialize.arg(1) def call(self, RES_TP): self._check_args() ffires = c_ffi_call(self.ll_cif, self.funcsym, @@ -645,7 +646,6 @@ self._clean_args() check_fficall_result(ffires, self.flags) return res -call._annspecialcase_ = 'specialize:arg(1)' def __del__(self): if self.ll_args: diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py --- a/rpython/rlib/jit.py +++ b/rpython/rlib/jit.py @@ -280,6 +280,7 @@ @oopspec("jit.isconstant(value)") +@specialize.call_location() def isconstant(value): """ While tracing, returns whether or not the value is currently known to be @@ -289,9 +290,9 @@ This is for advanced usage only. """ return NonConstant(False) -isconstant._annspecialcase_ = "specialize:call_location" @oopspec("jit.isvirtual(value)") +@specialize.call_location() def isvirtual(value): """ Returns if this value is virtual, while tracing, it's relatively @@ -300,7 +301,6 @@ This is for advanced usage only. """ return NonConstant(False) -isvirtual._annspecialcase_ = "specialize:call_location" @specialize.call_location() def loop_unrolling_heuristic(lst, size, cutoff=2): @@ -401,28 +401,27 @@ hop.exception_cannot_occur() return hop.inputconst(lltype.Signed, _we_are_jitted) - +@oopspec('jit.current_trace_length()') def current_trace_length(): """During JIT tracing, returns the current trace length (as a constant). If not tracing, returns -1.""" if NonConstant(False): return 73 return -1 -current_trace_length.oopspec = 'jit.current_trace_length()' +@oopspec('jit.debug(string, arg1, arg2, arg3, arg4)') def jit_debug(string, arg1=-sys.maxint-1, arg2=-sys.maxint-1, arg3=-sys.maxint-1, arg4=-sys.maxint-1): """When JITted, cause an extra operation JIT_DEBUG to appear in the graphs. Should not be left after debugging.""" keepalive_until_here(string) # otherwise the whole function call is removed -jit_debug.oopspec = 'jit.debug(string, arg1, arg2, arg3, arg4)' +@oopspec('jit.assert_green(value)') +@specialize.argtype(0) def assert_green(value): """Very strong assert: checks that 'value' is a green (a JIT compile-time constant).""" keepalive_until_here(value) -assert_green._annspecialcase_ = 'specialize:argtype(0)' -assert_green.oopspec = 'jit.assert_green(value)' class AssertGreenFailed(Exception): pass @@ -457,6 +456,7 @@ # # VRefs +@oopspec('virtual_ref(x)') @specialize.argtype(0) def virtual_ref(x): """Creates a 'vref' object that contains a reference to 'x'. Calls @@ -467,14 +467,13 @@ dereferenced (by the call syntax 'vref()'), it returns 'x', which is then forced.""" return
[pypy-commit] pypy py3k: 2to3
Author: Ronan LamyBranch: py3k Changeset: r87290:4b1d7e36364a Date: 2016-09-21 20:08 +0100 http://bitbucket.org/pypy/pypy/changeset/4b1d7e36364a/ Log:2to3 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 @@ -46,7 +46,7 @@ def test_fromdouble(self, space, api): w_value = api.PyLong_FromDouble(-12.74) -assert isinstance(w_value, W_LongObject) +assert space.isinstance_w(w_value, space.w_int) assert space.unwrap(w_value) == -12 assert api.PyLong_AsDouble(w_value) == -12 @@ -108,24 +108,20 @@ lltype.free(overflow, flavor='raw') def test_as_voidptr(self, space, api): -# CPython returns an int (not a long) depending on the value -# passed to PyLong_FromVoidPtr(). In all cases, NULL becomes -# the int 0. w_l = api.PyLong_FromVoidPtr(lltype.nullptr(rffi.VOIDP.TO)) assert space.is_w(space.type(w_l), space.w_int) assert space.unwrap(w_l) == 0 assert api.PyLong_AsVoidPtr(w_l) == lltype.nullptr(rffi.VOIDP.TO) -# Positive values also return an int (assuming, like always in -# PyPy, that an int is big enough to store any pointer). + p = rffi.cast(rffi.VOIDP, maxint) w_l = api.PyLong_FromVoidPtr(p) assert space.is_w(space.type(w_l), space.w_int) assert space.unwrap(w_l) == maxint assert api.PyLong_AsVoidPtr(w_l) == p -# Negative values always return a long. + p = rffi.cast(rffi.VOIDP, -maxint-1) w_l = api.PyLong_FromVoidPtr(p) -assert space.is_w(space.type(w_l), space.w_long) +assert space.is_w(space.type(w_l), space.w_int) assert space.unwrap(w_l) == maxint+1 assert api.PyLong_AsVoidPtr(w_l) == p @@ -287,7 +283,7 @@ return PyLong_FromLong(3); if (str + strlen(str) != end) return PyLong_FromLong(4); - return PyLong_FromLong(0); + return PyLong_FromLong(0); """)]) assert module.from_str() == 0 @@ -343,4 +339,4 @@ assert module.has_pow() == 0 assert module.has_hex() == '0x2aL' assert module.has_oct() == '052L' - + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Fix some JIT tests
Author: Spenser BaumanBranch: value-classes Changeset: r87288:9811cbee3e13 Date: 2016-09-21 14:09 -0400 http://bitbucket.org/pypy/pypy/changeset/9811cbee3e13/ Log:Fix some JIT tests diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -124,11 +124,11 @@ NODE3.become(lltype.GcStruct('NODE3', ('parent', OBJECT), ('value', lltype.Signed), ('next', lltype.Ptr(NODE3)), -hints={'immutable': True})) +hints={'value_class': True})) big_fields = [('big' + i, lltype.Signed) for i in string.ascii_lowercase] BIG = lltype.GcForwardReference() -BIG.become(lltype.GcStruct('BIG', *big_fields, hints={'immutable': True})) +BIG.become(lltype.GcStruct('BIG', *big_fields, hints={'value_class': True})) for field, _ in big_fields: locals()[field + 'descr'] = cpu.fielddescrof(BIG, field) @@ -202,7 +202,7 @@ ('intval', lltype.Signed)) INTOBJ_IMMUT = lltype.GcStruct('INTOBJ_IMMUT', ('parent', OBJECT), ('intval', lltype.Signed), -hints={'immutable': True}) +hints={'value_class': True}) intobj_noimmut_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True) intobj_immut_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True) noimmut_intval = cpu.fielddescrof(INTOBJ_NOIMMUT, 'intval') @@ -214,7 +214,7 @@ PTROBJ_IMMUT = lltype.GcStruct('PTROBJ_IMMUT', ('parent', OBJECT), ('ptrval', lltype.Ptr(OBJECT)), -hints={'immutable': True}) +hints={'value_class': True}) ptrobj_immut_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True) ptrobj_immut_descr = cpu.sizeof(PTROBJ_IMMUT, ptrobj_immut_vtable) immut_ptrval = cpu.fielddescrof(PTROBJ_IMMUT, 'ptrval') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Make a note and undo some changes to tests
Author: Spenser BaumanBranch: value-classes Changeset: r87289:41ba0c22b58a Date: 2016-09-21 14:19 -0400 http://bitbucket.org/pypy/pypy/changeset/41ba0c22b58a/ Log:Make a note and undo some changes to tests diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py --- a/rpython/jit/metainterp/optimizeopt/test/test_util.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py @@ -124,11 +124,11 @@ NODE3.become(lltype.GcStruct('NODE3', ('parent', OBJECT), ('value', lltype.Signed), ('next', lltype.Ptr(NODE3)), -hints={'value_class': True})) +hints={'immutable': True})) big_fields = [('big' + i, lltype.Signed) for i in string.ascii_lowercase] BIG = lltype.GcForwardReference() -BIG.become(lltype.GcStruct('BIG', *big_fields, hints={'value_class': True})) +BIG.become(lltype.GcStruct('BIG', *big_fields, hints={'immutable': True})) for field, _ in big_fields: locals()[field + 'descr'] = cpu.fielddescrof(BIG, field) 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 @@ -370,6 +370,9 @@ return _struct(self, n, initialization='example') def _immutable_field(self, field): +# The translator no longer accepts the _immutable_=True annotation +# but it is useful to have an to have a shorthand for immutable objects +# which are value classes for testing purposes. if (self._hints.get('immutable') or self._hints.get('value_class')): return True ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: 2to3fy test
Author: Ronan LamyBranch: py3k Changeset: r87287:29e03dc11794 Date: 2016-09-21 18:41 +0100 http://bitbucket.org/pypy/pypy/changeset/29e03dc11794/ Log:2to3fy test diff --git a/pypy/module/cpyext/test/test_version.py b/pypy/module/cpyext/test/test_version.py --- a/pypy/module/cpyext/test/test_version.py +++ b/pypy/module/cpyext/test/test_version.py @@ -3,7 +3,7 @@ import py, pytest from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase -only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names" +only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names" def test_pragma_version(): from pypy.module.sys.version import CPYTHON_VERSION @@ -46,10 +46,18 @@ def test_pypy_versions(self): import sys init = """ +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +"foo", /* m_name */ +NULL, /* m_doc */ +-1, /* m_size */ +NULL/* m_methods */ +}; if (Py_IsInitialized()) { -PyObject *m = Py_InitModule("foo", NULL); +PyObject *m = PyModule_Create(); PyModule_AddStringConstant(m, "pypy_version", PYPY_VERSION); PyModule_AddIntConstant(m, "pypy_version_num", PYPY_VERSION_NUM); +return m; } Py_RETURN_NONE; """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: failargs can have None entries, consider this while iterating
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r87286:46098ed56db2 Date: 2016-09-21 19:26 +0200 http://bitbucket.org/pypy/pypy/changeset/46098ed56db2/ Log:failargs can have None entries, consider this while iterating diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -46,7 +46,7 @@ if op.is_guard(): args = args[:] + op.getfailargs() for arg in args: -if arg.is_constant() or arg.is_inputarg(): +if arg is None or arg.is_constant() or arg.is_inputarg(): continue if arg not in self.seen: box = self.renamer.rename_box(arg) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Replace all _immutable_=True annotations with _immutable_fields_=[...]
Author: Spenser BaumanBranch: value-classes Changeset: r87283:b71c2014dd9d Date: 2016-09-21 12:11 -0400 http://bitbucket.org/pypy/pypy/changeset/b71c2014dd9d/ Log:Replace all _immutable_=True annotations with _immutable_fields_=[...] Tests converted to use _value_class_=True diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -332,7 +332,6 @@ activation_cls = type("BuiltinActivation_UwS_%s" % label, (BuiltinActivation,), d) -activation_cls._immutable_ = True cache[key] = activation_cls, self.run_args return activation_cls @@ -346,7 +345,7 @@ class BuiltinActivation(object): -_immutable_ = True +_immutable_fields_ = ['behavior'] def __init__(self, behavior): """NOT_RPYTHON""" @@ -564,7 +563,10 @@ class BuiltinCode(Code): "The code object implementing a built-in (interpreter-level) hook." -_immutable_ = True +_immutable_fields_ = ['docstring', 'identifier', '_argnames', + 'descrmismatch_op', 'descr_reqcls', + 'sig', 'minargs', 'maxargs', 'activation', + '_bltin', '_unwrap_spec', 'func__args__'] hidden_applevel = True descrmismatch_op = None descr_reqcls = None @@ -727,7 +729,6 @@ class BuiltinCodePassThroughArguments0(BuiltinCode): -_immutable_ = True def funcrun(self, func, args): space = func.space @@ -747,7 +748,6 @@ class BuiltinCodePassThroughArguments1(BuiltinCode): -_immutable_ = True fast_natural_arity = Code.PASSTHROUGHARGS1 def funcrun_obj(self, func, w_obj, args): @@ -768,7 +768,6 @@ class BuiltinCode0(BuiltinCode): -_immutable_ = True fast_natural_arity = 0 def fastcall_0(self, space, w_func): @@ -785,7 +784,6 @@ class BuiltinCode1(BuiltinCode): -_immutable_ = True fast_natural_arity = 1 def fastcall_1(self, space, w_func, w1): @@ -805,7 +803,6 @@ class BuiltinCode2(BuiltinCode): -_immutable_ = True fast_natural_arity = 2 def fastcall_2(self, space, w_func, w1, w2): @@ -825,7 +822,6 @@ class BuiltinCode3(BuiltinCode): -_immutable_ = True fast_natural_arity = 3 def fastcall_3(self, space, func, w1, w2, w3): @@ -845,7 +841,6 @@ class BuiltinCode4(BuiltinCode): -_immutable_ = True fast_natural_arity = 4 def fastcall_4(self, space, func, w1, w2, w3, w4): diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1344,14 +1344,13 @@ WHY_CONTINUE, SContinueLoop WHY_YIELD not needed """ -_immutable_ = True def nomoreblocks(self): raise BytecodeCorruption("misplaced bytecode - should not return") class SReturnValue(SuspendedUnroller): """Signals a 'return' statement. Argument is the wrapped object to return.""" -_immutable_ = True +_immutable_fields_ = ['w_returnvalue'] kind = 0x01 def __init__(self, w_returnvalue): self.w_returnvalue = w_returnvalue @@ -1361,7 +1360,7 @@ class SApplicationException(SuspendedUnroller): """Signals an application-level exception (i.e. an OperationException).""" -_immutable_ = True +_immutable_fields_ = ['operr'] kind = 0x02 def __init__(self, operr): self.operr = operr @@ -1370,14 +1369,13 @@ class SBreakLoop(SuspendedUnroller): """Signals a 'break' statement.""" -_immutable_ = True kind = 0x04 SBreakLoop.singleton = SBreakLoop() class SContinueLoop(SuspendedUnroller): """Signals a 'continue' statement. Argument is the bytecode position of the beginning of the loop.""" -_immutable_ = True +_immutable_fields_ = ['jump_to'] kind = 0x08 def __init__(self, jump_to): self.jump_to = jump_to @@ -1387,7 +1385,7 @@ """Abstract base class for frame blocks from the blockstack, used by the SETUP_XXX and POP_BLOCK opcodes.""" -_immutable_ = True +_immutable_fields_ = ['handlerposition', 'valuestackdepth', 'previous'] def __init__(self, frame, handlerposition, previous): self.handlerposition = handlerposition @@ -1426,7 +1424,6 @@ class LoopBlock(FrameBlock): """A loop block. Stores the end-of-loop pointer in case of 'break'.""" -_immutable_ = True _opname = 'SETUP_LOOP' handling_mask = SBreakLoop.kind | SContinueLoop.kind @@ -1448,7 +1445,6 @@ class ExceptBlock(FrameBlock): """An try:except: block. Stores the position of the exception handler.""" -_immutable_ = True _opname = 'SETUP_EXCEPT' handling_mask = SApplicationException.kind @@ -1472,7 +1468,6 @@ class FinallyBlock(FrameBlock): """A try:finally: block. Stores the
[pypy-commit] pypy value-classes: Change is_immutable to is_value_class
Author: Spenser BaumanBranch: value-classes Changeset: r87285:28ad6be3c6c6 Date: 2016-09-21 13:13 -0400 http://bitbucket.org/pypy/pypy/changeset/28ad6be3c6c6/ Log:Change is_immutable to is_value_class diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -136,9 +136,6 @@ self.S) return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self._vtable)) -def is_immutable(self): -return heaptracker.is_immutable_struct(self.S) - def is_value_class(self): return heaptracker.is_value_class(self.S) diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -60,19 +60,16 @@ size = 0 # help translation tid = llop.combine_ushort(lltype.Signed, 0, 0) vtable = lltype.nullptr(rclass.OBJECT_VTABLE) -immutable_flag = False value_class_flag = False def __init__(self, size, gc_fielddescrs=None, all_fielddescrs=None, vtable=lltype.nullptr(rclass.OBJECT_VTABLE), - immutable_flag=False, value_class_flag=False): assert lltype.typeOf(vtable) == lltype.Ptr(rclass.OBJECT_VTABLE) self.size = size self.gc_fielddescrs = gc_fielddescrs self.all_fielddescrs = all_fielddescrs self.vtable = vtable -self.immutable_flag = immutable_flag self.value_class_flag = value_class_flag def get_all_fielddescrs(self): @@ -94,9 +91,6 @@ # fields return objptr.typeptr == cls or rclass.ll_isinstance(objptr, cls) -def is_immutable(self): -return self.immutable_flag - def is_value_class(self): return self.value_class_flag @@ -114,14 +108,12 @@ return cache[STRUCT] except KeyError: size = symbolic.get_size(STRUCT, gccache.translate_support_code) -immutable_flag = heaptracker.is_immutable_struct(STRUCT) value_class_flag = heaptracker.is_value_class(STRUCT) if vtable: assert heaptracker.has_gcstruct_a_vtable(STRUCT) else: assert not heaptracker.has_gcstruct_a_vtable(STRUCT) sizedescr = SizeDescr(size, vtable=vtable, - immutable_flag=immutable_flag, value_class_flag=value_class_flag) gccache.init_size_descr(STRUCT, sizedescr) cache[STRUCT] = sizedescr diff --git a/rpython/jit/backend/llsupport/test/test_descr.py b/rpython/jit/backend/llsupport/test/test_descr.py --- a/rpython/jit/backend/llsupport/test/test_descr.py +++ b/rpython/jit/backend/llsupport/test/test_descr.py @@ -17,8 +17,8 @@ descr_t = get_size_descr(c0, T) assert descr_s.size == symbolic.get_size(S, False) assert descr_t.size == symbolic.get_size(T, False) -assert descr_s.is_immutable() == False -assert descr_t.is_immutable() == False +assert descr_s.is_value_class() == False +assert descr_t.is_value_class() == False assert descr_t.gc_fielddescrs == [] assert len(descr_s.gc_fielddescrs) == 1 assert descr_s == get_size_descr(c0, S) @@ -26,7 +26,7 @@ # descr_s = get_size_descr(c1, S) assert isinstance(descr_s.size, Symbolic) -assert descr_s.is_immutable() == False +assert descr_s.is_value_class() == False PARENT = lltype.Struct('P', ('x', lltype.Ptr(T))) STRUCT = lltype.GcStruct('S', ('parent', PARENT), ('y', lltype.Ptr(T))) @@ -34,38 +34,18 @@ assert len(descr_struct.gc_fielddescrs) == 2 def test_get_size_descr_immut(): -S = lltype.GcStruct('S', hints={'immutable': True}) +S = lltype.GcStruct('S', hints={'value_class': True}) T = lltype.GcStruct('T', ('parent', S), ('x', lltype.Char), -hints={'immutable': True}) +hints={'value_class': True}) U = lltype.GcStruct('U', ('parent', T), ('u', lltype.Ptr(T)), ('v', lltype.Signed), -hints={'immutable': True}) +hints={'value_class': True}) V = lltype.GcStruct('V', ('parent', U), ('miss1', lltype.Void), ('miss2', lltype.Void), -hints={'immutable': True}) -for STRUCT in [S, T, U, V]: -for translated in [False, True]: -c0 = GcCache(translated) -descr_s = get_size_descr(c0, STRUCT) -assert descr_s.is_immutable() == True - -def test_get_size_descr_value_class(): -hints = {'immutable': True, 'value_class': True} -S = lltype.GcStruct('S', hints=hints) -T = lltype.GcStruct('T', ('parent', S), -
[pypy-commit] pypy value-classes: Convert _immutable_ to _value_class_
Author: Spenser BaumanBranch: value-classes Changeset: r87284:2cb63cfbee57 Date: 2016-09-21 13:01 -0400 http://bitbucket.org/pypy/pypy/changeset/2cb63cfbee57/ Log:Convert _immutable_ to _value_class_ diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py --- a/rpython/rtyper/rclass.py +++ b/rpython/rtyper/rclass.py @@ -62,10 +62,6 @@ """Raised when the _immutable_ or _immutable_fields_ hints are not consistent across a class hierarchy.""" -class ValueClassConflictError(Exception): -"""Raise when the _value_class_ hints are not consistent across -the class heirarchy""" - def getclassrepr(rtyper, classdef): if classdef is None: return rtyper.rootclass_repr @@ -163,7 +159,7 @@ OBJECT_VTABLE = lltype.ForwardReference() CLASSTYPE = Ptr(OBJECT_VTABLE) OBJECT = GcStruct('object', ('typeptr', CLASSTYPE), - hints={'immutable': True, 'shouldntbenull': True, + hints={'value_class': True, 'shouldntbenull': True, 'typeptr': True}, rtti=True) OBJECTPTR = Ptr(OBJECT) @@ -175,7 +171,7 @@ ('name', Ptr(rstr.STR)), ('hash', Signed), ('instantiate', Ptr(FuncType([], OBJECTPTR))), -hints={'immutable': True})) +hints={'value_class': True})) # non-gc case NONGCOBJECT = Struct('nongcobject', ('typeptr', CLASSTYPE)) NONGCOBJECTPTR = Ptr(NONGCOBJECT) @@ -276,7 +272,7 @@ # self.rbase = getclassrepr(self.rtyper, self.classdef.basedef) self.rbase.setup() -kwds = {'hints': {'immutable': True}} +kwds = {'hints': {'value_class': True}} vtable_type = Struct('%s_vtable' % self.classdef.name, ('super', self.rbase.vtable_type), *llfields, **kwds) @@ -520,7 +516,6 @@ if hints is None: hints = {} hints = self._check_for_immutable_hints(hints) -hints = self._check_for_value_class_hints(hints) kwds = {} if self.gcflavor == 'gc': kwds['rtti'] = True @@ -544,27 +539,15 @@ def _check_for_immutable_hints(self, hints): hints = hints.copy() classdesc = self.classdef.classdesc -immut = classdesc.get_param('_immutable_', inherit=False) value_class = classdesc.get_param('_value_class_', inherit=False) -if immut is None: -immut = value_class -elif value_class is not None and value_class and not immut: -raise ImmutableConflictError( -"class %r: _immutable_ != True and _value_class_ = True") - -if immut is None: -if classdesc.get_param('_immutable_', inherit=True): -raise ImmutableConflictError( -"class %r inherits from its parent _immutable_=True, " -"so it should also declare _immutable_=True" % ( +if value_class is not None: +if value_class is not True: +raise TyperError( +"class %r: _value_class_ = something else than True" % ( self.classdef,)) -elif immut is not True: -raise TyperError( -"class %r: _immutable_ = something else than True" % ( -self.classdef,)) -else: -hints['immutable'] = True +else: +hints['value_class'] = True self.immutable_field_set = classdesc.immutable_fields if (classdesc.immutable_fields or 'immutable_fields' in self.rbase.object_type._hints): @@ -572,30 +555,6 @@ hints['immutable_fields'] = accessor return hints -def _check_for_value_class_hints(self, hints): -"""Look for value class hints in the class heirarchy to extract the proper -hints and ensure consistency of the _value_class_ annotation. This is -mostly equivalent to _check_for_immutable_hints except that -_value_class_=True imples _immutable_=True.""" -hints = hints.copy() -classdesc = self.classdef.classdesc -value_class = classdesc.get_param('_value_class_', inherit=False) -if value_class is None: -if classdesc.get_param('_value_class_', inherit=True): -raise ValueClassConflictError( -"class %r inherits from its parent _value_class_=True, " -"so it should also declare _value_class_=True" % ( -self.classdef,)) -elif value_class is not True: -raise TyperError( -"class %r: _value_class_ = something else than True" % ( -self.classdef,)) -else: -# _value_class_ = True implies _immutable_ = True -
[pypy-commit] pypy default: removed my hack, use filter instead (thx armin)
Author: Richard PlanggerBranch: Changeset: r87282:9310b8a0e6fa Date: 2016-09-21 19:20 +0200 http://bitbucket.org/pypy/pypy/changeset/9310b8a0e6fa/ Log:removed my hack, use filter instead (thx armin) diff --git a/rpython/jit/backend/test/test_ll_random.py b/rpython/jit/backend/test/test_ll_random.py --- a/rpython/jit/backend/test/test_ll_random.py +++ b/rpython/jit/backend/test/test_ll_random.py @@ -710,6 +710,12 @@ # 6. a conditional call (for now always with no exception raised) class CondCallOperation(BaseCallOperation): + +def filter(self, builder): +if not builder.cpu.supports_cond_call_value and \ + self.opnum == rop.COND_CALL_VALUE_I: +raise CannotProduceOperation + def produce_into(self, builder, r): fail_subset = builder.subset_of_intvars(r) if self.opnum == rop.COND_CALL: diff --git a/rpython/jit/backend/test/zll_stress.py b/rpython/jit/backend/test/zll_stress.py --- a/rpython/jit/backend/test/zll_stress.py +++ b/rpython/jit/backend/test/zll_stress.py @@ -19,14 +19,6 @@ cpu.setup_once() r = Random() r.jumpahead(piece*) -OPERATIONS = LLtypeOperationBuilder.OPERATIONS[:] -if not cpu.supports_cond_call_value: -# remove COND_CALL_VALUE_I if the cpu does not support it -ops = LLtypeOperationBuilder.OPERATIONS -LLtypeOperationBuilder.OPERATIONS = [op for op in ops \ -if op.opnum != rop.COND_CALL_VALUE_I] for i in range(piece*per_piece, (piece+1)*per_piece): print "i = %d; r.setstate(%s)" % (i, r.getstate()) check_random_function(cpu, LLtypeOperationBuilder, r, i, total_iterations) -# restore the old list -LLtypeOperationBuilder.OPERATIONS = OPERATIONS ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Use built-in module _operator to define built-in functions bin(), oct(), hex().
Author: Ronan LamyBranch: py3.5 Changeset: r87281:a014e942245e Date: 2016-09-21 17:16 +0100 http://bitbucket.org/pypy/pypy/changeset/a014e942245e/ Log:Use built-in module _operator to define built-in functions bin(), oct(), hex(). This should prevent potential bootstrapping issues caused by trying to import pure-Python stdlib modules too early. Also, mark _operator as an essential module. diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -16,7 +16,7 @@ essential_modules = set([ "exceptions", "_io", "sys", "builtins", "posix", "_warnings", -"itertools", "_frozen_importlib", +"itertools", "_frozen_importlib", "operator", ]) if sys.platform == "win32": essential_modules.add("_winreg") @@ -24,7 +24,7 @@ default_modules = essential_modules.copy() default_modules.update([ "_codecs", "atexit", "gc", "_weakref", "marshal", "errno", "imp", -"itertools", "math", "cmath", "_sre", "_pickle_support", "operator", +"itertools", "math", "cmath", "_sre", "_pickle_support", "parser", "symbol", "token", "_ast", "_random", "__pypy__", "_string", "_testing", "time" ]) diff --git a/pypy/module/__builtin__/app_operation.py b/pypy/module/__builtin__/app_operation.py --- a/pypy/module/__builtin__/app_operation.py +++ b/pypy/module/__builtin__/app_operation.py @@ -1,16 +1,16 @@ -import operator +import _operator def bin(x): """Return the binary representation of an integer.""" -value = operator.index(x) +value = _operator.index(x) return value.__format__("#b") def oct(x): """Return the octal representation of an integer.""" -x = operator.index(x) +x = _operator.index(x) return x.__format__("#o") def hex(x): """Return the hexadecimal representation of an integer.""" -x = operator.index(x) +x = _operator.index(x) return x.__format__("#x") diff --git a/pypy/module/operator/test/test_operator.py b/pypy/module/operator/test/test_operator.py --- a/pypy/module/operator/test/test_operator.py +++ b/pypy/module/operator/test/test_operator.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- class AppTestOperator: -spaceconfig = dict(usemodules=['operator']) - def test_getters_are_not_regular_functions(self): import _operator as operator class A(object): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: updates
Author: Armin RigoBranch: extradoc Changeset: r5709:5fb52c896f0b Date: 2016-09-21 18:00 +0200 http://bitbucket.org/pypy/extradoc/changeset/5fb52c896f0b/ Log:updates diff --git a/planning/py3.5/milestone-1-progress.rst b/planning/py3.5/milestone-1-progress.rst --- a/planning/py3.5/milestone-1-progress.rst +++ b/planning/py3.5/milestone-1-progress.rst @@ -37,6 +37,8 @@ * Windows: issue 2310: kill WindowsError +* bytearray: 'del x[:10]' is now amortized constant-time + Milestone 1 (Aug-Sep-Oct 2016) -- @@ -47,7 +49,7 @@ planned: * PEP 492, coroutines with async and await syntax. (The complete PEP - is included.) + is included.) DONE * PEP 465, a new matrix multiplication operator: a @ b. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Remove DONE entries. Add #2310.
Author: Armin RigoBranch: extradoc Changeset: r5708:1c567dfcb89a Date: 2016-09-21 17:54 +0200 http://bitbucket.org/pypy/extradoc/changeset/1c567dfcb89a/ Log:Remove DONE entries. Add #2310. diff --git a/planning/py3.5/milestone-1-progress.rst b/planning/py3.5/milestone-1-progress.rst --- a/planning/py3.5/milestone-1-progress.rst +++ b/planning/py3.5/milestone-1-progress.rst @@ -14,11 +14,6 @@ * richard: extended slicing for memory view * richard: bytes % args, bytearray % args: PEP 461 -* arigo: look at test failures relaced to os.scandir() or the pathlib - module, or the enum module - -* arigo: (py3k issue #2278) add full precision for st_mtime_ns - Misc stuff not formally in any milestone @@ -31,19 +26,8 @@ ``dict``. The main pain point is ``move_to_end(last=False)``. See https://mail.python.org/pipermail/python-dev/2016-August/145837.html -* interpreter/generator.py: move the common functionality from - GeneratorIterator and Coroutine to the base class. Review all - calls to _PyGen_yf() in genobject.c. This is needed before - adding gi_yieldfrom/cr_await to generator/coroutines. (Waiting - because some work might be going on with raffael_t.) - * compare ``dir(posix)`` on py3.5 and cpython 3.5. -* review all unwrap_spec() that are meant to pass booleans (now - with '=int'). Argument clinic turns these to PyObject_IsTrue(), i.e. - accepting any object whatsoever(?!), which is supposedly a feature - (see http://bugs.python.org/issue14705). DONE - * ``KeyError('pip.exceptions',) in weakref callback .cb at 0x7f118e2c0020> ignored`` we're getting them now on start-up, investigate @@ -51,8 +35,7 @@ * ``print 5`` should give ``SyntaxError: Missing parentheses in call to 'print'`` -* ``_utf8`` in W_UnicodeObject used to be quasi-immutable, - document why it doesn't work and do a proper fix. DONE +* Windows: issue 2310: kill WindowsError Milestone 1 (Aug-Sep-Oct 2016) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Remove dunder aliases from _operator, as on CPython
Author: Ronan LamyBranch: py3.5 Changeset: r87280:7ed96cd63af0 Date: 2016-09-21 16:34 +0100 http://bitbucket.org/pypy/pypy/changeset/7ed96cd63af0/ Log:Remove dunder aliases from _operator, as on CPython diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py --- a/pypy/module/operator/__init__.py +++ b/pypy/module/operator/__init__.py @@ -4,21 +4,8 @@ """Operator Builtin Module. """ applevel_name = '_operator' -# HACK! override loaders to be able to access different operations -# under same name. I.e., operator.eq == operator.__eq__ - -def __init__(self, space, w_name): -def create_lambda(name, alsoname): -return lambda space : self.getdictvalue(space, alsoname) - -MixedModule.__init__(self, space, w_name) -for name, alsoname in self.mapping.iteritems(): -self.loaders[name] = create_lambda(name, alsoname) - appleveldefs = {} - app_names = ['countOf', 'attrgetter', 'itemgetter', 'methodcaller'] - for name in app_names: appleveldefs[name] = 'app_operator.%s' % name @@ -41,53 +28,3 @@ for name in interp_names: interpleveldefs[name] = 'interp_operator.%s' % name - -mapping = { -'__abs__' : 'abs', -'__add__' : 'add', -'__and__' : 'and_', -'__concat__' : 'concat', -'__contains__' : 'contains', -'__index__' : 'index', -'__delitem__' : 'delitem', -'__eq__' : 'eq', -'__floordiv__' : 'floordiv', -'__ge__' : 'ge', -'__getitem__' : 'getitem', -'__gt__' : 'gt', -'__inv__' : 'inv', -'__invert__' : 'invert', -'__le__' : 'le', -'__lshift__' : 'lshift', -'__lt__' : 'lt', -'__mod__' : 'mod', -'__mul__' : 'mul', -'__ne__' : 'ne', -'__neg__' : 'neg', -'__not__' : 'not_', -'__or__' : 'or_', -'__pos__' : 'pos', -'__pow__' : 'pow', -'__rshift__' : 'rshift', -'__setitem__' : 'setitem', -'__sub__' : 'sub', -'__truediv__' : 'truediv', -'__xor__' : 'xor', -'__matmul__' : 'matmul', -# in-place -'__iadd__' : 'iadd', -'__iand__' : 'iand', -'__iconcat__' : 'iconcat', -'__ifloordiv__' : 'ifloordiv', -'__ilshift__' : 'ilshift', -'__imod__' : 'imod', -'__imul__' : 'imul', -'__ior__' : 'ior', -'__ipow__' : 'ipow', -'__irshift__' : 'irshift', -'__isub__' : 'isub', -'__itruediv__' : 'itruediv', -'__ixor__' : 'ixor', -'__imatmul__' : 'imatmul', -} - diff --git a/pypy/module/operator/test/test_operator.py b/pypy/module/operator/test/test_operator.py --- a/pypy/module/operator/test/test_operator.py +++ b/pypy/module/operator/test/test_operator.py @@ -3,10 +3,6 @@ class AppTestOperator: spaceconfig = dict(usemodules=['operator']) -def test_equality(self): -import _operator as operator -assert operator.eq == operator.__eq__ - def test_getters_are_not_regular_functions(self): import _operator as operator class A(object): @@ -191,7 +187,6 @@ def test_index(self): import _operator as operator assert operator.index(42) == 42 -assert operator.__index__(42) == 42 raises(TypeError, operator.index, "abc") exc = raises(TypeError, operator.index, "abc") assert str(exc.value) == "'str' object cannot be interpreted as an integer" ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove unsupported operation in the stress tests (call_cond_value)
Author: Richard PlanggerBranch: Changeset: r87279:fb75857b6dd4 Date: 2016-09-21 17:09 +0200 http://bitbucket.org/pypy/pypy/changeset/fb75857b6dd4/ Log:remove unsupported operation in the stress tests (call_cond_value) diff --git a/rpython/jit/backend/test/zll_stress.py b/rpython/jit/backend/test/zll_stress.py --- a/rpython/jit/backend/test/zll_stress.py +++ b/rpython/jit/backend/test/zll_stress.py @@ -1,6 +1,7 @@ from rpython.jit.backend.test.test_random import check_random_function, Random from rpython.jit.backend.test.test_ll_random import LLtypeOperationBuilder from rpython.jit.backend.detect_cpu import getcpuclass +from rpython.jit.metainterp.resoperation import rop import platform CPU = getcpuclass() @@ -18,6 +19,14 @@ cpu.setup_once() r = Random() r.jumpahead(piece*) +OPERATIONS = LLtypeOperationBuilder.OPERATIONS[:] +if not cpu.supports_cond_call_value: +# remove COND_CALL_VALUE_I if the cpu does not support it +ops = LLtypeOperationBuilder.OPERATIONS +LLtypeOperationBuilder.OPERATIONS = [op for op in ops \ +if op.opnum != rop.COND_CALL_VALUE_I] for i in range(piece*per_piece, (piece+1)*per_piece): print "i = %d; r.setstate(%s)" % (i, r.getstate()) check_random_function(cpu, LLtypeOperationBuilder, r, i, total_iterations) +# restore the old list +LLtypeOperationBuilder.OPERATIONS = OPERATIONS ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: translation fix
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r87278:beeb5219ac63 Date: 2016-09-21 17:15 +0200 http://bitbucket.org/pypy/pypy/changeset/beeb5219ac63/ Log:translation fix diff --git a/rpython/jit/metainterp/warmstate.py b/rpython/jit/metainterp/warmstate.py --- a/rpython/jit/metainterp/warmstate.py +++ b/rpython/jit/metainterp/warmstate.py @@ -315,7 +315,7 @@ self.vec_all = bool(ivalue) def set_param_vec_cost(self, ivalue): -self.vec_cost = value +self.vec_cost = ivalue def disable_noninlinable_function(self, greenkey): cell = self.JitCell.ensure_jit_cell_at_key(greenkey) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix translation
Author: Ronan LamyBranch: py3.5 Changeset: r87277:54ced20c6ee9 Date: 2016-09-21 16:13 +0100 http://bitbucket.org/pypy/pypy/changeset/54ced20c6ee9/ Log:Fix translation diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -102,7 +102,7 @@ else: w_stop = w_length return w_start, w_stop, w_step - + min_jitdriver = jit.JitDriver(name='min', greens=['has_key', 'has_item', 'w_type'], reds='auto') max_jitdriver = jit.JitDriver(name='max', @@ -136,7 +136,7 @@ "%s() expects at least one argument", implementation_of) w_key = None -has_default = False +w_default = None if any_kwds: kwds = args.keywords for n in range(len(kwds)): @@ -144,13 +144,12 @@ w_key = args.keywords_w[n] elif kwds[n] == "default": w_default = args.keywords_w[n] -has_default = True else: raise oefmt(space.w_TypeError, "%s() got unexpected keyword argument", implementation_of) -if has_default and len(args_w) > 1: +if w_default is not None and len(args_w) > 1: raise oefmt(space.w_TypeError, "Cannot specify a default for %s() with multiple positional arguments", implementation_of) @@ -180,7 +179,7 @@ w_max_item = w_item w_max_val = w_compare_with if w_max_item is None: -if has_default: +if w_default is not None: w_max_item = w_default else: raise oefmt(space.w_ValueError, "arg is an empty sequence") @@ -420,7 +419,7 @@ def descr_repr(self, space): if not space.is_true(space.eq(self.w_step, space.newint(1))): return space.mod(space.wrap("range(%d, %d, %d)"), - space.newtuple([self.w_start, self.w_stop, + space.newtuple([self.w_start, self.w_stop, self.w_step])) else: return space.mod(space.wrap("range(%d, %d)"), @@ -433,7 +432,7 @@ "Get a range item, when known to be inside bounds" # return self.start + (i * self.step) return space.add(self.w_start, space.mul(w_index, self.w_step)) - + def _compute_item(self, space, w_index): w_zero = space.newint(0) w_index = space.index(w_index) @@ -767,7 +766,7 @@ __iter__ = interp2app(W_Map.iter_w), __next__ = interp2app(W_Map.next_w), __reduce__ = interp2app(W_Map.descr_reduce), -__doc__ = """\ +__doc__ = """\ Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted.""") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Armin RigoBranch: py3k Changeset: r87276:ec5c171f3870 Date: 2016-09-21 17:10 +0200 http://bitbucket.org/pypy/pypy/changeset/ec5c171f3870/ Log:hg merge default diff --git a/pypy/module/_cffi_backend/test/test_ffi_obj.py b/pypy/module/_cffi_backend/test/test_ffi_obj.py --- a/pypy/module/_cffi_backend/test/test_ffi_obj.py +++ b/pypy/module/_cffi_backend/test/test_ffi_obj.py @@ -507,7 +507,7 @@ def test_bug_1(self): import _cffi_backend as _cffi1_backend ffi = _cffi1_backend.FFI() -q = ffi.new("char[]", "abcd") +q = ffi.new("char[]", b"abcd") p = ffi.cast("char(*)(void)", q) raises(TypeError, ffi.string, p) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: remove unsupported operation in the stress tests (call_cond_value)
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r87275:f180564486f9 Date: 2016-09-21 17:09 +0200 http://bitbucket.org/pypy/pypy/changeset/f180564486f9/ Log:remove unsupported operation in the stress tests (call_cond_value) diff --git a/rpython/jit/backend/test/zll_stress.py b/rpython/jit/backend/test/zll_stress.py --- a/rpython/jit/backend/test/zll_stress.py +++ b/rpython/jit/backend/test/zll_stress.py @@ -1,6 +1,7 @@ from rpython.jit.backend.test.test_random import check_random_function, Random from rpython.jit.backend.test.test_ll_random import LLtypeOperationBuilder from rpython.jit.backend.detect_cpu import getcpuclass +from rpython.jit.metainterp.resoperation import rop import platform CPU = getcpuclass() @@ -18,6 +19,14 @@ cpu.setup_once() r = Random() r.jumpahead(piece*) +OPERATIONS = LLtypeOperationBuilder.OPERATIONS[:] +if not cpu.supports_cond_call_value: +# remove COND_CALL_VALUE_I if the cpu does not support it +ops = LLtypeOperationBuilder.OPERATIONS +LLtypeOperationBuilder.OPERATIONS = [op for op in ops \ +if op.opnum != rop.COND_CALL_VALUE_I] for i in range(piece*per_piece, (piece+1)*per_piece): print "i = %d; r.setstate(%s)" % (i, r.getstate()) check_random_function(cpu, LLtypeOperationBuilder, r, i, total_iterations) +# restore the old list +LLtypeOperationBuilder.OPERATIONS = OPERATIONS ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Future py3k compat
Author: Armin RigoBranch: Changeset: r87274:94f2a130efb0 Date: 2016-09-21 17:05 +0200 http://bitbucket.org/pypy/pypy/changeset/94f2a130efb0/ Log:Future py3k compat diff --git a/pypy/module/_cffi_backend/test/test_ffi_obj.py b/pypy/module/_cffi_backend/test/test_ffi_obj.py --- a/pypy/module/_cffi_backend/test/test_ffi_obj.py +++ b/pypy/module/_cffi_backend/test/test_ffi_obj.py @@ -507,7 +507,7 @@ def test_bug_1(self): import _cffi_backend as _cffi1_backend ffi = _cffi1_backend.FFI() -q = ffi.new("char[]", "abcd") +q = ffi.new("char[]", b"abcd") p = ffi.cast("char(*)(void)", q) raises(TypeError, ffi.string, p) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Renaming a built-in module does not change the name of the corresponding usemodules.* option
Author: Ronan LamyBranch: py3.5 Changeset: r87273:ffe795342bf8 Date: 2016-09-21 15:57 +0100 http://bitbucket.org/pypy/pypy/changeset/ffe795342bf8/ Log:Renaming a built-in module does not change the name of the corresponding usemodules.* option diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -24,7 +24,7 @@ default_modules = essential_modules.copy() default_modules.update([ "_codecs", "atexit", "gc", "_weakref", "marshal", "errno", "imp", -"itertools", "math", "cmath", "_sre", "_pickle_support", "_operator", +"itertools", "math", "cmath", "_sre", "_pickle_support", "operator", "parser", "symbol", "token", "_ast", "_random", "__pypy__", "_string", "_testing", "time" ]) diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py --- a/pypy/tool/pytest/apptest.py +++ b/pypy/tool/pytest/apptest.py @@ -26,6 +26,7 @@ exceptions='builtins', struct='_struct', thread='_thread', +operator='_operator', ) class AppError(Exception): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: merge default
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r87272:b8579705f7e6 Date: 2016-09-21 16:46 +0200 http://bitbucket.org/pypy/pypy/changeset/b8579705f7e6/ Log:merge default diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.8.3 +Version: 1.8.4 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.8.3" -__version_info__ = (1, 8, 3) +__version__ = "1.8.4" +__version_info__ = (1, 8, 4) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -233,7 +233,7 @@ f = PySys_GetObject((char *)"stderr"); if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.8.3" + "\ncompiled with cffi version: 1.8.4" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -332,7 +332,7 @@ realtype = model.unknown_ptr_type(decl.name) else: realtype, quals = self._get_type_and_quals( -decl.type, name=decl.name) +decl.type, name=decl.name, partial_length_ok=True) self._declare('typedef ' + decl.name, realtype, quals=quals) else: raise api.CDefError("unrecognized construct", decl) @@ -781,11 +781,14 @@ exprnode.name in self._int_constants): return self._int_constants[exprnode.name] # -if partial_length_ok: -if (isinstance(exprnode, pycparser.c_ast.ID) and +if (isinstance(exprnode, pycparser.c_ast.ID) and exprnode.name == '__dotdotdotarray__'): +if partial_length_ok: self._partial_length = True return '...' +raise api.FFIError(":%d: unsupported '[...]' here, cannot derive " + "the actual array length in this context" + % exprnode.coord.line) # raise api.FFIError(":%d: unsupported expression: expected a " "simple numeric constant" % exprnode.coord.line) diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py --- a/lib_pypy/cffi/recompiler.py +++ b/lib_pypy/cffi/recompiler.py @@ -587,8 +587,11 @@ # -- # typedefs +def _typedef_type(self, tp, name): +return self._global_type(tp, "(*(%s *)0)" % (name,)) + def _generate_cpy_typedef_collecttype(self, tp, name): -self._do_collect_type(tp) +self._do_collect_type(self._typedef_type(tp, name)) def _generate_cpy_typedef_decl(self, tp, name): pass @@ -598,6 +601,7 @@ self._lsts["typename"].append(TypenameExpr(name, type_index)) def _generate_cpy_typedef_ctx(self, tp, name): +tp = self._typedef_type(tp, name) self._typedef_ctx(tp, name) if getattr(tp, "origin", None) == "unknown_type": self._struct_ctx(tp, tp.name, approxname=None) diff --git a/pypy/module/_cffi_backend/__init__.py b/pypy/module/_cffi_backend/__init__.py --- a/pypy/module/_cffi_backend/__init__.py +++ b/pypy/module/_cffi_backend/__init__.py @@ -3,7 +3,7 @@ from rpython.rlib import rdynload, clibffi, entrypoint from rpython.rtyper.lltypesystem import rffi -VERSION = "1.8.3" +VERSION = "1.8.4" FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI try: diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -1,7 +1,7 @@ # import sys -assert __version__ == "1.8.3", ("This test_c.py file is for testing a version" +assert __version__ == "1.8.4", ("This test_c.py file is for testing a version" " of cffi that differs from
[pypy-commit] pypy py3k: Move the docstrings to the proper place
Author: Armin RigoBranch: py3k Changeset: r87271:0c7e8fb3f755 Date: 2016-09-21 16:00 +0200 http://bitbucket.org/pypy/pypy/changeset/0c7e8fb3f755/ Log:Move the docstrings to the proper place diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py --- a/pypy/module/posix/app_posix.py +++ b/pypy/module/posix/app_posix.py @@ -40,9 +40,6 @@ st_atime = structseqfield(11, "time of last access") st_mtime = structseqfield(12, "time of last modification") st_ctime = structseqfield(13, "time of last change") -st_atime_ns = structseqfield(14, "time of last access in nanoseconds") -st_mtime_ns = structseqfield(15, "time of last modification in nanoseconds") -st_ctime_ns = structseqfield(16, "time of last change in nanoseconds") if "st_blksize" in posix._statfields: st_blksize = structseqfield(20, "blocksize for filesystem I/O") @@ -66,14 +63,17 @@ @property def st_atime_ns(self): +"time of last access in nanoseconds" return int(self[7]) * 10 + self.nsec_atime @property def st_mtime_ns(self): +"time of last modification in nanoseconds" return int(self[8]) * 10 + self.nsec_mtime @property def st_ctime_ns(self): +"time of last change in nanoseconds" return int(self[9]) * 10 + self.nsec_ctime ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy ppc-vsx-support: remove some unused options, change some tests in micronumpy
Author: Richard PlanggerBranch: ppc-vsx-support Changeset: r87270:c712f368bb91 Date: 2016-09-21 15:55 +0200 http://bitbucket.org/pypy/pypy/changeset/c712f368bb91/ Log:remove some unused options, change some tests in micronumpy diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py --- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py +++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py @@ -7,19 +7,19 @@ class TestMicroNumPy(BaseTestPyPyC): arith_comb = [('+','float','float', 4*3427, 3427, 1.0,3.0), - ('+','float','int', 9*7843, 7843, 4.0,5.0), - ('+','int','float', 8*2571, 2571, 9.0,-1.0), - ('+','float','int', -18*2653, 2653, 4.0,-22.0), - ('+','int','int', -1*1499, 1499, 24.0,-25.0), - ('-','float','float', -2*5523, 5523, 1.0,3.0), - ('*','float','float', 3*2999, 2999, 1.0,3.0), - ('/','float','float', 3*7632, 7632, 3.0,1.0), - ('/','float','float', 1.5*7632, 7632, 3.0,2.0), - ('&','int','int', 0,1500, 1,0), - ('&','int','int', 1500, 1500, 1,1), - ('|','int','int', 1500, 1500, 0,1), - ('|','int','int', 0,1500, 0,0), -] + ('+','float','int', 9*7843, 7843, 4.0,5.0), + ('+','int','float', 8*2571, 2571, 9.0,-1.0), + ('+','float','int', -18*2653, 2653, 4.0,-22.0), + ('+','int','int', -1*1499, 1499, 24.0,-25.0), + ('-','float','float', -2*5523, 5523, 1.0,3.0), + ('*','float','float', 3*2999, 2999, 1.0,3.0), + ('/','float','float', 3*7632, 7632, 3.0,1.0), + ('/','float','float', 1.5*7632, 7632, 3.0,2.0), + ('&','int','int', 0,1500, 1,0), + ('&','int','int', 1500, 1500, 1,1), + ('|','int','int', 1500, 1500, 0,1), + ('|','int','int', 0,1500, 0,0), + ] type_permuated = [] types = { 'int': ['int32','int64','int8','int16'], 'float': ['float32', 'float64'] @@ -54,7 +54,10 @@ assert log.jit_summary.vecopt_tried == 0 assert log.jit_summary.vecopt_success == 0 assert vlog.jit_summary.vecopt_tried > 0 -assert vlog.jit_summary.vecopt_success > 0 +if adtype in ('int64','float64') and bdtype in ('int64','float64'): +assert vlog.jit_summary.vecopt_success > 0 +else: +assert vlog.jit_summary.vecopt_success >= 0 arith_comb = [ @@ -88,14 +91,17 @@ return a.{method}() """.format(method=op, dtype=dtype, count=count, a=a) exec py.code.Source(source).compile() +log = self.run(main, [], vec=0) vlog = self.run(main, [], vec=1) -log = self.run(main, [], vec=0) assert log.result == vlog.result assert log.result == result assert log.jit_summary.vecopt_tried == 0 assert log.jit_summary.vecopt_success == 0 assert vlog.jit_summary.vecopt_tried > 0 -assert vlog.jit_summary.vecopt_success > 0 +if dtype in ('int64','float64') and (dtype != 'int64' and op != 'prod'): +assert vlog.jit_summary.vecopt_success > 0 +else: +assert vlog.jit_summary.vecopt_success >= 0 def test_reduce_logical_xor(self): def main(): @@ -166,17 +172,30 @@ assert log.result is True assert len(log.loops) == 1 loop = log._filter(log.loops[0]) +# loop.match(""" +# f31 = raw_load_f(i9, i29, 1, 0, descr=) +# guard_not_invalidated(descr=...) +# v32 = float_ne(f31, 0.00) +# guard_true(i32, descr=...) +# i36 = int_add(i24, 1) +# i37 = int_add(i29, 8) +# i38 = int_ge(i36, i30) +# guard_false(i38, descr=...) +# jump(..., descr=...) +# """) +# vector version assert loop.match(""" -f31 = raw_load_f(i9, i29, descr=) guard_not_invalidated(descr=...) -i32 = float_ne(f31, 0.00) -guard_true(i32, descr=...) -i36 = int_add(i24, 1) -i37 = int_add(i29, 8) -i38 = int_ge(i36, i30) -guard_false(i38, descr=...) -jump(..., descr=...) -""") +i38 = int_add(i25, 2) +i39 = int_ge(i38, i33) +guard_false(i39, descr=...) +v42 = vec_load_f(i9, i32, 1, 0, descr=) +v43 = vec_float_ne(v42, v36) +f46 = vec_unpack_f(v42, 0, 1) +vec_guard_true(v43, descr=...) +i48 = int_add(i32, 16) +i50 = int_add(i25, 2) +jump(..., descr=...)""")
[pypy-commit] pypy.org extradoc: update the values
Author: Armin RigoBranch: extradoc Changeset: r800:c50cd1b3de71 Date: 2016-09-21 15:05 +0200 http://bitbucket.org/pypy/pypy.org/changeset/c50cd1b3de71/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -15,7 +15,7 @@ - $65133 of $105000 (62.0%) + $65142 of $105000 (62.0%) @@ -23,7 +23,7 @@ This donation goes towards supporting Python 3 in PyPy. Current status: -we have $5583 left +we have $5591 left in the account. Read proposal ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Manual merge of a translation fix I've done only in the py3.5 branch (sorry)
Author: Armin RigoBranch: py3k Changeset: r87269:80e7245f0eb0 Date: 2016-09-21 14:38 +0200 http://bitbucket.org/pypy/pypy/changeset/80e7245f0eb0/ Log:Manual merge of a translation fix I've done only in the py3.5 branch (sorry) diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py +++ b/pypy/objspace/std/unicodeobject.py @@ -77,19 +77,21 @@ def unicode_w(self, space): return self._value -@jit.elidable def identifier_w(self, space): -identifier = self._utf8 -if identifier is not None: -return identifier -u = self._value -eh = unicodehelper.rpy_encode_error_handler() try: -identifier = unicode_encode_utf_8(u, len(u), None, - errorhandler=eh) -except unicodehelper.RUnicodeEncodeError as ue: -raise wrap_encode_error(space, ue) -self._utf8 = identifier +# call the elidable function, with a jit.call_shortcut in case +# self._utf8 is already computed +identifier = g_identifier_w(self, space) +except UnicodeEncodeError: +# bah, this is just to get an official app-level +# UnicodeEncodeError +u = self._value +eh = unicodehelper.rpy_encode_error_handler() +try: +identifier = unicode_encode_utf_8(u, len(u), None, + errorhandler=eh) +except unicodehelper.RUnicodeEncodeError as ue: +raise wrap_encode_error(space, ue) return identifier def listview_unicode(self): @@ -1306,6 +1308,16 @@ return unicodehelper.encode_utf8(space, u''.join(result), allow_surrogates=allow_surrogates) +@jit.elidable +@jit.call_shortcut +def g_identifier_w(self, space): +"""This is a global function because of @jit.call_shortcut""" +identifier = self._utf8 +if identifier is not None: +return identifier +identifier = self._value.encode('utf-8') +self._utf8 = identifier +return identifier _repr_function, _ = make_unicode_escape_function( pass_printable=True, unicode_output=True, quotes=True, prefix='') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Add tests for st.st_Xtime_ns
Author: Armin RigoBranch: py3k Changeset: r87268:703718ff9b54 Date: 2016-09-21 14:33 +0200 http://bitbucket.org/pypy/pypy/changeset/703718ff9b54/ Log:Add tests for st.st_Xtime_ns 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 @@ -137,14 +137,17 @@ assert st.st_size == 14 assert st.st_nlink == 1 -assert not hasattr(st, 'nsec_atime') - if sys.platform.startswith('linux'): assert isinstance(st.st_atime, float) assert isinstance(st.st_mtime, float) assert isinstance(st.st_ctime, float) assert hasattr(st, 'st_rdev') +assert isinstance(st.st_atime_ns, int) +assert abs(st.st_atime_ns - 1e9*st.st_atime) < 500 +assert abs(st.st_mtime_ns - 1e9*st.st_mtime) < 500 +assert abs(st.st_ctime_ns - 1e9*st.st_ctime) < 500 + def test_stat_float_times(self): path = self.path posix = self.posix ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: fixes
Author: Armin RigoBranch: py3k Changeset: r87267:0ac14db93823 Date: 2016-09-21 14:28 +0200 http://bitbucket.org/pypy/pypy/changeset/0ac14db93823/ Log:fixes 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 @@ -373,7 +373,14 @@ w_value = space.wrap(st[i]) lst[i] = w_value else: -w_value = space.wrap(getattr(st, name)) +try: +value = getattr(st, name) +except AttributeError: +# untranslated, there is no nsec_Xtime attribute +assert name.startswith('nsec_') +value = rposix_stat.get_stat_ns_as_bigint(st, name[5:]) +value = value.tolong() % 10 +w_value = space.wrap(value) space.setitem(w_keywords, space.wrap(name), w_value) # Note: 'w_keywords' contains the three attributes 'nsec_Xtime'. diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -1099,11 +1099,7 @@ raise oefmt(space.w_TypeError, "__slots__ must be identifiers") # create member slot_name = mangle(slot_name, w_self.name) -if slot_name in w_self.dict_w: -raise oefmt(space.w_ValueError, -"'%8' in __slots__ conflicts with class variable", -slot_name) -else: +if slot_name not in w_self.dict_w: # Force interning of slot names. slot_name = space.str_w(space.new_interned_str(slot_name)) # in cpython it is ignored less, but we probably don't care @@ -,7 +1107,10 @@ w_self.dict_w[slot_name] = space.wrap(member) return True else: -return False +# never returns False, but that's to minimize the diff with pypy2 +raise oefmt(space.w_ValueError, +"'%8' in __slots__ conflicts with class variable", +slot_name) def create_dict_slot(w_self): if not w_self.hasdict: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Armin RigoBranch: py3k Changeset: r87266:c7615cd6e615 Date: 2016-09-21 14:21 +0200 http://bitbucket.org/pypy/pypy/changeset/c7615cd6e615/ Log:hg merge default diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -33,28 +33,27 @@ if typecode == tc: a = space.allocate_instance(types[tc].w_class, w_cls) a.__init__(space) - -if len(__args__.arguments_w) > 0: -w_initializer = __args__.arguments_w[0] -if isinstance(w_initializer, W_ArrayBase): -a.extend(w_initializer, True) -elif space.type(w_initializer) is space.w_list: -a.descr_fromlist(space, w_initializer) -else: -try: -buf = space.bufferstr_w(w_initializer) -except OperationError as e: -if not e.match(space, space.w_TypeError): -raise -a.extend(w_initializer, True) -else: -a.descr_frombytes(space, buf) break else: raise oefmt(space.w_ValueError, "bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f " "or d)") +if len(__args__.arguments_w) > 0: +w_initializer = __args__.arguments_w[0] +if isinstance(w_initializer, W_ArrayBase): +a.extend(w_initializer, True) +elif space.type(w_initializer) is space.w_list: +a.descr_fromlist(space, w_initializer) +else: +try: +buf = space.bufferstr_w(w_initializer) +except OperationError as e: +if not e.match(space, space.w_TypeError): +raise +a.extend(w_initializer, True) +else: +a.descr_frombytes(space, buf) return a ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Armin RigoBranch: py3k Changeset: r87265:5d068bf3a13d Date: 2016-09-21 14:20 +0200 http://bitbucket.org/pypy/pypy/changeset/5d068bf3a13d/ Log:hg merge default diff too long, truncating to 2000 out of 2019 lines diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -13,6 +13,7 @@ import sys import os import shlex +import imp from distutils.errors import DistutilsPlatformError @@ -62,8 +63,7 @@ """Initialize the module as appropriate for POSIX systems.""" g = {} g['EXE'] = "" -g['SO'] = ".so" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check @@ -75,8 +75,7 @@ """Initialize the module as appropriate for NT""" g = {} g['EXE'] = ".exe" -g['SO'] = ".pyd" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] global _config_vars _config_vars = g diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -529,7 +529,7 @@ for suffix, mode, type_ in imp.get_suffixes(): if type_ == imp.C_EXTENSION: _CONFIG_VARS['SOABI'] = suffix.split('.')[1] -break +break if args: vals = [] diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.8.2 +Version: 1.8.4 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.8.2" -__version_info__ = (1, 8, 2) +__version__ = "1.8.4" +__version_info__ = (1, 8, 4) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -233,7 +233,7 @@ f = PySys_GetObject((char *)"stderr"); if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.8.2" + "\ncompiled with cffi version: 1.8.4" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -332,7 +332,7 @@ realtype = model.unknown_ptr_type(decl.name) else: realtype, quals = self._get_type_and_quals( -decl.type, name=decl.name) +decl.type, name=decl.name, partial_length_ok=True) self._declare('typedef ' + decl.name, realtype, quals=quals) else: raise api.CDefError("unrecognized construct", decl) @@ -781,11 +781,14 @@ exprnode.name in self._int_constants): return self._int_constants[exprnode.name] # -if partial_length_ok: -if (isinstance(exprnode, pycparser.c_ast.ID) and +if (isinstance(exprnode, pycparser.c_ast.ID) and exprnode.name == '__dotdotdotarray__'): +if partial_length_ok: self._partial_length = True return '...' +raise api.FFIError(":%d: unsupported '[...]' here, cannot derive " + "the actual array length in this context" + % exprnode.coord.line) # raise api.FFIError(":%d: unsupported expression: expected a " "simple numeric constant" % exprnode.coord.line) diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py --- a/lib_pypy/cffi/recompiler.py +++ b/lib_pypy/cffi/recompiler.py @@ -587,8 +587,11 @@ # -- # typedefs +def _typedef_type(self, tp, name): +return self._global_type(tp, "(*(%s *)0)" % (name,)) + def _generate_cpy_typedef_collecttype(self,
[pypy-commit] pypy default: Tweaks: don't use 'int(float-value-of-st.st_Xtime)': because precision
Author: Armin RigoBranch: Changeset: r87263:adb3947f8bb6 Date: 2016-09-21 13:36 +0200 http://bitbucket.org/pypy/pypy/changeset/adb3947f8bb6/ Log:Tweaks: don't use 'int(float-value-of-st.st_Xtime)': because precision loss can occur, this could in theory give a result that is one larger than what the system call returned. 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 @@ -226,13 +226,13 @@ w_keywords = space.newdict() stat_float_times = space.fromcache(StatState).stat_float_times for i, (name, TYPE) in FIELDS: -value = getattr(st, name) -if name in ('st_atime', 'st_mtime', 'st_ctime'): -value = int(value) # rounded to an integer for indexed access -w_value = space.wrap(value) if i < rposix_stat.N_INDEXABLE_FIELDS: +# get the first 10 items by indexing; this gives us +# 'st_Xtime' as an integer, too +w_value = space.wrap(st[i]) lst[i] = w_value -else: +elif name.startswith('st_'):# exclude 'nsec_Xtime' +w_value = space.wrap(getattr(st, name)) space.setitem(w_keywords, space.wrap(name), w_value) # non-rounded values for name-based access @@ -243,13 +243,8 @@ space.wrap('st_mtime'), space.wrap(st.st_mtime)) space.setitem(w_keywords, space.wrap('st_ctime'), space.wrap(st.st_ctime)) -else: -space.setitem(w_keywords, - space.wrap('st_atime'), space.wrap(int(st.st_atime))) -space.setitem(w_keywords, - space.wrap('st_mtime'), space.wrap(int(st.st_mtime))) -space.setitem(w_keywords, - space.wrap('st_ctime'), space.wrap(int(st.st_ctime))) +#else: +# filled by the __init__ method w_tuple = space.newtuple(lst) w_stat_result = space.getattr(space.getbuiltinmodule(os.name), 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 @@ -129,9 +129,9 @@ assert st[4] == st.st_uid assert st[5] == st.st_gid assert st[6] == st.st_size -assert st[7] == int(st.st_atime) -assert st[8] == int(st.st_mtime) -assert st[9] == int(st.st_ctime) +assert st[7] == int(st.st_atime) # in complete corner cases, rounding +assert st[8] == int(st.st_mtime) # here could maybe get the wrong +assert st[9] == int(st.st_ctime) # integer... assert stat.S_IMODE(st.st_mode) & stat.S_IRUSR assert stat.S_IMODE(st.st_mode) & stat.S_IWUSR @@ -141,13 +141,12 @@ assert st.st_size == 14 assert st.st_nlink == 1 -#if sys.platform.startswith('linux'): -## expects non-integer timestamps - it's unlikely that they are -## all three integers -#assert ((st.st_atime, st.st_mtime, st.st_ctime) != -#(st[7], st[8], st[9])) -#assert st.st_blksize * st.st_blocks >= st.st_size +assert not hasattr(st, 'nsec_atime') + if sys.platform.startswith('linux'): +assert isinstance(st.st_atime, float) +assert isinstance(st.st_mtime, float) +assert isinstance(st.st_ctime, float) assert hasattr(st, 'st_rdev') def test_stat_float_times(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: os.stat(): support full-precision nanosecond times in translated RPython
Author: Armin RigoBranch: Changeset: r87262:038a80811172 Date: 2016-09-21 13:35 +0200 http://bitbucket.org/pypy/pypy/changeset/038a80811172/ Log:os.stat(): support full-precision nanosecond times in translated RPython programs, as rbigint numbers. Before translation, it relies on Python 2.7's os.stat_result. This means that before translation you get lower-precision rbigints. diff --git a/rpython/rlib/rposix_stat.py b/rpython/rlib/rposix_stat.py --- a/rpython/rlib/rposix_stat.py +++ b/rpython/rlib/rposix_stat.py @@ -17,7 +17,7 @@ from rpython.rtyper.error import TyperError from rpython.rlib._os_support import _preferred_traits, string_traits -from rpython.rlib.objectmodel import specialize +from rpython.rlib.objectmodel import specialize, we_are_translated from rpython.rtyper.lltypesystem import lltype, rffi from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.rlib.rarithmetic import intmask @@ -51,15 +51,18 @@ ("st_uid", lltype.Signed), ("st_gid", lltype.Signed), ("st_size", lltype.SignedLongLong), -("st_atime", lltype.Float), -("st_mtime", lltype.Float), -("st_ctime", lltype.Float), +("st_atime", lltype.SignedLongLong), # integral number of seconds +("st_mtime", lltype.SignedLongLong), # +("st_ctime", lltype.SignedLongLong), # ("st_blksize", lltype.Signed), ("st_blocks",lltype.Signed), ("st_rdev", lltype.Signed), ("st_flags", lltype.Signed), #("st_gen", lltype.Signed), -- new in CPy 2.5, not implemented #("st_birthtime", lltype.Float), -- new in CPy 2.5, not implemented +("nsec_atime", lltype.Signed), # number of nanoseconds +("nsec_mtime", lltype.Signed), # +("nsec_ctime", lltype.Signed), # ] N_INDEXABLE_FIELDS = 10 @@ -79,6 +82,37 @@ ("f_namemax", lltype.Signed), ] +@specialize.arg(1) +def get_stat_ns_as_bigint(st, name): +"""'name' is one of the strings "atime", "mtime" or "ctime". +Returns a bigint that represents the number of nanoseconds +stored inside the RPython-level os.stat_result 'st'. + +Note that when running untranslated, the os.stat_result type +is from Python 2.7, which doesn't store more precision than +a float anyway. You will only get more after translation. +""" +from rpython.rlib.rbigint import rbigint + +if not we_are_translated(): +as_float = getattr(st, "st_" + name) +return rbigint.fromfloat(as_float * 1e9) + +if name == "atime": +i, j = 7, -3 +elif name == "mtime": +i, j = 8, -2 +elif name == "ctime": +i, j = 9, -1 +else: +raise AssertionError(name) + +sec = st[i] +nsec = st[j] +result = rbigint.fromrarith_int(sec).int_mul(10) +result = result.int_add(nsec) +return result + # # @@ -97,7 +131,15 @@ if not s_attr.is_constant(): raise annmodel.AnnotatorError("non-constant attr name in getattr()") attrname = s_attr.const -TYPE = STAT_FIELD_TYPES[attrname] +if attrname in ('st_atime', 'st_mtime', 'st_ctime'): +# like CPython, in RPython we can read the st_Xtime +# attribute and get a floating-point result. We can also +# get a full-precision bigint with get_stat_ns_as_bigint(). +# The floating-point result is computed like a property +# by _ll_get_st_Xtime(). +TYPE = lltype.Float +else: +TYPE = STAT_FIELD_TYPES[attrname] return lltype_to_annotation(TYPE) def _get_rmarshall_support_(self): # for rlib.rmarshal @@ -105,13 +147,14 @@ # (we ignore the extra values here for simplicity and portability) def stat_result_reduce(st): return (st[0], st[1], st[2], st[3], st[4], -st[5], st[6], st[7], st[8], st[9]) +st[5], st[6], st[7], st[8], st[9], +st[-3], st[-2], st[-1]) def stat_result_recreate(tup): -return make_stat_result(tup + extra_zeroes) +return make_stat_result(tup[:10] + extra_zeroes + tup[-3:]) s_reduced = annmodel.SomeTuple([lltype_to_annotation(TYPE) for name, TYPE in PORTABLE_STAT_FIELDS]) -extra_zeroes = (0,) * (len(STAT_FIELDS) - len(PORTABLE_STAT_FIELDS)) +extra_zeroes = (0,) * (len(STAT_FIELDS) - len(PORTABLE_STAT_FIELDS) - 3) return s_reduced, stat_result_reduce, stat_result_recreate @@ -119,7 +162,7 @@ def getitem((s_sta, s_int)): assert s_int.is_constant(), "os.stat()[index]: index must be constant" index = s_int.const -assert 0 <= index < N_INDEXABLE_FIELDS, "os.stat()[index] out of range" +assert -3 <= index <