Commit Graph

443 Commits (64e8b622917156bfe3a7ca3698072188be1ab862)

Author SHA1 Message Date
stijn 28fa84b445 py: Add optional support for descriptors' __get__ and __set__ methods.
Disabled by default.  Enabled on unix and windows ports.
2015-03-26 23:55:14 +00:00
Damien George 4a8556ca58 unix: Remove -Wdouble-promotion from main build, and 2 from coverage.
The 2 removed from coverage build are: -Wredundant-decls and
-Wstrict-prototypes.
2015-03-22 22:41:45 +00:00
Paul Sokolovsky 6bf423df2c unix: Bump stack limit and adjust for 64-bitness.
Without that, "import http.client" failed due to max recursion.
2015-03-21 02:16:45 +02:00
stijn 3cc17c69ff py: Allow retrieving a function's __name__.
Disabled by default.  Enabled on unix and stmhal ports.
2015-03-20 23:13:32 +00:00
Paul Sokolovsky 8d51c9d376 unix: When using separate obj output dirs, make -B is no longer relevant. 2015-03-21 00:42:29 +02:00
Damien George 2e22c2b477 unix: Move compiler warnings from production build to coverage build. 2015-03-20 22:33:13 +00:00
Paul Sokolovsky 0ef01d0a75 py: Implement core of OrderedDict type.
Given that there's already support for "fixed table" maps, which are
essentially ordered maps, the implementation of OrderedDict just extends
"fixed table" maps by adding an "is ordered" flag and add/remove
operations, and reuses 95% of objdict code, just making methods tolerant
to both dict and OrderedDict.

Some things are missing so far, like CPython-compatible repr and comparison.

OrderedDict is Disabled by default; enabled on unix and stmhal ports.
2015-03-20 17:26:10 +00:00
Damien George 92496abe0f unix: Enable extra compiler warnings.
To address issue #699.
2015-03-19 00:25:33 +00:00
Damien George 42e0c59308 py: Add MICROPY_COMP_{DOUBLE,TRIPLE}_TUPLE_ASSIGN config options.
These allow to fine-tune the compiler to select whether it optimises
tuple assignments of the form a, b = c, d and a, b, c = d, e, f.
Sensible defaults are provided.
2015-03-14 13:11:35 +00:00
Paul Sokolovsky 1129de5ac0 unix: Support readline history saving to file, improves interactive usage. 2015-03-13 21:46:19 +00:00
Damien George d891452a73 py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API. 2015-03-03 21:23:13 +00:00
Damien George 81e661f28b travis: Add automated coverage testing using coveralls. 2015-03-01 14:50:09 +00:00
Paul Sokolovsky cefcbb22b2 objarray: Implement array slice assignment.
This is rarely used feature which takes enough code to implement, so is
controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off.
But otherwise it may be useful, as allows to update arbitrary-sized data
buffers in-place.

Slice is yet to implement, and actually, slice assignment implemented in
such a way that RHS of assignment should be array of the exact same item
typecode as LHS. CPython has it more relaxed, where RHS can be any sequence
of compatible types (e.g. it's possible to assign list of int's to a
bytearray slice).

Overall, when all "slice write" features are implemented, it may cost ~1KB
of code.
2015-02-27 22:17:15 +02:00
Paul Sokolovsky bbaf68f2cb modffi: Implement 'O' type handling for func arguments. 2015-02-25 23:38:22 +02:00
Damien George 5cbeacebdb py: Make math special functions configurable and disabled by default.
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.

They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Paul Sokolovsky 99bcaa2fb6 modffi: Add toplevel func() function to create a function by pointer. 2015-02-11 07:21:03 +08:00
Damien George 0bfc7638ba py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.

This patch adds that feature in all places.  This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
Paul Sokolovsky 8775caf9f1 modffi: Add .addr() method to just get symbol address. 2015-02-06 00:19:43 +02:00
Paul Sokolovsky 98c4bc3fac py: Add MICROPY_PY_ALL_SPECIAL_METHODS and __iadd__ special method under it. 2015-01-31 00:35:56 +02:00
Damien George 598af3a7d6 unix: Add "coverage" target to do coverage testing using gcov. 2015-01-29 14:54:38 +00:00
Paul Sokolovsky 31c1f1300e modffi: 's' (string) return type: handle NULL properly (return None). 2015-01-25 01:36:14 +02:00
Paul Sokolovsky 2e526ff1a1 modffi: Support return values of mp_obj_t type. 2015-01-22 01:09:17 +02:00
Paul Sokolovsky 0ab3fc3805 modffi: Support open own executable using open(None). 2015-01-21 00:38:06 +02:00
Damien George ff8dd3f486 py, unix: Allow to compile with -Wunused-parameter.
See issue #699.
2015-01-20 12:47:20 +00:00
Damien George 50912e7f5d py, unix, stmhal: Allow to compile with -Wshadow.
See issue #699.
2015-01-20 11:55:10 +00:00
Damien George 51ef28a9d6 unix: Update .gitignore for "fast" and "minimal" builds. 2015-01-16 18:05:31 +00:00
Damien George 3926c72dd2 unix: Add target to build "minimal" uPy interpreter. 2015-01-16 18:03:01 +00:00
Damien George 963a5a3e82 py, unix: Allow to compile with -Wsign-compare.
See issue #699.
2015-01-16 17:47:07 +00:00
Damien George d95b519aa1 unix, windows: Don't call mp_unix_mark_exec on windows. 2015-01-14 11:43:51 +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 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 0178aa9a11 py, unix: Allow to compile with -Wdouble-promotion.
Ref issue #699.
2015-01-12 21:56:35 +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
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 115187f7ce unix: Allow to compile with float support disabled. 2015-01-08 15:41:11 +00:00
stijn afd6c8e1d2 Remove obsolete bss-related code/build features
GC for unix/windows builds doesn't make use of the bss section anymore,
so we do not need the (sometimes complicated) build features and code related to it
2015-01-08 15:29:44 +01:00
Damien George 7ee91cf861 py: Add option to cache map lookup results in bytecode.
This is a simple optimisation inspired by JITing technology: we cache in
the bytecode (using 1 byte) the offset of the last successful lookup in
a map. This allows us next time round to check in that location in the
hash table (mp_map_t) for the desired entry, and if it's there use that
entry straight away.  Otherwise fallback to a normal map lookup.

Works for LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR and STORE_ATTR opcodes.

On a few tests it gives >90% cache hit and greatly improves speed of
code.

Disabled by default.  Enabled for unix and stmhal ports.
2015-01-07 21:07:23 +00:00
Damien George b4b10fd350 py: Put all global state together in state structures.
This patch consolidates all global variables in py/ core into one place,
in a global structure.  Root pointers are all located together to make
GC tracing easier and more efficient.
2015-01-07 20:33:00 +00:00
Paul Sokolovsky ae58795c44 unix: Enable -fno-crossjumping for fast build.
Confirmed that it improves perfomance of simple "for i in range(N): pass"
loop by 15% on Core2.
2015-01-03 21:15:02 +02:00
Damien George 6d7e47087f unix: Prefix includes with py/; remove need for -I../py. 2015-01-01 20:40:19 +00:00
Damien George 51dfcb4bb7 py: Move to guarded includes, everywhere in py/ core.
Addresses issue #1022.
2015-01-01 20:32:09 +00:00
Paul Sokolovsky 8a8c1fc82f py: Add basic framework for issuing compile/runtime warnings. 2015-01-01 22:09:18 +02:00
Damien George 9ddbe291c4 py: Add include guards to mpconfig,misc,qstr,obj,runtime,parsehelper. 2014-12-29 01:02:19 +00:00
Damien George e37dcaafb4 py: Allow to properly disable builtin "set" object.
This patch makes MICROPY_PY_BUILTINS_SET compile-time option fully
disable the builtin set object (when set to 0).  This includes removing
set constructor/comprehension from the grammar, the compiler and the
emitters.  Now, enabling set costs 8168 bytes on unix x64, and 3576
bytes on stmhal.
2014-12-27 17:33:30 +00:00
Paul Sokolovsky 3b74c91684 Makefiles: Support py/*.h includes per #1022. 2014-12-27 16:32:52 +02:00
Paul Sokolovsky 9c658b6afc unix, windows: Add _os.system() call.
system() is the basic function to support automation of tasks, so have it
available builtin, for example, for bootstrapping rest of micropython
environment.
2014-12-23 12:56:24 +00:00
Paul Sokolovsky 8427c5b76c unix/windows: Make sure that process exit code is portable 8-bit value.
This fixes FORCED_EXIT internal flag leaking into Windows exit code.
2014-12-19 00:01:49 +02:00
Paul Sokolovsky 9d944c7fb2 unix: Rename "time" module to "utime" to allow extensibility.
Name choosen per latest conventions and for compatibiity with stmhal port.
2014-12-17 00:13:32 +02:00