summaryrefslogtreecommitdiffstatshomepage
path: root/py/bc.c
Commit message (Collapse)AuthorAge
* py: Add verbose debug compile-time flag MICROPY_DEBUG_VERBOSE.Stefan Naumann2017-08-15
| | | | It enables all the DEBUG_printf outputs in the py/ source code.
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* py: Provide mp_decode_uint_skip() to help reduce stack usage.Damien George2017-06-09
| | | | | | | | | 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.
* py: Add LOAD_SUPER_METHOD bytecode to allow heap-free super meth calls.Damien George2017-04-22
| | | | | | | | | | | | | | | | | | | | | | This patch allows the following code to run without allocating on the heap: super().foo(...) Before this patch such a call would allocate a super object on the heap and then load the foo method and call it right away. The super object is only needed to perform the lookup of the method and not needed after that. This patch makes an optimisation to allocate the super object on the C stack and discard it right after use. Changes in code size due to this patch are: bare-arm: +128 minimal: +232 unix x64: +416 unix nanbox: +364 stmhal: +184 esp8266: +340 cc3200: +128
* py: Use mp_raise_TypeError/mp_raise_ValueError helpers where possible.Damien George2017-03-28
| | | | Saves 168 bytes on bare-arm.
* py/bc: Provide better error message for an unexpected keyword argument.Damien George2017-03-22
| | | | | | | | | | | | | | Now, passing a keyword argument that is not expected will correctly report that fact. If normal or detailed error messages are enabled then the name of the unexpected argument will be reported. This patch decreases the code size of bare-arm and stmhal by 12 bytes, and cc3200 by 8 bytes. Other ports (minimal, unix, esp8266) remain the same in code size. For terse error message configuration this is because the new message is shorter than the old one. For normal (and detailed) error message configuration this is because the new error message already exists in py/objnamedtuple.c so there's no extra space in ROM needed for the string.
* py: Provide mp_decode_uint_value to help optimise stack usage.Damien George2017-03-17
| | | | | This has a noticeable improvement on x86-64 and Thumb2 archs, where stack usage is reduced by 2 machine words in the VM.
* py: Reduce size of mp_code_state_t structure.Damien George2017-03-17
| | | | | | | | | | | | | | | | | | | | | 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.
* py: Use mp_raise_msg helper function where appropriate.Damien George2016-10-17
| | | | | Saves the following number of bytes of code space: 176 for bare-arm, 352 for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
* py: Update opcode format table because 3 opcodes were removed, 1 added.Damien George2016-09-23
| | | | | LIST_APPEND, MAP_ADD and SET_ADD have been removed, and STORE_COMP has been added in adaf0d865cd6c81fb352751566460506392ed55f.
* py: Rename struct mp_code_state to mp_code_state_t.Damien George2016-08-27
| | | | Also at _t to mp_exc_stack pre-declaration in struct typedef.
* py: Fix bug passing a string as a keyword arg in a dict.Damien George2016-04-21
| | | | Addresses issue #1998.
* py/bc: Update opcode format table now that MP_BC_NOT opcode is gone.Damien George2016-01-28
| | | | | | MP_BC_NOT was removed and the "not" operation made a proper unary operator, and the opcode format table needs to be updated to reflect this change (but actually the change is only cosmetic).
* py/bc: Use size_t instead of mp_uint_t to count size of state and args.Damien George2015-12-17
|
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Make mp_setup_code_state take concrete pointer for func arg.Damien George2015-11-29
|
* py: Add MICROPY_PERSISTENT_CODE_LOAD/SAVE to load/save bytecode.Damien George2015-11-13
| | | | | | MICROPY_PERSISTENT_CODE must be enabled, and then enabling MICROPY_PERSISTENT_CODE_LOAD/SAVE (either or both) will allow loading and/or saving of code (at the moment just bytecode) from/to a .mpy file.
* py: Add constant table to bytecode.Damien George2015-11-13
| | | | | Contains just argument names at the moment but makes it easy to add arbitrary constants.
* py: Put all bytecode state (arg count, etc) in bytecode.Damien George2015-11-13
|
* py: Reorganise bytecode layout so it's more structured, easier to edit.Damien George2015-11-13
|
* py: Eliminate some cases which trigger unused parameter warnings.Damien George2015-09-04
|
* py: Add %q format support to mp_[v]printf, and use it.Damien George2015-04-16
|
* py: Implement full func arg passing for native emitter.Damien George2015-04-07
| | | | | | | | | | | This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
* py: Simplify bytecode prelude when encoding closed over variables.Damien George2015-04-07
|
* vm: Initial support for calling bytecode functions w/o C stack ("stackless").Paul Sokolovsky2015-04-03
|
* py: Allow retrieving a function's __name__.stijn2015-03-20
| | | | Disabled by default. Enabled on unix and stmhal ports.
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Make terse_arg_mismatch a global function and use it elsewhere.Damien George2015-01-01
| | | | Reduces code size when MICROPY_ERROR_REPORTING_TERSE is selected.
* py: Fix some macros defines; cleanup some includes.Damien George2014-11-05
|
* py: Store bytecode arg names in bytecode (were in own array).Damien George2014-10-25
| | | | | | | | | | | | | | | | | | | | 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.
* py: Convert [u]int to mp_[u]int_t where appropriate.Damien George2014-10-03
| | | | Addressing issue #50.
* py: Use variable length encoded uints in more places in bytecode.Damien George2014-09-04
| | | | | | Code-info size, block name, source name, n_state and n_exc_stack now use variable length encoded uints. This saves 7-9 bytes per bytecode function for most functions.
* Further factorise PASS_1 out of specific emit code.Damien2013-10-05
|
* Initial commit.Damien2013-10-04