Commit Graph

3325 Commits

Author SHA1 Message Date
Damien George
d9dc6fff21 py: Allocate memory for assembled code at start of PASS_EMIT.
Previously was allocating at end of PASS_COMPUTE, and this pass was
being run twice, so memory was being allocated twice.
2015-01-14 00:38:33 +00:00
Damien George
bc47c287df travis, minimal: Install gcc-multilib for -m32; use /bin/echo for test. 2015-01-14 00:26:39 +00:00
Damien George
1e1779eacf py: Reluctantly add an extra pass to bytecode compiler.
Bytecode also needs a pass to compute the stack size.  This is because
the state size of the bytecode function is encoded as a variable uint,
so we must know the value of this uint before we encode it (otherwise
the size of the generated code changes from one pass to the next).

Having an entire pass for this seems wasteful (in time).  Alternative is
to allocate fixed space for the state size (would need 3-4 bytes to be
general, when 1 byte is usually sufficient) which uses a bit of extra
RAM per bytecode function, and makes the code less elegant in places
where this uint is encoded/decoded.

So, for now, opt for an extra pass.
2015-01-14 00:20:28 +00:00
Damien George
2127e9a844 py, unix: Trace root pointers with native emitter under unix port.
Native code has GC-heap pointers in it so it must be scanned.  But on
unix port memory for native functions is mmap'd, and so it must have
explicit code to scan it for root pointers.
2015-01-14 00:11:09 +00:00
Damien George
c935d69f74 py: Make compiler not crash when default except is not last. 2015-01-13 23:33:16 +00:00
Damien George
d6ed6702f7 py/showbc.c: Handle new LOAD_CONST_OBJ opcode, and opcodes with cache. 2015-01-13 23:08:47 +00:00
Damien George
4c81ba8015 py: Never intern data of large string/bytes object; add relevant tests.
Previously to this patch all constant string/bytes objects were
interned by the compiler, and this lead to crashes when the qstr was too
long (noticeable now that qstr length storage defaults to 1 byte).

With this patch, long string/bytes objects are never interned, and are
referenced directly as constant objects within generated code using
load_const_obj.
2015-01-13 16:21:23 +00:00
Damien George
dab1385177 py: Add load_const_obj to emitter, add LOAD_CONST_OBJ to bytecode.
This allows to directly load a Python object to the Python stack.  See
issue #722 for background.
2015-01-13 15:55:54 +00:00
Damien George
d710cef661 minimal: Add simple test; build and run minimal test on Travis CI. 2015-01-13 12:39:29 +00:00
Damien George
a45b042e59 minimal/Makefile: Remove unnecessary -I of py/ dir. 2015-01-13 12:23:13 +00:00
Paul Sokolovsky
f41df1e611 minimal: Add "run" make target to run emulated build with suitable tty config. 2015-01-13 04:07:03 +02:00
Paul Sokolovsky
5ebabcda41 minimal: Convert "bare-arm" port to "minimal" port.
This enable libc functions, GC, and line-editing function. Also, UART
emulation for POSIX systems is added. Emulation build is set as default.
2015-01-13 04:02:56 +02:00
Paul Sokolovsky
d511a20a6b minimal: New port, intended to represent minimal working code.
Unlike bare-arm, which is mostly intended to show raw interpreter size,
without library and support code dependencies. This port is intended to
be a better base to start new ports, and also will include emulation
build to allow debug some aspects of embedded targets on POSIX systems.

This initial commit is verbatim copy of bare-arm code.
2015-01-13 03:17:47 +02:00
Damien George
bbf5cd01e3 py: Allow to compile with -Wstrict-prototypes. 2015-01-12 22:45:35 +00:00
Damien George
30d8a82220 py: Allow to compile with -Wredundant-decls. 2015-01-12 22:41:55 +00:00
Damien George
abc1959e2c py, unix, lib: Allow to compile with -Wold-style-definition. 2015-01-12 22:34:38 +00:00
Damien George
cd34207409 py: Can compile with -Wmissing-declarations and -Wmissing-prototypes. 2015-01-12 22:30:49 +00:00
Damien George
3dd1c0a88a py: Make a function static and comment out those not used. 2015-01-12 22:22:46 +00:00
Damien George
0178aa9a11 py, unix: Allow to compile with -Wdouble-promotion.
Ref issue #699.
2015-01-12 21:56:35 +00:00
Damien George
b58da9420c qemu-arm: Disable basics/memoryerror.py test. 2015-01-12 16:32:14 +00:00
Damien George
131185a2b8 stmhal: Add MICROPY_HW_USB_OTG_ID_PIN config, set for relevant boards.
This config option is for the USB OTG pin, pin A10.  This is used on
some boards but not others.  Eg PYBv3 uses PA10 for LED(2), so it
shouldn't be used for OTG ID (actually PA10 is multiplexed on this
board, but defaults to LED(2)).

Partially addresses issue #1059.
2015-01-12 16:13:29 +00:00
Damien George
7630d9ca0e travis: grep for failure in qemu-arm output if tests fail. 2015-01-12 15:50:08 +00:00
Damien George
5b76e3b75e windows: Enable MICROPY_STACK_CHECK. 2015-01-12 15:34:53 +00:00
Damien George
99dde4ed1f qemu-arm: Enable GC and native code-gen; enable more tests. 2015-01-12 12:07:42 +00:00
Paul Sokolovsky
3f9f9cac75 lib/mp-readline: Refactor to support coroutine/event-driven usage.
readline_process_char() can be fed character by character, for example,
received from external event loop. This will allow to integrate MicroPython
into cooperative multitasking systems.
2015-01-12 04:36:57 +02:00
Paul Sokolovsky
708574b082 teensy: Update for readline module moved to lib/. 2015-01-12 04:27:36 +02:00
Paul Sokolovsky
06e9cb688b esp8266: Update for readline module moved to lib/. 2015-01-12 04:27:36 +02:00
Paul Sokolovsky
a7bcb218fe stmhal: Move readline code to lib/mp-readline/. 2015-01-12 04:15:35 +02:00
Damien George
99ab64ffd4 py/makeqstrdata.py: Make it work again with both Python2 and Python3. 2015-01-11 22:40:38 +00:00
Damien George
95836f8439 py: Add MICROPY_QSTR_BYTES_IN_LEN config option, defaulting to 1.
This new config option sets how many fixed-number-of-bytes to use to
store the length of each qstr.  Previously this was hard coded to 2,
but, as per issue #1056, this is considered overkill since no-one
needs identifiers longer than 255 bytes.

With this patch the number of bytes for the length is configurable, and
defaults to 1 byte.  The configuration option filters through to the
makeqstrdata.py script.

Code size savings going from 2 to 1 byte:
- unix x64 down by 592 bytes
- stmhal down by 1148 bytes
- bare-arm down by 284 bytes

Also has RAM savings, and will be slightly more efficient in execution.
2015-01-11 22:27:30 +00:00
Damien George
6942f80a8f py: Add qstr cfg capability; generate QSTR_NULL and QSTR_ from script. 2015-01-11 22:06:53 +00:00
Damien George
e233a55a29 py: Remove unnecessary BINARY_OP_EQUAL code that just checks pointers.
Previous patch c38dc3ccc7 allowed any
object to be compared with any other, using pointer comparison for a
fallback.  As such, existing code which checked for this case is no
longer needed.
2015-01-11 21:07:15 +00:00
Damien George
c38dc3ccc7 py: Implement fallback for equality check for all types.
Return "not equal" for objects that don't implement equality check.
This is as per Python specs.
2015-01-11 15:13:18 +00:00
Damien George
ec21405821 py: Add (commented out) code to gc_dump_alloc_table for qstr info. 2015-01-11 14:37:06 +00:00
Damien George
56e1f99ca1 py/makeqstrdata.py: Add more allowed qstr characters; escape quot. 2015-01-11 14:16:24 +00:00
Damien George
01418e9690 py: Fix hard-coded hash for empty qstr (was 0x0000 now 0x1505). 2015-01-11 14:15:45 +00:00
Damien George
ddd1e18801 py: Add config option MICROPY_COMP_MODULE_CONST for module consts.
Compiler optimises lookup of module.CONST when enabled (an existing
feature).  Disabled by default; enabled for unix, windows, stmhal.
Costs about 100 bytes ROM on stmhal.
2015-01-10 14:07:24 +00:00
Paul Sokolovsky
7bfe4b21b9 tests: Make ffi_callback.py be able to run on uclibc and macosx.
Similar to ffi_float.py.
2015-01-10 00:35:48 +02:00
Damien George
58056b0f43 py: Fix handling of "0" mpz in some functions. 2015-01-09 20:58:58 +00:00
Damien George
f5465b9eb0 stmhal: Reclaim 72 bytes of stack by factoring out flash init code. 2015-01-09 20:38:23 +00:00
Damien George
5d48f234d2 py: Make mem_info print correct remaining stack bytes. 2015-01-09 20:37:49 +00:00
Damien George
a9a0862078 windows: Enable MICROPY_PY_MICROPYTHON_MEM_INFO. 2015-01-09 20:30:26 +00:00
Damien George
89deec0bab py: Add MICROPY_PY_MICROPYTHON_MEM_INFO to enable mem-info funcs.
This allows to enable mem-info functions in micropython module, even if
MICROPY_MEM_STATS is not enabled.  In this case, you get mem_info and
qstr_info but not mem_{total,current,peak}.
2015-01-09 20:12:54 +00:00
Damien George
4a5895c4eb py: Disable stack checking by default; enable on most ports. 2015-01-09 00:10:55 +00:00
Damien George
85e8e2ed5b qemu-arm: Add 'test' target to Makefile to run and verify test suite.
Replaces RUN_TEST=1 definition; now "make test" in qemu-arm directory
will run tests/basics/ and check that they all succeed.

This patch also enables the test on Travis CI.
2015-01-09 00:03:21 +00:00
Damien George
3990dcfcd7 docs: Add note about maximum frequency of busses. 2015-01-08 22:54:26 +00:00
Damien George
14fab60baf qemu-arm: Get "make RUN_TESTS=1" compiling after changes to core. 2015-01-08 22:12:44 +00:00
Damien George
d2d0648ad0 qemu-arm: Set stack limit in main. 2015-01-08 21:40:35 +00:00
Damien George
7a53ac8ec2 stmhal: Allow to build without float support if wanted. 2015-01-08 17:55:55 +00:00
Damien George
c33ecb83ba tests: Add test for when instance member overrides class member. 2015-01-08 17:48:44 +00:00