1. 22 Apr, 2017 7 commits
    • Damien George's avatar
      py/compile: Refactor handling of special super() call. · 5335942b
      Damien George authored
      This patch refactors the handling of the special super() call within the
      compiler.  It removes the need for a global (to the compiler) state variable
      which keeps track of whether the subject of an expression is super.  The
      handling of super() is now done entirely within one function, which makes
      the compiler a bit cleaner and allows to easily add more optimisations to
      super calls.
      Changes to the code size are:
         bare-arm: +12
          minimal:  +0
         unix x64: +48
      unix nanbox: -16
           stmhal:  +4
           cc3200:  +0
          esp8266: -56
    • Damien George's avatar
      py/compile: Don't do unnecessary check if iter parse node is a struct. · 0dd6a59c
      Damien George authored
      If we get to this point in the code then pn_iter is guaranteed to be a
    • Damien George's avatar
      mpy-cross, unix, windows, stmhal: Enable return-if-else optimisation. · 03053f82
      Damien George authored
      Prior to making this a config option it was previously available on these
      (and all other) ports, and it makes sense to keep it enabled for mpy-cross
      as well as ports that have a decent amount of space for the code.
    • Damien George's avatar
      py/compile: Add COMP_RETURN_IF_EXPR option to enable return-if-else opt. · ae54fbf1
      Damien George authored
      With this optimisation enabled the compiler optimises the if-else
      expression within a return statement.  The optimisation reduces bytecode
      size by 2 bytes for each use of such a return-if-else statement.  Since
      such a statement is not often used, and costs bytes for the code, the
      feature is disabled by default.
      For example the following code:
          def f(x):
              return 1 if x else 2
      compiles to this bytecode with the optimisation disabled (left column is
      bytecode offset in bytes):
          00 LOAD_FAST 0
          01 POP_JUMP_IF_FALSE 8
          04 LOAD_CONST_SMALL_INT 1
          05 JUMP 9
          08 LOAD_CONST_SMALL_INT 2
          09 RETURN_VALUE
      and to this bytecode with the optimisation enabled:
          00 LOAD_FAST 0
          01 POP_JUMP_IF_FALSE 6
          04 LOAD_CONST_SMALL_INT 1
          05 RETURN_VALUE
          06 LOAD_CONST_SMALL_INT 2
          07 RETURN_VALUE
      So the JUMP to RETURN_VALUE is optimised and replaced by RETURN_VALUE,
      saving 2 bytes and making the code a bit faster.
    • Damien George's avatar
      py/compile: Extract parse-node kind at start of func for efficiency. · 40b40ffc
      Damien George authored
      Otherwise the type of parse-node and its kind has to be re-extracted
      multiple times.  This optimisation reduces code size by a bit (16 bytes on
    • Damien George's avatar
      py/compile: Don't do unnecessary check if parse node is a struct. · fa03bbf0
      Damien George authored
      PN_atom_expr_normal parse nodes always have structs for their second
      sub-node, so simplify the check for the sub-node kind to save code size.
    • Damien George's avatar
      py/objtype: mp_obj_new_super doesn't need to be public, so inline it. · 4df013c8
      Damien George authored
      Saves code size (20 bytes on bare-arm) and makes it a tiny bit more
  2. 21 Apr, 2017 3 commits
  3. 19 Apr, 2017 1 commit
  4. 18 Apr, 2017 14 commits
  5. 16 Apr, 2017 7 commits
  6. 15 Apr, 2017 1 commit
  7. 14 Apr, 2017 2 commits
  8. 13 Apr, 2017 5 commits