mirror of
https://github.com/libretro/parallel-n64.git
synced 2026-11-07 12:37:50 -10:00
r4300: hash TLB pages with libretro-common's xxh3
TLBWrite hashes a page's code before unmapping it and again after the remap, so a page that maps the same code keeps it compiled. That hash now comes from libretro-common's encoding_xxh3 (synced from RetroArch) rather than the xxHash single header inlined into both interpreters' translation units, which goes away with its include path.
This commit is contained in:
1 parent
4d4ea6f6ca
commit
2a22f81f97
7 files changed
+1404
-6782
No files matched your search
@@ -1480,11 +1480,12 @@ test_fpu_compare$(EXE_EXT): tools/test_fpu_compare.c
|
||||
$^ -o $@ $(CHECK_LDFLAGS) $(CHECK_SANITIZE) -lm
|
||||
|
||||
TEST_R4300_INTERP_SRCS := $(CORE_DEVICE_DIR)/r4300/cp0.c $(CORE_DEVICE_DIR)/r4300/interrupt.c \
|
||||
$(CORE_DEVICE_DIR)/r4300/cp1.c $(CORE_DEVICE_DIR)/r4300/idec.c
|
||||
$(CORE_DEVICE_DIR)/r4300/cp1.c $(CORE_DEVICE_DIR)/r4300/idec.c \
|
||||
$(LIBRETRO_COMM_DIR)/encodings/encoding_xxh3.c $(LIBRETRO_COMM_DIR)/features/features_cpu.c
|
||||
test_r4300_interp$(EXE_EXT): tools/test_r4300_interp.c $(CORE_DEVICE_DIR)/r4300/pure_interp.c \
|
||||
$(CORE_DEVICE_DIR)/r4300/mips_instructions.def $(TEST_R4300_INTERP_SRCS)
|
||||
$(CC) $(CHECK_CFLAGS) $(CHECK_SANITIZE) -I$(CORE_DIR)/src -I$(CORE_DIR)/src/api \
|
||||
-I$(CORE_DIR)/custom -I$(CORE_DIR)/subprojects/xxhash -I$(LIBRETRO_COMM_DIR)/include -I$(ROOT_DIR)/libretro \
|
||||
-I$(CORE_DIR)/custom -I$(LIBRETRO_COMM_DIR)/include -I$(ROOT_DIR)/libretro \
|
||||
$< $(TEST_R4300_INTERP_SRCS) -o $@ $(CHECK_LDFLAGS) $(CHECK_SANITIZE) -lm
|
||||
|
||||
TEST_PI_SRCS := $(CORE_DEVICE_DIR)/rcp/pi/pi_controller.c $(CORE_DEVICE_DIR)/rcp/mi/mi_controller.c
|
||||
|
||||
+1
-1
@@ -49,7 +49,6 @@ INCFLAGS += \
|
||||
-I$(CORE_DIR)/src/api \
|
||||
-I$(CORE_DIR)/custom \
|
||||
-I$(CORE_DIR)/subprojects/md5 \
|
||||
-I$(CORE_DIR)/subprojects/xxhash \
|
||||
-I$(ROOT_DIR)/include \
|
||||
-I$(AUDIO_LIBRETRO_DIR) \
|
||||
-I$(LIBRETRO_COMM_DIR)/include \
|
||||
@@ -315,6 +314,7 @@ SOURCES_C += $(LIBRETRO_DIR)/libretro.c \
|
||||
$(CORE_DIR)/src/plugin/emulate_game_controller_via_libretro.c \
|
||||
$(LIBRETRO_COMM_DIR)/memmap/memalign.c \
|
||||
$(LIBRETRO_COMM_DIR)/encodings/encoding_crc32.c \
|
||||
$(LIBRETRO_COMM_DIR)/encodings/encoding_xxh3.c \
|
||||
$(LIBRETRO_COMM_DIR)/encodings/encoding_deflate.c \
|
||||
$(LIBRETRO_COMM_DIR)/formats/zip/rzip_archive.c \
|
||||
$(LIBRETRO_COMM_DIR)/formats/7z/r7z_archive.c \
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,89 @@
|
||||
/* Copyright (C) 2010-2026 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (xxh3.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _LIBRETRO_ENCODINGS_XXH3_H
|
||||
#define _LIBRETRO_ENCODINGS_XXH3_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* xxh3_64:
|
||||
* @data : the octets
|
||||
* @len : how many
|
||||
* @seed : the seed; 0 is the unseeded hash
|
||||
*
|
||||
* The 64-bit XXH3 of @data, as xxHash specifies it (XXH3_64bits and
|
||||
* XXH3_64bits_withSeed), with its default secret. Inputs over 240
|
||||
* octets go through AVX-512, AVX2 or SSE2 where the CPU has them,
|
||||
* chosen once, or NEON; the value is the same every way and on every
|
||||
* host.
|
||||
*
|
||||
* Returns: the hash.
|
||||
*/
|
||||
uint64_t xxh3_64(const void *data, size_t len, uint64_t seed);
|
||||
|
||||
/* The same hash taken over pieces handed to it one after another,
|
||||
* XXH3_64bits_update() and its digest. Pieces are taken where they lie
|
||||
* a 64-octet stripe at a time; at most 1024 octets are held between
|
||||
* calls, after the last stripe taken. */
|
||||
typedef struct xxh3_state
|
||||
{
|
||||
uint64_t acc[8]; /* the accumulators */
|
||||
uint64_t total; /* octets taken */
|
||||
uint64_t seed;
|
||||
uint8_t sec[192]; /* the seeded secret, with a seed */
|
||||
uint8_t buf[64 + 1024]; /* the last stripe taken, then what is held */
|
||||
uint32_t held; /* how much is held */
|
||||
unsigned pos; /* the next stripe's place in its block */
|
||||
/* what takes the pieces past what is held, on this CPU's path */
|
||||
void (*take)(struct xxh3_state *s, const uint8_t *p, size_t len);
|
||||
} xxh3_state_t;
|
||||
|
||||
/**
|
||||
* xxh3_reset:
|
||||
*
|
||||
* Starts @s over with @seed: nothing taken yet.
|
||||
*/
|
||||
void xxh3_reset(xxh3_state_t *s, uint64_t seed);
|
||||
|
||||
/**
|
||||
* xxh3_update:
|
||||
*
|
||||
* Takes @len more octets at @data, which may be any length.
|
||||
*/
|
||||
void xxh3_update(xxh3_state_t *s, const void *data, size_t len);
|
||||
|
||||
/**
|
||||
* xxh3_digest:
|
||||
*
|
||||
* Returns: xxh3_64() of what @s has taken, which may go on taking more.
|
||||
*/
|
||||
uint64_t xxh3_digest(const xxh3_state_t *s);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -743,6 +743,7 @@
|
||||
<ClCompile Include="..\..\..\libretro-common\libco\libco.c" />
|
||||
<ClCompile Include="..\..\..\libretro-common\memmap\memalign.c" />
|
||||
<ClCompile Include="..\..\..\libretro-common\encodings\encoding_crc32.c" />
|
||||
<ClCompile Include="..\..\..\libretro-common\encodings\encoding_xxh3.c" />
|
||||
<ClCompile Include="..\..\..\libretro-common\streams\file_stream.c" />
|
||||
<ClCompile Include="..\..\..\mupen64plus-core\src\ai\ai_controller.c">
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsC</CompileAs>
|
||||
|
||||
@@ -58,8 +58,7 @@
|
||||
#include "device/rdram/rdram.h"
|
||||
#include "osal/preproc.h"
|
||||
|
||||
#define XXH_INLINE_ALL
|
||||
#include <xxhash.h>
|
||||
#include <encodings/xxh3.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
@@ -1221,7 +1220,7 @@ static void TLBWrite(struct r4300_core* r4300, unsigned int idx)
|
||||
}
|
||||
if (!r4300->cached_interp.invalid_code[i])
|
||||
{
|
||||
r4300->cached_interp.blocks[i]->xxhash = XXH3_64bits(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000);
|
||||
r4300->cached_interp.blocks[i]->xxhash = xxh3_64(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000, 0);
|
||||
r4300->cached_interp.invalid_code[i] = 1;
|
||||
}
|
||||
else if (r4300->cached_interp.blocks[i])
|
||||
@@ -1240,7 +1239,7 @@ static void TLBWrite(struct r4300_core* r4300, unsigned int idx)
|
||||
}
|
||||
if (!r4300->cached_interp.invalid_code[i])
|
||||
{
|
||||
r4300->cached_interp.blocks[i]->xxhash = XXH3_64bits(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000);
|
||||
r4300->cached_interp.blocks[i]->xxhash = xxh3_64(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000, 0);
|
||||
r4300->cached_interp.invalid_code[i] = 1;
|
||||
}
|
||||
else if (r4300->cached_interp.blocks[i])
|
||||
@@ -1289,7 +1288,7 @@ static void TLBWrite(struct r4300_core* r4300, unsigned int idx)
|
||||
{
|
||||
if(r4300->cached_interp.blocks[i] && r4300->cached_interp.blocks[i]->xxhash)
|
||||
{
|
||||
if(r4300->cached_interp.blocks[i]->xxhash == XXH3_64bits(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000)) {
|
||||
if(r4300->cached_interp.blocks[i]->xxhash == xxh3_64(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000, 0)) {
|
||||
r4300->cached_interp.invalid_code[i] = 0;
|
||||
}
|
||||
}
|
||||
@@ -1302,7 +1301,7 @@ static void TLBWrite(struct r4300_core* r4300, unsigned int idx)
|
||||
{
|
||||
if(r4300->cached_interp.blocks[i] && r4300->cached_interp.blocks[i]->xxhash)
|
||||
{
|
||||
if(r4300->cached_interp.blocks[i]->xxhash == XXH3_64bits(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000)) {
|
||||
if(r4300->cached_interp.blocks[i]->xxhash == xxh3_64(&r4300->rdram->dram[(r4300->cp0.tlb.LUT_r[i]&0x7FF000)/4], 0x1000, 0)) {
|
||||
r4300->cached_interp.invalid_code[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user