summaryrefslogtreecommitdiff
path: root/qemu-arm/test_main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-12 12:07:42 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-12 12:07:42 +0000
commit99dde4ed1f8edd5ff566a6f0cfec0c83f01ef657 (patch)
tree3ef8d8d2c8d8f9f896be4998b4c10ecff9cd59b7 /qemu-arm/test_main.c
parent3f9f9cac75b8894dc4cc641e48778ad5cd9ac3bc (diff)
qemu-arm: Enable GC and native code-gen; enable more tests.
Diffstat (limited to 'qemu-arm/test_main.c')
-rw-r--r--qemu-arm/test_main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/qemu-arm/test_main.c b/qemu-arm/test_main.c
index 30bd16904..cc4e15357 100644
--- a/qemu-arm/test_main.c
+++ b/qemu-arm/test_main.c
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <malloc.h>
#include "py/nlr.h"
#include "py/obj.h"
@@ -9,6 +10,7 @@
#include "py/runtime0.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
+#include "py/gc.h"
#include "py/repl.h"
#include "py/pfenv.h"
@@ -58,6 +60,8 @@ end:
int main() {
const char a[] = {"sim"};
mp_stack_set_limit(10240);
+ void *heap = malloc(256 * 1024);
+ gc_init(heap, (char*)heap + 256 * 1024);
mp_init();
int r = tinytest_main(1, (const char **) a, groups);
mp_deinit();
@@ -66,6 +70,18 @@ int main() {
}
void gc_collect(void) {
+ gc_collect_start();
+
+ // get the registers and the sp
+ jmp_buf env;
+ setjmp(env);
+ volatile mp_uint_t dummy;
+ void *sp = (void*)&dummy;
+
+ // trace the stack, including the registers (since they live on the stack in this function)
+ gc_collect_root((void**)sp, ((uint32_t)MP_STATE_VM(stack_top) - (uint32_t)sp) / sizeof(uint32_t));
+
+ gc_collect_end();
}
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {