1. 20 Feb, 2018 3 commits
  2. 08 Feb, 2018 1 commit
  3. 06 Feb, 2018 1 commit
  4. 19 Dec, 2017 1 commit
  5. 11 Dec, 2017 4 commits
    • Damien George's avatar
      py/runtime: Use the Python stack when building *arg and **kwarg state. · 30fd8484
      Damien George authored
      With MICROPY_ENABLE_PYSTACK enabled the following language constructs no
      longer allocate on the heap: f(*arg), f(**kwarg).
    • Damien George's avatar
    • Damien George's avatar
      py: Introduce a Python stack for scoped allocation. · 02d830c0
      Damien George authored
      This patch introduces the MICROPY_ENABLE_PYSTACK option (disabled by
      default) which enables a "Python stack" that allows to allocate and free
      memory in a scoped, or Last-In-First-Out (LIFO) way, similar to alloca().
      A new memory allocation API is introduced along with this Py-stack.  It
      includes both "local" and "nonlocal" LIFO allocation.  Local allocation is
      intended to be equivalent to using alloca(), whereby the same function must
      free the memory.  Nonlocal allocation is where another function may free
      the memory, so long as it's still LIFO.
      Follow-up patches will convert all uses of alloca() and VLA to the new
      scoped allocation API.  The old behaviour (using alloca()) will still be
      available, but when MICROPY_ENABLE_PYSTACK is enabled then alloca() is no
      longer required or used.
      The benefits of enabling this option are (or will be once subsequent
      patches are made to convert alloca()/VLA):
      - Toolchains without alloca() can use this feature to obtain correct and
        efficient scoped memory allocation (compared to using the heap instead
        of alloca(), which is slower).
      - Even if alloca() is available, enabling the Py-stack gives slightly more
        efficient use of stack space when calling nested Python functions, due to
        the way that compilers implement alloca().
      - Enabling the Py-stack with the stackless mode allows for even more
        efficient stack usage, as well as retaining high performance (because the
        heap is no longer used to build and destroy stackless code states).
      - With Py-stack and stackless enabled, Python-calling-Python is no longer
        recursive in the C mp_execute_bytecode function.
      The micropython.pystack_use() function is included to measure usage of the
      Python stack.
    • Damien George's avatar
      py/runtime: Move mp_exc_recursion_depth to runtime and rename to raise. · 5b8998da
      Damien George authored
      For consistency this helper function is renamed to match the other
      exception helpers, and moved to their location in runtime.c.
  6. 08 Dec, 2017 1 commit
  7. 24 Nov, 2017 2 commits
    • Damien George's avatar
      py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN. · 5e34a113
      Damien George authored
      Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it
      meant that the args needed to be swapped, but coming from within the
      runtime meant that the args were already in the correct order.  This lead
      to some confusion in the code and comments stating how args were reversed.
      It also lead to 2 bugs: 1) containment for a subclass of a native type
      didn't work; 2) the expression "{True} in True" would illegally succeed and
      return True.  In both of these cases it was because the args to
      MP_BINARY_OP_IN ended up being reversed twice.
      To fix these things this patch introduces MP_BINARY_OP_CONTAINS which
      corresponds exactly to the __contains__ special method, and this is the
      operator that built-in types should implement.  MP_BINARY_OP_IN is now only
      emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by
      swapping the arguments.
    • Damien George's avatar
      py/runtime: Simplify handling of containment binary operator. · 9783ac28
      Damien George authored
      In mp_binary_op, there is no need to explicitly check for type->getiter
      being non-null and raising an exception because this is handled exactly by
      mp_getiter().  So just call the latter unconditionally.
  8. 13 Oct, 2017 1 commit
    • Damien George's avatar
      extmod/uos_dupterm: Update uos.dupterm() and helper funcs to have index. · 37282f8f
      Damien George authored
      The uos.dupterm() signature and behaviour is updated to reflect the latest
      enhancements in the docs.  It has minor backwards incompatibility in that
      it no longer accepts zero arguments.
      The dupterm_rx helper function is moved from esp8266 to extmod and
      generalised to support multiple dupterm slots.
      A port can specify multiple slots by defining the MICROPY_PY_OS_DUPTERM
      config macro to an integer, being the number of slots it wants to have;
      0 means to disable the dupterm feature altogether.
      The unix and esp8266 ports are updated to work with the new interface and
      are otherwise unchanged with respect to functionality.
  9. 04 Oct, 2017 1 commit
    • Damien George's avatar
      all: Remove inclusion of internal py header files. · a3dc1b19
      Damien George authored
      Header files that are considered internal to the py core and should not
      normally be included directly are:
          py/nlr.h - internal nlr configuration and declarations
          py/bc0.h - contains bytecode macro definitions
          py/runtime0.h - contains basic runtime enums
      Instead, the top-level header files to include are one of:
          py/obj.h - includes runtime0.h and defines everything to use the
              mp_obj_t type
          py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
              and defines everything to use the general runtime support functions
      Additional, specific headers (eg py/objlist.h) can be included if needed.
  10. 17 Sep, 2017 1 commit
    • Paul Sokolovsky's avatar
      py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS. · 9dce823c
      Paul Sokolovsky authored
      This allows user classes to implement __abs__ special method, and saves
      code size (104 bytes for x86_64), even though during refactor, an issue
      was fixed and few optimizations were made:
      * abs() of minimum (negative) small int value is calculated properly.
      * objint_longlong and objint_mpz avoid allocating new object is the
        argument is already non-negative.
  11. 10 Sep, 2017 1 commit
  12. 31 Aug, 2017 1 commit
  13. 29 Aug, 2017 1 commit
  14. 15 Aug, 2017 1 commit
  15. 13 Aug, 2017 1 commit
    • Javier Candeira's avatar
      all: Raise exceptions via mp_raise_XXX · 35a1fea9
      Javier Candeira authored
        - Changed: ValueError, TypeError, NotImplementedError
        - OSError invocations unchanged, because the corresponding utility
          function takes ints, not strings like the long form invocation.
        - OverflowError, IndexError and RuntimeError etc. not changed for now
          until we decide whether to add new utility functions.
  16. 31 Jul, 2017 1 commit
  17. 19 Jul, 2017 1 commit
  18. 14 Jul, 2017 1 commit
  19. 07 Jul, 2017 1 commit
  20. 03 Jul, 2017 1 commit
  21. 10 Apr, 2017 1 commit
  22. 29 Mar, 2017 2 commits
    • Damien George's avatar
    • Damien George's avatar
      py: Convert mp_uint_t to size_t for tuple/list accessors. · 6213ad7f
      Damien George authored
      This patch changes mp_uint_t to size_t for the len argument of the
      following public facing C functions:
      These functions take a pointer to the len argument (to be filled in by the
      function) and callers of these functions should update their code so the
      type of len is changed to size_t.  For ports that don't use nan-boxing
      there should be no change in generate code because the size of the type
      remains the same (word sized), and in a lot of cases there won't even be a
      compiler warning if the type remains as mp_uint_t.
      The reason for this change is to standardise on the use of size_t for
      variables that count memory (or memory related) sizes/lengths.  It helps
      builds that use nan-boxing.
  23. 28 Mar, 2017 1 commit
  24. 24 Mar, 2017 1 commit
  25. 20 Mar, 2017 1 commit
  26. 07 Mar, 2017 2 commits
  27. 24 Feb, 2017 1 commit
  28. 16 Feb, 2017 4 commits
  29. 27 Jan, 2017 1 commit
    • Damien George's avatar
      extmod: Add generic VFS sub-system. · dcb9ea72
      Damien George authored
      This provides mp_vfs_XXX functions (eg mount, open, listdir) which are
      agnostic to the underlying filesystem type, and just require an object with
      the relevant filesystem-like methods (eg .mount, .open, .listidr) which can
      then be mounted.
      These mp_vfs_XXX functions would typically be used by a port to implement
      the "uos" module, and mp_vfs_open would be the builtin open function.
      This feature is controlled by MICROPY_VFS, disabled by default.