summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpstate.h
Commit message (Collapse)AuthorAge
* extmod: Remove MICROPY_FSUSERMOUNT and related files.Damien George2017-01-30
| | | | Replaced by MICROPY_VFS and the VFS sub-system.
* extmod/vfs: Expose mp_vfs_mount_t type.Damien George2017-01-27
| | | | | It should only be used for low-level things and with caution, for example putting mounted VFS data in ROM or the static data section.
* extmod: Add generic VFS sub-system.Damien George2017-01-27
| | | | | | | | | | | | This provides mp_vfs_XXX functions (eg mount, open, listdir) which are agnostic to the underlying filesystem type, and just require an object with the relevant filesystem-like methods (eg .mount, .open, .listidr) which can then be mounted. These mp_vfs_XXX functions would typically be used by a port to implement the "uos" module, and mp_vfs_open would be the builtin open function. This feature is controlled by MICROPY_VFS, disabled by default.
* py: Add MICROPY_KBD_EXCEPTION config option to provide mp_kbd_exception.Damien George2016-12-15
| | | | | | | | Defining and initialising mp_kbd_exception is boiler-plate code and so the core runtime can provide it, instead of each port needing to do it themselves. The exception object is placed in the VM state rather than on the heap.
* py/gc: Implement GC running by allocation threshold.Paul Sokolovsky2016-07-21
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, MicroPython runs GC when it could not allocate a block of memory, which happens when heap is exhausted. However, that policy can't work well with "inifinity" heaps, e.g. backed by a virtual memory - there will be a lot of swap thrashing long before VM will be exhausted. Instead, in such cases "allocation threshold" policy is used: a GC is run after some number of allocations have been made. Details vary, for example, number or total amount of allocations can be used, threshold may be self-adjusting based on GC outcome, etc. This change implements a simple variant of such policy for MicroPython. Amount of allocated memory so far is used for threshold, to make it useful to typical finite-size, and small, heaps as used with MicroPython ports. And such GC policy is indeed useful for such types of heaps too, as it allows to better control fragmentation. For example, if a threshold is set to half size of heap, then for an application which usually makes big number of small allocations, that will (try to) keep half of heap memory in a nice defragmented state for an occasional large allocation. For an application which doesn't exhibit such behavior, there won't be any visible effects, except for GC running more frequently, which however may affect performance. To address this, the GC threshold is configurable, and by default is off so far. It's configured with gc.threshold(amount_in_bytes) call (can be queries without an argument).
* extmod/moduos_dupterm: Reserve buffer bytearray object for dupterm.Paul Sokolovsky2016-07-04
| | | | | Allocating it for each read/write operation is a memory fragmentation hazard.
* py: Implement a simple global interpreter lock.Damien George2016-06-28
| | | | | This makes the VM/runtime thread safe, at the cost of not being able to run code in parallel.
* py: Make interning of qstrs thread safe.Damien George2016-06-28
|
* py/gc: Make memory manager and garbage collector thread safe.Damien George2016-06-28
| | | | | | By using a single, global mutex, all memory-related functions (alloc, free, realloc, collect, etc) are made thread safe. This means that only one thread can be in such a function at any one time.
* py: Add basic _thread module, with ability to start a new thread.Damien George2016-06-28
|
* py: Add MP_STATE_THREAD to hold state specific to a given thread.Damien George2016-06-28
|
* py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime.Damien George2016-02-25
| | | | | | | | | | | | | | This new compile-time option allows to make the bytecode compiler configurable at runtime by setting the fields in the mp_dynamic_compiler structure. By using this feature, the compiler can generate bytecode that targets any MicroPython runtime/VM, regardless of the host and target compile-time settings. Options so far that fall under this dynamic setting are: - maximum number of bits that a small int can hold; - whether caching of lookups is used in the bytecode; - whether to use unicode strings or not (lexer behaviour differs, and therefore generated string constants differ).
* py/mpstate.h: fs_user_mount is now standard, reusable uPy functionality.Paul Sokolovsky2016-02-15
|
* py: Clean up instantiation of dupterm object.Paul Sokolovsky2016-01-01
| | | | To comply with already established scheme for extmod's.
* py/qstr: Use size_t instead of mp_uint_t when counting allocated bytes.Damien George2015-12-17
|
* py/gc: Use size_t instead of mp_uint_t to count things related to heap.Damien George2015-12-16
| | | | | | | size_t is the correct type to use to count things related to the size of the address space. Using size_t (instead of mp_uint_t) is important for the efficiency of ports that configure mp_uint_t to larger than the machine word size.
* py/modsys: Implement sys.modules.Paul Sokolovsky2015-12-05
| | | | | This for example will allow people to reload modules which didn't load successfully (e.g. due to syntax error).
* 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/gc: Move away from using mp_uint_t, instead use uintptr_t and size_t.Damien George2015-11-29
| | | | The GC works with concrete pointers and so the types should reflect this.
* py/mpstate: Make mp_pending_exception volatile.Damien George2015-11-17
| | | | It can change asynchronously.
* extmod/modlwip: slip: Use stream protocol and be port-independent.Paul Sokolovsky2015-10-27
| | | | | Based on the original patch by Galen Hazelwood: https://github.com/micropython/micropython/pull/1517 .
* py: Improve allocation policy of qstr data.Damien George2015-07-14
| | | | | | | | | | | | | | | | | | | | Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
* modsys: Add basic sys.exc_info() implementation.Paul Sokolovsky2015-04-25
| | | | | | The implementation is very basic and non-compliant and provided solely for CPython compatibility. The function itself is bad Python2 heritage, its usage is discouraged.
* py: Put mp_sys_path, mp_sys_argv and gc_collected in mp_state_ctx_t.Damien George2015-02-07
| | | | | Without mp_sys_path and mp_sys_argv in the root pointer section of the state, their memory was being incorrectly collected by GC.
* stmhal: Put mod_network_nic_list in global root-pointer state.Damien George2015-01-22
| | | | It needs to be scanned by GC. Thanks to Daniel Campora.
* 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.