summaryrefslogtreecommitdiffstatshomepage
path: root/py/runtime.c
Commit message (Collapse)AuthorAge
* py: Add finer configuration of static funcs when not in stackless mode.Damien George2015-04-02
| | | | Also rename call_args_t to mp_call_args_t.
* runtime: Split mp_call_prepare_args_n_kw_var() from mp_call_method_n_kw_var().Paul Sokolovsky2015-04-03
| | | | | Allow for reuse for stackless design, where preparing args is separate from calling.
* py: Combine duplicated code that converts members from a lookup.Damien George2015-03-21
| | | | | | | | | | | | Despite initial guess, this code factoring does not hamper performance. In fact it seems to improve speed by a little: running pystone(1.2) on pyboard (which gives a very stable result) this patch takes pystones from 1729.51 up to 1742.16. Also, pystones on x64 increase by around the same proportion (but it's much noisier). Taking a look at the generated machine code, stack usage with this patch is unchanged, and call is tail-optimised with all arguments in registers. Code size decreases by about 50 bytes on Thumb2 archs.
* runtime: mp_load_method_maybe(): Don't use confusing "base" term.Paul Sokolovsky2015-03-21
| | | | | | | "Base" should rather refer to "base type"."Base object for attribute lookup" should rather be just "object". Also, a case of common subexpression elimination.
* runtime: Typo fixes in comments.Paul Sokolovsky2015-03-03
|
* py: Simplify and remove redundant code for __iter__ method lookup.Damien George2015-02-15
|
* py: Parse big-int/float/imag constants directly in parser.Damien George2015-02-08
| | | | | | | | | Previous to this patch, a big-int, float or imag constant was interned (made into a qstr) and then parsed at runtime to create an object each time it was needed. This is wasteful in RAM and not efficient. Now, these constants are parsed straight away in the parser and turned into objects. This allows constants with large numbers of digits (so addresses issue #1103) and takes us a step closer to #722.
* py: Protect mp_parse and mp_compile with nlr push/pop block.Damien George2015-02-07
| | | | | | | | | | 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.
* py: Specify unary/binary op name in TypeError error message.Damien George2015-01-27
| | | | | | | Eg, "() + 1" now tells you that __add__ is not supported for tuple and int types (before it just said the generic "binary operator"). We reuse the table of names for slot lookup because it would be a waste of code space to store the pretty name for each operator.
* py, unix, stmhal: Allow to compile with -Wshadow.Damien George2015-01-20
| | | | See issue #699.
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py: Put all global state together in state structures.Damien George2015-01-07
| | | | | | 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.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Fix iteration over map in 2 places.Damien George2014-12-21
|
* py: Allow builtins to be overridden.Damien George2014-12-09
| | | | | | | | | | | | | | This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
* py: Optimise lexer by exposing lexer type.Damien George2014-12-05
| | | | | | | | | mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer functions (like checking current token kind) are now inlined. This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460 bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t is a bit smaller. Also will run a bit more efficiently.
* py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.Damien George2014-11-06
| | | | | | | | Going from MICROPY_ERROR_REPORTING_NORMAL to MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2, and 2200 bytes ROM for 32-bit x86. This is about a 2.5% code size reduction for bare-arm.
* py: Fix bug with right-shifting small ints by large amounts.Paul Sokolovsky2014-11-02
| | | | Undefined behavior in C, needs explicit check.
* py: Add mp_pending_exception global variable, for VM soft interrupt.Damien George2014-10-25
| | | | | | | | | | | This allows to implement KeyboardInterrupt on unix, and a much safer ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM will notice it; second ctrl-C is a hard one that kills anything (for both unix and stmhal). One needs to check for a pending exception in the VM only for jump opcodes. Others can't produce an infinite loop (infinite recursion is caught by stack check).
* py: Implement compile builtin, enabled only on unix port.Damien George2014-10-25
| | | | | | | This should be pretty compliant with CPython, except perhaps for some corner cases to do with globals/locals context. Addresses issue #879.
* py: Factor out mp_obj_is_package() function.Paul Sokolovsky2014-10-25
|
* py: Use MP_OBJ_NULL instead of NULL in a few places.Damien George2014-10-23
|
* py: Add #if guard around gc-specific code.Damien George2014-10-09
|
* Allow real memory errors (from locked gc) to be reported with traceback.Dave Hylands2014-10-07
|
* py: Implement proper context save/restore for eval/exec; factor code.Damien George2014-10-05
| | | | | | | | | This has benefits all round: code factoring for parse/compile/execute, proper context save/restore for exec, allow to sepcify globals/locals for eval, and reduced ROM usage by >100 bytes on stmhal and unix. Also, the call to mp_parse_compile_execute is tail call optimised for the import code, so it doesn't increase stack memory usage.
* py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.Damien George2014-10-03
| | | | This should pretty much resolve issue #50.
* py: Tidy up exception matching; allow matching of tuple of exceptions.Damien George2014-09-25
| | | | Addresses issue #864.
* py: For malloc and vstr functions, use size_t exclusively for int type.Damien George2014-09-25
| | | | | | It seems most sensible to use size_t for measuring "number of bytes" in malloc and vstr functions (since that's what size_t is for). We don't use mp_uint_t because malloc and vstr are not Micro Python specific.
* stmhal: Initialise stack pointer correctly.Damien George2014-09-23
| | | | | | | | | | | | | Stack is full descending and must be 8-byte aligned. It must start off pointing to just above the last byte of RAM. Previously, stack started pointed to last byte of RAM (eg 0x2001ffff) and so was not 8-byte aligned. This caused a bug in combination with alloca. This patch also updates some debug printing code. Addresses issue #872 (among many other undiscovered issues).
* py: Small simplifications in tuple and list accessors.Damien George2014-08-30
|
* py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Change all uint to mp_uint_t in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Make tuple and list use mp_int_t/mp_uint_t.Damien George2014-08-30
| | | | Part of code cleanup, to resolve issue #50.
* py: Move native glue code from runtime.c to new file nativeglue.c.v1.3.1Damien George2014-08-28
| | | | | | | | This way, the native glue code is only compiled if native code is enabled (which makes complete sense; thanks to Paul Sokolovsky for the idea). Should fix issue #834.
* py: Code clean-up in native emitter; improve thumb native calls.Damien George2014-08-16
|
* py: Viper can call functions with native types, and raise exceptions.Damien George2014-08-16
|
* py: Viper can now store to global.Damien George2014-08-15
|
* Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.Damien George2014-08-04
| | | | | | | qstr_init is always called exactly before mp_init, so makes sense to just have mp_init call it. Similarly with mp_init_emergency_exception_buf. Doing this makes the ports simpler and less error prone (ie they can no longer forget to call these).
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* stackctrl: Add "mp_" prefix.Paul Sokolovsky2014-07-01
|
* py: Move stack_ctrl_init() to mp_init().Paul Sokolovsky2014-06-27
| | | | | | As stack checking is enabled by default, ports which don't call stack_ctrl_init() are broken now (report RuntimeError on startup). Save them trouble and just init stack control framework in interpreter init.
* py: Separate MICROPY_PY_BUILTINS_COMPLEX from MICROPY_PY_BUILTINS_FLOAT.Paul Sokolovsky2014-06-20
| | | | | One thing is wanting to do 1 / 2 and get something else but 0, and quite another - doing rocket science ;-).
* Merge branch 'alloca' of github.com:marcusva/micropython into marcusva-allocaDamien George2014-06-08
|\
| * - FreeBSD provides alloca() via stdlib.h, in contrast to Linux and WindowsMarcus von Appen2014-06-07
| | | | | | | | - Move the includes for alloca() intp mpconfigport.h
* | py: Add generic mp_not_implemented() func to use instead of assert().Paul Sokolovsky2014-06-07
|/ | | | | | Benefits: won't crash baremetal targets, will provide Python source location when not implemented feature used (it will no longer provide C source location, but just grep for error message).
* Change comments (mainly URLs) to no longer specifically say Python 3.3Chris Angelico2014-06-06
|
* py: Allow tail call optimisation in mp_call_function_n_kw.Damien George2014-06-03
| | | | This saves 4 words of stack space per Python call.
* py: Instead of having "debug on" var, have "optimization level" var.Paul Sokolovsky2014-06-03
| | | | | This allows to have multiple "optimization" levels (CPython has two (-OO removes docstrings), we can have more).
* py: Fix configurability of builtin slice.Damien George2014-06-01
|
* py: Add option to disable set() object (enabled by default).Damien George2014-06-01
|