summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2019-05-27py/vm: Remove obsolete comments about matching of exception opcodes.Damien George
These are incorrect since 5a2599d96299ad37cda954f1de345159f9acf11c
2019-05-22py/mkrules.mk: Remove unnecessary ; in makefile.Sebastien Rinsoz
This ; make Windows compilation fail with GNU makefile 4.2.1. It was added in 0dc85c9f86735c35cf14555482b2c8923cf31a6a as part of a shell if- statement, but this if-statement was subsequently removed in 23a693ec2d8c2a194f61482dc0e1adb070fb6ad4 so the semicolon is not needed.
2019-05-22py: Update makefiles to use $(TOUCH) instead of hard coded "touch".Sebastien Rinsoz
The variable $(TOUCH) is initialized with the "touch" value in mkenv.mk like for the other command line tools (rm, echo, cp, mkdir etc). With this, for example, Windows users can specify the path of touch.exe.
2019-05-21py: Update makefiles to use $(CAT) variable instead of hard coded "cat".Sébastien Rinsoz
The variable $(CAT) is initialised with the "cat" value in mkenv.mk like for the other command line tools (rm, echo, cp, mkdir etc). With this, for example, Windows users can specify the path of cat.exe.
2019-05-21py/objarray: Add decode method to bytearray.stijn
Reuse the implementation for bytes since it works the same way regardless of the underlying type. This method gets added for CPython compatibility of bytearray, but to keep the code simple and small array.array now also has a working decode method, which is non-standard but doesn't hurt.
2019-05-17various: Update early copyright years to match actual edit history.Damien George
2019-05-17various: Add and update my copyright line based on git history.Paul Sokolovsky
For modules I initially created or made substantial contributions to.
2019-05-14py/objarray: Add support for memoryview.itemsize attribute.stijn
This allows figuring out the number of bytes in the memoryview object as len(memview) * memview.itemsize. The feature is enabled via MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE and is disabled by default.
2019-05-13py/persistentcode: Change "len" type to size_t for mp_obj_str_get_data.Henrik Vendelbo
2019-05-09py/misc.h: Rename _MP_STRINGIFY to not use leading underscore in ident.Damien George
Macro identifiers with a leading underscore are reserved.
2019-05-09py/objgenerator: Remove unneeded forward decl and clean up white space.Damien George
2019-05-09py/objgenerator: Fix handling of None passed as 2nd arg to throw().Damien George
Fixes issue #4527.
2019-05-07mpy-cross: Add --version command line option to print version info.Damien George
Prints something like: MicroPython v1.10-304-g8031b7a25 on 2019-05-02; mpy-cross emitting mpy v4
2019-05-06py: remove "if (0)" and "if (false)" branches.Jun Wu
Prior to this commit, building the unix port with `DEBUG=1` and `-finstrument-functions` the compilation would fail with an error like "control reaches end of non-void function". This change fixes this by removing the problematic "if (0)" branches. Not all branches affect compilation, but they are all removed for consistency.
2019-05-06extmod/moducryptolib: Add AES-CTR support.Yonatan Goldschmidt
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR. Disabled by default.
2019-05-03py/native: Improve support for bool type in viper functions.Damien George
Variables with type bool now act more like an int, and there is proper casting to/from Python objects.
2019-05-01py/asmthumb: Support asm_thumb code running on normal ARM processors.Damien George
With this change, @micropython.asm_thumb functions will work on standard ARM processors (that are in ARM state by default), in scripts and precompiled .mpy files. Addresses issue #4675.
2019-04-23py/mpprint: Support printing %ld and %lu formats on 64-bit archs.Damien George
Fixes issue #4702.
2019-04-15py/runtime: Fix mp_unpack_ex so seq can't be reclaimed by GC during use.Damien George
The issue described in the comment added here can be seen by forcing a gc_collect() at the start of each call to gc_alloc().
2019-04-15py/objset: Remove unused forward declaration and clean up whitespace.Damien George
2019-04-15py/runtime: Optimise to not create temp float for int to power negative.Damien George
2019-04-12py/makedefs: Use io.open with utf-8 encoding when processing source.Damien George
In case (user) source code contains utf-8 encoded data and the default locale is not utf-8. See #4592.
2019-03-26py/nlrthumb: Add support for iOS where the C func is _nlr_push_tail.Romain Goyet
2019-03-26py/scheduler: Convert micropythyon.schedule() to a circular buffer.Andrew Leech
This means the schedule operates on a first-in, first-executed manner rather than the current last-in, first executed.
2019-03-20py/runtime: Remove long-obsolete MICROPY_FSUSERMOUNT init code.Damien George
In 1808b2e8d5c9fff8020628a7849a537ffa9790e3 it was replaced by MICROPY_VFS and related code.
2019-03-14py/compile: Check that arch is set when compiling native, viper or asm.Damien George
2019-03-14py/compile: Support multiple inline asm emitters.Damien George
2019-03-14py/compile: Add support to select the native emitter at runtime.Damien George
2019-03-14py/nativeglue: Rename native convert funs to match other native helpers.Damien George
2019-03-14py: Move mp_native_type_from_qstr() from emitnative.c to nativeglue.c.Damien George
2019-03-08py: Update and rework build system for including external C modules.Andrew Leech
How to use this feature is documented in docs/develop/cmodules.rst.
2019-03-08py: Implement a module system for external, user C modules.Ayke van Laethem
This system makes it a lot easier to include external libraries as static, native modules in MicroPython. Simply pass USER_C_MODULES (like FROZEN_MPY_DIR) as a make parameter.
2019-03-08py: Allow registration of modules at their definition.Andrew Leech
During make, makemoduledefs.py parses the current builds c files for MP_REGISTER_MODULE(module_name, obj_module, enabled_define) These are used to generate a header with the required entries for "mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c
2019-03-08py/persistentcode: Bump .mpy version to 4.Damien George
2019-03-08py: Add support to save native, viper and asm code to .mpy files.Damien George
This commit adds support for saving and loading .mpy files that contain native code (native, viper and inline-asm). A lot of the ground work was already done for this in the form of removing pointers from generated native code. The changes here are mainly to link in qstr values to the native code, and change the format of .mpy files to contain native code blocks (possibly mixed with bytecode). A top-level summary: - @micropython.native, @micropython.viper and @micropython.asm_thumb/ asm_xtensa are now allowed in .py files when compiling to .mpy, and they work transparently to the user. - Entire .py files can be compiled to native via mpy-cross -X emit=native and for the most part the generated .mpy files should work the same as their bytecode version. - The .mpy file format is changed to 1) specify in the header if the file contains native code and if so the architecture (eg x86, ARMV7M, Xtensa); 2) for each function block the kind of code is specified (bytecode, native, viper, asm). - When native code is loaded from a .mpy file the native code must be modified (in place) to link qstr values in, just like bytecode (see py/persistentcode.c:arch_link_qstr() function). In addition, this now defines a public, native ABI for dynamically loadable native code generated by other languages, like C.
2019-03-08py/emitglue: Remove union in mp_raw_code_t to combine bytecode & native.Damien George
2019-03-08py/emitnative: Adjust accounting of size of const_table.Damien George
n_obj no longer includes a count for mp_fun_table to make it a bit simpler.
2019-03-08py/emitnative: Provide concentrated points of qstr emit.Damien George
2019-03-08py/emitnative: Consolidate where HASCONSTS is set to load-const-obj fun.Damien George
Simplifies the code and fixes handling of the Ellipsis const in native code generation (which also needs the constant table so must set this flag).
2019-03-08py: Add independent config for debugging sentinel object values.Damien George
The new compile-time option is MICROPY_DEBUG_MP_OBJ_SENTINELS, disabled by default. This is to allow finer control of whether this debugging feature is enabled or not (because, for example, this setting must be the same for mpy-cross and the MicroPython main code when using native code generation).
2019-03-05py/persistentcode: Define static qstr set to reduce size of mpy files.Damien George
When encoded in the mpy file, if qstr <= QSTR_LAST_STATIC then store two bytes: 0, static_qstr_id. Otherwise encode the qstr as usual (either with string data or a reference into the qstr window). Reduces mpy file size by about 5%.
2019-03-05py/persistentcode: Pack qstrs directly in bytecode to reduce mpy size.Damien George
Instead of emitting two bytes in the bytecode for where the linked qstr should be written to, it is now replaced by the actual qstr data, or a reference into the qstr window. Reduces mpy file size by about 10%.
2019-03-05py/persistentcode: Add a qstr window to save mpy files more efficiently.Damien George
This is an implementation of a sliding qstr window used to reduce the number of qstrs stored in a .mpy file. The window size is configured to 32 entries which takes a fixed 64 bytes (16-bits each) on the C stack when loading/saving a .mpy file. It allows to remember the most recent 32 qstrs so they don't need to be stored again in the .mpy file. The qstr window uses a simple least-recently-used mechanism to discard the least recently used qstr when the window overflows (similar to dictionary compression). This scheme only needs a single pass to save/load the .mpy file. Reduces mpy file size by about 25% with a window size of 32.
2019-03-05py: Replace POP_BLOCK and POP_EXCEPT opcodes with POP_EXCEPT_JUMP.Damien George
POP_BLOCK and POP_EXCEPT are now the same, and are always followed by a JUMP. So this optimisation reduces code size, and RAM usage of bytecode by two bytes for each try-except handler.
2019-03-05py/vm: Remove currently_in_except_block variable.Damien George
After the previous commit it is no longer needed.
2019-03-05py: Fix VM crash with unwinding jump out of a finally block.Damien George
This patch fixes a bug in the VM when breaking within a try-finally. The bug has to do with executing a break within the finally block of a try-finally statement. For example: def f(): for x in (1,): print('a', x) try: raise Exception finally: print(1) break print('b', x) f() Currently in uPy the above code will print: a 1 1 1 segmentation fault (core dumped) micropython Not only is there a seg fault, but the "1" in the finally block is printed twice. This is because when the VM executes a finally block it doesn't really know if that block was executed due to a fall-through of the try (no exception raised), or because an exception is active. In particular, for nested finallys the VM has no idea which of the nested ones have active exceptions and which are just fall-throughs. So when a break (or continue) is executed it tries to unwind all of the finallys, when in fact only some may be active. It's questionable whether break (or return or continue) should be allowed within a finally block, because they implicitly swallow any active exception, but nevertheless it's allowed by CPython (although almost never used in the standard library). And uPy should at least not crash in such a case. The solution here relies on the fact that exception and finally handlers always appear in the bytecode after the try body. Note: there was a similar bug with a return in a finally block, but that was previously fixed in b735208403a54774f9fd3d966f7c1a194c41870f
2019-03-04py/py.mk: Update lwip build config to work with latest lwip version.Damien George
Also, to make it possible for ports to provide their own lwipopts.h, the default include directory of extmod/lwip-include is no longer added and instead a port should now make sure the correct include directory is included in the list (can still use extmod/lwip-include).
2019-03-04py/objexcept: Fix hash of exc str created in mp_obj_new_exception_msg.Tom Collins
2019-03-01py/compile: Add optimisation to compile OrderedDict inplace.Damien George
This optimisation eliminates the need to create a temporary normal dict. The optimisation is enabled via MICROPY_COMP_CONST_LITERAL which is enabled by default (although only has an effect if OrderdDict is enabled). Thanks to @pfalcon for the initial idea and implementation.
2019-02-26py/compile: Fix handling of unwinding BaseException in async with.Damien George
All exceptions that unwind through the async-with must be caught and BaseException is the top-level class, which includes Exception and others. Fixes issue #4552.