1. 02 May, 2017 2 commits
  2. 01 May, 2017 5 commits
  3. 30 Apr, 2017 5 commits
  4. 29 Apr, 2017 5 commits
  5. 28 Apr, 2017 1 commit
  6. 27 Apr, 2017 3 commits
  7. 26 Apr, 2017 4 commits
  8. 25 Apr, 2017 6 commits
  9. 22 Apr, 2017 9 commits
    • Paul Sokolovsky's avatar
    • Damien George's avatar
    • Damien George's avatar
      py: Add LOAD_SUPER_METHOD bytecode to allow heap-free super meth calls. · dd11af20
      Damien George authored
      This patch allows the following code to run without allocating on the heap:
      
          super().foo(...)
      
      Before this patch such a call would allocate a super object on the heap and
      then load the foo method and call it right away.  The super object is only
      needed to perform the lookup of the method and not needed after that.  This
      patch makes an optimisation to allocate the super object on the C stack and
      discard it right after use.
      
      Changes in code size due to this patch are:
      
         bare-arm: +128
          minimal: +232
         unix x64: +416
      unix nanbox: +364
           stmhal: +184
          esp8266: +340
           cc3200: +128
      dd11af20
    • 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
      5335942b
    • 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
      struct.
      0dd6a59c
    • 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.
      03053f82
    • 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.
      ae54fbf1
    • 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
      bare-arm).
      40b40ffc
    • 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.
      fa03bbf0