1. 02 Apr, 2015 1 commit
  2. 26 Mar, 2015 1 commit
  3. 25 Mar, 2015 1 commit
  4. 26 Feb, 2015 1 commit
  5. 10 Feb, 2015 1 commit
  6. 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
  7. 13 Jan, 2015 1 commit
  8. 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
  9. 01 Jan, 2015 1 commit
  10. 29 Dec, 2014 1 commit
  11. 28 Dec, 2014 1 commit
  12. 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
  13. 12 Dec, 2014 1 commit
  14. 02 Dec, 2014 1 commit
  15. 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
  16. 04 Sep, 2014 1 commit
  17. 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
  18. 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
  19. 03 Jul, 2014 1 commit
  20. 07 Jun, 2014 2 commits
  21. 03 Jun, 2014 1 commit
  22. 01 Jun, 2014 3 commits
    • Damien George's avatar
    • Damien George's avatar
      Rename bultins config variables to MICROPY_PY_BUILTINS_*. · fb510b3b
      Damien George authored
      This renames:
      MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
      MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
      MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
      MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT
      
      See issue #35 for discussion.
      fb510b3b
    • Damien George's avatar
      py, vm: Replace save_ip, save_sp with code_state->{ip, sp}. · c60a261e
      Damien George authored
      This may seem a bit of a risky change, in that it may introduce crazy
      bugs with respect to volatile variables in the VM loop.  But, I think it
      should be fine: code_state points to some external memory, so the
      compiler should always read/write to that memory when accessing the
      ip/sp variables (ie not put them in registers).
      
      Anyway, it passes all tests and improves on all efficiency fronts: about
      2-4% faster (64-bit unix), 16 bytes less stack space per call (64-bit
      unix) and slightly less executable size (unix and stmhal).
      
      The reason it's more efficient is save_ip and save_sp were volatile
      variables, so were anyway stored on the stack (in memory, not regs).
      Thus converting them to code_state->{ip, sp} doesn't cost an extra
      memory dereference (except maybe to get code_state, but that can be put
      in a register and then made more efficient for other uses of it).
      c60a261e
  23. 31 May, 2014 5 commits
  24. 30 May, 2014 1 commit
    • Damien George's avatar
      py: Fix break from within a for loop. · 25c84643
      Damien George authored
      Needed to pop the iterator object when breaking out of a for loop.  Need
      also to be careful to unwind exception handler before popping iterator.
      
      Addresses issue #635.
      25c84643
  25. 28 May, 2014 1 commit
  26. 25 May, 2014 1 commit
    • Damien George's avatar
      py, vm: Where possible, make variables local to each opcode. · d8675541
      Damien George authored
      This helps the compiler do its optimisation, makes it clear which
      variables are local per opcode and which global, and makes it consistent
      when extra variables are needed in an opcode (in addition to old obj1,
      obj2 pair, for example).
      
      Could also make unum local, but that's for another time.
      d8675541
  27. 24 May, 2014 2 commits
  28. 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
  29. 13 May, 2014 1 commit