Commit Graph

146 Commits

Author SHA1 Message Date
Damien George dd11af209d py: Add LOAD_SUPER_METHOD bytecode to allow heap-free super meth calls.
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
2017-04-22 23:39:20 +10:00
Paul Sokolovsky 3e1310d6e2 tools/pyboard: Provide more details when expected reply not received.
When trying to execute a command via raw REPL and expected "OK" reply
not received, show what was received instead.
2017-04-07 01:04:47 +03:00
Paul Sokolovsky 2cbe997834 tools/pyboard: ProcessPtyToTerminal: Add workaround for PySerial bug.
When working with a "virtual" port, like PTY. The issue described in
http://stackoverflow.com/questions/34831131/pyserial-does-not-play-well-with-virtual-port
2017-04-05 12:30:39 +03:00
Paul Sokolovsky 546ef301a1 tools/pyboard: execpty: Use shell=False to workaround some curdir issues.
Without this, Zephyr's port "make test" doesn't work.
2017-04-05 00:46:12 +03:00
Paul Sokolovsky 647e72ca63 tools/pyboard: Add "exec" and "execpty" pseudo-devices support.
This allows to execute a command and communicate with its stdin/stdout
via pipes ("exec") or with command-created pseudo-terminal ("execpty"),
to emulate serial access. Immediate usecase is controlling a QEMU process
which emulates board's serial via normal console, but it could be used
e.g. with helper binaries to access real board over other hadware
protocols, etc.

An example of device specification for these cases is:

	--device exec:../zephyr/qemu.sh
	--device execpty:../zephyr/qemu2.sh

Where qemu.sh contains long-long qemu startup line, or calls another
command. There's a special support in this patch for running the command
in a new terminal session, to support shell wrappers like that (without
new terminal session, only wrapper script would be terminated, but its
child processes would continue to run).
2017-04-04 17:46:02 +03:00
Paul Sokolovsky 9b3f423c14 tools/pyboard: Tighten up Pyboard object closure on errors.
Some "device" implementations may be sensitive to this.
2017-04-02 20:48:53 +03:00
Paul Sokolovsky 320099aab9 tools/tinytest-codegen: Update for recent test renaming ("intbig" suffix). 2017-03-06 22:40:04 +01:00
Damien George e4be56a0ea qemu-arm: Enable machine module and associated tests. 2017-03-02 16:39:58 +11:00
Krzysztof Blazewicz 23ccb3e12e tools/gen-cpydiff.py: configurable CPython and micropython executables 2017-02-27 15:39:55 +11:00
Damien George 1034d9acc8 tools/gen-cpydiff.py: Set the Python import path to find test modules. 2017-02-22 15:50:58 +11:00
Rami Ali b7fa63c7ce tools: Add gen-cpydiff.py to generate docs differences.
This patch introduces the a small framework to track differences between
uPy and CPython.  The framework consists of:

- A set of "tests" which test for an individual feature that differs between
  uPy and CPy.  Each test is like a normal uPy test in the test suite, but
  has a special comment at the start with some meta-data: a category (eg
  syntax, core language), a human-readable description of the difference, a
  cause, and a workaround.  Following the meta-data there is a short code
  snippet which demonstrates the difference.  See tests/cpydiff directory
  for the initial set of tests.

- A program (this patch) which runs all the tests (on uPy and CPy) and
  generates nicely-formated .rst documenting the differences.

- Integration into the docs build so that everything is automatic, and the
  differences appear in a way that is easy for users to read/reference (see
  latter commits).

The idea with using this new framework is:

- When a new difference is found it's easy to write a short test for it,
  along with a description, and add it to the existing ones.  It's also easy
  for contributors to submit tests for differences they find.

- When something is no longer different the tool will give an error and
  difference can be removed (or promoted to a proper feature test).
2017-02-20 17:14:34 +11:00
Damien George 6a11048af1 py/persistentcode: Bump .mpy version due to change in bytecode. 2017-02-17 00:19:34 +11:00
Paul Sokolovsky aac2db9aaf tools/upip: Update to 1.1.5. Better and more user-friendly error handling. 2017-02-10 20:18:05 +03:00
Damien George f1db8a3097 qemu-arm: Don't compile tests in "REPL" mode.
Previous to this patch the qemu-arm tests were compiled with is_relp=true
meaning that the __repl_print__ function was called for all lines of code
in the outer scope.  This is not the right behaviour for scripts that are
executed as though they were a file (eg tests).

With this fix the micropython/heapalloc_str.py test now works so it is
removed from the test blacklist.
2017-01-27 12:35:46 +11:00
Paul Sokolovsky 4614403f63 tools/tinytest-codegen.py: Blacklist heapalloc_str.py test for qemu-arm. 2017-01-27 01:19:36 +03:00
Damien George 98458a46ec tools/mpy-tool.py: Add support for OPT_CACHE_MAP_LOOKUP_IN_BYTECODE.
With caching of map lookups in the bytecode, frozen bytecode can still
work but must be stored in RAM, not ROM.  This patch allows mpy-tool.py to
generate code that works with this optimisation, but it's not recommended
to use it on embedded targets (because of lack of RAM).
2017-01-05 15:52:52 +11:00
Damien George 29b5879613 tools/pyboard.py: Refactor so target is not reset between scripts/cmd.
Previous to this patch pyboard.py would open a new serial connection to
the target for each script that was run, and for any command that was run.
Apart from being inefficient, this meant that the board was soft-reset
between scripts/commands, which precludes scripts from accessing variables
set in a previous one.

This patch changes the behaviour of pyboard.py so that the connection to
the target is created only once, and it's not reset between scripts or any
command that is sent with the -c option.
2016-12-15 11:29:33 +11:00
Paul Sokolovsky 30cfdc29ed tools/tinytest-codegen: Blacklist recently added uheapq_timeq test (qemu-arm). 2016-11-12 03:24:36 +03:00
Paul Sokolovsky 61d74fdef8 tools, unix: Replace upip tarball with just source files.
To make its inclusion as frozen modules in multiple ports less magic.
Ports are just expected to symlink 2 files into their scripts/modules
subdirs.

Unix port updated to use this and in general follow frozen modules setup
tested and tried on baremetal ports, where there's "scripts" predefined
dir (overridable with FROZEN_DIR make var), and a user just drops Python
files there.
2016-11-07 18:39:41 +03:00
Damien George ca973bd308 qemu-arm: Enable software floating point support, and float tests.
This helps to test floating point code on Cortex-M hardware.

As part of this patch the link-time-optimisation was disabled because it
wasn't compatible with software FP support.  In particular, the linker
could not find the __aeabi_f2d, __aeabi_d2f etc functions even though they
were provided by lib/libm/math.c.
2016-11-03 12:28:31 +11:00
Paul Sokolovsky 796b720dbc tools/tinytest-codegen: Exclude ticks_diff test for qemu-arm port. 2016-10-30 22:24:07 +03:00
Alex March 52aa532050 qemu-arm: Exclude new vfs_fat tests. 2016-10-27 12:25:28 +11:00
Paul Sokolovsky f7aa692093 tools/check_code_size.sh: Code size validation script for CI. 2016-10-25 11:43:55 +03:00
Paul Sokolovsky b78144c64d tools/pip-micropython: Remove deprecated wrapper tool.
Deprecated for long time, pip-micropython now can't install packages
optimized for low-heap ports (like whole of micropython-lib).
2016-10-24 16:52:15 +03:00
Alex March 06e7032906 qemu-arm: Exclude extmod/vfs_fat_fileio.py test. 2016-10-24 12:49:19 +11:00
Paul Sokolovsky 197a5724d8 tools: Upgrade upip to 1.1.4.
Fix error on unix when installing to non-existing absolute path.
2016-10-22 21:14:58 +03:00
Damien George b0a15aa735 qemu-arm: Enable lots of extmods and enable tests for them.
The qemu-arm port is used for testing of ARM Thumb architecture on a
desktop so should have many features enabled.
2016-10-14 00:08:19 +11:00
Paul Sokolovsky cdbeee0c50 tools: Upgrade upip to 1.1.3.
Initial support for running on a baremetal, low-heap systems (like esp8266),
using Python module interface.
2016-10-12 18:55:31 +03:00
Paul Sokolovsky cecf6bee97 tools: Upgrade upip to 1.0.
Fully self-hosted release (without fallbacks), and uses stream gzip
decompression (step towards support for limited-heap baremetal systems).
2016-10-05 00:34:09 +03:00
Paul Sokolovsky 4c63986101 tools: Update upip to 0.8. Fixes IPv6 support. 2016-09-23 15:35:06 +03:00
Damien George 7df9291b6c py: Update opcode format table because 3 opcodes were removed, 1 added.
LIST_APPEND, MAP_ADD and SET_ADD have been removed, and STORE_COMP has
been added in adaf0d865c.
2016-09-23 12:48:57 +10:00
Damien George c51c883cc8 tools/mpy-tool.py: Support freezing of complex numbers. 2016-09-03 00:19:02 +10:00
Damien George b6bdf18deb tools/mpy-tool.py: Compute the hash value for str/bytes objects.
This makes it more efficient at runtime to hash str/bytes objects.
2016-09-02 15:10:45 +10:00
Damien George b4790afdaf tools/mpy-tool.py: Store qstr config values in global config object.
Makes it easier to access them without passing around another dict of the
config values.
2016-09-02 15:09:21 +10:00
Damien George 72ae3c72c7 tools/mpy-tool.py: Support freezing float literals with obj-repr C.
The tool now generates code for freezing floats in obj-repr A, B or C,
with the specific representation detected at compile time using macros.
2016-08-10 13:26:11 +10:00
Paul Sokolovsky cbe544a76d tools: Upgrade upip to 0.7.
SSL certificate warning, switch to uerrno, and better usage message.
2016-05-28 02:57:53 +03:00
Damien George 25a42fb6ef tools/mpy-tool.py: Don't strip directories from the frozen source name.
Directories are now supported by the frozen import system (to implement
frozen packages) so we should keep them.
2016-05-23 13:29:03 +01:00
Damien George 9b4c013823 tools/mpy-tool.py: Include .py extension in frozen filename.
So that it can be correctly stat'd when looking for frozen files.
2016-05-23 12:46:02 +01:00
Paul Sokolovsky daa4793578 tools/make-frozen: Update for latest changes in frozen modules support.
Frozen modules are now stored with extensions and with '/' as path
separator. In other words, frozen modules paths stored as they are
in normal filesystem.
2016-05-21 21:39:27 +03:00
Damien George 99b4719357 tools/mpy-tool.py: Add checks for critical configuration vars.
When an mpy file is frozen it must know the values of certain
configuration variables.  This patch provides an explicit check in the
generated C file that the configuration variables are what they are
supposed to be.
2016-05-16 23:13:30 +01:00
Paul Sokolovsky 7b1bf0c308 tools/make-frozen.py: Quick fix to support package-modules.
It allows to "import foo.bar", but not "from foo import bar".
2016-05-14 16:30:02 +03:00
Damien George 5985e41afc tools/make-frozen.py: Properly escape hex chars when making C strings. 2016-05-13 13:12:01 +01:00
Damien George 02fd83bcbc tools/mpy-tool: Make sure that all C-level variables are unique.
Fixes issue #2023.
2016-05-03 12:24:39 +01:00
Damien George c3beb16db3 tools/mpy-tool.py: Add support for Python 2.7. 2016-04-15 11:56:10 +01:00
Damien George 0a2e9650f5 py: Add ability to have frozen persistent bytecode from .mpy files.
The config variable MICROPY_MODULE_FROZEN is now made of two separate
parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY.  This
allows to have none, either or both of frozen strings and frozen mpy
files (aka frozen bytecode).
2016-04-13 16:07:47 +01:00
Damien George 0699c6bf9e tools: Add mpy-tool.py, to work with .mpy files.
Currently it can freeze .mpy files.
2016-04-13 16:05:43 +01:00
Damien George be989be861 qemu-arm: Enable builtin override feature, and enable more tests.
Hopefully these tests run reliably on Travis.
2016-03-15 13:45:32 +00:00
Paul Sokolovsky 17f324b836 py/frozenmod: Store frozen module names together, to quickly scan them. 2016-01-03 18:08:45 +02:00
Paul Sokolovsky 0992588811 py/frozenmod: Make frozen module content be 0-terminated.
To allow simple zero-terminated lexers.
2016-01-01 07:51:07 +02:00
Damien George 4bd95f8b44 tools: Add C middle-processor to make builtin tables proper hash tables. 2015-12-31 00:24:33 +00:00