replace tsl map with unordered_dense

Co-authored-by: Lizze <danishreyjavik@outlook.com>
Signed-off-by: swurl <swurl@swurl.xyz>
This commit is contained in:
swurl
2025-05-15 23:15:58 -04:00
parent 1ec2bafc2a
commit ec9349f20e
22 changed files with 48 additions and 51 deletions

6
.gitmodules vendored
View File

@@ -13,9 +13,6 @@
[submodule "oaknut"]
path = externals/oaknut
url = https://git.eden-emu.dev/eden-emu/oaknut.git
[submodule "robin-map"]
path = externals/robin-map
url = https://git.eden-emu.dev/eden-emu/robin-map.git
[submodule "xbyak"]
path = externals/xbyak
url = https://git.eden-emu.dev/eden-emu/xbyak.git
@@ -25,3 +22,6 @@
[submodule "zydis"]
path = externals/zydis
url = https://git.eden-emu.dev/eden-emu/zydis.git
[submodule "unordered_dense"]
path = externals/unordered_dense
url = https://github.com/Lizzie841/unordered_dense.git

View File

@@ -135,18 +135,15 @@ if (DYNARMIC_USE_BUNDLED_EXTERNALS)
set(CMAKE_DISABLE_FIND_PACKAGE_fmt ON)
set(CMAKE_DISABLE_FIND_PACKAGE_mcl ON)
set(CMAKE_DISABLE_FIND_PACKAGE_oaknut ON)
set(CMAKE_DISABLE_FIND_PACKAGE_tsl-robin-map ON)
set(CMAKE_DISABLE_FIND_PACKAGE_unordered_dense ON)
set(CMAKE_DISABLE_FIND_PACKAGE_xbyak ON)
set(CMAKE_DISABLE_FIND_PACKAGE_Zydis ON)
endif()
# Ensure that robin-map `export`s
set(TSL_ROBIN_MAP_ENABLE_INSTALL ON)
find_package(Boost 1.57 REQUIRED)
find_package(fmt 9 CONFIG)
find_package(mcl 0.1.12 EXACT CONFIG)
find_package(tsl-robin-map CONFIG)
find_package(unordered_dense CONFIG)
if ("arm64" IN_LIST ARCHITECTURE OR DYNARMIC_TESTS)
find_package(oaknut 2.0.1 CONFIG)

View File

@@ -8,7 +8,7 @@ if (NOT @BUILD_SHARED_LIBS@)
find_dependency(Boost 1.57)
find_dependency(fmt 9)
find_dependency(mcl 0.1.12 EXACT)
find_dependency(tsl-robin-map)
find_dependency(unordered_dense)
if ("arm64" IN_LIST ARCHITECTURE)
find_dependency(oaknut 2.0.1)

View File

@@ -315,12 +315,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
### robin-map
### unordered_dense
```
MIT License
Copyright (c) 2017 Thibaut Goetghebuer-Planchon <tessil@gmx.com>
Copyright (c) 2022 Martin Leitner-Ankerl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -56,10 +56,11 @@ if (NOT TARGET merry::oaknut)
endif()
endif()
# robin-map
# unordered_dense
if (NOT TARGET tsl::robin_map)
add_subdirectory(robin-map)
if (NOT TARGET ankerl::unordered_dense)
set(UNORDERED_DENSE_INSTALL ON)
add_subdirectory(unordered_dense)
endif()
# xbyak

1
externals/robin-map vendored

Submodule externals/robin-map deleted from 054ec5ad67

1
externals/unordered_dense vendored Submodule

View File

@@ -506,7 +506,7 @@ target_link_libraries(dynarmic
Boost::boost
fmt::fmt
merry::mcl
tsl::robin_map
unordered_dense::unordered_dense
)
if (DYNARMIC_USE_LLVM)
target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS})

View File

@@ -70,7 +70,7 @@ CodePtr AddressSpace::GetOrEmit(IR::LocationDescriptor descriptor) {
return block_info.entry_point;
}
void AddressSpace::InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& descriptors) {
void AddressSpace::InvalidateBasicBlocks(const ankerl::unordered_dense::set<IR::LocationDescriptor>& descriptors) {
UnprotectCodeMemory();
for (const auto& descriptor : descriptors) {

View File

@@ -11,8 +11,7 @@
#include <mcl/stdint.hpp>
#include <oaknut/code_block.hpp>
#include <oaknut/oaknut.hpp>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/arm64/emit_arm64.h"
#include "dynarmic/backend/arm64/fastmem.h"
@@ -39,7 +38,7 @@ public:
CodePtr GetOrEmit(IR::LocationDescriptor descriptor);
void InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& descriptors);
void InvalidateBasicBlocks(const ankerl::unordered_dense::set<IR::LocationDescriptor>& descriptors);
void ClearCache();
@@ -75,10 +74,10 @@ protected:
// A IR::LocationDescriptor will have one current CodePtr.
// However, there can be multiple other CodePtrs which are older, previously invalidated blocks.
tsl::robin_map<IR::LocationDescriptor, CodePtr> block_entries;
std::map<CodePtr, IR::LocationDescriptor> reverse_block_entries;
tsl::robin_map<CodePtr, EmittedBlockInfo> block_infos;
tsl::robin_map<IR::LocationDescriptor, tsl::robin_set<CodePtr>> block_references;
ankerl::unordered_dense::map<IR::LocationDescriptor, CodePtr> block_entries;
ankerl::unordered_dense::map<CodePtr, EmittedBlockInfo> block_infos;
ankerl::unordered_dense::map<IR::LocationDescriptor, ankerl::unordered_dense::set<CodePtr>> block_references;
ExceptionHandler exception_handler;
FastmemManager fastmem_manager;

View File

@@ -11,7 +11,7 @@
#include <vector>
#include <mcl/stdint.hpp>
#include <tsl/robin_map.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/arm64/fastmem.h"
#include "dynarmic/interface/A32/coprocessor.h"
@@ -102,8 +102,8 @@ struct EmittedBlockInfo {
CodePtr entry_point;
size_t size;
std::vector<Relocation> relocations;
tsl::robin_map<IR::LocationDescriptor, std::vector<BlockRelocation>> block_relocations;
tsl::robin_map<std::ptrdiff_t, FastmemPatchInfo> fastmem_patch_info;
ankerl::unordered_dense::map<IR::LocationDescriptor, std::vector<BlockRelocation>> block_relocations;
ankerl::unordered_dense::map<std::ptrdiff_t, FastmemPatchInfo> fastmem_patch_info;
};
struct EmitConfig {

View File

@@ -10,7 +10,7 @@
#include <mcl/hash/xmrx.hpp>
#include <mcl/stdint.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/exception_handler.h"
#include "dynarmic/ir/location_descriptor.h"
@@ -50,7 +50,7 @@ public:
private:
ExceptionHandler& exception_handler;
tsl::robin_set<DoNotFastmemMarker, DoNotFastmemMarkerHash> do_not_fastmem;
ankerl::unordered_dense::set<DoNotFastmemMarker, DoNotFastmemMarkerHash> do_not_fastmem;
};
} // namespace Dynarmic::Backend::Arm64

View File

@@ -15,7 +15,7 @@
#include <mcl/stdint.hpp>
#include <mcl/type_traits/is_instance_of_template.hpp>
#include <oaknut/oaknut.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/arm64/stack_layout.h"
#include "dynarmic/ir/cond.h"
@@ -335,7 +335,7 @@ private:
mutable std::mt19937 rand_gen;
tsl::robin_set<const IR::Inst*> defined_insts;
ankerl::unordered_dense::set<const IR::Inst*> defined_insts;
};
template<typename T>

View File

@@ -8,7 +8,7 @@
#include <boost/icl/interval_map.hpp>
#include <boost/icl/interval_set.hpp>
#include <mcl/stdint.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
namespace Dynarmic::Backend {
@@ -23,8 +23,8 @@ void BlockRangeInformation<ProgramCounterType>::ClearCache() {
}
template<typename ProgramCounterType>
tsl::robin_set<IR::LocationDescriptor> BlockRangeInformation<ProgramCounterType>::InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges) {
tsl::robin_set<IR::LocationDescriptor> erase_locations;
ankerl::unordered_dense::set<IR::LocationDescriptor> BlockRangeInformation<ProgramCounterType>::InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges) {
ankerl::unordered_dense::set<IR::LocationDescriptor> erase_locations;
for (auto invalidate_interval : ranges) {
auto pair = block_ranges.equal_range(invalidate_interval);
for (auto it = pair.first; it != pair.second; ++it) {

View File

@@ -9,7 +9,7 @@
#include <boost/icl/interval_map.hpp>
#include <boost/icl/interval_set.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/ir/location_descriptor.h"
@@ -20,7 +20,7 @@ class BlockRangeInformation {
public:
void AddRange(boost::icl::discrete_interval<ProgramCounterType> range, IR::LocationDescriptor location);
void ClearCache();
tsl::robin_set<IR::LocationDescriptor> InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges);
ankerl::unordered_dense::set<IR::LocationDescriptor> InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges);
private:
boost::icl::interval_map<ProgramCounterType, std::set<IR::LocationDescriptor>> block_ranges;

View File

@@ -6,7 +6,7 @@
#pragma once
#include <biscuit/assembler.hpp>
#include <tsl/robin_map.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/riscv64/code_block.h"
#include "dynarmic/backend/riscv64/emit_riscv64.h"
@@ -71,8 +71,8 @@ private:
CodeBlock cb;
biscuit::Assembler as;
tsl::robin_map<u64, CodePtr> block_entries;
tsl::robin_map<u64, EmittedBlockInfo> block_infos;
ankerl::unordered_dense::map<u64, CodePtr> block_entries;
ankerl::unordered_dense::map<u64, EmittedBlockInfo> block_infos;
struct PreludeInfo {
CodePtr end_of_prelude;

View File

@@ -16,7 +16,7 @@
#include <mcl/assert.hpp>
#include <mcl/stdint.hpp>
#include <mcl/type_traits/is_instance_of_template.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/riscv64/stack_layout.h"
#include "dynarmic/ir/cond.h"

View File

@@ -10,7 +10,7 @@
#include <set>
#include <tuple>
#include <tsl/robin_map.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/block_range_information.h"
#include "dynarmic/backend/x64/a32_jitstate.h"
@@ -104,7 +104,7 @@ protected:
DoNotFastmemMarker marker;
bool recompile;
};
tsl::robin_map<u64, FastmemPatchInfo> fastmem_patch_info;
ankerl::unordered_dense::map<u64, FastmemPatchInfo> fastmem_patch_info;
std::set<DoNotFastmemMarker> do_not_fastmem;
std::optional<DoNotFastmemMarker> ShouldFastmem(A32EmitContext& ctx, IR::Inst* inst) const;
FakeCall FastmemCallback(u64 rip);

View File

@@ -9,6 +9,7 @@
#include <map>
#include <optional>
#include <tuple>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/block_range_information.h"
#include "dynarmic/backend/x64/a64_jitstate.h"
@@ -102,7 +103,7 @@ protected:
DoNotFastmemMarker marker;
bool recompile;
};
tsl::robin_map<u64, FastmemPatchInfo> fastmem_patch_info;
ankerl::unordered_dense::map<u64, FastmemPatchInfo> fastmem_patch_info;
std::set<DoNotFastmemMarker> do_not_fastmem;
std::optional<DoNotFastmemMarker> ShouldFastmem(A64EmitContext& ctx, IR::Inst* inst) const;
FakeCall FastmemCallback(u64 rip);

View File

@@ -11,7 +11,7 @@
#include <utility>
#include <mcl/stdint.hpp>
#include <tsl/robin_map.h>
#include <ankerl/unordered_dense.h>
#include <xbyak/xbyak.h>
namespace Dynarmic::Backend::X64 {
@@ -40,7 +40,7 @@ private:
}
};
tsl::robin_map<ConstantT, void*, ConstantHash> constant_info;
ankerl::unordered_dense::map<ConstantT, void*, ConstantHash> constant_info;
BlockOfCode& code;
std::span<ConstantT> pool;

View File

@@ -11,7 +11,7 @@
#include <mcl/bit/bit_field.hpp>
#include <mcl/scope_exit.hpp>
#include <mcl/stdint.hpp>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include "dynarmic/backend/x64/block_of_code.h"
#include "dynarmic/backend/x64/nzcv_util.h"
@@ -394,7 +394,7 @@ void EmitX64::ClearCache() {
PerfMapClear();
}
void EmitX64::InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& locations) {
void EmitX64::InvalidateBasicBlocks(const ankerl::unordered_dense::set<IR::LocationDescriptor>& locations) {
code.EnableWriting();
SCOPE_EXIT {
code.DisableWriting();

View File

@@ -14,8 +14,7 @@
#include <vector>
#include <mcl/bitsizeof.hpp>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <ankerl/unordered_dense.h>
#include <xbyak/xbyak.h>
#include <xbyak/xbyak_util.h>
@@ -88,7 +87,7 @@ public:
virtual void ClearCache();
/// Invalidates a selection of basic blocks.
void InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& locations);
void InvalidateBasicBlocks(const ankerl::unordered_dense::set<IR::LocationDescriptor>& locations);
protected:
// Microinstruction emitters
@@ -138,8 +137,8 @@ protected:
// State
BlockOfCode& code;
ExceptionHandler exception_handler;
tsl::robin_map<IR::LocationDescriptor, BlockDescriptor> block_descriptors;
tsl::robin_map<IR::LocationDescriptor, PatchInformation> patch_information;
ankerl::unordered_dense::map<IR::LocationDescriptor, BlockDescriptor> block_descriptors;
ankerl::unordered_dense::map<IR::LocationDescriptor, PatchInformation> patch_information;
};
} // namespace Dynarmic::Backend::X64