Skip to content
Snippets Groups Projects
  1. May 17, 2019
  2. Mar 05, 2019
  3. Oct 04, 2017
    • Damien George's avatar
      all: Remove inclusion of internal py header files. · a3dc1b19
      Damien George authored
      Header files that are considered internal to the py core and should not
      normally be included directly are:
          py/nlr.h - internal nlr configuration and declarations
          py/bc0.h - contains bytecode macro definitions
          py/runtime0.h - contains basic runtime enums
      
      Instead, the top-level header files to include are one of:
          py/obj.h - includes runtime0.h and defines everything to use the
              mp_obj_t type
          py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
              and defines everything to use the general runtime support functions
      
      Additional, specific headers (eg py/objlist.h) can be included if needed.
      a3dc1b19
  4. Jul 31, 2017
  5. Jul 18, 2017
    • Alexander Steffen's avatar
      all: Unify header guard usage. · 299bc625
      Alexander Steffen authored
      The code conventions suggest using header guards, but do not define how
      those should look like and instead point to existing files. However, not
      all existing files follow the same scheme, sometimes omitting header guards
      altogether, sometimes using non-standard names, making it easy to
      accidentally pick a "wrong" example.
      
      This commit ensures that all header files of the MicroPython project (that
      were not simply copied from somewhere else) follow the same pattern, that
      was already present in the majority of files, especially in the py folder.
      
      The rules are as follows.
      
      Naming convention:
      * start with the words MICROPY_INCLUDED
      * contain the full path to the file
      * replace special characters with _
      
      In addition, there are no empty lines before #ifndef, between #ifndef and
      one empty line before #endif. #endif is followed by a comment containing
      the name of the guard macro.
      
      py/grammar.h cannot use header guards by design, since it has to be
      included multiple times in a single C file. Several other files also do not
      need header guards as they are only used internally and guaranteed to be
      included only once:
      * MICROPY_MPHALPORT_H
      * mpconfigboard.h
      * mpconfigport.h
      * mpthreadport.h
      * pin_defs_*.h
      * qstrdefs*.h
      299bc625
  6. Jun 09, 2017
    • Damien George's avatar
      py: Provide mp_decode_uint_skip() to help reduce stack usage. · a8a5d1e8
      Damien George authored
      Taking the address of a local variable leads to increased stack usage, so
      the mp_decode_uint_skip() function is added to reduce the need for taking
      addresses.  The changes in this patch reduce stack usage of a Python call
      by 8 bytes on ARM Thumb, by 16 bytes on non-windowing Xtensa archs, and by
      16 bytes on x86-64.  Code size is also slightly reduced on most archs by
      around 32 bytes.
      a8a5d1e8
  7. Mar 17, 2017
    • Damien George's avatar
      py: Provide mp_decode_uint_value to help optimise stack usage. · 5640e6da
      Damien George authored
      This has a noticeable improvement on x86-64 and Thumb2 archs, where stack
      usage is reduced by 2 machine words in the VM.
      5640e6da
    • Damien George's avatar
      py: Reduce size of mp_code_state_t structure. · 71a3d6ec
      Damien George authored
      Instead of caching data that is constant (code_info, const_table and
      n_state), store just a pointer to the underlying function object from which
      this data can be derived.
      
      This helps reduce stack usage for the case when the mp_code_state_t
      structure is stored on the stack, as well as heap usage when it's stored
      on the heap.
      
      The downside is that the VM becomes a little more complex because it now
      needs to derive the data from the underlying function object.  But this
      doesn't impact the performance by much (if at all) because most of the
      decoding of data is done outside the main opcode loop.  Measurements using
      pystone show that little to no performance is lost.
      
      This patch also fixes a nasty bug whereby the bytecode can be reclaimed by
      the GC during execution.  With this patch there is always a pointer to the
      function object held by the VM during execution, since it's stored in the
      mp_code_state_t structure.
      71a3d6ec
  8. Jan 27, 2017
  9. Aug 27, 2016
  10. Dec 17, 2015
  11. Nov 29, 2015
  12. Nov 13, 2015
  13. Apr 02, 2015
  14. Feb 15, 2015
  15. Jan 01, 2015
  16. Dec 27, 2014
  17. Dec 22, 2014
    • 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
  18. Oct 25, 2014
    • Damien George's avatar
      py: Store bytecode arg names in bytecode (were in own array). · 1084b0f9
      Damien George authored
      This saves a lot of RAM for 2 reasons:
      
      1. For functions that don't have default values, var args or var kw
      args (which is a large number of functions in the general case), the
      mp_obj_fun_bc_t type now fits in 1 GC block (previously needed 2 because
      of the extra pointer to point to the arg_names array).  So this saves 16
      bytes per function (32 bytes on 64-bit machines).
      
      2. Combining separate memory regions generally saves RAM because the
      unused bytes at the end of the GC block are saved for 1 of the blocks
      (since that block doesn't exist on its own anymore).  So generally this
      saves 8 bytes per function.
      
      Tested by importing lots of modules:
      
      - 64-bit Linux gave about an 8% RAM saving for 86k of used RAM.
      - pyboard gave about a 6% RAM saving for 31k of used RAM.
      1084b0f9
  19. Oct 03, 2014
  20. Sep 04, 2014
  21. Aug 24, 2014
  22. Jul 03, 2014
  23. Jun 11, 2014
  24. Jun 07, 2014
  25. Jun 02, 2014
  26. May 31, 2014
  27. May 10, 2014
  28. May 03, 2014
    • Damien George's avatar
      Add license header to (almost) all files. · 04b9147e
      Damien George authored
      Blanket wide to all .c and .h files.  Some files originating from ST are
      difficult to deal with (license wise) so it was left out of those.
      
      Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
      04b9147e
  29. Apr 23, 2014
  30. Mar 30, 2014
  31. Mar 29, 2014
    • Paul Sokolovsky's avatar
      vm: Save current active exception on opening new try block. · 0c904df8
      Paul Sokolovsky authored
      Required to reraise correct exceptions in except block, regardless if more
      try blocks with active exceptions happen in the same except block.
      
      P.S. This "automagic reraise" appears to be quite wasteful feature of Python
      - we need to save pending exception just in case it *might* be reraised.
      Instead, programmer could explcitly capture exception to a variable using
      "except ... as var", and reraise that. So, consider disabling argless raise
      support as an optimization.
      0c904df8
Loading