aboutsummaryrefslogtreecommitdiff
path: root/py/runtime.c
AgeCommit message (Collapse)Author
2014-04-17py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
2014-04-17py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.Damien George
mp_obj_t->subscr now does load/store/delete.
2014-04-17py: Don't assert but go to unsupported_op in mp_binary_op for small int.Damien George
2014-04-13Merge pull request #476 from pfalcon/static-sysDamien George
Convert sys module to static allocation
2014-04-13py: Remove unique_codes from emitglue.c. Replace with pointers.Damien George
Attempt to address issue #386. unique_code_id's have been removed and replaced with a pointer to the "raw code" information. This pointer is stored in the actual byte code (aligned, so the GC can trace it), so that raw code (ie byte code, native code and inline assembler) is kept only for as long as it is needed. In memory it's now like a tree: the outer module's byte code points directly to its children's raw code. So when the outer code gets freed, if there are no remaining functions that need the raw code, then the children's code gets freed as well. This is pretty much like CPython does it, except that CPython stores indexes in the byte code rather than machine pointers. These indices index the per-function constant table in order to find the relevant code.
2014-04-13py, unix: Convert sys module to static representation.Paul Sokolovsky
2014-04-12py: Fix compiler warning when floats disabled.Damien George
2014-04-12py: Make ImportError message match CPython's.Paul Sokolovsky
2014-04-12builtinimport: Fix thinko passing 0 vs NULL.Paul Sokolovsky
2014-04-12py: Implement "from pkg import mod" variant of import.Paul Sokolovsky
2014-04-10py: Fix float/complex binop returning NULL; implement complex power.Damien George
2014-04-08py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.Damien George
This makes the runtime and object APIs more consistent. mp_store_subscr functionality now moved into objects (ie list and dict store_item).
2014-04-08py: Finish implementation of all del opcodes.Damien George
At this point, all opcodes are now implemented! Some del opcodes have been combined with store opcodes, with the value to store being MP_OBJ_NULL.
2014-04-08py: implement UNPACK_EX byte code (for: a, *b, c = d)Damien George
2014-04-06py: Implement more features in native emitter.Damien George
On x64, native emitter now passes 70 of the tests.
2014-04-06py: Revert mp_load_attr() to its previous state (not supporting default val).Paul Sokolovsky
Based on the discussion in #433. mp_load_attr() is critical-path function, so any extra check will slowdown any script. As supporting default val required only for getattr() builtin, move correspending implementation there (still as a separate function due to concerns of maintainability of such almost-duplicated code instances).
2014-04-05py: Make globals and locals proper dictionary objects.Damien George
Finishes addressing issue #424. In the end this was a very neat refactor that now makes things a lot more consistent across the py code base. It allowed some simplifications in certain places, now that everything is a dict object. Also converted builtins tables to dictionaries. This will be useful when we need to turn builtins into a proper module.
2014-04-05py: Change module globals from mp_map_t* to mp_obj_dict_t*.Damien George
Towards addressing issue #424. Had a small increase to ROM usage (order 60 bytes).
2014-04-05py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George
This does not affect code size or performance when debugging turned off. To address issue #420.
2014-04-05Merge pull request #433 from pfalcon/getattr-3argDamien George
py: Support 3-arg getattr() builtin (with default value).
2014-04-05py: Implement DELETE_SUBSCR bytecode; implement mp_obj_dict_delete.Damien George
2014-04-05py: Support 3-arg getattr() builtin (with default value).Paul Sokolovsky
2014-04-05py: Put default namespace into module __main__.Paul Sokolovsky
That's how CPython has it, in particular, "import __main__" should work.
2014-04-05mp_load_name(): Optimize for outer scope where locals == globals.Paul Sokolovsky
2014-04-04py: This time, real proper overflow checking of small int power.Damien George
Previous overflow test was inadequate.
2014-04-04py: Add m_malloc_fail function to handle memory allocation error.Damien George
A malloc/realloc fail now throws MemoryError.
2014-04-04py: Handle small int power overflow correctly.Damien George
2014-04-02py: Fix up so that it can compile without float.Damien George
2014-03-31py: Implement __getattr__.Damien George
It's not completely satisfactory, because a failed call to __getattr__ should not raise an exception. __setattr__ could be implemented, but it would slow down all stores to a user created object. Need to implement some caching system.
2014-03-31py: Wrap .__class__ handling in MICROPY_CPYTHON_COMPAT.Paul Sokolovsky
Because it's superfluos in the presence of type(), a remenant from Python's "old classes".
2014-03-31Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-03-31py: Remove old "run time" functions that were 1 liners.Damien George
2014-03-31mp_resume: Dare to pass send_value of NULL.Paul Sokolovsky
There was thinkos that either send_value or throw_value is specified, but there were cases with both. Note that send_value is pushed onto generator's stack - but that's probably only good, because if we throw exception into gen, it should not ever use send_value, and that will be just extra "assert".
2014-03-31mp_resume: Elaborate handling of .throw() for objects which lack it.Paul Sokolovsky
In this case, the exception is just re-thrown - the ideas is that object doesn't handle this exception specially, so it will propagated per Python semantics.
2014-03-31Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-03-31py: Add LOAD_NULL bytecode and use it to simplify function calls.Damien George
Adding this bytecode allows to remove 4 others related to function/method calls with * and ** support. Will also help with bytecodes that make functions/closures with default positional and keyword args.
2014-03-31py: Properly implement divide-by-zero handling.Paul Sokolovsky
"1/0" is sacred idiom, the shortest way to break program execution (sys.exit() is too long).
2014-03-30py: Implement support for generalized generator protocol.Paul Sokolovsky
Iterators and ducktype objects can now be arguments of yield from.
2014-03-30py: Implement positional and keyword args via * and **.Damien George
Extends previous implementation with * for function calls to * and ** for both function and method calls.
2014-03-30Merge map.h into obj.h.Damien George
Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
2014-03-30Rename rt_* to mp_*.Damien George
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
2014-03-29py: Rename old const type objects to mp_type_* for consistency.Damien George
2014-03-29py: Change mp_const_* objects to macros.Damien George
Addresses issue #388.
2014-03-28py: Fix bugs with debugging output.Damien George
show_bc now decodes the prelude correctly. Moved WRITE_FILE stuff from runtime.c to emitglue.c. Addresses issue #385.
2014-03-27py: Factor out code from runtime.c to emitglue.c.Damien George
2014-03-27py: Put n_state for bytecode in the bytecode prelude.Damien George
Rationale: setting up the stack (state for locals and exceptions) is really part of the "code", it's the prelude of the function. For example, native code adjusts the stack pointer on entry to the function. Native code doesn't need to know n_state for any other reason. So putting the state size in the bytecode prelude is sensible. It reduced ROM usage on STM by about 30 bytes :) And makes it easier to pass information about the bytecode between functions.
2014-03-26Merge pull request #381 from pfalcon/closure-defargsDamien George
py: Support closures with default args.
2014-03-26py: Fix logic bugs in object attribute/method extraction.Damien George
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
2014-03-26py: Support closures with default args.Paul Sokolovsky