1. 13 Jun, 2015 1 commit
  2. 12 May, 2015 1 commit
    • Damien George's avatar
      py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. · c2a4e4ef
      Damien George authored
      Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as
      the operator argument.  Hashing for int, str and bytes still go via
      fast-path in mp_unary_op since they are the most common objects which
      need to be hashed.
      
      This lead to quite a bit of code cleanup, and should be more efficient
      if anything.  It saves 176 bytes code space on Thumb2, and 360 bytes on
      x86.
      
      The only loss is that the error message "unhashable type" is now the
      more generic "unsupported type for __hash__".
      c2a4e4ef
  3. 11 May, 2015 1 commit
  4. 10 May, 2015 1 commit
  5. 05 May, 2015 1 commit
  6. 25 Apr, 2015 2 commits
  7. 24 Apr, 2015 1 commit
  8. 11 Apr, 2015 1 commit
  9. 09 Apr, 2015 2 commits
  10. 02 Apr, 2015 6 commits
  11. 26 Mar, 2015 1 commit
  12. 25 Mar, 2015 1 commit
  13. 26 Feb, 2015 1 commit
  14. 10 Feb, 2015 1 commit
  15. 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
  16. 13 Jan, 2015 1 commit
  17. 07 Jan, 2015 2 commits
    • Damien George's avatar
      py: Add option to cache map lookup results in bytecode. · 7ee91cf8
      Damien George authored
      This is a simple optimisation inspired by JITing technology: we cache in
      the bytecode (using 1 byte) the offset of the last successful lookup in
      a map. This allows us next time round to check in that location in the
      hash table (mp_map_t) for the desired entry, and if it's there use that
      entry straight away.  Otherwise fallback to a normal map lookup.
      
      Works for LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR and STORE_ATTR opcodes.
      
      On a few tests it gives >90% cache hit and greatly improves speed of
      code.
      
      Disabled by default.  Enabled for unix and stmhal ports.
      7ee91cf8
    • Damien George's avatar
      py: Put all global state together in state structures. · b4b10fd3
      Damien George authored
      This patch consolidates all global variables in py/ core into one place,
      in a global structure.  Root pointers are all located together to make
      GC tracing easier and more efficient.
      b4b10fd3
  18. 01 Jan, 2015 1 commit
  19. 29 Dec, 2014 1 commit
  20. 28 Dec, 2014 1 commit
  21. 22 Dec, 2014 1 commit
    • Damien George's avatar
      py: Reduce size of VM exception stack element by 1 machine word. · 74eb44c3
      Damien George authored
      This optimisation reduces the VM exception stack element (mp_exc_stack_t)
      by 1 word, by using bit 1 of a pointer to store whether the opcode was a
      FINALLY or WITH opcode.  This optimisation was pending, waiting for
      maturity of the exception handling code, which has now proven itself.
      
      Saves 1 machine word RAM for each exception (4->3 words per exception).
      Increases stmhal code by 4 bytes, and decreases unix x64 code by 32
      bytes.
      74eb44c3
  22. 12 Dec, 2014 1 commit
  23. 02 Dec, 2014 1 commit
  24. 25 Oct, 2014 3 commits
    • Damien George's avatar
      b0b0012f
    • Damien George's avatar
      py: Add mp_pending_exception global variable, for VM soft interrupt. · 124df6f8
      Damien George authored
      This allows to implement KeyboardInterrupt on unix, and a much safer
      ctrl-C in stmhal port.  First ctrl-C is a soft one, with hope that VM
      will notice it; second ctrl-C is a hard one that kills anything (for
      both unix and stmhal).
      
      One needs to check for a pending exception in the VM only for jump
      opcodes.  Others can't produce an infinite loop (infinite recursion is
      caught by stack check).
      124df6f8
    • Damien George's avatar
      py: Compress load-int, load-fast, store-fast, unop, binop bytecodes. · 8456cc01
      Damien George authored
      There is a lot potential in compress bytecodes and make more use of the
      coding space.  This patch introduces "multi" bytecodes which have their
      argument included in the bytecode (by addition).
      
      UNARY_OP and BINARY_OP now no longer take a 1 byte argument for the
      opcode.  Rather, the opcode is included in the first byte itself.
      
      LOAD_FAST_[0,1,2] and STORE_FAST_[0,1,2] are removed in favour of their
      multi versions, which can take an argument between 0 and 15 inclusive.
      The majority of LOAD_FAST/STORE_FAST codes fit in this range and so this
      saves a byte for each of these.
      
      LOAD_CONST_SMALL_INT_MULTI is used to load small ints between -16 and 47
      inclusive.  Such ints are quite common and now only need 1 byte to
      store, and now have much faster decoding.
      
      In all this patch saves about 2% RAM for typically bytecode (1.8% on
      64-bit test, 2.5% on pyboard test).  It also reduces the binary size
      (because bytecodes are simplified) and doesn't harm performance.
      8456cc01
  25. 04 Sep, 2014 1 commit
  26. 26 Aug, 2014 1 commit
    • Damien George's avatar
      py: Fix line number printing for file with 1 line. · b427d6ae
      Damien George authored
      With a file with 1 line (and an error on that line), used to show the
      line as number 0.  Now shows it correctly as line number 1.
      
      But, when line numbers are disabled, it now prints line number 1 for any
      line that has an error (instead of 0 as previously).  This might end up
      being confusing, but requires extra RAM and/or hack logic to make it
      print something special in the case of no line numbers.
      b427d6ae
  27. 31 Jul, 2014 1 commit
    • Damien George's avatar
      py: Improve encoding scheme for line-number to bytecode map. · 4747becc
      Damien George authored
      Reduces by about a factor of 10 on average the amount of RAM needed to
      store the line-number to bytecode map in the bytecode prelude.
      
      Using CPython3.4's stdlib for statistics: previously, an average of
      13 bytes were used per (bytecode offset, line-number offset) pair, and
      now with this improvement, that's down to 1.3 bytes on average.
      
      Large RAM usage before was due to some very large steps in line numbers,
      both from the start of the first line in a function way down in the
      file, and also functions that have big comments and/or big strings in
      them (both cases were significant).
      
      Although the savings are large on average for the CPython stdlib, it
      won't have such a big effect for small scripts used in embedded
      programming.
      
      Addresses issue #648.
      4747becc
  28. 03 Jul, 2014 1 commit
  29. 07 Jun, 2014 2 commits