summaryrefslogtreecommitdiffstatshomepage
path: root/py/objgenerator.c
Commit message (Collapse)AuthorAge
* py/objgenerator: Don't raise RuntimeError if GeneratorExit ignored.Damien George2017-01-17
| | | | In this case it's allowed to be ignored.
* py/objgenerator: When throwing an object, don't make an exc instance.Damien George2017-01-17
| | | | Arguments to throw() for generators don't need to be exceptions.
* py: Use mp_raise_msg helper function where appropriate.Damien George2016-10-17
| | | | | Saves the following number of bytes of code space: 176 for bare-arm, 352 for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
* py: Rename struct mp_code_state to mp_code_state_t.Damien George2016-08-27
| | | | Also at _t to mp_exc_stack pre-declaration in struct typedef.
* py: Get rid of assert() in method argument checking functions.Paul Sokolovsky2016-08-12
| | | | | | Checks for number of args removes where guaranteed by function descriptor, self checking is replaced with mp_check_self(). In few cases, exception is raised instead of assert.
* py/vm: "yield from" didn't handle MP_OBJ_STOP_ITERATION optimization.Paul Sokolovsky2016-04-28
| | | | E.g. crashed when yielding from already stopped generators.
* py: Change type signature of builtin funs that take variable or kw args.Damien George2016-01-11
| | | | | With this patch the n_args parameter is changed type from mp_uint_t to size_t.
* py: Change type of .make_new and .call args: mp_uint_t becomes size_t.Damien George2016-01-11
| | | | | | | This patch changes the type signature of .make_new and .call object method slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more efficient when mp_uint_t is larger than a machine word. Doesn't affect ports when size_t and mp_uint_t have the same size.
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George2015-11-29
|
* py: Add constant table to bytecode.Damien George2015-11-13
| | | | | Contains just argument names at the moment but makes it easy to add arbitrary constants.
* py: Reorganise bytecode layout so it's more structured, easier to edit.Damien George2015-11-13
|
* objgenerator: Can optimize StopIteration to STOP_ITERATION only if arg is None.Paul Sokolovsky2015-05-11
| | | | | | Unfortunately, MP_OBJ_STOP_ITERATION doesn't have means to pass an associated value, so we can't optimize StopIteration exception with (non-None) argument to MP_OBJ_STOP_ITERATION.
* objgenerator: If generator yielded STOP_ITERATION value, it's stopped.Paul Sokolovsky2015-05-11
| | | | | MP_OBJ_STOP_ITERATION is equivalent of raising StopIteration, except mp_vm_return_kind_t for it is "yield".
* py: Add %q format support to mp_[v]printf, and use it.Damien George2015-04-16
|
* py: Overhaul and simplify printf/pfenv mechanism.Damien George2015-04-16
| | | | | | | | | | | | | | | | | | | | | | Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
* py: Implement full func arg passing for native emitter.Damien George2015-04-07
| | | | | | | | | | | This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
* py: Allow retrieving a function's __name__.stijn2015-03-20
| | | | Disabled by default. Enabled on unix and stmhal ports.
* py, unix: Allow to compile with -Wunused-parameter.Damien George2015-01-20
| | | | See issue #699.
* py: Add "default" to switches to allow better code flow analysis.Damien George2015-01-14
| | | | | This helps compiler produce smaller code. Saves 124 bytes on stmhal and bare-arm.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Make functions static where appropriate.Damien George2014-12-10
|
* py: Store bytecode arg names in bytecode (were in own array).Damien George2014-10-25
| | | | | | | | | | | | | | | | | | | | This saves a lot of RAM for 2 reasons: 1. For functions that don't have default values, var args or var kw args (which is a large number of functions in the general case), the mp_obj_fun_bc_t type now fits in 1 GC block (previously needed 2 because of the extra pointer to point to the arg_names array). So this saves 16 bytes per function (32 bytes on 64-bit machines). 2. Combining separate memory regions generally saves RAM because the unused bytes at the end of the GC block are saved for 1 of the blocks (since that block doesn't exist on its own anymore). So generally this saves 8 bytes per function. Tested by importing lots of modules: - 64-bit Linux gave about an 8% RAM saving for 86k of used RAM. - pyboard gave about a 6% RAM saving for 31k of used RAM.
* py: Use variable length encoded uints in more places in bytecode.Damien George2014-09-04
| | | | | | Code-info size, block name, source name, n_state and n_exc_stack now use variable length encoded uints. This saves 7-9 bytes per bytecode function for most functions.
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* objgenerator: Finish refactor to use mp_setup_code_state().Paul Sokolovsky2014-06-11
|
* objgenerator: First iteration of refactor to use mp_setup_code_state().Paul Sokolovsky2014-06-11
|
* py: Merge mp_execute_bytecode into fun_bc_call.Damien George2014-06-07
| | | | | | This reduces stack usage by 16 words (64 bytes) for stmhal/ port. See issue #640.
* vm: Factor out structure with code execution state and pass it around.Paul Sokolovsky2014-05-31
| | | | | | | This improves stack usage in callers to mp_execute_bytecode2, and is step forward towards unifying execution interface for function and generators (which is important because generators don't even support full forms of arguments passing (keywords, etc.)).
* py: Reformat few long functions argument lists for clarity.Paul Sokolovsky2014-05-31
|
* py: More mp_identity usage.Paul Sokolovsky2014-05-17
|
* py, unix: Add copyright for modules I worked closely on.Paul Sokolovsky2014-05-13
|
* py: Rename byte_code to bytecode everywhere.Damien George2014-05-10
| | | | bytecode is the more widely used. See issue #590.
* py: Comment exc_state member from mp_obj_gen_instance_t as it gives troublestijn2014-05-05
| | | | | | | ...to some compilers who can't process 2 zero-sized arrays in structs. It's never referenced directly anyway. See disussion on #568 as well.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* objgenerator: .print(): Output real underlying function name.Paul Sokolovsky2014-05-01
|
* py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George2014-04-17
| | | | | Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
* py: Simplify objfun/objgenerator connection, no need to call bc_get.Damien George2014-04-17
|
* objgenerator: Generator must execute in its defining lexical context.Paul Sokolovsky2014-04-17
| | | | | I.e. with its own globals. So, just as for functions, we need to switch globals when resuming a generator.
* py: Clear state to MP_OBJ_NULL before executing byte code.Damien George2014-04-09
|
* py: Generators can have their locals closed over.Damien George2014-04-09
|
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* objgenerator.throw(GeneratorExit) is not equivalent to .close().Paul Sokolovsky2014-03-31
| | | | | | | | | .throw() propagates any exceptions, and .close() swallows them. Yielding in reponse to .throw(GeneratorExit) is still fatal, and we need to handle it for .throw() case separately (previously it was handled only for .close() case). Obscure corner cases due to test_pep380.py.
* objgenerator: Another obscure case of propagating MP_OBJ_NULL optimization.Paul Sokolovsky2014-03-31
|
* py: Don't wrap necessary function calls in assert.Damien George2014-03-30
|
* Merge pull request #399 from pfalcon/gen-defargsDamien George2014-03-30
|\ | | | | objgenerator: Handle default args to generator functions.
| * objgenerator: Handle default args to generator functions.Paul Sokolovsky2014-03-30
| | | | | | | | Addresses #397.
* | py: Implement support for generalized generator protocol.Paul Sokolovsky2014-03-30
|/ | | | Iterators and ducktype objects can now be arguments of yield from.