aboutsummaryrefslogtreecommitdiff
path: root/py/vm.c
AgeCommit message (Collapse)Author
2014-04-15Rename header file.AZ Huang
2014-04-15Move entry_table to separated header file.AZ Huang
2014-04-14Make USE_COMPUTED_GOTO a config option in mpconfig.h.Damien George
Disabled by default. Enabled in unix port.
2014-04-15Use computed goto instead of switching op-codes.AZ Huang
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-12py: Make all LOAD_FAST ops check for unbound local.Damien George
This is necessary to catch all cases where locals are referenced before assignment. We still keep the _0, _1, _2 versions of LOAD_FAST to help reduced the byte code size in RAM. Addresses issue #457.
2014-04-11py: Change compile order for default positional and keyword args.Damien George
This simplifies the compiler a little, since now it can do 1 pass over a function declaration, to determine default arguments. I would have done this originally, but CPython 3.3 somehow had the default keyword args compiled before the default position args (even though they appear in the other order in the text of the script), and I thought it was important to have the same order of execution when evaluating default arguments. CPython 3.4 has changed the order to the more obvious one, so we can also change.
2014-04-10py: Fix VM stack overflow detection.Damien George
2014-04-10py: Add option to VM to detect stack overflow.Damien George
2014-04-09py: Clear state to MP_OBJ_NULL before executing byte code.Damien George
2014-04-09py: Properly implement deletion of locals and derefs, and detect errors.Damien George
Needed to reinstate 2 delete opcodes, to specifically check that a local is not deleted twice.
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-08py: Raise exception for unimplemented byte codes.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-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-05py: Fix bug in DELETE_SUBSCR bytecode, decreasing sp too much.Damien George
2014-04-05py: Implement DELETE_SUBSCR bytecode; implement mp_obj_dict_delete.Damien George
2014-04-04py: Add m_malloc_fail function to handle memory allocation error.Damien George
A malloc/realloc fail now throws MemoryError.
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-31py: Towards default keyword arguments.Damien George
These are default arguments after a bare *.
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-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 pull request #396 from pfalcon/call-starDamien George
vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).
2014-03-30vm: Implement DELETE_FAST_N bytecode.Paul Sokolovsky
2014-03-30vm: Implement CALL_FUNCTION_VAR opcode (foo(*(1, 2, 3))).Paul Sokolovsky
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-30py: Rename mp_exc_stack to mp_exc_stack_t.Damien George
2014-03-30py: Fix reraise logic.Damien George
2014-03-30vm: Save current active exception on opening new try block.Paul Sokolovsky
Required to reraise correct exceptions in except block, regardless if more try blocks with active exceptions happen in the same except block. P.S. This "automagic reraise" appears to be quite wasteful feature of Python - we need to save pending exception just in case it *might* be reraised. Instead, programmer could explcitly capture exception to a variable using "except ... as var", and reraise that. So, consider disabling argless raise support as an optimization.
2014-03-30vm: WITH_CLEANUP: use POP_EXC_BLOCK().Paul Sokolovsky
2014-03-29vm: Establish macros PUSH_EXC_BLOCK & POP_EXC_BLOCK to deal with exc stack.Paul Sokolovsky
E.g. to handle currently_in_except_block restoring properly.
2014-03-29py: Reraising exception possible only in except block.Paul Sokolovsky
2014-03-29vm: Elaborate comments for WITH_CLEANUP, other cosmetic fixes.Paul Sokolovsky
2014-03-29py: Make MP_BC_SETUP_WITH use the bytecode stack for load_method.Damien George
The compiler allocates 7 entries on the stack for a with statement (following CPython, but probably can be reduced). This is enough for the method load and call in SETUP_WITH.
2014-03-29Merge pull request #389 from pfalcon/with-statementDamien George
With statement implementation
2014-03-29py: Fix regress with GeneratorExit object becoming truly const.Damien George
2014-03-29py: Change mp_const_* objects to macros.Damien George
Addresses issue #388.
2014-03-29Merge pull request #383 from pfalcon/yield-fromDamien George
Implement "yield from"
2014-03-29py: Free unique_code slot for outer module.Damien George
Partly (very partly!) addresses issue #386. Most importantly, at the REPL command line, each invocation does not now lead to increased memory usage (unless you define a function/lambda).
2014-03-29vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes).Paul Sokolovsky
2014-03-29vm: Make sure that exception triple is <type, instance, traceback>.Paul Sokolovsky
This reduntant triple is one of the ugliest parts of Python, which they chickened out to fix in Python3. We really should consider passing just as single exception instance (without breaking Python-level APIs of course), but until we do, let's follow CPython layout.
2014-03-29vm: Factor out exception block setup to a macro.Paul Sokolovsky
Will be reused in WITH bytecodes.
2014-03-28py: yield from: Elaborate GeneratorExit (gen.close()) handling.Paul Sokolovsky
Handling of GeneratorExit is really peculiar - it subverts normal exception propagation rules.
2014-03-28py: Core "yield from" implementation.Paul Sokolovsky
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.