summaryrefslogtreecommitdiff
path: root/py/compile.c
AgeCommit message (Collapse)Author
2015-03-03py: Give error for duplicate label in inline assembler.Damien George
2015-03-01py: Set compiler scope before folding constants so error messages work.Damien George
Addresses issue #1140.
2015-02-28py: Combine complie functions for or_test/and_test to reduce code size.Damien George
Saves around 60 bytes code on Thumb2 archs.
2015-02-28py: Combine emit functions for jump true/false to reduce code size.Damien George
Saves 116 bytes for stmhal and 56 bytes for cc3200 port.
2015-02-28py: Combine logic for compiling and/or tests, to reduce code size.Damien George
Reduces code size by 72 bytes on Thumb2 archs.
2015-02-27py: Transform assert logic in compiler to save code space.Damien George
Saves about 250 code bytes for Thumb2 archs.
2015-02-16py: More robust checking in inline assembler compiler.Damien George
2015-02-13py: Expose compile.c:list_get as mp_parse_node_extract_list.Damien George
2015-02-13py: Make inline assembler raise proper SyntaxError exception on error.Damien George
Also gives line number of location of error. Very useful!
2015-02-08py: Parse big-int/float/imag constants directly in parser.Damien George
Previous to this patch, a big-int, float or imag constant was interned (made into a qstr) and then parsed at runtime to create an object each time it was needed. This is wasteful in RAM and not efficient. Now, these constants are parsed straight away in the parser and turned into objects. This allows constants with large numbers of digits (so addresses issue #1103) and takes us a step closer to #722.
2015-02-07py: Protect mp_parse and mp_compile with nlr push/pop block.Damien George
To enable parsing constants more efficiently, mp_parse should be allowed to raise an exception, and mp_compile can already raise a MemoryError. So these functions need to be protected by an nlr push/pop block. This patch adds that feature in all places. This allows to simplify how mp_parse and mp_compile are called: they now raise an exception if they have an error and so explicit checking is not needed anymore.
2015-01-28py: Change vstr so that it doesn't null terminate buffer by default.Damien George
This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
2015-01-21py: Remove mp_obj_str_builder and use vstr instead.Damien George
With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
2015-01-20py, unix: Allow to compile with -Wunused-parameter.Damien George
See issue #699.
2015-01-20py, unix, stmhal: Allow to compile with -Wshadow.Damien George
See issue #699.
2015-01-16py, unix: Allow to compile with -Wsign-compare.Damien George
See issue #699.
2015-01-16py: Remove unnecessary id_flags argument from emitter's load_fast.Damien George
Saves 24 bytes in bare-arm.
2015-01-14py: Add "default" to switches to allow better code flow analysis.Damien George
This helps compiler produce smaller code. Saves 124 bytes on stmhal and bare-arm.
2015-01-14py: Only allocate strings/bytes once for load_const_obj.Damien George
2015-01-14py: Reluctantly add an extra pass to bytecode compiler.Damien George
Bytecode also needs a pass to compute the stack size. This is because the state size of the bytecode function is encoded as a variable uint, so we must know the value of this uint before we encode it (otherwise the size of the generated code changes from one pass to the next). Having an entire pass for this seems wasteful (in time). Alternative is to allocate fixed space for the state size (would need 3-4 bytes to be general, when 1 byte is usually sufficient) which uses a bit of extra RAM per bytecode function, and makes the code less elegant in places where this uint is encoded/decoded. So, for now, opt for an extra pass.
2015-01-13py: Make compiler not crash when default except is not last.Damien George
2015-01-13py: Never intern data of large string/bytes object; add relevant tests.Damien George
Previously to this patch all constant string/bytes objects were interned by the compiler, and this lead to crashes when the qstr was too long (noticeable now that qstr length storage defaults to 1 byte). With this patch, long string/bytes objects are never interned, and are referenced directly as constant objects within generated code using load_const_obj.
2015-01-10py: Add config option MICROPY_COMP_MODULE_CONST for module consts.Damien George
Compiler optimises lookup of module.CONST when enabled (an existing feature). Disabled by default; enabled for unix, windows, stmhal. Costs about 100 bytes ROM on stmhal.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-12-27py: Allow to properly disable builtin slice operation.Damien George
This patch makes the MICROPY_PY_BUILTINS_SLICE compile-time option fully disable the builtin slice operation (when set to 0). This includes removing the slice sytanx from the grammar. Now, enabling slice costs 4228 bytes on unix x64, and 1816 bytes on stmhal.
2014-12-27py: Allow to properly disable builtin "set" object.Damien George
This patch makes MICROPY_PY_BUILTINS_SET compile-time option fully disable the builtin set object (when set to 0). This includes removing set constructor/comprehension from the grammar, the compiler and the emitters. Now, enabling set costs 8168 bytes on unix x64, and 3576 bytes on stmhal.
2014-12-21py: Remove last uses of printf from compile; use proper SyntaxError.Damien George
2014-12-21py: Move global/nonlocal decl code to compiler for proper SyntaxError.Damien George
This patch gives proper SyntaxError exceptions for bad global/nonlocal declarations. It also reduces code size: 304 bytes on unix x64, 132 bytes on stmhal.
2014-12-20py: Remove unnecessary RULE_none and PN_none from parser.Damien George
2014-12-12py: Fix optimised for-loop compiler so it follows proper semantics.Damien George
You can now assign to the range end variable and the for-loop still works correctly. This fully addresses issue #565. Also fixed a bug with the stack not being fully popped when breaking out of an optimised for-loop (and it's actually impossible to write a test for this case!).
2014-12-11py: Fix a semantic issue with range optimisation.Damien George
Now you can assign to the range variable within the for loop and it will still work. Partially addresses issue #565.
2014-12-10py: Make functions static where appropriate.Damien George
2014-11-02py: Fix bug with right-shifting small ints by large amounts.Paul Sokolovsky
Undefined behavior in C, needs explicit check.
2014-10-17py: Add more compiler optimisations for constant if/while conditions.Damien George
2014-10-17py: Simplify compilation of elif blocks.Damien George
2014-10-17py: Fix compiling of nested while/for and exception handler.Damien George
Addresses issue #912.
2014-10-05py: Make compiler return a proper exception on SyntaxError.Damien George
2014-10-03py: Fix unix-cpy to compile with uint->mp_uint_t changes.Damien George
2014-10-03py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.Damien George
This should pretty much resolve issue #50.
2014-10-03py: Convert [u]int to mp_[u]int_t where appropriate.Damien George
Addressing issue #50.
2014-09-23py: Free non-interned strings in the parser when not needed.Damien George
mp_parse_node_free now frees the memory associated with non-interned strings. And the parser calls mp_parse_node_free when discarding a non-used node (such as a doc string). Also, the compiler now frees the parse tree explicitly just before it exits (as opposed to relying on the caller to do this). Addresses issue #708 as best we can.
2014-09-08py: Convert [u]int to mp_[u]int_t in emit.h and associated .c files.Damien George
Towards resolving issue #50.
2014-09-06py: Add support for emitting native x86 machine code.Damien George
2014-09-03Code style/whitespace cleanup; remove obsolete headers.Damien George
And move the MAP_ANON redefinition from py/asmx64.c to unix/alloc.c.
2014-08-29py: Add compiler optimisation for conditions in parenthesis.Damien George
Optimises: if () -> if False if (x,...) -> if True if (a and b) -> if a and b
2014-08-27Basic native ARM emitterFabian Vogt
2014-08-15py: Fix typing of viper locals; allow default types in annotation.Damien George
2014-08-15py: Allow viper to have type annotations.Damien George
Viper functions can now be annotated with the type of their arguments and return value. Eg: @micropython.viper def f(x:int) -> int: return x + 1
2014-08-15py: Clean up and simplify functions in scope; add STATIC in compiler.Damien George
Some small code clean-ups that result in about 80 bytes ROM saving for stmhal.
2014-07-09moductypes: Foreign data interface module, roughly based on ctype ideas.Paul Sokolovsky
But much smaller and memory-efficient. Uses Python builtin data structures (dict, tuple, int) to describe structure layout.