- 27 Sep, 2016 1 commit
-
-
Damien George authored
When an exception is raised and is to be handled by the VM, it is stored on the Python value stack so the bytecode can access it. CPython stores 3 objects on the stack for each exception: exc type, exc instance and traceback. uPy followed this approach, but it turns out not to be necessary. Instead, it is enough to store just the exception instance on the Python value stack. The only place where the 3 values are needed explicitly is for the __exit__ handler of a with-statement context, but for these cases the 3 values can be extracted from the single exception instance. This patch removes the need to store 3 values on the stack, and instead just stores the exception instance. Code size is reduced by about 50-100 bytes, the compiler and VM are slightly simpler, generate bytecode is smaller (by 2 bytes for each try block), and the Python value stack is reduced in size for functions that handle exceptions.
-
- 19 Sep, 2016 1 commit
-
-
Damien George authored
The 3 kinds of comprehensions are similar enough that merging their emit functions reduces code size. Decreases in code size in bytes are: bare-arm:24, minimal:96, unix(NDEBUG,x86-64):328, stmhal:80, esp8266:76.
-
- 26 Aug, 2016 1 commit
-
-
Damien George authored
As per CPython.
-
- 20 May, 2016 1 commit
-
-
Damien George authored
Otherwise some compilers (eg without optimisation) will put this read-only data in RAM instead of ROM.
-
- 13 Apr, 2016 2 commits
-
-
Damien George authored
-
- 07 Apr, 2016 2 commits
-
-
Damien George authored
-
Damien George authored
Because different emitters need to handle with-cleanup in different ways.
-
- 16 Mar, 2016 1 commit
-
-
Damien George authored
Previous to this patch, the "**b" in "a**b" had its own parse node with just one item (the "b"). Now, the "b" is just the last element of the power parse-node. This saves (a tiny bit of) RAM when compiling.
-
- 25 Feb, 2016 1 commit
-
-
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).
-
- 27 Jan, 2016 1 commit
-
-
Damien George authored
Supported return types are: object, bool, int, uint. For example: @micropython.asm_thumb def foo(r0, r1) -> uint: add(r0, r0, r1)
-
- 07 Jan, 2016 1 commit
-
-
Damien George authored
Before this patch, (x+y)*z would be parsed to a tree that contained a redundant identity parse node corresponding to the parenthesis. With this patch such nodes are optimised away, which reduces memory requirements for expressions with parenthesis, and simplifies the compiler because it doesn't need to handle this identity case. A parenthesis parse node is still needed for tuples.
-
- 18 Dec, 2015 2 commits
-
-
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.
-
Damien George authored
Saves 88 bytes on Thumb2, and 200 bytes on x86-64 archs.
-
- 17 Dec, 2015 1 commit
-
-
Damien George authored
-
- 12 Dec, 2015 1 commit
-
-
Damien George authored
Addresses issue #1709.
-
- 08 Dec, 2015 1 commit
-
-
Damien George authored
Addresses issue #1693.
-
- 29 Nov, 2015 2 commits
-
-
Damien George authored
To use, put the following in mpconfigport.h: #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) typedef int64_t mp_int_t; typedef uint64_t mp_uint_t; #define UINT_FMT "%llu" #define INT_FMT "%lld" Currently does not work with native emitter enabled.
-
Damien George authored
-
- 23 Nov, 2015 1 commit
-
-
Damien George authored
This patch checks that there is only one *, and that ** is last in the arg list.
-
- 20 Nov, 2015 1 commit
-
-
Damien George authored
This can then be passed to mp_raw_code_save_file to save a .mpy file.
-
- 17 Nov, 2015 2 commits
-
-
Damien George authored
-
Damien George authored
Parameter lists can't be nested so there is no need to save the global state when compiling them.
-
- 13 Nov, 2015 1 commit
-
-
Damien George authored
-
- 14 Oct, 2015 1 commit
-
-
Damien George authored
-
- 12 Oct, 2015 1 commit
-
-
Damien George authored
It makes much more sense to do constant folding in the parser while the parse tree is being built. This eliminates the need to create parse nodes that will just be folded away. The code is slightly simpler and a bit smaller as well. Constant folding now has a configuration option, MICROPY_COMP_CONST_FOLDING, which is enabled by default.
-
- 08 Oct, 2015 2 commits
-
-
Damien George authored
This patch eliminates the need for a nested parse node for assignments and keyword arguments. It saves a little bit of RAM when parsing.
-
Damien George authored
Also adds tests specifically for testing constant folding.
-
- 03 Oct, 2015 1 commit
-
-
Damien George authored
-
- 01 Oct, 2015 2 commits
-
-
Damien George authored
With this patch parse nodes are allocated sequentially in chunks. This reduces fragmentation of the heap and prevents waste at the end of individually allocated parse nodes. Saves roughly 20% of RAM during parse stage.
-
Damien George authored
-
- 24 Sep, 2015 1 commit
-
-
Damien George authored
It's relatively small (between 44 and 56 bytes) and helps to reduce heap pressure and fragmentation during compilation.
-
- 23 Sep, 2015 2 commits
-
-
Damien George authored
Saves a few bytes of code space and eliminates need for rot_two bytecode (hence saving RAM and execution time, by a tiny bit).
-
Delio Brignoli authored
-
- 07 Sep, 2015 1 commit
-
-
Damien George authored
-
- 04 Sep, 2015 1 commit
-
-
Damien George authored
Function annotations are only needed when the native emitter is enabled and when the current scope is emitted in viper mode. All other times the annotations can be skipped completely.
-
- 17 Aug, 2015 2 commits
-
-
Damien George authored
-
Damien George authored
unix-cpy was originally written to get semantic equivalent with CPython without writing functional tests. When writing the initial implementation of uPy it was a long way between lexer and functional tests, so the half-way test was to make sure that the bytecode was correct. The idea was that if the uPy bytecode matched CPython 1-1 then uPy would be proper Python if the bytecodes acted correctly. And having matching bytecode meant that it was less likely to miss some deep subtlety in the Python semantics that would require an architectural change later on. But that is all history and it no longer makes sense to retain the ability to output CPython bytecode, because: 1. It outputs CPython 3.3 compatible bytecode. CPython's bytecode changes from version to version, and seems to have changed quite a bit in 3.5. There's no point in changing the bytecode output to match CPython anymore. 2. uPy and CPy do different optimisations to the bytecode which makes it harder to match. 3. The bytecode tests are not run. They were never part of Travis and are not run locally anymore. 4. The EMIT_CPYTHON option needs a lot of extra source code which adds heaps of noise, especially in compile.c. 5. Now that there is an extensive test suite (which tests functionality) there is no need to match the bytecode. Some very subtle behaviour is tested with the test suite and passing these tests is a much better way to stay Python-language compliant, rather than trying to match CPy bytecode.
-
- 29 Jul, 2015 1 commit
-
-
Damien George authored
Previous to this patch there were some cases where line numbers for errors were 0 (unknown). Now the compiler attempts to give a better line number where possible, in some cases giving the line number of the closest statement, and other cases the line number of the inner-most scope of the error (eg the line number of the start of the function). This helps to give good (and sometimes exact) line numbers for ViperTypeError exceptions. This patch also makes sure that the first compile error (eg SyntaxError) that is encountered is reported (previously it was the last one that was reported).
-
- 27 Jul, 2015 1 commit
-
-
Damien George authored
ViperTypeError now includes filename and function name where the error occurred. The line number is the line number of the start of the function definition, which is the best that can be done without a lot more work. Partially addresses issue #1381.
-