Skip to content
Snippets Groups Projects
  1. Mar 08, 2019
  2. Mar 07, 2019
  3. Mar 05, 2019
    • Damien George's avatar
    • Damien George's avatar
      py/persistentcode: Define static qstr set to reduce size of mpy files. · 4f0931b2
      Damien George authored
      When encoded in the mpy file, if qstr <= QSTR_LAST_STATIC then store two
      bytes: 0, static_qstr_id.  Otherwise encode the qstr as usual (either with
      string data or a reference into the qstr window).
      
      Reduces mpy file size by about 5%.
      4f0931b2
    • Damien George's avatar
      py/persistentcode: Pack qstrs directly in bytecode to reduce mpy size. · 992a6e1d
      Damien George authored
      Instead of emitting two bytes in the bytecode for where the linked qstr
      should be written to, it is now replaced by the actual qstr data, or a
      reference into the qstr window.
      
      Reduces mpy file size by about 10%.
      992a6e1d
    • Damien George's avatar
      py/persistentcode: Add a qstr window to save mpy files more efficiently. · 5996eeb4
      Damien George authored
      This is an implementation of a sliding qstr window used to reduce the
      number of qstrs stored in a .mpy file.  The window size is configured to 32
      entries which takes a fixed 64 bytes (16-bits each) on the C stack when
      loading/saving a .mpy file.  It allows to remember the most recent 32 qstrs
      so they don't need to be stored again in the .mpy file.  The qstr window
      uses a simple least-recently-used mechanism to discard the least recently
      used qstr when the window overflows (similar to dictionary compression).
      This scheme only needs a single pass to save/load the .mpy file.
      
      Reduces mpy file size by about 25% with a window size of 32.
      5996eeb4
    • Damien George's avatar
      py: Replace POP_BLOCK and POP_EXCEPT opcodes with POP_EXCEPT_JUMP. · 5a2599d9
      Damien George authored
      POP_BLOCK and POP_EXCEPT are now the same, and are always followed by a
      JUMP.  So this optimisation reduces code size, and RAM usage of bytecode by
      two bytes for each try-except handler.
      5a2599d9
    • Damien George's avatar
      py/vm: Remove currently_in_except_block variable. · 6f9e3ff7
      Damien George authored
      After the previous commit it is no longer needed.
      6f9e3ff7
    • Damien George's avatar
      py: Fix VM crash with unwinding jump out of a finally block. · e1fb03f3
      Damien George authored
      This patch fixes a bug in the VM when breaking within a try-finally.  The
      bug has to do with executing a break within the finally block of a
      try-finally statement.  For example:
      
          def f():
              for x in (1,):
                  print('a', x)
                  try:
                      raise Exception
                  finally:
                      print(1)
                      break
                  print('b', x)
          f()
      
      Currently in uPy the above code will print:
      
          a 1
          1
          1
          segmentation fault (core dumped)  micropython
      
      Not only is there a seg fault, but the "1" in the finally block is printed
      twice.  This is because when the VM executes a finally block it doesn't
      really know if that block was executed due to a fall-through of the try (no
      exception raised), or because an exception is active.  In particular, for
      nested finallys the VM has no idea which of the nested ones have active
      exceptions and which are just fall-throughs.  So when a break (or continue)
      is executed it tries to unwind all of the finallys, when in fact only some
      may be active.
      
      It's questionable whether break (or return or continue) should be allowed
      within a finally block, because they implicitly swallow any active
      exception, but nevertheless it's allowed by CPython (although almost never
      used in the standard library).  And uPy should at least not crash in such a
      case.
      
      The solution here relies on the fact that exception and finally handlers
      always appear in the bytecode after the try body.
      
      Note: there was a similar bug with a return in a finally block, but that
      was previously fixed in b7352084
      e1fb03f3
    • Damien George's avatar
      b5f33ac2
    • Damien George's avatar
      e959f219
    • Damien George's avatar
    • Damien George's avatar
      lib/oofatfs: Update oofatfs library to R0.13c working branch. · 1a24bac6
      Damien George authored
      From https://github.com/micropython/oofatfs, branch work-R0.13c,
      commit cb05c9486d3b48ffd6bd7542d8dbbab4b1caf790.
      
      Large code pages (932, 936, 949, 950) have been removed from ffunicode.c
      because they were not included in previous versions here.
      1a24bac6
    • Francisco J. Manno's avatar
      stm32: Add compile-time option to use HSI as clock source. · f938e70c
      Francisco J. Manno authored
      To use HSI instead of HSE define MICROPY_HW_CLK_USE_HSI as 1 in the board
      configuration file.  The default is to use HSE.
      
      HSI has been made the default for the NUCLEO_F401RE board to serve as an
      example, and because early revisions of this board need a hardware
      modification to get HSE working.
      f938e70c
  4. Mar 04, 2019
  5. Mar 01, 2019
Loading