Skip to content

Commit 99dde4e

Browse files
committed
qemu-arm: Enable GC and native code-gen; enable more tests.
1 parent 3f9f9ca commit 99dde4e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

qemu-arm/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdint.h>
22
#include <stdio.h>
33
#include <string.h>
4+
#include <malloc.h>
45

56
#include "py/nlr.h"
67
#include "py/obj.h"
@@ -9,6 +10,7 @@
910
#include "py/runtime0.h"
1011
#include "py/runtime.h"
1112
#include "py/stackctrl.h"
13+
#include "py/gc.h"
1214
#include "py/repl.h"
1315
#include "py/pfenv.h"
1416

@@ -51,6 +53,8 @@ void do_str(const char *src) {
5153

5254
int main(int argc, char **argv) {
5355
mp_stack_set_limit(10240);
56+
void *heap = malloc(16 * 1024);
57+
gc_init(heap, (char*)heap + 16 * 1024);
5458
mp_init();
5559
do_str("print('hello world!')");
5660
mp_deinit();

qemu-arm/mpconfigport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
#define MICROPY_ALLOC_PATH_MAX (512)
66
#define MICROPY_EMIT_X64 (0)
7-
#define MICROPY_EMIT_THUMB (0)
8-
#define MICROPY_EMIT_INLINE_THUMB (0)
7+
#define MICROPY_EMIT_THUMB (1)
8+
#define MICROPY_EMIT_INLINE_THUMB (1)
99
#define MICROPY_MEM_STATS (0)
1010
#define MICROPY_DEBUG_PRINTERS (0)
11-
#define MICROPY_ENABLE_GC (0)
11+
#define MICROPY_ENABLE_GC (1)
1212
#define MICROPY_STACK_CHECK (1)
1313
#define MICROPY_HELPER_REPL (0)
1414
#define MICROPY_HELPER_LEXER_UNIX (0)

qemu-arm/test_main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdint.h>
22
#include <stdio.h>
33
#include <string.h>
4+
#include <malloc.h>
45

56
#include "py/nlr.h"
67
#include "py/obj.h"
@@ -9,6 +10,7 @@
910
#include "py/runtime0.h"
1011
#include "py/runtime.h"
1112
#include "py/stackctrl.h"
13+
#include "py/gc.h"
1214
#include "py/repl.h"
1315
#include "py/pfenv.h"
1416

@@ -58,6 +60,8 @@ inline void do_str(const char *src) {
5860
int main() {
5961
const char a[] = {"sim"};
6062
mp_stack_set_limit(10240);
63+
void *heap = malloc(256 * 1024);
64+
gc_init(heap, (char*)heap + 256 * 1024);
6165
mp_init();
6266
int r = tinytest_main(1, (const char **) a, groups);
6367
mp_deinit();
@@ -66,6 +70,18 @@ int main() {
6670
}
6771

6872
void gc_collect(void) {
73+
gc_collect_start();
74+
75+
// get the registers and the sp
76+
jmp_buf env;
77+
setjmp(env);
78+
volatile mp_uint_t dummy;
79+
void *sp = (void*)&dummy;
80+
81+
// trace the stack, including the registers (since they live on the stack in this function)
82+
gc_collect_root((void**)sp, ((uint32_t)MP_STATE_VM(stack_top) - (uint32_t)sp) / sizeof(uint32_t));
83+
84+
gc_collect_end();
6985
}
7086

7187
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {

tools/tinytest-codegen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def script_to_map(t):
4646

4747
## XXX: may be we could have `--without <groups>` argument...
4848
# currently these tests are selected because they pass on qemu-arm
49-
test_dirs = ('basics',) # 'float', 'import', 'io', 'misc')
50-
exclude_tests = ('basics/builtin_override.py', 'basics/class_super_object.py', 'basics/memoryview_gc.py',)
49+
test_dirs = ('basics', 'micropython', 'inlineasm') # 'float', 'import', 'io', 'misc')
50+
exclude_tests = ('basics/builtin_override.py', 'basics/class_super_object.py', 'micropython/heapalloc.py')
5151

5252
output = []
5353

0 commit comments

Comments
 (0)