summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorChristian Walther <cwalther@gmx.ch>2020-10-11 14:59:33 +0200
committerChristian Walther <cwalther@gmx.ch>2020-11-28 17:50:23 +0100
commitc7404a3ff89c738c002ec63448a58d56330dfcc3 (patch)
treeb7eabbfe9dd8cdd9f6029252dc9c341e1b3d1ac1 /ports
parentbd87201c4f5a326e0328648700e1929d876b8c36 (diff)
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.
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/supervisor/port.c4
-rw-r--r--ports/cxd56/supervisor/port.c8
-rw-r--r--ports/esp32s2/supervisor/port.c8
-rw-r--r--ports/litex/supervisor/port.c4
-rw-r--r--ports/mimxrt10xx/supervisor/port.c7
-rw-r--r--ports/nrf/supervisor/port.c4
-rw-r--r--ports/stm/supervisor/port.c4
7 files changed, 14 insertions, 25 deletions
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index d65d09825..fc1d1198e 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -390,8 +390,8 @@ void reset_cpu(void) {
reset();
}
-supervisor_allocation* port_fixed_stack(void) {
- return NULL;
+bool port_has_fixed_stack(void) {
+ return false;
}
uint32_t *port_stack_get_limit(void) {
diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c
index 086c2d198..d69f35779 100644
--- a/ports/cxd56/supervisor/port.c
+++ b/ports/cxd56/supervisor/port.c
@@ -98,12 +98,8 @@ void reset_to_bootloader(void) {
}
}
-supervisor_allocation _fixed_stack;
-
-supervisor_allocation* port_fixed_stack(void) {
- _fixed_stack.ptr = port_stack_get_limit();
- _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t);
- return &_fixed_stack;
+bool port_has_fixed_stack(void) {
+ return true;
}
uint32_t *port_stack_get_limit(void) {
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index aff7dbda4..264bdee97 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -193,12 +193,8 @@ uint32_t *port_stack_get_top(void) {
return port_stack_get_limit() + ESP_TASK_MAIN_STACK / (sizeof(uint32_t) / sizeof(StackType_t));
}
-supervisor_allocation _fixed_stack;
-
-supervisor_allocation* port_fixed_stack(void) {
- _fixed_stack.ptr = port_stack_get_limit();
- _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t);
- return &_fixed_stack;
+bool port_has_fixed_stack(void) {
+ return true;
}
// Place the word to save just after our BSS section that gets blanked.
diff --git a/ports/litex/supervisor/port.c b/ports/litex/supervisor/port.c
index 02617b9af..f5c362ea6 100644
--- a/ports/litex/supervisor/port.c
+++ b/ports/litex/supervisor/port.c
@@ -98,8 +98,8 @@ void reset_cpu(void) {
for(;;) {}
}
-supervisor_allocation* port_fixed_stack(void) {
- return NULL;
+bool port_has_fixed_stack(void) {
+ return false;
}
uint32_t *port_heap_get_bottom(void) {
diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c
index e3fef373f..1be2b1039 100644
--- a/ports/mimxrt10xx/supervisor/port.c
+++ b/ports/mimxrt10xx/supervisor/port.c
@@ -334,11 +334,8 @@ uint32_t *port_stack_get_top(void) {
return &_ld_stack_top;
}
-supervisor_allocation _fixed_stack;
-supervisor_allocation* port_fixed_stack(void) {
- _fixed_stack.ptr = port_stack_get_limit();
- _fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t);
- return &_fixed_stack;
+bool port_has_fixed_stack(void) {
+ return true;
}
uint32_t *port_heap_get_bottom(void) {
diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c
index 493de43e0..5f1c9f1ba 100644
--- a/ports/nrf/supervisor/port.c
+++ b/ports/nrf/supervisor/port.c
@@ -251,8 +251,8 @@ uint32_t *port_heap_get_top(void) {
return port_stack_get_top();
}
-supervisor_allocation* port_fixed_stack(void) {
- return NULL;
+bool port_has_fixed_stack(void) {
+ return false;
}
uint32_t *port_stack_get_limit(void) {
diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c
index a8aab00ff..dba1cf21e 100644
--- a/ports/stm/supervisor/port.c
+++ b/ports/stm/supervisor/port.c
@@ -267,8 +267,8 @@ uint32_t *port_heap_get_top(void) {
return &_ld_heap_end;
}
-supervisor_allocation* port_fixed_stack(void) {
- return NULL;
+bool port_has_fixed_stack(void) {
+ return false;
}
uint32_t *port_stack_get_limit(void) {