aboutsummaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2019-12-27py/runtime: Don't allocate iter buf for user-defined types.Damien George
A user-defined type that defines __iter__ doesn't need any memory to be pre-allocated for its iterator (because it can't use such memory). So optimise for this case by not allocating the iter-buf.
2019-12-27py/asmx86: Remove unused 5th argument facility.Damien George
In commit 71a3d6ec3bd02c5bd13334537e1bd146bb643bad mp_setup_code_state was changed from a 5-arg function to a 4-arg function, and at that point 5-arg calls in native code were no longer needed. See also commit 4f9842ad80c235188955fd83317f715033a596c0.
2019-12-27py/asmx86: Fix stack to be 16-byte aligned for entry and sub-call.Damien George
2019-12-23py/nlrx86: Silence possible warnings about unused nlr argument.Damien George
2019-12-21py/objobject: Add object.__delattr__ function.Yonatan Goldschmidt
Similar to object.__setattr__.
2019-12-21py/objobject: Add object.__setattr__ function.Yonatan Goldschmidt
Allows assigning attributes on class instances that implement their own __setattr__. Both object.__setattr__ and super(A, b).__setattr__ will work with this commit.
2019-12-20py/obj.h: Remove comments about additional mp_buffer_info_t entries.Damien George
These entries are unlikely to be needed, so remove them to clean up the struct definition.
2019-12-20py: Remove commented-out debug printf's from emitbc and objlist.Damien George
Any debugging prints should use a macro like DEBUG_printf.
2019-12-20all: Bump version to 1.12.Damien George
2019-12-20py/profile: Fix debug opcode decoding of MP_BC_RAISE_xxx opcodes.Damien George
2019-12-20py/vm: Fix comment to refer to MP_BC_RAISE_OBJ instead of RAISE_VARARGS.Damien George
2019-12-17py/persistentcode: Move loading of rodata/bss to before obj/raw-code.Damien George
This makes the loading of viper-code-with-relocations a bit neater and easier to understand, by treating the rodata/bss like a special object to be loaded into the constant table (which is how it behaves).
2019-12-13py/dynruntime: Implement uint new/get, mp_obj_len and mp_obj_subscr.Damien George
2019-12-12py/dynruntime: Add support for float API to make/get floats.Damien George
We don't want to add a feature flag to .mpy files that indicate float support because it will get complex and difficult to use. Instead the .mpy is built using whatever precision it chooses (float or double) and the native glue API will convert between this choice and what the host runtime actually uses.
2019-12-12py/nativeglue: Add float new/get functions with both single and double.Damien George
2019-12-12py/persistentcode: Make ARM Thumb archs support multiple sub-archs.Damien George
2019-12-12tools/mpy_ld.py: Add new mpy_ld.py tool and associated build files.Damien George
This commit adds a new tool called mpy_ld.py which is essentially a linker that builds .mpy files directly from .o files. A new header file (dynruntime.h) and makefile fragment (dynruntime.mk) are also included which allow building .mpy files from C source code. Such .mpy files can then be dynamically imported as though they were a normal Python module, even though they are implemented in C. Converting .o files directly (rather than pre-linked .elf files) allows the resulting .mpy to be more efficient because it has more control over the relocations; for example it can skip PLT indirection. Doing it this way also allows supporting more architectures, such as Xtensa which has specific needs for position-independent code and the GOT. The tool supports targets of x86, x86-64, ARM Thumb and Xtensa (windowed and non-windowed). BSS, text and rodata sections are supported, with relocations to all internal sections and symbols, as well as relocations to some external symbols (defined by dynruntime.h), and linking of qstrs.
2019-12-12py/nativeglue: Add funcs/types to native glue table for dynamic runtime.Damien George
These allow discovery of symbols by native code that is loaded dynamically.
2019-12-12py/nativeglue: Add new header file with native function table typedef.Damien George
2019-12-12py/persistentcode: Add ability to relocate loaded native code.Damien George
Implements text, rodata and bss generalised relocations, as well as generic qstr-object linking. This allows importing dynamic native modules on all supported architectures in a unified way.
2019-12-09py/objenumerate: Check for valid args in enumerate constructor.Emil Renner Berthing
For the case where MICROPY_CPYTHON_COMPAT is disabled. This fix makes basics/fun_error2.py pass and not crash the interpreter.
2019-11-26py: Remove 3 obsolete commented-out lines from header files.Damien George
2019-11-26py/objstringio: Slightly optimize stringio_copy_on_write for code size.Yonatan Goldschmidt
With the memcpy() call placed last it avoids the effects of registers clobbering. It's definitely effective in non-inlined functions, but even here it is still making a small difference. For example, on stm32, this saves an extra `ldr` instruction to load `o->vstr` after the memcpy() returns.
2019-11-26py/qstr: Raise exception in qstr_from_strn if str to intern is too long.Léa Saviot
The string length being longer than the allowed qstr length can happen in many locations, for example in the parser with very long variable names. Without an explicit check that the length is within range (as done in this patch) the code would exhibit crashes and strange behaviour with truncated strings.
2019-11-26py/builtinimport: Raise exception on empty module name.Léa Saviot
To prevent a crash returning MP_OBJ_NULL. A test is added for this case.
2019-11-21py/compile: Coalesce error message for break/continue outside loop.Petr Viktorin
To reduce code size.
2019-11-21py/ringbuf: Add peek16 method.Jim Mussared
2019-11-13py/objdict: Support ujson.dump() of OrderedDict objects.Andrew Leech
Following CPython, OrderedDict are dumped with the syntax of dict.
2019-11-07py/emitnx86: Make mp_f_n_args table match order of mp_fun_kind_t.Damien George
2019-11-07py/emitnative: Fix typo, REG_PARENT_ARG_RET should be REG_PARENT_RET.Thea Flowers
2019-11-05all: Convert nlr_raise(mp_obj_new_exception_msg(x)) to mp_raise_msg(x).Damien George
This helper function was added a while ago and these are the remaining cases to convert, to save a bit of code size.
2019-11-04py/modsys: Report .mpy version in sys.implementation.Damien George
This commit adds a sys.implementation.mpy entry when the system supports importing .mpy files. This entry is a 16-bit integer which encodes two bytes of information from the header of .mpy files that are supported by the system being run: the second and third bytes, .mpy version, and flags and native architecture. This allows determining the supported .mpy file dynamically by code, and also for the user to find it out by inspecting this value. It's further possible to dynamically detect if the system supports importing .mpy files by `hasattr(sys.implementation, 'mpy')`.
2019-11-04py/persistentcode: Move declarations for .mpy header from .c to .h file.Damien George
2019-11-04py/objgenerator: Allow pend_throw to an unstarted generator.Jim Mussared
Replace the is_running field with a tri-state variable to indicate running/not-running/pending-exception. Update tests to cover the various cases. This allows cancellation in uasyncio even if the coroutine hasn't been executed yet. Fixes #5242
2019-11-04py/objgenerator: Remove globals from mp_obj_gen_instance_t.Jim Mussared
This wasn't necessary as the wrapped function already has a reference to its globals. But it had a dual purpose of tracking whether the function was currently running, so replace it with a bool.
2019-11-01py/nativeglue: Remove unused mp_obj_new_cell from mp_fun_table.Damien George
It has been unused since 9988618e0e0f5c319e31b135d993e22efb593093
2019-10-31py/stream.h: Add MP_STREAM_POLL_NVAL constant.Damien George
2019-10-29py/runtime: Reorder some binary ops so they don't require conditionals.Damien George
runtime0.h is part of the MicroPython ABI so it's simpler if it's independent of config options, like MICROPY_PY_REVERSE_SPECIAL_METHODS. What's effectively done here is to move MP_BINARY_OP_DIVMOD and MP_BINARY_OP_CONTAINS up in the enum, then remove the #if MICROPY_PY_REVERSE_SPECIAL_METHODS conditional. Without this change .mpy files would need to have a feature flag for MICROPY_PY_REVERSE_SPECIAL_METHODS (when embedding native code that uses this enum). This commit has no effect when MICROPY_PY_REVERSE_SPECIAL_METHODS is disabled. With this option enabled this commit reduces code size by about 60 bytes.
2019-10-29extmod: Add VFS littlefs bindings.Damien George
Both LFS1 and LFS2 are supported at the same time.
2019-10-29extmod/vfs_blockdev: Factor out block device interface code.Damien George
2019-10-22powerpc: Add initial port to bare metal PowerPC arch.Michael Neuling
Runs in microwatt (GHDL and FPGA) and qemu. Port done initially by Michael Neuling, with help from Anton Blanchard and Jordan Niethe.
2019-10-22extmod/modbluetooth: Rename module to "ubluetooth".Jim Mussared
For consistency with "umachine". Now that weak links are enabled by default for built-in modules, this should be a no-op, but allows extension of the bluetooth module by user code. Also move registration of ubluetooth to objmodule rather than port-specific.
2019-10-22py/modarray: Rename "array" module to "uarray".Damien George
Following the other modules like ustruct, ucollections. See issues #4370 and #4449.
2019-10-22py: Automatically provide weak links from "foo" to "ufoo" module name.Damien George
This commit implements automatic module weak links for all built-in modules, by searching for "ufoo" in the built-in module list if "foo" cannot be found. This means that all modules named "ufoo" are always available as "foo". Also, a port can no longer add any other weak links, which makes strict the definition of a weak link. It saves some code size (about 100-200 bytes) on ports that previously had lots of weak links. Some changes from the previous behaviour: - It doesn't intern the non-u module names (eg "foo" is not interned), which saves code size, but will mean that "import foo" creates a new qstr (namely "foo") in RAM (unless the importing module is frozen). - help('modules') no longer lists non-u module names, only the u-variants; this reduces duplication in the help listing. Weak links are effectively the same as having a set of symbolic links on the filesystem that is searched last. So an "import foo" will search built-in modules first, then all paths in sys.path, then weak links last, importing "ufoo" if it exists. Thus a file called "foo.py" somewhere in sys.path will still have precedence over the weak link of "foo" to "ufoo". See issues: #1740, #4449, #5229, #5241.
2019-10-22py/objstr: Size-optimise failure path for mp_obj_str_get_buffer.Jim Mussared
These fields are never looked at if the function returns non-zero.
2019-10-21py/mkrules.mk: Add warning/error for invalid frozen config.Jim Mussared
2019-10-21tools/makemanifest.py: Eval relative paths w.r.t. current manifest file.Jim Mussared
When loading a manifest file, e.g. by include(), it will chdir first to the directory of that manifest. This means that all file operations within a manifest are relative to that manifest's location. As a consequence of this, additional environment variables are needed to find absolute paths, so the following are added: $(MPY_LIB_DIR), $(PORT_DIR), $(BOARD_DIR). And rename $(MPY) to $(MPY_DIR) to be consistent. Existing manifests are updated to match.
2019-10-18py/objtype: Add type.__bases__ attribute.Josh Lloyd
Enabled as part of MICROPY_CPYTHON_COMPAT.
2019-10-15tools: Add mechanism to provide a manifest of frozen files.Damien George
This introduces a new build variable FROZEN_MANIFEST which can be set to a manifest listing (written in Python) that describes the set of files to be frozen in to the firmware.
2019-10-15ports: Add new make target "submodules" which inits required modules.Damien George