m68kmac: Proper gc collection, perhaps.

Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit is contained in:
Jeff Epler 2025-06-26 17:14:55 +02:00
parent 235752869c
commit 40e171a72c
5 changed files with 50 additions and 7 deletions

View file

@ -41,7 +41,7 @@ SRC_C = \
SRC_C += \ SRC_C += \
$(BUILD)/_frozen_mpy.c \ $(BUILD)/_frozen_mpy.c \
shared/runtime/stdout_helpers.c \ shared/runtime/stdout_helpers.c \
shared/runtime/gchelper_generic.c \ shared/runtime/gchelper_native.c \
shared/readline/readline.c \ shared/readline/readline.c \
shared/runtime/pyexec.c \ shared/runtime/pyexec.c \
@ -51,15 +51,15 @@ SRC_CXX += \
retro/ConsoleWindow.cpp \ retro/ConsoleWindow.cpp \
retro/InitConsole.cpp \ retro/InitConsole.cpp \
# shared/libc/printf.c \ SRC_S += \
shared/runtime/gchelper_m68k.S \
#SRC_C += shared/libc/string0.c
SRC_QSTR += shared/readline/readline.c shared/runtime/pyexec.c SRC_QSTR += shared/readline/readline.c shared/runtime/pyexec.c
OBJ += $(PY_CORE_O) OBJ += $(PY_CORE_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.S=.o))
all: $(BUILD)/micropython.bin all: $(BUILD)/micropython.bin

View file

@ -18,9 +18,9 @@ To run the executable and get a basic working REPL do:
## Key TODOs ## Key TODOs
* Correctly implement GC collection (stack + registers) * Correctly implement stack checking
* Add Mac API support (e.g., quickdraw, arbitrary traps) * Add Mac API support (e.g., quickdraw, arbitrary traps)
* Add filesystem access * Add filesystem access
* Add the ability to run python scripts in files * Add the ability to run python scripts in files
* Support larger heap * Support larger heap (via split heap?)
* Address GPL files (RetroConsole), GitHub Actions CI, and other issues that might prevent upstream inclusion. * Address GPL files (RetroConsole), GitHub Actions CI, and other issues that might prevent upstream inclusion.

View file

@ -14,7 +14,6 @@
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool #define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_GC (1)
#define MICROPY_GCREGS_SETJMP (1)
#define MICROPY_HELPER_REPL (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_MODULE_FROZEN_MPY (1) #define MICROPY_MODULE_FROZEN_MPY (1)
#define MICROPY_ENABLE_EXTERNAL_IMPORT (1) #define MICROPY_ENABLE_EXTERNAL_IMPORT (1)

View file

@ -43,6 +43,8 @@ typedef uintptr_t gc_helper_regs_t[10];
typedef uintptr_t gc_helper_regs_t[11]; // x19-x29 typedef uintptr_t gc_helper_regs_t[11]; // x19-x29
#elif defined(__riscv) && (__riscv_xlen <= 64) #elif defined(__riscv) && (__riscv_xlen <= 64)
typedef uintptr_t gc_helper_regs_t[12]; // S0-S11 typedef uintptr_t gc_helper_regs_t[12]; // S0-S11
#elif defined(__m68k__)
typedef uintptr_t gc_helper_regs_t[8]; // a0-a4/d3-d7
#endif #endif
#endif #endif

View file

@ -0,0 +1,42 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2024 Alessandro Gatti
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
.global gc_helper_get_regs_and_sp
.type gc_helper_get_regs_and_sp, @function
gc_helper_get_regs_and_sp:
/* Store registers into the given array. */
move.w 4(%sp),%a0
movem.l (%a0)+, %a2-%a4/%d3-%d7
/* Return the stack pointer. */
move %d0, %sp
rts
.size gc_helper_get_regs_and_sp, .-gc_helper_get_regs_and_sp