aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-12-11tests/heapalloc, heapalloc_super: Skip in strict stackless mode.Paul Sokolovsky
These tests involves testing allocation-free function calling, and in strict stackless mode, it's not possible to make a function call with heap locked (because function activation record aka frame is allocated on the heap).
2017-12-11tests/heapalloc_*: Refactor some tests to work in strict stackless mode.Paul Sokolovsky
In strict stackless mode, it's not possible to make a function call with heap locked (because function activation record aka frame is allocated on heap). So, if the only purpose of function is to introduce local variable scope, move heap lock/unlock calls inside the function.
2017-12-11py/runtime: Use the Python stack when building *arg and **kwarg state.Damien George
With MICROPY_ENABLE_PYSTACK enabled the following language constructs no longer allocate on the heap: f(*arg), f(**kwarg).
2017-12-11stm32: Add support for using the Python stack.Damien George
2017-12-11unix: Add support for using the Python stack.Damien George
2017-12-11extmod/modure: Convert alloca() to use new scoped allocation API.Damien George
2017-12-11extmod/machine_signal: Change VLA to use new scoped allocation API.Damien George
2017-12-11py: Convert all uses of alloca() to use new scoped allocation API.Damien George
2017-12-11py: Introduce a Python stack for scoped allocation.Damien George
This patch introduces the MICROPY_ENABLE_PYSTACK option (disabled by default) which enables a "Python stack" that allows to allocate and free memory in a scoped, or Last-In-First-Out (LIFO) way, similar to alloca(). A new memory allocation API is introduced along with this Py-stack. It includes both "local" and "nonlocal" LIFO allocation. Local allocation is intended to be equivalent to using alloca(), whereby the same function must free the memory. Nonlocal allocation is where another function may free the memory, so long as it's still LIFO. Follow-up patches will convert all uses of alloca() and VLA to the new scoped allocation API. The old behaviour (using alloca()) will still be available, but when MICROPY_ENABLE_PYSTACK is enabled then alloca() is no longer required or used. The benefits of enabling this option are (or will be once subsequent patches are made to convert alloca()/VLA): - Toolchains without alloca() can use this feature to obtain correct and efficient scoped memory allocation (compared to using the heap instead of alloca(), which is slower). - Even if alloca() is available, enabling the Py-stack gives slightly more efficient use of stack space when calling nested Python functions, due to the way that compilers implement alloca(). - Enabling the Py-stack with the stackless mode allows for even more efficient stack usage, as well as retaining high performance (because the heap is no longer used to build and destroy stackless code states). - With Py-stack and stackless enabled, Python-calling-Python is no longer recursive in the C mp_execute_bytecode function. The micropython.pystack_use() function is included to measure usage of the Python stack.
2017-12-11py/runtime: Move mp_exc_recursion_depth to runtime and rename to raise.Damien George
For consistency this helper function is renamed to match the other exception helpers, and moved to their location in runtime.c.
2017-12-11docs/reference/packages: Add chapter on distribution packages and deployment.Paul Sokolovsky
A long overdue overview of preparing packages, installing them with upip, freezing, dealing with resources. Initial version, more iterations required.
2017-12-10unix/mpconfigport: Disable uio.resource_stream().Paul Sokolovsky
This function was implemented as an experiment, and was enabled only in unix port. To remind, it allows to access arbitrary files frozen as source modules (vs bytecode). However, further experimentation showed that the same functionality can be implemented with frozen bytecode. The process requires more steps, but with suitable toolset it doesn't matter patch. This process is: 1. Convert binary files into "Python resource module" with tools/mpy_bin2res.py. 2. Freeze as the bytecode. 3. Use micropython-lib's pkg_resources.resource_stream() to access it. In other words, the extra step is using tools/mpy_bin2res.py (because there would be wrapper for uio.resource_stream() anyway). Going frozen bytecode route allows more flexibility, and same/additional efficiency: 1. Frozen source support can be disabled altogether for additional code savings. 2. Resources could be also accessed as a buffer, not just as a stream. There're few caveats too: 1. It wasn't actually profiled the overhead of storing a resource in "Python resource module" vs storing it directly, but it's assumed that overhead is small. 2. The "efficiency" claim above applies to the case when resource file is frozen as the bytecode. If it's not, it actually will take a lot of RAM on loading. But in this case, the resource file should not be used (i.e. generated) in the first place, and micropython-lib's pkg_resources.resource_stream() implementation has the appropriate fallback to read the raw files instead. This still poses some distribution issues, e.g. to deployable to baremetal ports (which almost certainly would require freezeing as the bytecode), a distribution package should include the resource module. But for non-freezing deployment, presense of resource module will lead to memory inefficiency. All the discussion above reminds why uio.resource_stream() was implemented in the first place - to address some of the issues above. However, since then, frozen bytecode approach seems to prevail, so, while there're still some issues to address with it, this change is being made. This change saves 488 bytes for the unix x86_64 port.
2017-12-10py/mkrules.mk: Add "clean-frozen" target to clean frozen script/modules dir.Paul Sokolovsky
This target removes any stray files (i.e. something not committed to git) from scripts/ and modules/ dirs (or whatever FROZEN_DIR and FROZEN_MPY_DIR is set to). The expected workflow is: 1. make clean-frozen 2. micropython -m upip -p modules <packages_to_freeze> 3. make As it can be expected that people may drop random thing in those dirs which they can miss later, the content is actually backed up before cleaning.
2017-12-09py/map: Allow to trace rehashing operations.Paul Sokolovsky
2017-12-09py/objfun: Factor out macro for initializing codestate.Paul Sokolovsky
This is second part of fun_bc_call() vs mp_obj_fun_bc_prepare_codestate() common code refactor. This factors out code to initialize codestate object. After this patch, mp_obj_fun_bc_prepare_codestate() is effectively DECODE_CODESTATE_SIZE() followed by allocation followed by INIT_CODESTATE(), and fun_bc_call() starts with that too.
2017-12-09py/objfun, vm: Add comments on codestate allocation in stackless mode.Paul Sokolovsky
2017-12-09py/objfun: Factor out macro for decoding codestate size.Paul Sokolovsky
fun_bc_call() starts with almost the same code as mp_obj_fun_bc_prepare_codestate(), the only difference is a way to allocate the codestate object (heap vs stack with heap fallback). Still, would be nice to avoid code duplication to make further refactoring easier. So, this commit factors out the common code before the allocation - decoding and calculating codestate size. It produces two values, so structured as a macro which writes to 2 variables passed as arguments.
2017-12-09py/gc: In sweep debug output, print pointer as a pointer.Paul Sokolovsky
Or it will be truncated on a 64-bit platform.
2017-12-09py/gc: Factor out a macro to trace GC mark operations.Paul Sokolovsky
To allow easier override it for custom tracing.
2017-12-09py/runtime: When tracing unary/binary ops, output op (method) name.Paul Sokolovsky
E.g.: >>> 1+1 binary 26 __add__ 3 3 Output is similar to bytecode dump (numeric code, then op name).
2017-12-08py/objint_longlong: Check for zero division/modulo.Paul Sokolovsky
2017-12-08lib/tinytest: Move from tools/tinytest.Paul Sokolovsky
Tinytest library was misplaced under tools/. By convention, any target libraries belong to lib/, while tools/ contains host-side tools.
2017-12-08qemu-arm/test_main: Clean up invocation of tinytest_main().Paul Sokolovsky
Command-line argc and argv should be passed, and as we don't have them, placeholders were passed, but incorrectly. As we don't have them, just pass 0/NULL. Looking at the source, this migh lead to problems under Windows, but this test doesn't run under Windows. Also, use "%d" printf format consistently with the rest of the codebase.
2017-12-08zephyr/main: Move var declarations to the top of file.Paul Sokolovsky
2017-12-08py/asmbase: Revert removal of clearing of label offsets for native emit.Damien George
The assembler back-end for most architectures needs to know if a jump is backwards in order to emit optimised machine code, and they do this by checking if the destination label has been set or not. So always reset label offsets to -1 (this reverts partially the previous commit, with some minor optimisation for the if-logic with the pass variable).
2017-12-08py/{emitbc,asmbase}: Only clear emit labels to -1 when in debug mode.Damien George
Clearing the labels to -1 is purely a debugging measure. For release builds there is no need to do it as the label offset table should always have the correct value assigned.
2017-12-08py/gc: Add CLEAR_ON_SWEEP option to debug mis-traced objects.Paul Sokolovsky
Accessing them will crash immediately instead still working for some time, until overwritten by some other data, leading to much less deterministic crashes.
2017-12-07py/malloc: Allow to use debug logging if !MICROPY_MALLOC_USES_ALLOCATED_SIZE.Paul Sokolovsky
This is mostly a workaround for forceful rebuilding of mpy-cross on every codebase change. If this file has debug logging enabled (by patching), mpy-cross build failed.
2017-12-07py/malloc: MICROPY_MEM_STATS requires MICROPY_MALLOC_USES_ALLOCATED_SIZE.Paul Sokolovsky
Error out if they're set incompatibly.
2017-12-07py/mpprint: Fix "%x" vs "%X" regression introduced in previous commit.Paul Sokolovsky
2017-12-07py/mpprint: Support "%lx" format on 64-bit systems.Paul Sokolovsky
Before that, the output was truncated to 32 bits. Only "%x" format is handled, because a typical use is for addresses. This refactor actually decreased x86_64 code size by 30 bytes.
2017-12-07py/mpprint: Make "%p" format work properly on 64-bit systems.Paul Sokolovsky
Before, the output was truncated to 32 bits.
2017-12-06zephyr/CMakeLists.txt: Properly separate CFLAGS parts gotten from CMake.Paul Sokolovsky
Lack of spaces between them led to weird option artifacts like -Ifoo-Dbar.
2017-12-06zephyr/CMakeLists.txt: Update for latest Zephyr buildsys changes.Paul Sokolovsky
2017-12-06docs/glossary: Clarify wording for "baremetal".Paul Sokolovsky
2017-12-05py/modbuiltins: Use standard arg-parsing helper func for builtin print.Damien George
This allows the function to raise an exception when unknown keyword args are passed in. This patch also reduces code size by (in bytes): bare-arm: -24 minimal x86: -76 unix x64: -56 unix nanbox: -84 stm32: -40 esp8266: -68 cc3200: -48 Furthermore, this patch adds space (" ") to the set of ROM qstrs which means it doesn't need to be put in RAM if it's ever used.
2017-12-05tests/run-tests: Wrap long lists to facilitate adding more items.Paul Sokolovsky
2017-12-05py: mp_call_function_*_protected(): Pass-thru return value if possible.Paul Sokolovsky
Return the result of called function. If exception happened, return MP_OBJ_NULL. Allows to use mp_call_function_*_protected() with callbacks returning values, etc.
2017-12-04docs/library: Add xrefs to "stream" dictionary entry for many modules.Paul Sokolovsky
2017-12-04py/misc.h: Add m_new_obj_var_with_finaliser().Paul Sokolovsky
Similar to existing m_new_obj_with_finaliser().
2017-12-04docs/glossary: Describe string interning.Paul Sokolovsky
2017-12-04esp8266/modnetwork: Make sure to intern string passed to .config("param").Paul Sokolovsky
This is the proper fix for https://github.com/micropython/micropython/issues/3442.
2017-12-03docs/glossary: Describe "stream" term.Paul Sokolovsky
2017-12-03docs/uerrno: Fix xref-vs-code markup.Paul Sokolovsky
2017-12-03tests/cpydiff: Fix markup where "`" (xref) was used instead of "``" (code).Paul Sokolovsky
2017-12-03docs/glossary: Describe the callee-owned tuple concept.Paul Sokolovsky
2017-12-01zephyr/Makefile: syscall_macros.h generation was moved from CMake to make.Paul Sokolovsky
Required for #include <zephyr.h> to work.
2017-12-01stm32/boards/*_af.csv: Make consistent use of JTMS, JTCK, SWDIO, SWCLK.Damien George
5-pin JTAG and 2-pin SWD are logically separate interfaces so encode them in the AF tables as separate entries (separated by /, not -).
2017-12-01stm32/boards/stm32f767_af.csv: Update AF table based on datasheet.Damien George
Based on ST datasheet, DocID029041 Rev 3, DM00273119.pdf.
2017-11-30docs/uselect: ipoll: Fix grammar/wording of one-shot flag description.Paul Sokolovsky