1. 08 Oct, 2015 2 commits
  2. 03 Oct, 2015 1 commit
  3. 01 Oct, 2015 2 commits
  4. 24 Sep, 2015 1 commit
  5. 23 Sep, 2015 2 commits
  6. 07 Sep, 2015 1 commit
  7. 04 Sep, 2015 1 commit
  8. 17 Aug, 2015 2 commits
    • Damien George's avatar
    • 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
  9. 29 Jul, 2015 1 commit
    • Damien George's avatar
      py/compile: Give more precise line number for compile errors. · cfc4c338
      Damien George authored
      Previous to this patch there were some cases where line numbers for
      errors were 0 (unknown).  Now the compiler attempts to give a better
      line number where possible, in some cases giving the line number of the
      closest statement, and other cases the line number of the inner-most
      scope of the error (eg the line number of the start of the function).
      This helps to give good (and sometimes exact) line numbers for
      ViperTypeError exceptions.
      
      This patch also makes sure that the first compile error (eg SyntaxError)
      that is encountered is reported (previously it was the last one that was
      reported).
      cfc4c338
  10. 27 Jul, 2015 1 commit
  11. 25 Jun, 2015 1 commit
    • Damien George's avatar
      py: Remove mp_load_const_bytes and instead load precreated bytes object. · 59fba2d6
      Damien George authored
      Previous to this patch each time a bytes object was referenced a new
      instance (with the same data) was created.  With this patch a single
      bytes object is created in the compiler and is loaded directly at execute
      time as a true constant (similar to loading bignum and float objects).
      This saves on allocating RAM and means that bytes objects can now be
      used when the memory manager is locked (eg in interrupts).
      
      The MP_BC_LOAD_CONST_BYTES bytecode was removed as part of this.
      
      Generated bytecode is slightly larger due to storing a pointer to the
      bytes object instead of the qstr identifier.
      
      Code size is reduced by about 60 bytes on Thumb2 architectures.
      59fba2d6
  12. 20 Apr, 2015 1 commit
  13. 11 Apr, 2015 1 commit
  14. 09 Apr, 2015 2 commits
  15. 26 Mar, 2015 3 commits
    • Damien George's avatar
      py, compiler: When just bytecode, make explicit calls instead of table. · 4112590a
      Damien George authored
      When just the bytecode emitter is needed there is no need to have a
      dynamic method table for the emitter back-end, and we can instead
      directly call the mp_emit_bc_XXX functions.  This gives a significant
      reduction in code size and a very slight performance boost for the
      compiler.
      
      This patch saves 1160 bytes code on Thumb2 and 972 bytes on x86, when
      native emitters are disabled.
      
      Overall savings in code over the last 3 commits are:
      
      bare-arm: 1664 bytes.
      minimal:  2136 bytes.
      stmhal:    584 bytes (it has native emitter enabled).
      cc3200:   1736 bytes.
      4112590a
    • Damien George's avatar
      py, compiler: Remove emit_pass1 code, using emit_bc to do its job. · a210c774
      Damien George authored
      First pass for the compiler is computing the scope (eg if an identifier
      is local or not) and originally had an entire table of methods dedicated
      to this, most of which did nothing.  With changes from previous commit,
      this set of methods can be removed and the methods from the bytecode
      emitter used instead, with very little modification -- this is what is
      done in this commit.
      
      This factoring has little to no impact on the speed of the compiler
      (tested by compiling 3763 Python scripts and timing it).
      
      This factoring reduces code size by about 270-300 bytes on Thumb2 archs,
      and 400 bytes on x86.
      a210c774
    • Damien George's avatar
      py, compiler: Refactor load/store/delete_id logic to reduce code size. · 542bd6b4
      Damien George authored
      Saves around 230 bytes on Thumb2 and 750 bytes on x86.
      542bd6b4
  16. 25 Mar, 2015 2 commits
  17. 14 Mar, 2015 3 commits
  18. 03 Mar, 2015 2 commits
  19. 01 Mar, 2015 1 commit
  20. 28 Feb, 2015 3 commits
  21. 27 Feb, 2015 1 commit
  22. 16 Feb, 2015 1 commit
  23. 13 Feb, 2015 2 commits
  24. 08 Feb, 2015 1 commit
    • Damien George's avatar
      py: Parse big-int/float/imag constants directly in parser. · 7d414a1b
      Damien George authored
      Previous to this patch, a big-int, float or imag constant was interned
      (made into a qstr) and then parsed at runtime to create an object each
      time it was needed.  This is wasteful in RAM and not efficient.  Now,
      these constants are parsed straight away in the parser and turned into
      objects.  This allows constants with large numbers of digits (so
      addresses issue #1103) and takes us a step closer to #722.
      7d414a1b
  25. 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
  26. 28 Jan, 2015 1 commit
    • Damien George's avatar
      py: Change vstr so that it doesn't null terminate buffer by default. · 0d3cb672
      Damien George authored
      This cleans up vstr so that it's a pure "variable buffer", and the user
      can decide whether they need to add a terminating null byte.  In most
      places where vstr is used, the vstr did not need to be null terminated
      and so this patch saves code size, a tiny bit of RAM, and makes vstr
      usage more efficient.  When null termination is needed it must be
      done explicitly using vstr_null_terminate.
      0d3cb672