summaryrefslogtreecommitdiff
path: root/supervisor/shared/memory.c
AgeCommit message (Collapse)Author
2020-11-30Eliminate goto.Christian Walther
2020-11-29Optimize out allocation moving code on boards that don't need it.Christian Walther
When no features are enabled that use movable allocations, supervisor_move_memory() is not needed.
2020-11-29Unify redundant low/high_address computation to save a bit of code size.Christian Walther
2020-11-28Make CIRCUITPY_SUPERVISOR_ALLOC_COUNT dependent on enabled features.Christian Walther
Avoids wasted memory and makes it easier to keep track of who needs how much for future additions.
2020-11-28Add movable allocation system.Christian Walther
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap. By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-10-02When there is not enough free space, but a matching hole on the other side, ↵Christian Walther
use it.
2020-10-02Allow allocate_memory() to reuse holes when matching exactly.Christian Walther
This requires recovering the pointer of the allocation, which could be done by adding up neighbor lengths, but the simpler way is to stop NULLing it out in the first place and instead mark an allocation as freed by the client by setting the lowest bit of the length (which is always zero in a valid length).
2020-10-02Fix inconsistent supervisor heap.Christian Walther
When allocations were freed in a different order from the reverse of how they were allocated (leaving holes), the heap would get into an inconsistent state, eventually resulting in crashes. free_memory() relies on having allocations in order, but allocate_memory() did not guarantee that: It reused the first allocation with a NULL ptr without ensuring that it was between low_address and high_address. When it belongs to a hole in the allocated memory, such an allocation is not really free for reuse, because free_memory() still needs its length. Instead, explicitly mark allocations available for reuse with a special (invalid) value in the length field. Only allocations that lie between low_address and high_address are marked that way.
2020-05-15Initial ESP32S2 port.Scott Shawcroft
Basic blinky works but doesn't check pins.
2020-04-14protomatter: more memory allocation fixesJeff Epler
- bump supervisor alloc count by 4 (we actually use 5) - move reconstruct to after gc heap is reset - destroy protomatter object entirely if not used by a FramebufferDisplay - ensure previous supervisor allocations are released - zero out pointers so GC can collect them
2020-04-14allow retrieving info about a supervisor allocationJeff Epler
2020-01-17Refine iMX RT memory layout and add three boardsScott Shawcroft
Introduces a way to place CircuitPython code and data into tightly coupled memory (TCM) which is accessible by the CPU in a single cycle. It also frees up room in the corresponding cache for intermittent data. Loading from external flash is slow! The data cache is also now enabled. Adds support for the iMX RT 1021 chip. Adds three new boards: * iMX RT 1020 EVK * iMX RT 1060 EVK * Teensy 4.0 Related to #2492, #2472 and #2477. Fixes #2475.
2019-10-18Use get top and limit stack functionsKamil Tomaszewski
2019-01-31Hook up the terminal based on the first display.Scott Shawcroft
2018-08-16Fix crash due to unsigned index and 0 boundary loop.Scott Shawcroft
2018-08-02Add todo for handling improper free.Scott Shawcroft
2018-08-02Share memory.c and a bit of polish.Scott Shawcroft