Map a 8 MiB code buffer at (base + 0x80.0000), right after the emulated
RAM. In this code buffer, Lightrec will write the recompiled code for
the host machine.
In general, the code buffer support is very useful when the host
platform has only a small RW+X memory area available for JIT purposes,
like it's the case on the WiiU.
On Linux, this isn't a concern, but having a code buffer does still
bring a benefit: if both the start address and the end address of the
code buffer's address fit in 32 bits, then Lightrec's code LUT can be
shrunk in half (2.5 MiB instead of 5 MiB), as it only needs to store
32-bit pointers.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
deps/lightning/lib/%.o: CFLAGS += -DHAVE_MMAP
ifeq ($(LIGHTREC_CUSTOM_MAP),1)
LDLIBS += -lrt
deps/lightning/lib/%.o: CFLAGS += -DHAVE_MMAP
ifeq ($(LIGHTREC_CUSTOM_MAP),1)
LDLIBS += -lrt
-OBJS += libpcsxcore/lightrec/mem.o
+OBJS += libpcsxcore/lightrec/mem.o deps/lightrec/tlsf/tlsf.o
endif
OBJS += libpcsxcore/lightrec/plugin.o
OBJS += deps/lightning/lib/jit_disasm.o \
endif
OBJS += libpcsxcore/lightrec/plugin.o
OBJS += deps/lightning/lib/jit_disasm.o \
#define ENABLE_THREADED_COMPILER 1
#define ENABLE_FIRST_PASS 1
#define ENABLE_DISASSEMBLER 0
#define ENABLE_THREADED_COMPILER 1
#define ENABLE_FIRST_PASS 1
#define ENABLE_DISASSEMBLER 0
-#define ENABLE_TINYMM 0
-#define ENABLE_CODE_BUFFER 0
+#define ENABLE_CODE_BUFFER 1
#define HAS_DEFAULT_ELM 1
#define HAS_DEFAULT_ELM 1
#define MFD_HUGETLB 0x0004
#endif
#define MFD_HUGETLB 0x0004
#endif
static const uintptr_t supported_io_bases[] = {
0x0,
0x10000000,
static const uintptr_t supported_io_bases[] = {
0x0,
0x10000000,
+ map = mmap_huge((void *)(base + 0x800000), CODE_BUFFER_SIZE,
+ PROT_EXEC | PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS,
+ 0, 0);
+ if (map == MAP_FAILED) {
+ err = -EINVAL;
+ fprintf(stderr, "Unable to mmap code buffer\n");
+ goto err_unmap_scratch;
+ }
+
+ code_buffer = map;
+
+err_unmap_scratch:
+ munmap(psxH, 0x10000);
err_unmap_bios:
munmap(psxR, 0x80000);
err_unmap_parallel:
err_unmap_bios:
munmap(psxR, 0x80000);
err_unmap_parallel:
+ munmap(code_buffer, CODE_BUFFER_SIZE);
munmap(psxH, 0x10000);
munmap(psxR, 0x80000);
munmap(psxP, 0x10000);
munmap(psxH, 0x10000);
munmap(psxR, 0x80000);
munmap(psxP, 0x10000);
#ifndef __LIGHTREC_MEM_H__
#define __LIGHTREC_MEM_H__
#ifndef __LIGHTREC_MEM_H__
#define __LIGHTREC_MEM_H__
+#define CODE_BUFFER_SIZE (8 * 1024 * 1024)
+
+extern void *code_buffer;
+
int lightrec_init_mmap(void);
void lightrec_free_mmap(void);
int lightrec_init_mmap(void);
void lightrec_free_mmap(void);
#include "../frontend/main.h"
#include "../frontend/main.h"
#if (defined(__arm__) || defined(__aarch64__)) && !defined(ALLOW_LIGHTREC_ON_ARM)
#error "Lightrec should not be used on ARM (please specify DYNAREC=ari64 to make)"
#endif
#if (defined(__arm__) || defined(__aarch64__)) && !defined(ALLOW_LIGHTREC_ON_ARM)
#error "Lightrec should not be used on ARM (please specify DYNAREC=ari64 to make)"
#endif
.length = 0x200000,
.mirror_of = &lightrec_map[PSX_MAP_KERNEL_USER_RAM],
},
.length = 0x200000,
.mirror_of = &lightrec_map[PSX_MAP_KERNEL_USER_RAM],
},
+ [PSX_MAP_CODE_BUFFER] = {
+ .length = CODE_BUFFER_SIZE,
+ },
};
static void lightrec_enable_ram(struct lightrec_state *state, bool enable)
};
static void lightrec_enable_ram(struct lightrec_state *state, bool enable)
lightrec_map[PSX_MAP_MIRROR1].address = psxM + 0x200000;
lightrec_map[PSX_MAP_MIRROR2].address = psxM + 0x400000;
lightrec_map[PSX_MAP_MIRROR3].address = psxM + 0x600000;
lightrec_map[PSX_MAP_MIRROR1].address = psxM + 0x200000;
lightrec_map[PSX_MAP_MIRROR2].address = psxM + 0x400000;
lightrec_map[PSX_MAP_MIRROR3].address = psxM + 0x600000;
+ lightrec_map[PSX_MAP_CODE_BUFFER].address = code_buffer;
}
lightrec_debug = !!getenv("LIGHTREC_DEBUG");
}
lightrec_debug = !!getenv("LIGHTREC_DEBUG");