1. 17 Aug, 2015 1 commit
    • Damien George's avatar
      unix-cpy: Remove unix-cpy. It's no longer needed. · 65dc960e
      Damien George authored
      unix-cpy was originally written to get semantic equivalent with CPython
      without writing functional tests.  When writing the initial
      implementation of uPy it was a long way between lexer and functional
      tests, so the half-way test was to make sure that the bytecode was
      correct.  The idea was that if the uPy bytecode matched CPython 1-1 then
      uPy would be proper Python if the bytecodes acted correctly.  And having
      matching bytecode meant that it was less likely to miss some deep
      subtlety in the Python semantics that would require an architectural
      change later on.
      
      But that is all history and it no longer makes sense to retain the
      ability to output CPython bytecode, because:
      
      1. It outputs CPython 3.3 compatible bytecode.  CPython's bytecode
      changes from version to version, and seems to have changed quite a bit
      in 3.5.  There's no point in changing the bytecode output to match
      CPython anymore.
      
      2. uPy and CPy do different optimisations to the bytecode which makes it
      harder to match.
      
      3. The bytecode tests are not run.  They were never part of Travis and
      are not run locally anymore.
      
      4. The EMIT_CPYTHON option needs a lot of extra source code which adds
      heaps of noise, especially in compile.c.
      
      5. Now that there is an extensive test suite (which tests functionality)
      there is no need to match the bytecode.  Some very subtle behaviour is
      tested with the test suite and passing these tests is a much better
      way to stay Python-language compliant, rather than trying to match
      CPy bytecode.
      65dc960e
  2. 24 Jul, 2015 2 commits
  3. 14 Jul, 2015 1 commit
    • Damien George's avatar
      py: Improve allocation policy of qstr data. · ade9a052
      Damien George authored
      Previous to this patch all interned strings lived in their own malloc'd
      chunk.  On average this wastes N/2 bytes per interned string, where N is
      the number-of-bytes for a quanta of the memory allocator (16 bytes on 32
      bit archs).
      
      With this patch interned strings are concatenated into the same malloc'd
      chunk when possible.  Such chunks are enlarged inplace when possible,
      and shrunk to fit when a new chunk is needed.
      
      RAM savings with this patch are highly varied, but should always show an
      improvement (unless only 3 or 4 strings are interned).  New version
      typically uses about 70% of previous memory for the qstr data, and can
      lead to savings of around 10% of total memory footprint of a running
      script.
      
      Costs about 120 bytes code size on Thumb2 archs (depends on how many
      calls to gc_realloc are made).
      ade9a052
  4. 21 Apr, 2015 1 commit
  5. 23 Feb, 2015 1 commit
  6. 13 Feb, 2015 1 commit
  7. 08 Feb, 2015 2 commits
  8. 07 Feb, 2015 1 commit
    • Damien George's avatar
      py: Protect mp_parse and mp_compile with nlr push/pop block. · 0bfc7638
      Damien George authored
      To enable parsing constants more efficiently, mp_parse should be allowed
      to raise an exception, and mp_compile can already raise a MemoryError.
      So these functions need to be protected by an nlr push/pop block.
      
      This patch adds that feature in all places.  This allows to simplify how
      mp_parse and mp_compile are called: they now raise an exception if they
      have an error and so explicit checking is not needed anymore.
      0bfc7638
  9. 24 Jan, 2015 1 commit
  10. 20 Jan, 2015 1 commit
  11. 16 Jan, 2015 1 commit
  12. 14 Jan, 2015 1 commit
  13. 13 Jan, 2015 1 commit
    • Damien George's avatar
      py: Never intern data of large string/bytes object; add relevant tests. · 4c81ba80
      Damien George authored
      Previously to this patch all constant string/bytes objects were
      interned by the compiler, and this lead to crashes when the qstr was too
      long (noticeable now that qstr length storage defaults to 1 byte).
      
      With this patch, long string/bytes objects are never interned, and are
      referenced directly as constant objects within generated code using
      load_const_obj.
      4c81ba80
  14. 01 Jan, 2015 1 commit
  15. 20 Dec, 2014 3 commits
  16. 05 Dec, 2014 1 commit
    • Damien George's avatar
      py: Optimise lexer by exposing lexer type. · a4c52c5a
      Damien George authored
      mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer
      functions (like checking current token kind) are now inlined.
      
      This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460
      bytes on bare-arm.  It also saves a tiny bit of RAM since mp_lexer_t
      is a bit smaller.  Also will run a bit more efficiently.
      a4c52c5a
  17. 23 Oct, 2014 1 commit
  18. 23 Sep, 2014 1 commit
    • Damien George's avatar
      py: Free non-interned strings in the parser when not needed. · 52b5d76a
      Damien George authored
      mp_parse_node_free now frees the memory associated with non-interned
      strings.  And the parser calls mp_parse_node_free when discarding a
      non-used node (such as a doc string).
      
      Also, the compiler now frees the parse tree explicitly just before it
      exits (as opposed to relying on the caller to do this).
      
      Addresses issue #708 as best we can.
      52b5d76a
  19. 15 Aug, 2014 1 commit
  20. 03 Jul, 2014 2 commits
  21. 21 Jun, 2014 1 commit
  22. 28 May, 2014 1 commit
  23. 25 May, 2014 2 commits
  24. 21 May, 2014 1 commit
    • Damien George's avatar
      Tidy up some configuration options. · 58ebde46
      Damien George authored
      MP_ALLOC_* -> MICROPY_ALLOC_*
      MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX
      MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL
      MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX
      MICROPY_EXTRA_* -> MICROPY_PORT_*
      
      See issue #35.
      58ebde46
  25. 10 May, 2014 1 commit
    • Damien George's avatar
      py: Improve handling of memory error in parser. · 1b82e9af
      Damien George authored
      Parser shouldn't raise exceptions, so needs to check when memory
      allocation fails.  This patch does that for the initial set up of the
      parser state.
      
      Also, we now put the parser object on the stack.  It's small enough to
      go there instead of on the heap.
      
      This partially addresses issue #558.
      1b82e9af
  26. 08 May, 2014 1 commit
  27. 06 May, 2014 1 commit
  28. 05 May, 2014 1 commit
    • Damien George's avatar
      py: Turn down amount of RAM parser and compiler use. · 66e18f04
      Damien George authored
      There are 2 locations in parser, and 1 in compiler, where memory
      allocation is not precise.  In the parser it's the rule stack and result
      stack, in the compiler it's the array for the identifiers in the current
      scope.  All other mallocs are exact (ie they don't allocate more than is
      needed).
      
      This patch adds tuning options (MP_ALLOC_*) to mpconfig.h for these 3
      inexact allocations.
      
      The inexact allocations in the parser should actually be close to
      logarithmic: you need an exponentially larger script (absent pathological
      cases) to use up more room on the rule and result stacks.  As such, the
      default allocation policy for these is now to start with a modest sized
      stack, but grow only in small increments.
      
      For the identifier arrays in the compiler, these now start out quite
      small (4 entries, since most functions don't have that many ids), and
      grow incrementally by 6 (since if you have more ids than 4, you probably
      have quite a few more, but it wouldn't be exponentially more).
      
      Partially addresses issue #560.
      66e18f04
  29. 03 May, 2014 1 commit
    • Damien George's avatar
      Add license header to (almost) all files. · 04b9147e
      Damien George authored
      Blanket wide to all .c and .h files.  Some files originating from ST are
      difficult to deal with (license wise) so it was left out of those.
      
      Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
      04b9147e
  30. 10 Apr, 2014 1 commit
  31. 17 Mar, 2014 1 commit
    • xbe's avatar
      py: Clean up includes. · efe34223
      xbe authored
      Remove unnecessary includes. Add includes that improve portability.
      efe34223
  32. 01 Mar, 2014 1 commit
    • Damien George's avatar
      py: Implement bit-shift and not operations for mpz. · 06201ff3
      Damien George authored
      Implement not, shl and shr in mpz library.  Add function to create mpzs
      on the stack, used for memory efficiency when rhs is a small int.
      Factor out code to parse base-prefix of number into a dedicated function.
      06201ff3
  33. 22 Feb, 2014 1 commit
  34. 21 Feb, 2014 1 commit