Skip to content

Commit feca1de

Browse files
committed
Allocate runtime memory based on scenarios
Previously, the emulator was configured to allocate 4 GiB of memory during initialization, which made it unsuitable for environments with limited memory, such as a virtualized Linux guest configured with 4 GiB. This commit adjusts the memory mapping requirement to 2^{19} bytes, sufficient for all known benchmarks. For configurations with SDL enabled, which support video games like Doom and Quake, the memory allocation is increased to 4 GiB. We should develop an adaptive memory mapping mechanism to address this issue effectively, rather than relying solely on static memory mapping during initialization. Reported by ztex <[email protected]> and Yen-Fu Chen <[email protected]>. Close #448
1 parent e804bff commit feca1de

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ $(call set-feature, SDL)
9898
ifeq ($(call has, SDL), 1)
9999
OBJS_EXT += syscall_sdl.o
100100
$(OUT)/syscall_sdl.o: CFLAGS += $(shell sdl2-config --cflags)
101+
# 4 GiB of memory is required to run video games.
102+
$(OUT)/main.o: CFLAGS += -DMEM_SIZE=0xFFFFFFFFULL # 2^{32} - 1
101103
LDFLAGS += $(shell sdl2-config --libs) -pthread
102104
LDFLAGS += $(shell pkg-config --libs SDL2_mixer)
103105
endif

src/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ static void dump_test_signature(const char *prog_name)
172172
#ifndef CYCLE_PER_STEP
173173
#define CYCLE_PER_STEP 100
174174
#endif
175-
/* MEM_SIZE shall be defined on different runtime */
175+
/* FIXME: MEM_SIZE shall be defined on different runtime */
176176
#ifndef MEM_SIZE
177-
#define MEM_SIZE 0xFFFFFFFFULL /* 2^32 - 1 */
177+
/* Allocate 2^{19} - 1 bytes, which is ample for all known benchmarks. */
178+
#define MEM_SIZE 0x80000
178179
#endif
179180
#define STACK_SIZE 0x1000 /* 4096 */
180181
#define ARGS_OFFSET_SIZE 0x1000 /* 4096 */

0 commit comments

Comments
 (0)