[ARM] Start using mmap'ed JIT caches for most builds

Will revisit remaining platforms and try to clean them too.
This should fix Android once and for all.
This commit is contained in:
David Guillen Fandos 2021-10-29 22:51:39 +02:00
parent 5c1467cb63
commit c39f5391f0
4 changed files with 9 additions and 12 deletions

View File

@ -257,6 +257,7 @@ else ifeq ($(platform), rpi3)
CFLAGS += -fomit-frame-pointer -ffast-math CFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CPU_ARCH := arm CPU_ARCH := arm
HAVE_MMAP = 1
HAVE_DYNAREC = 1 HAVE_DYNAREC = 1
# Raspberry Pi 2 # Raspberry Pi 2
@ -268,6 +269,7 @@ else ifeq ($(platform), rpi2)
CFLAGS += -fomit-frame-pointer -ffast-math CFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CPU_ARCH := arm CPU_ARCH := arm
HAVE_MMAP = 1
HAVE_DYNAREC = 1 HAVE_DYNAREC = 1
# Raspberry Pi 1 # Raspberry Pi 1
@ -280,6 +282,7 @@ else ifeq ($(platform), rpi1)
CFLAGS += -fomit-frame-pointer -ffast-math CFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CPU_ARCH := arm CPU_ARCH := arm
HAVE_MMAP = 1
HAVE_DYNAREC = 1 HAVE_DYNAREC = 1
# Classic Platforms #################### # Classic Platforms ####################
@ -307,6 +310,7 @@ else ifeq ($(platform), classic_armv7_a7)
ARCH = arm ARCH = arm
BUILTIN_GPU = neon BUILTIN_GPU = neon
CPU_ARCH := arm CPU_ARCH := arm
HAVE_MMAP = 1
HAVE_DYNAREC = 1 HAVE_DYNAREC = 1
ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1)
CFLAGS += -march=armv7-a CFLAGS += -march=armv7-a
@ -348,6 +352,7 @@ else ifneq (,$(findstring armv,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so TARGET := $(TARGET_NAME)_libretro.so
SHARED := -shared -Wl,--version-script=link.T SHARED := -shared -Wl,--version-script=link.T
CPU_ARCH := arm CPU_ARCH := arm
HAVE_MMAP = 1
fpic := -fPIC fpic := -fPIC
ifneq (,$(findstring cortexa5,$(platform))) ifneq (,$(findstring cortexa5,$(platform)))
CFLAGS += -marm -mcpu=cortex-a5 CFLAGS += -marm -mcpu=cortex-a5

View File

@ -844,13 +844,7 @@ defsymbl(palette_ram_converted)
@ Make this section executable! @ Make this section executable!
.text .text
#ifdef __ANDROID__
@ Unfortunately Android builds don't like nobits, so we ship a ton of zeros
@ TODO: Revisit this whenever we upgrade to the latest clang NDK
.section .jit,"awx",%progbits
#else
.section .jit,"awx",%nobits .section .jit,"awx",%nobits
#endif
.align 4 .align 4
defsymbl(rom_translation_cache) defsymbl(rom_translation_cache)
.space ROM_TRANSLATION_CACHE_SIZE .space ROM_TRANSLATION_CACHE_SIZE

View File

@ -9,7 +9,7 @@ HAVE_DYNAREC :=
COREFLAGS := -DINLINE=inline -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565 COREFLAGS := -DINLINE=inline -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565
ifeq ($(TARGET_ARCH),arm) ifeq ($(TARGET_ARCH),arm)
COREFLAGS += -DARM_ARCH COREFLAGS += -DARM_ARCH -DHAVE_MMAP
CPU_ARCH := arm CPU_ARCH := arm
HAVE_DYNAREC := 1 HAVE_DYNAREC := 1
else ifeq ($(TARGET_ARCH),x86) else ifeq ($(TARGET_ARCH),x86)

View File

@ -459,10 +459,9 @@ void retro_init(void)
{ {
#if defined(HAVE_DYNAREC) #if defined(HAVE_DYNAREC)
#if defined(HAVE_MMAP) #if defined(HAVE_MMAP)
rom_translation_cache = mmap(NULL, ROM_TRANSLATION_CACHE_SIZE, rom_translation_cache = mmap(NULL, ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
ram_translation_cache = mmap(NULL, RAM_TRANSLATION_CACHE_SIZE,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
ram_translation_cache = &rom_translation_cache[ROM_TRANSLATION_CACHE_SIZE];
#elif defined(_3DS) #elif defined(_3DS)
if (__ctr_svchax && !translation_caches_inited) if (__ctr_svchax && !translation_caches_inited)
{ {
@ -550,8 +549,7 @@ void retro_deinit(void)
memory_term(); memory_term();
#if defined(HAVE_MMAP) && defined(HAVE_DYNAREC) #if defined(HAVE_MMAP) && defined(HAVE_DYNAREC)
munmap(rom_translation_cache, ROM_TRANSLATION_CACHE_SIZE); munmap(rom_translation_cache, ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE);
munmap(ram_translation_cache, RAM_TRANSLATION_CACHE_SIZE);
#endif #endif
#if defined(_3DS) && defined(HAVE_DYNAREC) #if defined(_3DS) && defined(HAVE_DYNAREC)