summaryrefslogtreecommitdiffstatshomepage
path: root/py
Commit message (Collapse)AuthorAge
...
| * py/builtinimport: Support importing packages from compiled .mpy files.Damien George2016-12-13
| | | | | | | | | | This patch ensures that __init__.mpy files are imported if their containing directory is imported as a package.
| * py/binary: Do zero extension when storing a value larger than word size.Damien George2016-12-12
| |
| * py/objint: from_bytes, to_bytes: Require byteorder arg, require "little".Paul Sokolovsky2016-12-09
| | | | | | | | | | CPython requires byteorder arg, make uPy compatible. As we support only "little", error out on anything else.
| * py/asm: Fix x86 and ARM assemblers due to recent code refactoring.Damien George2016-12-09
| |
| * py/asm: Remove need for dummy_data when doing initial assembler passes.Damien George2016-12-09
| | | | | | | | | | | | | | | | For all but the last pass the assembler only needs to count how much space is needed for the machine code, it doesn't actually need to emit anything. The dummy_data just uses unnecessary RAM and without it the code is not any more complex (and code size does not increase for Thumb and Xtensa archs).
| * py/emitinline: Move common code for end of final pass to compiler.Damien George2016-12-09
| | | | | | | | | | | | This patch moves some common code from the individual inline assemblers to the compiler, the code that calls the emit-glue to assign the machine code to the functions scope.
| * py/emitinline: Move inline-asm align and data methods to compiler.Damien George2016-12-09
| | | | | | | | | | These are generic methods that don't depend on the architecture and so can be handled directly by the compiler.
| * py/emitinline: Embed entire asm struct instead of a pointer to it.Damien George2016-12-09
| | | | | | | | | | | | This reduces fragmentation, and memory use by 1 word. But more importantly it means the emit_inline_asm_t struct now "derives" from mp_asm_base.
| * py: Add inline Xtensa assembler.Damien George2016-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the MICROPY_EMIT_INLINE_XTENSA option, which, when enabled, allows the @micropython.asm_xtensa decorator to be used. The following opcodes are currently supported (ax is a register, a0-a15): ret_n() callx0(ax) j(label) jx(ax) beqz(ax, label) bnez(ax, label) mov(ax, ay) movi(ax, imm) # imm can be full 32-bit, uses l32r if needed and_(ax, ay, az) or_(ax, ay, az) xor(ax, ay, az) add(ax, ay, az) sub(ax, ay, az) mull(ax, ay, az) l8ui(ax, ay, imm) l16ui(ax, ay, imm) l32i(ax, ay, imm) s8i(ax, ay, imm) s16i(ax, ay, imm) s32i(ax, ay, imm) l16si(ax, ay, imm) addi(ax, ay, imm) ball(ax, ay, label) bany(ax, ay, label) bbc(ax, ay, label) bbs(ax, ay, label) beq(ax, ay, label) bge(ax, ay, label) bgeu(ax, ay, label) blt(ax, ay, label) bnall(ax, ay, label) bne(ax, ay, label) bnone(ax, ay, label) Upon entry to the assembly function the registers a0, a12, a13, a14 are pushed to the stack and the stack pointer (a1) decreased by 16. Upon exit, these registers and the stack pointer are restored, and ret.n is executed to return to the caller (caller address is in a0). Note that the ABI for the Xtensa emitters is non-windowing.
| * py: Allow inline-assembler emitter to be generic.Damien George2016-12-09
| | | | | | | | | | This patch refactors some code so that it is easier to integrate new inline assemblers for different architectures other than ARM Thumb.
| * py: Integrate Xtensa assembler into native emitter.Damien George2016-12-09
| | | | | | | | | | | | The config option MICROPY_EMIT_XTENSA can now be enabled to target the Xtensa architecture with @micropython.native and @micropython.viper decorators.
| * py/asmxtensa: Add low-level Xtensa assembler.Damien George2016-12-09
| |
| * py/asmbase: Add MP_PLAT_COMMIT_EXEC option for handling exec code.Damien George2016-12-09
| | | | | | | | | | | | | | If a port defines MP_PLAT_COMMIT_EXEC then this function is used to turn RAM data into executable code. For example a port may want to write the data to flash for execution. The function must return a pointer to the executable data.
| * py: Move arch-specific assembler macros from emitnative to asmXXX.h.Damien George2016-12-09
| |
| * py/emit.h: Remove long-obsolete declarations for cpython emitter.Damien George2016-12-09
| |
| * py/compile: Simplify configuration of native emitter.Damien George2016-12-07
| |
| * py/stream: Move ad-hoc ioctl constants to stream.h and rename them.Damien George2016-12-02
| | | | | | | | | | | | | | | | The constants MP_IOCTL_POLL_xxx, which were stmhal-specific, are moved from stmhal/pybioctl.h (now deleted) to py/stream.h. And they are renamed to MP_STREAM_POLL_xxx to be consistent with other such constants. All uses of these constants have been updated.
| * py/asmthumb: Fix build for F7 MCUs after recent code refactoring.Damien George2016-11-30
| |
| * py: Factor out common code from assemblers into asmbase.[ch].Damien George2016-11-28
| | | | | | | | All assemblers should "derive" from mp_asm_base_t.
| * py/compile: Remove comment about TODO for short circuiting for if-stmt.Damien George2016-11-26
| | | | | | | | | | Short circuiting is handled correctly by c_if_cond, and constants within short-circuit expressions are optimised by the parser.
| * py/objtype: Implement __call__ handling for an instance w/o heap alloc.Paul Sokolovsky2016-11-22
| | | | | | | | By refactoring and reusing code from objboundmeth.
| * stmhal/moduselect: Move to extmod/ for reuse by other ports.Paul Sokolovsky2016-11-21
| |
| * py/lexer: Make lexer use an mp_reader as its source.Damien George2016-11-16
| |
| * py/lexer: Rewrite mp_lexer_new_from_fd in terms of mp_reader.Damien George2016-11-16
| |
| * py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.Damien George2016-11-16
| | | | | | | | | | | | If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then lexer.c now provides an implementation of mp_lexer_new_from_file using the mp_reader_new_file function.
| * py/lexer: Rewrite mp_lexer_new_from_str_len in terms of mp_reader_mem.Damien George2016-11-16
| |
| * py: Factor out persistent-code reader into separate files.Damien George2016-11-16
| | | | | | | | | | | | | | Implementations of persistent-code reader are provided for POSIX systems and systems using FatFS. Macros to use these are MICROPY_READER_POSIX and MICROPY_READER_FATFS respectively. If an alternative implementation is needed then a port can define the function mp_reader_new_file.
| * py: Factor persistent code load/save funcs into persistentcode.[ch].Damien George2016-11-16
| |
| * py/parse: Add code to fold logical constants in or/and/not operations.Damien George2016-11-15
| | | | | | | | Adds about 200 bytes to the code size when constant folding is enabled.
| * py/parse: Make mp_parse_node_new_leaf an inline function.Damien George2016-11-15
| | | | | | | | | | | | It is split into 2 functions, one to make small ints and the other to make a non-small-int leaf node. This reduces code size by 32 bytes on bare-arm, 64 bytes on unix (x64-64) and 144 bytes on stmhal.
| * py/parse: Move function to check for const parse node to parse.[ch].Damien George2016-11-15
| |
| * py/*.mk: Replace uses of 'sed' with $(SED).Damien George2016-11-15
| |
| * py/mkrules.mk: Rework find command so it works on OSX.Dave Hylands2016-11-15
| | | | | | | | | | The Mac version of find doesn't support -printf, so this changes things to use sed to strip off the leading path element instead.
| * py/runtime: mp_resume: Fix exception handling for nanbox port.Paul Sokolovsky2016-11-15
| |
| * py/runtime: mp_resume: Handle exceptions in Python __next__().Paul Sokolovsky2016-11-15
| | | | | | | | | | | | | | | | This includes StopIteration and thus are important to make Python-coded iterables work with yield from/await. Exceptions in Python send() are still not handled and left for future consideration and optimization.
| * py/objexcept: Allow clearing traceback with 'exc.__traceback__ = None'.Paul Sokolovsky2016-11-14
| | | | | | | | | | | | | | | | | | | | | | | | | | We allow 'exc.__traceback__ = None' assignment as a low-level optimization of pre-allocating exception instance and raising it repeatedly - this avoids memory allocation during raise. However, uPy will keep adding traceback entries to such exception instance, so before throwing it, traceback should be cleared like above. 'exc.__traceback__ = None' syntax is CPython compatible. However, unlike it, reading that attribute or setting it to any other value is not supported (and not intended to be supported, again, the only reason for adding this feature is to allow zero-memalloc exception raising).
| * all: Remove readall() method, which is equivalent to read() w/o args.Paul Sokolovsky2016-11-14
| | | | | | | | | | | | Its addition was due to an early exploration on how to add CPython-like stream interface. It's clear that it's not needed and just takes up bytes in all ports.
| * py/emitnative: Fix native import emitter when in viper mode.Damien George2016-11-10
| |
* | Merge tag 'v1.8.6' into parse-bytecodeDamien George2017-08-14
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ESP8266 port uses SDK 2.0, has more heap, has support for 512k devices This release brings some code size reductions to the core as well as more tests and improved coverage which is now at 94.3%. The time.ticks_diff(a, b) function has changed: the order of the arguments has been swapped so that it behaves like "a - b", and it can now return a negative number if "a" came before "b" (modulo the period of the ticks functions). For the ESP8266 port the Espressif SDK has been updated to 2.0.0, the heap has been increased from 28k to 36k, and there is support for 512k devices via "make 512k". upip is included by default as frozen bytecode. The network module now allows access-point reconnection without WiFi credentials, and exposes configuration for the station DHCP hostname. The DS18B20 driver now handles negative temperatures, and NeoPixel and APA102 drivers handle 4 bytes-per-pixel LEDs. For the CC3200 port there is now support for loading of precompiled .mpy files and threading now works properly with interrupts. A detailed list of changes follows. py core: - py.mk: automatically add frozen.c to source list if FROZEN_DIR is defined - be more specific with MP_DECLARE_CONST_FUN_OBJ macros - specialise builtin funcs to use separate type for fixed arg count - {modbuiltins,obj}: use MP_PYTHON_PRINTER where possible - modbuiltins: add builtin "slice", pointing to existing slice type - add "delattr" builtin, conditional on MICROPY_CPYTHON_COMPAT - sequence: fix reverse slicing of lists - fix null pointer dereference in mpz.c, fix missing va_end in warning.c - remove asserts that are always true in emitbc.c - fix wrong assumption that m_renew will not move if shrinking - change config default so m_malloc0 uses memset if GC not enabled - add MICROPY_FLOAT_CONST macro for defining float constants - move frozen bytecode Makefile rules from ports to common mk files - strip leading dirs from frozen mpy files, so any path can be used extmod: - vfs_fat_file: check fatfs f_sync() and f_close() returns for errors - vfs_fat_file: make file.close() a no-op if file already closed - utime_mphal: ticks_diff(): switch arg order, return signed value - utime_mphal: add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions - utime_mphal: implement ticks_add(), add to all maintained ports - utime_mphal: allow ticks functions period be configurable by a port lib: - utils/pyhelp.c: use mp_printf() instead of printf() - utils/pyexec: add mp_hal_set_interrupt_char() prototype - libm: move Thumb-specific sqrtf function to separate file drivers: - add "from micropython import const" when const is used tools: - upgrade upip to 1.1.4: fix error on unix when installing to non-existing absolute path - pip-micropython: remove deprecated wrapper tool - check_code_size.sh: code size validation script for CI - replace upip tarball with just source file, to make its inclusion as frozen modules in multiple ports less magic tests: - extmod/vfs_fat: improve VFS test coverage - basics/builtin_slice: add test for "slice" builtin name - basics: add test for builtin "delattr" - extmod/vfs_fat_fsusermount: improve fsusermount test coverage - extmod/vfs_fat_oldproto: test old block device protocol - basics/gc1: garbage collector threshold() coverage - extmod/uhashlib_sha1: coverage for SHA1 algorithm - extmod/uhashlib_sha256: rename sha256.py test - btree1: fix out of memory error running on esp8266 - extmod/ticks_diff: test for new semantics of ticks_diff() - extmod/framebuf1: test framebuffer pixel clear, and text function minimal port: - Makefile: split rule for firmware.bin generation unix port: - Makefile: remove references to deprecated pip-micropython - modtime: use ticks_diff() implementation from extmod/utime_mphal.c - mphalport.h: add warning of mp_hal_delay_ms() implementation - modtime: switch ticks/sleep_ms/us() to utime_mphal - fix symbol references for x86 Mac - replace upip tarball with just source file windows port: - enable utime_mphal following unix, define mp_hal_ticks_* - fix utime_mphal compilation for msvc - implement mp_hal_ticks_cpu in terms of QueryPerformanceCounter qemu-arm port: - exclude ticks_diff test for qemu-arm port - exclude extmod/vfs_fat_fileio.py test - exclude new vfs_fat tests - enable software floating point support, and float tests stmhal port: - modutime: refactor to use extmod's version of ticks_cpu - refactor pin usage to use mp_hal_pin API - led: refactor LED to use mp_hal_pin_output() init function - Makefile: use standard rules for frozen module generation - modutime: consistently convert to MP_ROM_QSTR/MP_ROM_PTR - enable SD power save (disable CLK on idle) cc3200 port: - use mp_raise_XXX helper functions to reduce code size - mods/pybspi: allow "write" arg of read/readinto to be positional - enable loading of precompiled .mpy files - fix thread mutex's so threading works with interrupts teensy port: - update to provide new mp_hal_pin_XXX functions following stmhal esp8266 port: - Makefile: use latest esptool.py flash size auto-detection - esp_init_data: auto-initialize system params with vendor SDK 2.0.0 - esp8266.ld: move help.o to iROM - esp8266.ld: move modmachine.o to iROM - esp8266.ld: move main.o to iROM - add MP_FASTCODE modifier to put a function to iRAM - main: mark nlr_jump_fail() as MP_FASTCODE - modules/webrepl: enforce only one concurrent WebREPL connection - etshal.h: add few more ESP8266 vendor lib prototypes - modesp: add flash_user_start() function - add support for building firmware version for 512K modules - scripts: make neopixel/apa102 handle 4bpp LEDs with common code - modutime: consistently convert to MP_ROM_QSTR/MP_ROM_PTR - modnetwork: config(): fix copy-paste error in setting "mac" - scripts/port_diag: add descriptions for esf_buf types - modnetwork.c: allows AP reconnection without WiFi credentials - main: bump heap size to 36K - etshal.h: add prototypes for SPIRead/SPIWrite/SPIEraseSector - etshal.h: adjust size of MD5_CTX structure - modules: fix negative temperature in ds18x20 driver - rename "machine" module implementation to use contemporary naming - rework webrepl_setup to run over wired REPL - espneopixel.c: solve glitching LED issues with cpu at 80MHz - include upip as a standard frozen bytecode module - update docs for esptool 1.2.1/SDK 2.0 (--flash_size=detect) - modnetwork.c: expose configuration for station DHCP hostname zephyr port: - implement utime module - use board/SoC values for startup banner based on Zephyr config - initial implementation of machine.Pin - zephyr_getchar: update for recent Zephyr refactor of console hooks - support time -> utime module "weaklink" - README: update for the current featureset, add more info - mpconfigport.h: move less important params to the bottom - Makefile: allow to adjust heap size from make command line - Makefile: update comments to the current state of affairs - Makefile: allow to override Zephyr config from make command line - Makefile: add minimal port - Makefile: add -fomit-frame-pointer to reduce code size - mphalport.h: update for new "unified" kernal API (sleep functions) docs: - machine.SPI: bring up to date with Hardware API, make vendor-neutral - machine.SPI: improve descriptions of xfer methods - library/builtins: add docs for delattr and slice - library/network: reword intro paragraph - library/network: typo fixes, consistent acronym capitalization - library/index: update TOCs so builtins sorted before modules - utime: document ticks_cpu() in more detail - utime: describe new semantics of ticks_diff() (signed ring arithmetics) - utime: add docs for ticks_add(), improvements for other ticks_*() - esp8266: update for new WebREPL setup procedure - */quickref.rst: use new semantics of ticks_diff() - library/machine.Pin: update Pin docs to align with new HW API travis: - integrate tools/check_code_size.sh - minimal: Use CROSS=1, for binary size check examples: - http_server_simplistic: add "not suitable for real use" note - hwapi: example showing best practices for HW API usage in apps - hwapi: add hwconfig for DragonBoard 410c
| * py: Strip leading dirs from frozen mpy files, so any path can be used.Damien George2016-11-08
| | | | | | | | | | | | | | | | With this patch one can now do "make FROZEN_MPY_DIR=../../frozen" to specify a directory containing scripts to be frozen (as well as absolute paths). The compiled .mpy files are now stored in $(BUILD)/frozen_mpy/.
| * py: Move frozen bytecode Makefile rules from ports to common mk files.Damien George2016-11-08
| | | | | | | | | | | | Now, to use frozen bytecode all a port needs to do is define FROZEN_MPY_DIR to the directory containing the .py files to freeze, and define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
| * py: Add MICROPY_FLOAT_CONST macro for defining float constants.Damien George2016-11-03
| | | | | | | | | | | | All float constants in the core should use this macro to prevent unnecessary creation of double-precision floats, which makes code less efficient.
| * py: Change config default so m_malloc0 uses memset if GC not enabled.Colin Hogben2016-11-03
| | | | | | | | | | With MICROPY_ENABLE_GC set to false the alternate memory manager may not clear all memory that is allocated, so it must be cleared in m_malloc0.
| * py: Fix wrong assumption that m_renew will not move if shrinkingColin Hogben2016-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In both parse.c and qstr.c, an internal chunking allocator tidies up by calling m_renew to shrink an allocated chunk to the size used, and assumes that the chunk will not move. However, when MICROPY_ENABLE_GC is false, m_renew calls the system realloc, which does not guarantee this behaviour. Environments where realloc may return a different pointer include: (1) mbed-os with MBED_HEAP_STATS_ENABLED (which adds a wrapper around malloc & friends; this is where I was hit by the bug); (2) valgrind on linux (how I diagnosed it). The fix is to call m_renew_maybe with allow_move=false.
| * unix: fix symbol references for x86 MacJan Pochyla2016-11-02
| |
| * py: remove asserts that are always true in emitbc.cPavol Rusnak2016-10-31
| |
| * py: fix null pointer dereference in mpz.c, fix missing va_end in warning.cPavol Rusnak2016-10-31
| |
| * py/sequence: Fix reverse slicing of lists.Fabio Utzig2016-10-30
| |
| * extmod/utime_mphal: Allow ticks functions period be configurable by a port.Paul Sokolovsky2016-10-30
| | | | | | | | Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
| * py/stream: Typo fix in comment.Paul Sokolovsky2016-10-27
| |