Skip to content
Snippets Groups Projects
  1. Jun 12, 2018
  2. 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
  3. Aug 13, 2017
    • Javier Candeira's avatar
      all: Raise exceptions via mp_raise_XXX · 35a1fea9
      Javier Candeira authored
        - Changed: ValueError, TypeError, NotImplementedError
        - OSError invocations unchanged, because the corresponding utility
          function takes ints, not strings like the long form invocation.
        - OverflowError, IndexError and RuntimeError etc. not changed for now
          until we decide whether to add new utility functions.
      35a1fea9
  4. Jul 31, 2017
  5. Jul 07, 2017
  6. May 12, 2017
  7. May 09, 2017
  8. Mar 28, 2017
    • Damien George's avatar
      py/lexer: Simplify and reduce code size for operator tokenising. · 5010d195
      Damien George authored
      By removing the 'E' code from the operator token encoding mini-language the
      tokenising can be simplified.  The 'E' code was only used for the !=
      operator which is now handled as a special case; the optimisations for the
      general case more than make up for the addition of this single, special
      case.  Furthermore, the . and ... operators can be handled in the same way
      as != which reduces the code size a little further.
      
      This simplification also removes a "goto".
      
      Changes in code size for this patch are (measured in bytes):
      
      bare-arm:       -48
      minimal x86:    -64
      unix x86-64:   -112
      unix nanbox:    -64
      stmhal:         -48
      cc3200:         -48
      esp8266:        -76
      5010d195
  9. Mar 23, 2017
  10. Mar 14, 2017
    • Damien George's avatar
      py: Allow lexer to raise exceptions during construction. · 1831034b
      Damien George authored
      This patch refactors the error handling in the lexer, to simplify it (ie
      reduce code size).
      
      A long time ago, when the lexer/parser/compiler were first written, the
      lexer and parser were designed so they didn't use exceptions (ie nlr) to
      report errors but rather returned an error code.  Over time that has
      gradually changed, the parser in particular has more and more ways of
      raising exceptions.  Also, the lexer never really handled all errors without
      raising, eg there were some memory errors which could raise an exception
      (and in these rare cases one would get a fatal nlr-not-handled fault).
      
      This patch accepts the fact that the lexer can raise exceptions in some
      cases and allows it to raise exceptions to handle all its errors, which are
      for the most part just out-of-memory errors during construction of the
      lexer.  This makes the lexer a bit simpler, and also the persistent code
      stuff is simplified.
      
      What this means for users of the lexer is that calls to it must be wrapped
      in a nlr handler.  But all uses of the lexer already have such an nlr
      handler for the parser (and compiler) so that doesn't put any extra burden
      on the callers.
      1831034b
  11. Feb 17, 2017
    • Damien George's avatar
    • Damien George's avatar
      py: Do adjacent str/bytes literal concatenation in lexer, not compiler. · 534b7c36
      Damien George authored
      It's much more efficient in RAM and code size to do implicit literal string
      concatenation in the lexer, as opposed to the compiler.
      
      RAM usage is reduced because the concatenation can be done right away in the
      tokeniser by just accumulating the string/bytes literals into the lexer's
      vstr.  Prior to this patch adjacent strings/bytes would create a parse tree
      (one node per string/bytes) and then in the compiler a whole new chunk of
      memory was allocated to store the concatenated string, which used more than
      double the memory compared to just accumulating in the lexer.
      
      This patch also significantly reduces code size:
      
      bare-arm: -204
      minimal:  -204
      unix x64: -328
      stmhal:   -208
      esp8266:  -284
      cc3200:   -224
      534b7c36
    • Damien George's avatar
      py/lexer: Simplify handling of line-continuation error. · 773278ec
      Damien George authored
      Previous to this patch there was an explicit check for errors with line
      continuation (where backslash was not immediately followed by a newline).
      
      But this check is not necessary: if there is an error then the remaining
      logic of the tokeniser will reject the backslash and correctly produce a
      syntax error.
      773278ec
    • Damien George's avatar
      py/lexer: Use strcmp to make keyword searching more efficient. · ae436797
      Damien George authored
      Since the table of keywords is sorted, we can use strcmp to do the search
      and stop part way through the search if the comparison is less-than.
      
      Because all tokens that are names are subject to this search, this
      optimisation will improve the overall speed of the lexer when processing
      a script.
      
      The change also decreases code size by a little bit because we now use
      strcmp instead of the custom str_strn_equal function.
      ae436797
  12. Feb 16, 2017
  13. Jan 30, 2017
  14. Jan 27, 2017
    • Damien George's avatar
      extmod: Add generic VFS sub-system. · dcb9ea72
      Damien George authored
      This provides mp_vfs_XXX functions (eg mount, open, listdir) which are
      agnostic to the underlying filesystem type, and just require an object with
      the relevant filesystem-like methods (eg .mount, .open, .listidr) which can
      then be mounted.
      
      These mp_vfs_XXX functions would typically be used by a port to implement
      the "uos" module, and mp_vfs_open would be the builtin open function.
      
      This feature is controlled by MICROPY_VFS, disabled by default.
      dcb9ea72
  15. Dec 21, 2016
  16. Nov 16, 2016
  17. Oct 12, 2016
    • Damien George's avatar
      py/lexer: Remove unnecessary code, and unreachable code. · 31101d91
      Damien George authored
      Setting emit_dent=0 is unnecessary because arriving in that part of the
      if-logic will guarantee that emit_dent is already zero.
      
      The block to check indent_top(lex)>0 is unreachable because a newline is
      always inserted an the end of the input stream, and hence dedents are
      always processed before EOF.
      31101d91
  18. Sep 19, 2016
    • Damien George's avatar
      py/vstr: Remove vstr.had_error flag and inline basic vstr functions. · 5da0d29d
      Damien George authored
      The vstr.had_error flag was a relic from the very early days which assumed
      that the malloc functions (eg m_new, m_renew) returned NULL if they failed
      to allocate.  But that's no longer the case: these functions will raise an
      exception if they fail.
      
      Since it was impossible for had_error to be set, this patch introduces no
      change in behaviour.
      
      An alternative option would be to change the malloc calls to the _maybe
      variants, which return NULL instead of raising, but then a lot of code
      will need to explicitly check if the vstr had an error and raise if it
      did.
      
      The code-size savings for this patch are, in bytes: bare-arm:188,
      minimal:456, unix(NDEBUG,x86-64):368, stmhal:228, esp8266:360.
      5da0d29d
  19. May 20, 2016
  20. Apr 13, 2016
    • pohmelie's avatar
      py: add async/await/async for/async with syntax · 81ebba7e
      pohmelie authored
      They are sugar for marking function as generator, "yield from"
      and pep492 python "semantically equivalents" respectively.
      
      @dpgeorge was the original author of this patch, but @pohmelie made
      changes to implement `async for` and `async with`.
      81ebba7e
  21. Feb 25, 2016
    • Damien George's avatar
      py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime. · ea235204
      Damien George authored
      This new compile-time option allows to make the bytecode compiler
      configurable at runtime by setting the fields in the mp_dynamic_compiler
      structure.  By using this feature, the compiler can generate bytecode
      that targets any MicroPython runtime/VM, regardless of the host and
      target compile-time settings.
      
      Options so far that fall under this dynamic setting are:
      - maximum number of bits that a small int can hold;
      - whether caching of lookups is used in the bytecode;
      - whether to use unicode strings or not (lexer behaviour differs, and
        therefore generated string constants differ).
      ea235204
  22. Dec 18, 2015
    • Damien George's avatar
      py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts. · dd5353a4
      Damien George authored
      MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler,
      which is useful when only loading of pre-compiled bytecode is supported.
      It is enabled by default.
      
      MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin
      functions.  By default they are only included if MICROPY_ENABLE_COMPILER
      is enabled.
      
      Disabling both options saves about 40k of code size on 32-bit x86.
      dd5353a4
  23. Sep 07, 2015
  24. Jul 23, 2015
  25. Jun 22, 2015
  26. Jun 09, 2015
  27. May 20, 2015
Loading