Commit Graph

13 Commits

Author SHA1 Message Date
Christian Walther c7404a3ff8 Add movable allocation system.
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-11-28 17:50:23 +01:00
Christian Walther be8092f4d3 When there is not enough free space, but a matching hole on the other side, use it. 2020-10-02 23:07:07 +02:00
Christian Walther 5bdb8c45dd Allow allocate_memory() to reuse holes when matching exactly.
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-02 23:03:21 +02:00
Christian Walther d6d02c67d2 Fix inconsistent supervisor heap.
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-10-02 23:03:21 +02:00
Scott Shawcroft 6aaab005c5
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
2020-05-15 15:36:16 -07:00
Jeff Epler 3a94412cd3 protomatter: more memory allocation fixes
- 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-14 18:24:58 -05:00
Jeff Epler 094fe05bdd allow retrieving info about a supervisor allocation 2020-04-14 18:24:54 -05:00
Scott Shawcroft 7d8dac9211
Refine iMX RT memory layout and add three boards
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.
2020-01-17 17:36:08 -08:00
Kamil Tomaszewski f3151bb6c4 Use get top and limit stack functions 2019-10-18 11:05:08 +02:00
Scott Shawcroft 1a1dbef992
Hook up the terminal based on the first display. 2019-01-31 11:42:14 -08:00
Scott Shawcroft e72cebbad6
Fix crash due to unsigned index and 0 boundary loop. 2018-08-16 00:29:18 -07:00
Scott Shawcroft 4b247eacd8
Add todo for handling improper free. 2018-08-02 14:45:21 -07:00
Scott Shawcroft 5704bc8c93
Share memory.c and a bit of polish. 2018-08-02 14:35:46 -07:00