Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r61563:42449723af3a Date: 2013-02-21 12:55 -0800 http://bitbucket.org/pypy/pypy/changeset/42449723af3a/
Log: merge default diff --git a/pypy/doc/_ref.txt b/pypy/doc/_ref.txt --- a/pypy/doc/_ref.txt +++ b/pypy/doc/_ref.txt @@ -1,24 +1,19 @@ .. _`ctypes_configure/doc/sample.py`: https://bitbucket.org/pypy/pypy/src/default/ctypes_configure/doc/sample.py -.. _`demo/`: https://bitbucket.org/pypy/pypy/src/default/demo/ +.. _`dotviewer/`: https://bitbucket.org/pypy/pypy/src/default/dotviewer/ .. _`lib-python/`: https://bitbucket.org/pypy/pypy/src/default/lib-python/ .. _`lib-python/2.7/dis.py`: https://bitbucket.org/pypy/pypy/src/default/lib-python/2.7/dis.py .. _`lib_pypy/`: https://bitbucket.org/pypy/pypy/src/default/lib_pypy/ .. _`lib_pypy/greenlet.py`: https://bitbucket.org/pypy/pypy/src/default/lib_pypy/greenlet.py .. _`lib_pypy/pypy_test/`: https://bitbucket.org/pypy/pypy/src/default/lib_pypy/pypy_test/ .. _`lib_pypy/tputil.py`: https://bitbucket.org/pypy/pypy/src/default/lib_pypy/tputil.py -.. _`pypy/annotation`: -.. _`pypy/annotation/`: https://bitbucket.org/pypy/pypy/src/default/pypy/annotation/ -.. _`pypy/annotation/annrpython.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/annotation/annrpython.py -.. _`pypy/annotation/binaryop.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/annotation/binaryop.py -.. _`pypy/annotation/builtin.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/annotation/builtin.py .. _`pypy/bin/`: https://bitbucket.org/pypy/pypy/src/default/pypy/bin/ -.. _`pypy/bin/translatorshell.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/bin/translatorshell.py +.. _`pypy/bin/pyinteractive.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/bin/pyinteractive.py .. _`pypy/config/`: https://bitbucket.org/pypy/pypy/src/default/pypy/config/ .. _`pypy/config/pypyoption.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/config/pypyoption.py -.. _`pypy/config/translationoption.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/config/translationoption.py .. _`pypy/doc/`: https://bitbucket.org/pypy/pypy/src/default/pypy/doc/ .. _`pypy/doc/config/`: https://bitbucket.org/pypy/pypy/src/default/pypy/doc/config/ .. _`pypy/doc/discussion/`: https://bitbucket.org/pypy/pypy/src/default/pypy/doc/discussion/ +.. _`pypy/goal/`: https://bitbucket.org/pypy/pypy/src/default/pypy/goal/ .. _`pypy/interpreter`: .. _`pypy/interpreter/`: https://bitbucket.org/pypy/pypy/src/default/pypy/interpreter/ .. _`pypy/interpreter/argument.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/interpreter/argument.py @@ -54,11 +49,8 @@ .. _`pypy/module`: .. _`pypy/module/`: https://bitbucket.org/pypy/pypy/src/default/pypy/module/ .. _`pypy/module/__builtin__/__init__.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/module/__builtin__/__init__.py -.. _`pypy/objspace`: .. _`pypy/objspace/`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/ -.. _`pypy/objspace/flow`: .. _`pypy/objspace/flow/`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/flow/ -.. _`pypy/objspace/flow/model.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/flow/model.py .. _`pypy/objspace/std`: .. _`pypy/objspace/std/`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/ .. _`pypy/objspace/std/listtype.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/listtype.py @@ -70,49 +62,55 @@ .. _`pypy/objspace/std/transparent.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/transparent.py .. _`pypy/objspace/std/tupleobject.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/tupleobject.py .. _`pypy/objspace/std/tupletype.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/objspace/std/tupletype.py -.. _`pypy/rlib`: -.. _`pypy/rlib/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/ -.. _`pypy/rlib/listsort.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/listsort.py -.. _`pypy/rlib/nonconst.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/nonconst.py -.. _`pypy/rlib/objectmodel.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/objectmodel.py -.. _`pypy/rlib/parsing/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/parsing/ -.. _`pypy/rlib/parsing/tree.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/parsing/tree.py -.. _`pypy/rlib/rarithmetic.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/rarithmetic.py -.. _`pypy/rlib/rbigint.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/rbigint.py -.. _`pypy/rlib/rrandom.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/rrandom.py -.. _`pypy/rlib/rsocket.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/rsocket.py -.. _`pypy/rlib/streamio.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/streamio.py -.. _`pypy/rlib/test`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/test/ -.. _`pypy/rlib/unroll.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/unroll.py -.. _`pypy/rpython`: -.. _`pypy/rpython/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/ -.. _`pypy/rpython/lltypesystem/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/lltypesystem/ -.. _`pypy/rpython/lltypesystem/lltype.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/lltypesystem/lltype.py -.. _`pypy/rpython/memory/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/ -.. _`pypy/rpython/memory/gc/generation.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/generation.py -.. _`pypy/rpython/memory/gc/hybrid.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/hybrid.py -.. _`pypy/rpython/memory/gc/markcompact.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/markcompact.py -.. _`pypy/rpython/memory/gc/marksweep.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/marksweep.py -.. _`pypy/rpython/memory/gc/minimarkpage.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/minimarkpage.py -.. _`pypy/rpython/memory/gc/semispace.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/memory/gc/semispace.py -.. _`pypy/rpython/ootypesystem/`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/ootypesystem/ -.. _`pypy/rpython/ootypesystem/ootype.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/ootypesystem/ootype.py -.. _`pypy/rpython/rint.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/rint.py -.. _`pypy/rpython/rlist.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/rlist.py -.. _`pypy/rpython/rmodel.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/rmodel.py -.. _`pypy/rpython/rtyper.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/rtyper.py -.. _`pypy/rpython/test/test_llinterp.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/rpython/test/test_llinterp.py .. _`pypy/tool/`: https://bitbucket.org/pypy/pypy/src/default/pypy/tool/ .. _`pypy/tool/algo/`: https://bitbucket.org/pypy/pypy/src/default/pypy/tool/algo/ .. _`pypy/tool/pytest/`: https://bitbucket.org/pypy/pypy/src/default/pypy/tool/pytest/ -.. _`pypy/tool/traceconfig.py`: https://bitbucket.org/pypy/pypy/src/default/pypy/tool/traceconfig.py -.. _`pypy/translator`: -.. _`pypy/translator/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/ -.. _`pypy/translator/backendopt/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/backendopt/ -.. _`pypy/translator/c/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/c/ -.. _`pypy/translator/c/src/stacklet/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/c/src/stacklet/ -.. _`pypy/translator/c/src/stacklet/stacklet.h`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/c/src/stacklet/stacklet.h -.. _`pypy/translator/cli/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/cli/ -.. _`pypy/translator/goal/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/goal/ -.. _`pypy/translator/jvm/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/jvm/ -.. _`pypy/translator/tool/`: https://bitbucket.org/pypy/pypy/src/default/pypy/translator/tool/ +.. _`rpython/annotator`: +.. _`rpython/annotator/`: https://bitbucket.org/pypy/pypy/src/default/rpython/annotator/ +.. _`rpython/annotator/annrpython.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/annotator/annrpython.py +.. _`rpython/annotator/binaryop.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/annotator/binaryop.py +.. _`rpython/annotator/builtin.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/annotator/builtin.py +.. _`rpython/bin/translatorshell.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/bin/translatorshell.py +.. _`rpython/config/`: https://bitbucket.org/pypy/pypy/src/default/rpython/config/ +.. _`rpython/config/translationoption.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/config/translationoption.py +.. _`rpython/flowspace/`: https://bitbucket.org/pypy/pypy/src/default/rpython/flowspace/ +.. _`rpython/flowspace/model.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/flowspace/model.py +.. _`rpython/rlib`: +.. _`rpython/rlib/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/ +.. _`rpython/rlib/listsort.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/listsort.py +.. _`rpython/rlib/nonconst.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/nonconst.py +.. _`rpython/rlib/objectmodel.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/objectmodel.py +.. _`rpython/rlib/parsing/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/parsing/ +.. _`rpython/rlib/parsing/tree.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/parsing/tree.py +.. _`rpython/rlib/rarithmetic.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/rarithmetic.py +.. _`rpython/rlib/rbigint.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/rbigint.py +.. _`rpython/rlib/rrandom.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/rrandom.py +.. _`rpython/rlib/rsocket.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/rsocket.py +.. _`rpython/rlib/streamio.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/streamio.py +.. _`rpython/rlib/test`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/test/ +.. _`rpython/rlib/unroll.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/unroll.py +.. _`rpython/rtyper`: +.. _`rpython/rtyper/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/ +.. _`rpython/rtyper/lltypesystem/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/lltypesystem/ +.. _`rpython/rtyper/lltypesystem/lltype.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/lltypesystem/lltype.py +.. _`rpython/rtyper/memory/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/memory/ +.. _`rpython/rtyper/memory/gc/generation.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/memory/gc/generation.py +.. _`rpython/rtyper/memory/gc/hybrid.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/memory/gc/hybrid.py +.. _`rpython/rtyper/memory/gc/minimarkpage.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/memory/gc/minimarkpage.py +.. _`rpython/rtyper/memory/gc/semispace.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/memory/gc/semispace.py +.. _`rpython/rtyper/ootypesystem/`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/ootypesystem/ +.. _`rpython/rtyper/ootypesystem/ootype.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/ootypesystem/ootype.py +.. _`rpython/rtyper/rint.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/rint.py +.. _`rpython/rtyper/rlist.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/rlist.py +.. _`rpython/rtyper/rmodel.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/rmodel.py +.. _`rpython/rtyper/rtyper.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/rtyper.py +.. _`rpython/rtyper/test/test_llinterp.py`: https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/test/test_llinterp.py +.. _`rpython/translator`: +.. _`rpython/translator/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/ +.. _`rpython/translator/backendopt/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/backendopt/ +.. _`rpython/translator/c/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/c/ +.. _`rpython/translator/c/src/stacklet/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/c/src/stacklet/ +.. _`rpython/translator/c/src/stacklet/stacklet.h`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/c/src/stacklet/stacklet.h +.. _`rpython/translator/cli/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/cli/ +.. _`rpython/translator/jvm/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/jvm/ +.. _`rpython/translator/tool/`: https://bitbucket.org/pypy/pypy/src/default/rpython/translator/tool/ diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst --- a/pypy/doc/coding-guide.rst +++ b/pypy/doc/coding-guide.rst @@ -303,7 +303,7 @@ dicts with a unique key type only, provided it is hashable. Custom hash functions and custom equality will not be honored. - Use ``pypy.rlib.objectmodel.r_dict`` for custom hash functions. + Use ``rpython.rlib.objectmodel.r_dict`` for custom hash functions. **list comprehensions** @@ -328,7 +328,7 @@ **builtin functions** A number of builtin functions can be used. The precise set can be - found in `pypy/annotation/builtin.py`_ (see ``def builtin_xxx()``). + found in `rpython/annotator/builtin.py`_ (see ``def builtin_xxx()``). Some builtin functions may be limited in what they support, though. ``int, float, str, ord, chr``... are available as simple conversion @@ -365,7 +365,7 @@ We use normal integers for signed arithmetic. It means that before translation we get longs in case of overflow, and after translation we get a silent wrap-around. Whenever we need more control, we use the following -helpers (which live the `pypy/rlib/rarithmetic.py`_): +helpers (which live in `rpython/rlib/rarithmetic.py`_): **ovfcheck()** diff --git a/pypy/doc/configuration.rst b/pypy/doc/configuration.rst --- a/pypy/doc/configuration.rst +++ b/pypy/doc/configuration.rst @@ -188,7 +188,7 @@ toolchain`_ toolchain, have two separate sets of options. The translation toolchain options can be found on the ``config`` attribute of all ``TranslationContext`` -instances and are described in `pypy/config/translationoption.py`_. The interpreter options +instances and are described in `rpython/config/translationoption.py`_. The interpreter options are attached to the object space, also under the name ``config`` and are described in `pypy/config/pypyoption.py`_. diff --git a/pypy/doc/garbage_collection.rst b/pypy/doc/garbage_collection.rst --- a/pypy/doc/garbage_collection.rst +++ b/pypy/doc/garbage_collection.rst @@ -42,7 +42,7 @@ Two arenas of equal size, with only one arena in use and getting filled with new objects. When the arena is full, the live objects are copied into the other arena using Cheney's algorithm. The old arena is then -cleared. See `pypy/rpython/memory/gc/semispace.py`_. +cleared. See `rpython/rtyper/memory/gc/semispace.py`_. On Unix the clearing is done by reading ``/dev/zero`` into the arena, which is extremely memory efficient at least on Linux: it lets the @@ -55,7 +55,7 @@ Generational GC --------------- -This is a two-generations GC. See `pypy/rpython/memory/gc/generation.py`_. +This is a two-generations GC. See `rpython/rtyper/memory/gc/generation.py`_. It is implemented as a subclass of the Semispace copying collector. It adds a nursery, which is a chunk of the current semispace. Its size is @@ -86,7 +86,7 @@ Each generation is collected much less often than the previous one. The division of the generations is slightly more complicated than just nursery / semispace / external; see the diagram at the start of the -source code, in `pypy/rpython/memory/gc/hybrid.py`_. +source code, in `rpython/rtyper/memory/gc/hybrid.py`_. Mark & Compact GC ----------------- @@ -161,7 +161,7 @@ to the old stage. The dying case 2 objects are immediately freed. - The old stage is an area of memory containing old (small) objects. It - is handled by `pypy/rpython/memory/gc/minimarkpage.py`_. It is organized + is handled by `rpython/rtyper/memory/gc/minimarkpage.py`_. It is organized as "arenas" of 256KB or 512KB, subdivided into "pages" of 4KB or 8KB. Each page can either be free, or contain small objects of all the same size. Furthermore at any point in time each object location can be diff --git a/pypy/doc/getting-started-dev.rst b/pypy/doc/getting-started-dev.rst --- a/pypy/doc/getting-started-dev.rst +++ b/pypy/doc/getting-started-dev.rst @@ -172,23 +172,23 @@ ``xxxobject.py`` contain respectively the definition of the type and its (default) implementation. -* `pypy/translator`_ contains the code analysis and generation stuff. +* `rpython/translator`_ contains the code analysis and generation stuff. Start reading from translator.py, from which it should be easy to follow the pieces of code involved in the various translation phases. -* `pypy/annotation`_ contains the data model for the type annotation that +* `rpython/annotator`_ contains the data model for the type annotation that can be inferred about a graph. The graph "walker" that uses this is in - `pypy/annotation/annrpython.py`_. + `rpython/annotator/annrpython.py`_. -* `pypy/rpython`_ contains the code of the RPython typer. The typer transforms +* `rpython/rtyper`_ contains the code of the RPython typer. The typer transforms annotated flow graphs in a way that makes them very similar to C code so that they can be easy translated. The graph transformations are controlled - by the code in `pypy/rpython/rtyper.py`_. The object model that is used can - be found in `pypy/rpython/lltypesystem/lltype.py`_. For each RPython type + by the code in `rpython/rtyper/rtyper.py`_. The object model that is used can + be found in `rpython/rtyper/lltypesystem/lltype.py`_. For each RPython type there is a file rxxxx.py that contains the low level functions needed for this type. -* `pypy/rlib`_ contains the `RPython standard library`_, things that you can +* `rpython/rlib`_ contains the `RPython standard library`_, things that you can use from rpython. .. _`RPython standard library`: rlib.html @@ -319,10 +319,10 @@ Demos ------- -The `demo/`_ directory contains examples of various aspects of PyPy, -ranging from running regular Python programs (that we used as compliance goals) -over experimental distribution mechanisms to examples translating -sufficiently static programs into low level code. +The `example-interpreter`_ repository contains an example interpreter +written using the RPython translation toolchain. + +.. _`example-interpreter`: https://bitbucket.org/pypy/example-interpreter Additional Tools for running (and hacking) PyPy ----------------------------------------------- diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst --- a/pypy/doc/index.rst +++ b/pypy/doc/index.rst @@ -217,17 +217,20 @@ Here is a fully referenced alphabetical two-level deep directory overview of PyPy: -================================ =========================================== +================================= ============================================ Directory explanation/links -================================ =========================================== +================================= ============================================ +`pypy/bin/`_ command-line scripts, mainly + `pypy/bin/pyinteractive.py`_ -`pypy/bin/`_ command-line scripts, mainly `pyinteractive.py`_ +`pypy/config/`_ handles the numerous options for building + and running PyPy -`pypy/config/`_ handles the numerous options for building and running PyPy +`pypy/doc/`_ text versions of PyPy developer + documentation -`pypy/doc/`_ text versions of PyPy developer documentation - -`pypy/doc/config/`_ documentation for the numerous translation options +`pypy/doc/config/`_ documentation for the numerous translation + options `pypy/doc/discussion/`_ drafts of ideas and documentation @@ -238,19 +241,24 @@ `pypy/interpreter/pyparser/`_ interpreter-level Python source parser -`pypy/interpreter/astcompiler/`_ interpreter-level bytecode compiler, via an AST - representation +`pypy/interpreter/astcompiler/`_ interpreter-level bytecode compiler, + via an AST representation -`pypy/module/`_ contains `mixed modules`_ implementing core modules with +`pypy/module/`_ contains `mixed modules`_ + implementing core modules with both application and interpreter level code. - Not all are finished and working. Use the ``--withmod-xxx`` - or ``--allworkingmodules`` translation options. + Not all are finished and working. Use + the ``--withmod-xxx`` + or ``--allworkingmodules`` translation + options. `pypy/objspace/`_ `object space`_ implementations -`pypy/objspace/std/`_ the StdObjSpace_ implementing CPython's objects and types +`pypy/objspace/std/`_ the StdObjSpace_ implementing CPython's + objects and types -`pypy/tool/`_ various utilities and hacks used from various places +`pypy/tool/`_ various utilities and hacks used + from various places `pypy/tool/algo/`_ general-purpose algorithmic and mathematic tools @@ -258,49 +266,58 @@ `pypy/tool/pytest/`_ support code for our `testing methods`_ -`rpython/annotator/`_ `type inferencing code`_ for `RPython`_ programs +`rpython/annotator/`_ `type inferencing code`_ for + `RPython`_ programs `rpython/config/`_ handles the numerous options for RPython -`rpython/flowspace/`_ the FlowObjSpace_ implementing `abstract interpretation`_ +`rpython/flowspace/`_ the FlowObjSpace_ implementing + `abstract interpretation`_ - -`rpython/rlib/`_ a `"standard library"`_ for RPython_ programs +`rpython/rlib/`_ a `"standard library"`_ for RPython_ + programs `rpython/rtyper/`_ the `RPython Typer`_ -`rpython/rtyper/lltypesystem/`_ the `low-level type system`_ for C-like backends +`rpython/rtyper/lltypesystem/`_ the `low-level type system`_ for + C-like backends -`rpython/rtyper/ootypesystem/`_ the `object-oriented type system`_ for OO backends +`rpython/rtyper/ootypesystem/`_ the `object-oriented type system`_ + for OO backends -`rpython/rtyper/memory/`_ the `garbage collector`_ construction framework +`rpython/rtyper/memory/`_ the `garbage collector`_ construction + framework `rpython/translator/`_ translation_ backends and support code -`rpython/translator/backendopt/`_ general optimizations that run before a backend generates code +`rpython/translator/backendopt/`_ general optimizations that run before a + backend generates code -`rpython/translator/c/`_ the `GenC backend`_, producing C code from an +`rpython/translator/c/`_ the `GenC backend`_, producing C code + from an RPython program (generally via the rtyper_) -`rpython/translator/cli/`_ the `CLI backend`_ for `.NET`_ (Microsoft CLR or Mono_) +`rpython/translator/cli/`_ the `CLI backend`_ for `.NET`_ + (Microsoft CLR or Mono_) -`pypy/goal/`_ our `main PyPy-translation scripts`_ live here +`pypy/goal/`_ our `main PyPy-translation scripts`_ + live here `rpython/translator/jvm/`_ the Java backend -`rpython/translator/tool/`_ helper tools for translation, including the Pygame - `graph viewer`_ +`rpython/translator/tool/`_ helper tools for translation -``*/test/`` many directories have a test subdirectory containing test +`dotviewer/`_ `graph viewer`_ + +``*/test/`` many directories have a test subdirectory + containing test modules (see `Testing in PyPy`_) -``_cache/`` holds cache files from internally `translating application - level to interpreterlevel`_ code. -================================ =========================================== +``_cache/`` holds cache files from various purposes +================================= ============================================ .. _`bytecode interpreter`: interpreter.html -.. _`translating application level to interpreterlevel`: geninterp.html .. _`Testing in PyPy`: coding-guide.html#testing-in-pypy .. _`mixed modules`: coding-guide.html#mixed-modules .. _`modules`: coding-guide.html#modules diff --git a/pypy/doc/rlib.rst b/pypy/doc/rlib.rst --- a/pypy/doc/rlib.rst +++ b/pypy/doc/rlib.rst @@ -7,18 +7,18 @@ .. contents:: -This page lists some of the modules in `pypy/rlib`_ together with some hints +This page lists some of the modules in `rpython/rlib`_ together with some hints for what they can be used for. The modules here will make up some general library useful for RPython programs (since most of the standard library modules are not RPython). Most of these modules are somewhat rough still and are likely to change at some point. Usually it is useful to look at the tests in -`pypy/rlib/test`_ to get an impression of how to use a module. +`rpython/rlib/test`_ to get an impression of how to use a module. ``listsort`` ============ -The `pypy/rlib/listsort.py`_ module contains an implementation of the timsort sorting algorithm +The `rpython/rlib/listsort.py`_ module contains an implementation of the timsort sorting algorithm (the sort method of lists is not RPython). To use it, subclass from the ``listsort.TimSort`` class and override the ``lt`` method to change the comparison behaviour. The constructor of ``TimSort`` takes a list as an @@ -30,7 +30,7 @@ ``nonconst`` ============ -The `pypy/rlib/nonconst.py`_ module is useful mostly for tests. The `flow object space`_ and +The `rpython/rlib/nonconst.py`_ module is useful mostly for tests. The `flow object space`_ and the `annotator`_ do quite some constant folding, which is sometimes not desired in a test. To prevent constant folding on a certain value, use the ``NonConst`` class. The constructor of ``NonConst`` takes an arbitrary value. The instance of @@ -44,7 +44,7 @@ ``objectmodel`` =============== -The `pypy/rlib/objectmodel.py`_ module is a mixed bag of various functionality. Some of the +The `rpython/rlib/objectmodel.py`_ module is a mixed bag of various functionality. Some of the more useful ones are: ``ComputedIntSymbolic``: @@ -94,7 +94,7 @@ ``rarithmetic`` =============== -The `pypy/rlib/rarithmetic.py`_ module contains functionality to handle the small differences +The `rpython/rlib/rarithmetic.py`_ module contains functionality to handle the small differences in the behaviour of arithmetic code in regular Python and RPython code. Most of them are already described in the `coding guide`_ @@ -104,7 +104,7 @@ ``rbigint`` =========== -The `pypy/rlib/rbigint.py`_ module contains a full RPython implementation of the Python ``long`` +The `rpython/rlib/rbigint.py`_ module contains a full RPython implementation of the Python ``long`` type (which itself is not supported in RPython). The ``rbigint`` class contains that implementation. To construct ``rbigint`` instances use the static methods ``fromint``, ``frombool``, ``fromfloat`` and ``fromdecimalstr``. To convert back @@ -118,7 +118,7 @@ ``rrandom`` =========== -The `pypy/rlib/rrandom.py`_ module contains an implementation of the mersenne twister random +The `rpython/rlib/rrandom.py`_ module contains an implementation of the mersenne twister random number generator. It contains one class ``Random`` which most importantly has a ``random`` method which returns a pseudo-random floating point number between 0.0 and 1.0. @@ -126,7 +126,7 @@ ``rsocket`` =========== -The `pypy/rlib/rsocket.py`_ module contains an RPython implementation of the functionality of +The `rpython/rlib/rsocket.py`_ module contains an RPython implementation of the functionality of the socket standard library with a slightly different interface. The difficulty with the Python socket API is that addresses are not "well-typed" objects: depending on the address family they are tuples, or strings, and @@ -137,7 +137,7 @@ ``streamio`` ============ -The `pypy/rlib/streamio.py`_ contains an RPython stream I/O implementation (which was started +The `rpython/rlib/streamio.py`_ contains an RPython stream I/O implementation (which was started by Guido van Rossum as `sio.py`_ in the CPython sandbox as a prototype for the upcoming new file implementation in Python 3000). @@ -146,7 +146,7 @@ ``unroll`` ========== -The `pypy/rlib/unroll.py`_ module most importantly contains the function ``unrolling_iterable`` +The `rpython/rlib/unroll.py`_ module most importantly contains the function ``unrolling_iterable`` which wraps an iterator. Looping over the iterator in RPython code will not produce a loop in the resulting flow graph but will unroll the loop instead. @@ -154,7 +154,7 @@ ``parsing`` =========== -The `pypy/rlib/parsing/`_ module is a still in-development module to generate tokenizers and +The `rpython/rlib/parsing/`_ module is a still in-development module to generate tokenizers and parsers in RPython. It is still highly experimental and only really used by the `Prolog interpreter`_ (although in slightly non-standard ways). The easiest way to specify a tokenizer/grammar is to write it down using regular expressions and @@ -204,7 +204,7 @@ anything except a. To parse a regular expression and to get a matcher for it, you can use the -function ``make_runner(s)`` in the ``pypy.rlib.parsing.regexparse`` module. It +function ``make_runner(s)`` in the ``rpython.rlib.parsing.regexparse`` module. It returns a object with a ``recognize(input)`` method that returns True or False depending on whether ``input`` matches the string or not. @@ -213,7 +213,7 @@ EBNF ---- -To describe a tokenizer and a grammar the ``pypy.rlib.parsing.ebnfparse`` +To describe a tokenizer and a grammar the ``rpython.rlib.parsing.ebnfparse`` defines a syntax for doing that. The syntax file contains a sequence or rules. Every rule either describes a @@ -295,7 +295,7 @@ The parsing process builds up a tree consisting of instances of ``Symbol`` and ``Nonterminal``, the former corresponding to tokens, the latter to nonterminal -symbols. Both classes live in the `pypy/rlib/parsing/tree.py`_ module. You can use +symbols. Both classes live in the `rpython/rlib/parsing/tree.py`_ module. You can use the ``view()`` method ``Nonterminal`` instances to get a pygame view of the parse tree. @@ -310,7 +310,7 @@ ++++++++ To write tree visitors for the parse trees that are RPython, there is a special -baseclass ``RPythonVisitor`` in `pypy/rlib/parsing/tree.py`_ to use. If your +baseclass ``RPythonVisitor`` in `rpython/rlib/parsing/tree.py`_ to use. If your class uses this, it will grow a ``dispatch(node)`` method, that calls an appropriate ``visit_<symbol>`` method, depending on the ``node`` argument. Here the <symbol> is replaced by the ``symbol`` attribute of the visited node. diff --git a/pypy/doc/rtyper.rst b/pypy/doc/rtyper.rst --- a/pypy/doc/rtyper.rst +++ b/pypy/doc/rtyper.rst @@ -4,7 +4,7 @@ .. contents:: -The RPython Typer lives in the directory `pypy/rpython/`_. +The RPython Typer lives in the directory `rpython/rtyper/`_. Overview @@ -52,7 +52,7 @@ where -- in C notation -- all three variables v1, v2 and v3 are typed ``int``. This is done by attaching an attribute ``concretetype`` to v1, v2 and v3 (which might be instances of Variable or possibly Constant). In our model, -this ``concretetype`` is ``pypy.rpython.lltypesystem.lltype.Signed``. Of +this ``concretetype`` is ``rpython.rtyper.lltypesystem.lltype.Signed``. Of course, the purpose of replacing the operation called ``add`` with ``int_add`` is that code generators no longer have to worry about what kind of addition (or concatenation maybe?) it means. @@ -66,7 +66,7 @@ each operation. In both cases the analysis of an operation depends on the annotations of its input arguments. This is reflected in the usage of the same ``__extend__`` syntax in the source files (compare e.g. -`pypy/annotation/binaryop.py`_ and `pypy/rpython/rint.py`_). +`rpython/annotator/binaryop.py`_ and `rpython/rtyper/rint.py`_). The analogy stops here, though: while it runs, the Annotator is in the middle of computing the annotations, so it might need to reflow and generalize until @@ -104,7 +104,7 @@ implementations for the same high-level operations. This is the reason for turning representations into explicit objects. -The base Repr class is defined in `pypy/rpython/rmodel.py`_. Most of the +The base Repr class is defined in `rpython/rtyper/rmodel.py`_. Most of the ``rpython/r*.py`` files define one or a few subclasses of Repr. The method getrepr() of the RTyper will build and cache a single Repr instance per SomeXxx() instance; moreover, two SomeXxx() instances that are equal get the @@ -131,9 +131,9 @@ The RPython Typer uses a standard low-level model which we believe can correspond rather directly to various target languages such as C. This model is implemented in the first part of -`pypy/rpython/lltypesystem/lltype.py`_. +`rpython/rtyper/lltypesystem/lltype.py`_. -The second part of `pypy/rpython/lltypesystem/lltype.py`_ is a runnable +The second part of `rpython/rtyper/lltypesystem/lltype.py`_ is a runnable implementation of these types, for testing purposes. It allows us to write and test plain Python code using a malloc() function to obtain and manipulate structures and arrays. This is useful for example to implement and test @@ -147,7 +147,7 @@ Here is a quick tour: - >>> from pypy.rpython.lltypesystem.lltype import * + >>> from rpython.rtyper.lltypesystem.lltype import * Here are a few primitive low-level types, and the typeOf() function to figure them out: @@ -191,7 +191,7 @@ types like list in this elementary world. The ``malloc()`` function is a kind of placeholder, which must eventually be provided by the code generator for the target platform; but as we have just seen its Python implementation in -`pypy/rpython/lltypesystem/lltype.py`_ works too, which is primarily useful for +`rpython/rtyper/lltypesystem/lltype.py`_ works too, which is primarily useful for testing, interactive exploring, etc. The argument to ``malloc()`` is the structure type directly, but it returns a @@ -245,7 +245,7 @@ +++++++++++++++ Structure types are built as instances of -``pypy.rpython.lltypesystem.lltype.Struct``:: +``rpython.rtyper.lltypesystem.lltype.Struct``:: MyStructType = Struct('somename', ('field1', Type1), ('field2', Type2)...) MyStructType = GcStruct('somename', ('field1', Type1), ('field2', Type2)...) @@ -277,7 +277,7 @@ +++++++++++ An array type is built as an instance of -``pypy.rpython.lltypesystem.lltype.Array``:: +``rpython.rtyper.lltypesystem.lltype.Array``:: MyIntArray = Array(Signed) MyOtherArray = Array(MyItemType) @@ -316,7 +316,7 @@ with care: the bigger structure of which they are part of could be freed while the Ptr to the substructure is still in use. In general, it is a good idea to avoid passing around pointers to inlined substructures of malloc()ed structures. -(The testing implementation of `pypy/rpython/lltypesystem/lltype.py`_ checks to some +(The testing implementation of `rpython/rtyper/lltypesystem/lltype.py`_ checks to some extent that you are not trying to use a pointer to a structure after its container has been freed, using weak references. But pointers to non-GC structures are not officially meant to be weak references: using them after what @@ -429,7 +429,7 @@ change needed to the Annotator to allow it to perform type inference of our very-low-level snippets of code. -See for example `pypy/rpython/rlist.py`_. +See for example `rpython/rtyper/rlist.py`_. .. _`oo type`: @@ -441,10 +441,10 @@ targeting low level backends such as C, but it is not good enough for targeting higher level backends such as .NET CLI or Java JVM, so a new object oriented model has been introduced. This model is -implemented in the first part of `pypy/rpython/ootypesystem/ootype.py`_. +implemented in the first part of `rpython/rtyper/ootypesystem/ootype.py`_. As for the low-level typesystem, the second part of -`pypy/rpython/ootypesystem/ootype.py`_ is a runnable implementation of +`rpython/rtyper/ootypesystem/ootype.py`_ is a runnable implementation of these types, for testing purposes. @@ -751,7 +751,7 @@ The LLInterpreter is a simple piece of code that is able to interpret flow graphs. This is very useful for testing purposes, especially if you work on the RPython Typer. The most useful interface for it is the ``interpret`` -function in the file `pypy/rpython/test/test_llinterp.py`_. It takes as +function in the file `rpython/rtyper/test/test_llinterp.py`_. It takes as arguments a function and a list of arguments with which the function is supposed to be called. Then it generates the flow graph, annotates it according to the types of the arguments you passed to it and runs the diff --git a/pypy/doc/stackless.rst b/pypy/doc/stackless.rst --- a/pypy/doc/stackless.rst +++ b/pypy/doc/stackless.rst @@ -29,7 +29,7 @@ on 32-bit or a complete megabyte on 64-bit. Moreover, the feature is only available (so far) on x86 and x86-64 CPUs; for other CPUs you need to add a short page of custom assembler to -`pypy/translator/c/src/stacklet/`_. +`rpython/translator/c/src/stacklet/`_. Theory @@ -271,7 +271,7 @@ Continulets are internally implemented using stacklets, which is the generic RPython-level building block for "one-shot continuations". For more information about them please see the documentation in the C source -at `pypy/translator/c/src/stacklet/stacklet.h`_. +at `rpython/translator/c/src/stacklet/stacklet.h`_. The module ``pypy.rlib.rstacklet`` is a thin wrapper around the above functions. The key point is that new() and switch() always return a diff --git a/pypy/doc/tool/makeref.py b/pypy/doc/tool/makeref.py --- a/pypy/doc/tool/makeref.py +++ b/pypy/doc/tool/makeref.py @@ -1,10 +1,9 @@ import py -py.path.local(__file__) import pypy -pypydir = py.path.local(pypy.__file__).dirpath() -distdir = pypydir.dirpath() -issue_url = 'http://codespeak.net/issue/pypy-dev/' +pypydir = py.path.local(pypy.__file__).join('..') +distdir = pypydir.dirpath() +issue_url = 'http://bugs.pypy.org/issue/pypy-dev/' bitbucket_url = 'https://bitbucket.org/pypy/pypy/src/default/' import urllib2, posixpath diff --git a/pypy/doc/translation.rst b/pypy/doc/translation.rst --- a/pypy/doc/translation.rst +++ b/pypy/doc/translation.rst @@ -90,7 +90,7 @@ (although these steps are not quite as distinct as you might think from this presentation). -There is an `interactive interface`_ called `pypy/bin/translatorshell.py`_ to the +There is an `interactive interface`_ called `rpython/bin/translatorshell.py`_ to the translation process which allows you to interactively work through these stages. @@ -116,7 +116,7 @@ which are the basic data structures of the translation process. -All these types are defined in `pypy/objspace/flow/model.py`_ (which is a rather +All these types are defined in `rpython/flowspace/model.py`_ (which is a rather important module in the PyPy source base, to reinforce the point). The flow graph of a function is represented by the class ``FunctionGraph``. diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -65,3 +65,6 @@ .. branch: signal-and-thread Add "__pypy__.thread.signals_enabled", a context manager. Can be used in a non-main thread to enable the processing of signal handlers in that thread. + +.. branch: coding-guide-update-rlib-refs +.. branch: rlib-doc-rpython-refs diff --git a/rpython/jit/backend/x86/test/test_zrpy_gc.py b/rpython/jit/backend/x86/test/test_zrpy_gc.py --- a/rpython/jit/backend/x86/test/test_zrpy_gc.py +++ b/rpython/jit/backend/x86/test/test_zrpy_gc.py @@ -5,10 +5,9 @@ """ import weakref -import py, os -from rpython.annotator import policy as annpolicy +import os from rpython.rlib import rgc -from rpython.rtyper.lltypesystem import lltype, llmemory, rffi +from rpython.rtyper.lltypesystem import lltype from rpython.rlib.jit import JitDriver, dont_look_inside from rpython.rlib.jit import elidable, unroll_safe from rpython.jit.backend.llsupport.gc import GcLLDescr_framework diff --git a/rpython/jit/backend/x86/test/test_zrpy_releasegil.py b/rpython/jit/backend/x86/test/test_zrpy_releasegil.py --- a/rpython/jit/backend/x86/test/test_zrpy_releasegil.py +++ b/rpython/jit/backend/x86/test/test_zrpy_releasegil.py @@ -1,13 +1,13 @@ from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.rlib.jit import dont_look_inside +from rpython.rlib.objectmodel import invoke_around_extcall from rpython.jit.metainterp.optimizeopt import ALL_OPTS_NAMES -from rpython.rlib.libffi import CDLL, types, ArgChain, clibffi -from rpython.rtyper.lltypesystem.ll2ctypes import libc_name from rpython.rtyper.annlowlevel import llhelper from rpython.jit.backend.x86.test.test_zrpy_gc import BaseFrameworkTests from rpython.jit.backend.x86.test.test_zrpy_gc import check +from rpython.tool.udir import udir class ReleaseGILTests(BaseFrameworkTests): @@ -15,35 +15,33 @@ def define_simple(self): class Glob: - pass + def __init__(self): + self.event = 0 glob = Glob() # - def f42(n): - c_strchr = glob.c_strchr - raw = rffi.str2charp("foobar" + chr((n & 63) + 32)) - argchain = ArgChain() - argchain = argchain.arg(rffi.cast(lltype.Signed, raw)) - argchain = argchain.arg(rffi.cast(rffi.INT, ord('b'))) - res = c_strchr.call(argchain, rffi.CCHARP) - check(rffi.charp2str(res) == "bar" + chr((n & 63) + 32)) - rffi.free_charp(raw) - # + + c_strchr = rffi.llexternal('strchr', [rffi.CCHARP, lltype.Signed], + rffi.CCHARP) + + def func(): + glob.event += 1 + def before(n, x): - libc = CDLL(libc_name) - c_strchr = libc.getpointer('strchr', [types.pointer, types.sint], - types.pointer) - glob.c_strchr = c_strchr + invoke_around_extcall(func, func) return (n, None, None, None, None, None, None, None, None, None, None, None) # def f(n, x, *args): - f42(n) + a = rffi.str2charp(str(n)) + c_strchr(a, ord('0')) + lltype.free(a, flavor='raw') n -= 1 return (n, x) + args return before, f, None def test_simple(self): self.run('simple') + assert 'call_release_gil' in udir.join('TestCompileFramework.log').read() def define_close_stack(self): # @@ -66,30 +64,23 @@ @dont_look_inside def free1(p): llmemory.raw_free(p) + + c_qsort = rffi.llexternal('qsort', [rffi.VOIDP, rffi.SIZE_T, + rffi.SIZE_T, CALLBACK], lltype.Void) # def f42(): length = len(glob.lst) - c_qsort = glob.c_qsort raw = alloc1() fn = llhelper(CALLBACK, rffi._make_wrapper_for(CALLBACK, callback)) - argchain = ArgChain() - argchain = argchain.arg(rffi.cast(lltype.Signed, raw)) - argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 2)) - argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 8)) - argchain = argchain.arg(rffi.cast(lltype.Signed, fn)) - c_qsort.call(argchain, lltype.Void) + c_qsort(rffi.cast(rffi.VOIDP, raw), rffi.cast(rffi.SIZE_T, 2), + rffi.cast(rffi.SIZE_T, 8), fn) free1(raw) check(len(glob.lst) > length) del glob.lst[:] # def before(n, x): - libc = CDLL(libc_name) - types_size_t = clibffi.cast_type_to_ffitype(rffi.SIZE_T) - c_qsort = libc.getpointer('qsort', [types.pointer, types_size_t, - types_size_t, types.pointer], - types.void) - glob.c_qsort = c_qsort glob.lst = [] + return (n, None, None, None, None, None, None, None, None, None, None, None) # @@ -101,6 +92,7 @@ def test_close_stack(self): self.run('close_stack') + assert 'call_release_gil' in udir.join('TestCompileFramework.log').read() class TestShadowStack(ReleaseGILTests): diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py --- a/rpython/jit/metainterp/pyjitpl.py +++ b/rpython/jit/metainterp/pyjitpl.py @@ -1082,7 +1082,7 @@ def opimpl_debug_fatalerror(self, box): from rpython.rtyper.lltypesystem import rstr, lloperation msg = box.getref(lltype.Ptr(rstr.STR)) - lloperation.llop.debug_fatalerror(msg) + lloperation.llop.debug_fatalerror(lltype.Void, msg) @arguments("box", "box", "box", "box", "box") def opimpl_jit_debug(self, stringbox, arg1box, arg2box, arg3box, arg4box): diff --git a/rpython/rtyper/lltypesystem/rdict.py b/rpython/rtyper/lltypesystem/rdict.py --- a/rpython/rtyper/lltypesystem/rdict.py +++ b/rpython/rtyper/lltypesystem/rdict.py @@ -385,48 +385,60 @@ # be direct_call'ed from rtyped flow graphs, which means that they will # get flowed and annotated, mostly with SomePtr. +@objectmodel.enforceargs(None, int) def ll_everused_from_flag(entries, i): return entries[i].f_everused +@objectmodel.enforceargs(None, int) def ll_everused_from_key(entries, i): return bool(entries[i].key) +@objectmodel.enforceargs(None, int) def ll_everused_from_value(entries, i): return bool(entries[i].value) +@objectmodel.enforceargs(None, int) def ll_valid_from_flag(entries, i): return entries[i].f_valid +@objectmodel.enforceargs(None, int) def ll_mark_deleted_in_flag(entries, i): entries[i].f_valid = False +@objectmodel.enforceargs(None, int) def ll_valid_from_key(entries, i): ENTRIES = lltype.typeOf(entries).TO dummy = ENTRIES.dummy_obj.ll_dummy_value return entries.everused(i) and entries[i].key != dummy +@objectmodel.enforceargs(None, int) def ll_mark_deleted_in_key(entries, i): ENTRIES = lltype.typeOf(entries).TO dummy = ENTRIES.dummy_obj.ll_dummy_value entries[i].key = dummy +@objectmodel.enforceargs(None, int) def ll_valid_from_value(entries, i): ENTRIES = lltype.typeOf(entries).TO dummy = ENTRIES.dummy_obj.ll_dummy_value return entries.everused(i) and entries[i].value != dummy +@objectmodel.enforceargs(None, int) def ll_mark_deleted_in_value(entries, i): ENTRIES = lltype.typeOf(entries).TO dummy = ENTRIES.dummy_obj.ll_dummy_value entries[i].value = dummy +@objectmodel.enforceargs(None, int) def ll_hash_from_cache(entries, i): return entries[i].f_hash +@objectmodel.enforceargs(None, int) def ll_hash_recomputed(entries, i): ENTRIES = lltype.typeOf(entries).TO return ENTRIES.fasthashfn(entries[i].key) +@objectmodel.enforceargs(None, int) def ll_get_value(d, i): return d.entries[i].value diff --git a/rpython/rtyper/lltypesystem/rlist.py b/rpython/rtyper/lltypesystem/rlist.py --- a/rpython/rtyper/lltypesystem/rlist.py +++ b/rpython/rtyper/lltypesystem/rlist.py @@ -419,6 +419,7 @@ def __init__(self, r_list): self.r_list = r_list + self.external_item_repr = r_list.external_item_repr self.lowleveltype = Ptr(GcStruct('listiter', ('list', r_list.lowleveltype), ('index', Signed))) diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py --- a/rpython/rtyper/lltypesystem/rstr.py +++ b/rpython/rtyper/lltypesystem/rstr.py @@ -1054,15 +1054,18 @@ def __init__(self): self.ll_striter = ll_striter self.ll_strnext = ll_strnext + self.ll_getnextindex = ll_getnextindex class StringIteratorRepr(BaseStringIteratorRepr): + external_item_repr = char_repr lowleveltype = Ptr(GcStruct('stringiter', ('string', string_repr.lowleveltype), ('index', Signed))) class UnicodeIteratorRepr(BaseStringIteratorRepr): + external_item_repr = unichar_repr lowleveltype = Ptr(GcStruct('unicodeiter', ('string', unicode_repr.lowleveltype), ('index', Signed))) @@ -1087,6 +1090,9 @@ iter.index = index + 1 return chars[index] +def ll_getnextindex(iter): + return iter.index + string_repr.iterator_repr = StringIteratorRepr() unicode_repr.iterator_repr = UnicodeIteratorRepr() diff --git a/rpython/rtyper/ootypesystem/rstr.py b/rpython/rtyper/ootypesystem/rstr.py --- a/rpython/rtyper/ootypesystem/rstr.py +++ b/rpython/rtyper/ootypesystem/rstr.py @@ -428,14 +428,17 @@ class StringIteratorRepr(AbstractStringIteratorRepr): + external_item_repr = char_repr lowleveltype = ootype.Record({'string': string_repr.lowleveltype, 'index': ootype.Signed}) def __init__(self): self.ll_striter = ll_striter self.ll_strnext = ll_strnext + self.ll_getnextindex = ll_getnextindex class UnicodeIteratorRepr(AbstractStringIteratorRepr): + external_item_repr = unichar_repr lowleveltype = ootype.Record({'string': unicode_repr.lowleveltype, 'index': ootype.Signed}) @@ -463,6 +466,9 @@ iter.index = index + 1 return string.ll_stritem_nonneg(index) +def ll_getnextindex(iter): + return iter.index + StringRepr.string_iterator_repr = StringIteratorRepr() UnicodeRepr.string_iterator_repr = UnicodeIteratorRepr() diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py --- a/rpython/rtyper/rclass.py +++ b/rpython/rtyper/rclass.py @@ -395,7 +395,7 @@ assert not s_attr.is_constant() if '__iter__' in self.allinstancefields: raise Exception("__iter__ on instance disallowed") - r_method = self.rtyper.makerepr(s_attr) + r_method = self.rtyper.getrepr(s_attr) r_method.get_method_from_instance(self, vinst, hop.llops) hop2 = hop.copy() hop2.spaceop.opname = 'simple_call' diff --git a/rpython/rtyper/rptr.py b/rpython/rtyper/rptr.py --- a/rpython/rtyper/rptr.py +++ b/rpython/rtyper/rptr.py @@ -23,6 +23,8 @@ def rtyper_makerepr(self, rtyper): return InteriorPtrRepr(self.ll_ptrtype) + def rtyper_makekey(self): + return self.__class__, self.ll_ptrtype class PtrRepr(Repr): @@ -345,3 +347,10 @@ if r_from.lowleveltype == r_to.lowleveltype: return v return NotImplemented + +class __extend__(pairtype(InteriorPtrRepr, InteriorPtrRepr)): + + def convert_from_to((r_from, r_to), v, llops): + if r_from.__dict__ == r_to.__dict__: + return v + return NotImplemented diff --git a/rpython/rtyper/rrange.py b/rpython/rtyper/rrange.py --- a/rpython/rtyper/rrange.py +++ b/rpython/rtyper/rrange.py @@ -207,7 +207,7 @@ v_index = hop.gendirectcall(self.ll_getnextindex, v_enumerate) hop2 = hop.copy() hop2.args_r = [self.r_baseiter] - r_item_src = self.r_baseiter.r_list.external_item_repr + r_item_src = self.r_baseiter.external_item_repr r_item_dst = hop.r_result.items_r[1] v_item = self.r_baseiter.rtype_next(hop2) v_item = hop.llops.convertvar(v_item, r_item_src, r_item_dst) diff --git a/rpython/rtyper/test/test_rptr.py b/rpython/rtyper/test/test_rptr.py --- a/rpython/rtyper/test/test_rptr.py +++ b/rpython/rtyper/test/test_rptr.py @@ -336,6 +336,21 @@ res = interpret(f, []) assert res == 1 +def test_interior_ptr_convert(): + S = lltype.Struct("S", ("x", lltype.Signed)) + T = lltype.GcArray(S) + def f(i): + t = lltype.malloc(T, 2) + if i: + x = t[0] + else: + x = t[1] + x.x = 3 + return t[0].x + + res = interpret(f, [13]) + assert res == 3 + def test_interior_ptr_with_field_and_index(): S = lltype.Struct("S", ('x', lltype.Signed)) T = lltype.GcStruct("T", ('items', lltype.Array(S))) diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py --- a/rpython/rtyper/test/test_rstr.py +++ b/rpython/rtyper/test/test_rstr.py @@ -1035,6 +1035,17 @@ got = self.interpret(f, [7]) assert self.ll_to_string(got) == 'None' + def test_enumerate(self): + const = self.const + def fn(n): + s = const('abcde') + for i, x in enumerate(s): + if i == n: + return x + return 'x' + res = self.interpret(fn, [2]) + assert res == 'c' + def FIXME_test_str_to_pystringobj(): def f(n): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit