Use tsl::robin_map and tsl::robin_set

Replace std::unordered_map and std::unordered_set with the above.
Better performance profile.
This commit is contained in:
MerryMage 2020-05-21 21:31:18 +01:00
parent 91578edc69
commit 93c289b54f
10 changed files with 68 additions and 27 deletions

View file

@ -5,7 +5,6 @@
#include <algorithm>
#include <optional>
#include <unordered_map>
#include <utility>
#include <fmt/format.h>

View file

@ -9,7 +9,8 @@
#include <optional>
#include <set>
#include <tuple>
#include <unordered_map>
#include <tsl/robin_map.h>
#include <dynarmic/A32/a32.h>
#include <dynarmic/A32/config.h>
@ -91,7 +92,7 @@ protected:
u64 callback;
DoNotFastmemMarker marker;
};
std::unordered_map<u64, FastmemPatchInfo> fastmem_patch_info;
tsl::robin_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

@ -3,10 +3,9 @@
* SPDX-License-Identifier: 0BSD
*/
#include <unordered_set>
#include <boost/icl/interval_map.hpp>
#include <boost/icl/interval_set.hpp>
#include <tsl/robin_set.h>
#include "backend/x64/block_range_information.h"
#include "common/common_types.h"
@ -24,8 +23,8 @@ void BlockRangeInformation<ProgramCounterType>::ClearCache() {
}
template <typename ProgramCounterType>
std::unordered_set<IR::LocationDescriptor> BlockRangeInformation<ProgramCounterType>::InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges) {
std::unordered_set<IR::LocationDescriptor> erase_locations;
tsl::robin_set<IR::LocationDescriptor> BlockRangeInformation<ProgramCounterType>::InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges) {
tsl::robin_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

@ -6,10 +6,10 @@
#pragma once
#include <set>
#include <unordered_set>
#include <boost/icl/interval_map.hpp>
#include <boost/icl/interval_set.hpp>
#include <tsl/robin_set.h>
#include "frontend/ir/location_descriptor.h"
@ -20,7 +20,7 @@ class BlockRangeInformation {
public:
void AddRange(boost::icl::discrete_interval<ProgramCounterType> range, IR::LocationDescriptor location);
void ClearCache();
std::unordered_set<IR::LocationDescriptor> InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges);
tsl::robin_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

@ -4,7 +4,8 @@
*/
#include <iterator>
#include <unordered_map>
#include <tsl/robin_set.h>
#include "backend/x64/block_of_code.h"
#include "backend/x64/emit_x64.h"
@ -305,7 +306,7 @@ void EmitX64::ClearCache() {
PerfMapClear();
}
void EmitX64::InvalidateBasicBlocks(const std::unordered_set<IR::LocationDescriptor>& locations) {
void EmitX64::InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& locations) {
code.EnableWriting();
SCOPE_EXIT { code.DisableWriting(); };

View file

@ -9,10 +9,11 @@
#include <optional>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
#include <xbyak_util.h>
#include "backend/x64/exception_handler.h"
@ -69,7 +70,7 @@ public:
virtual void ClearCache();
/// Invalidates a selection of basic blocks.
void InvalidateBasicBlocks(const std::unordered_set<IR::LocationDescriptor>& locations);
void InvalidateBasicBlocks(const tsl::robin_set<IR::LocationDescriptor>& locations);
protected:
// Microinstruction emitters
@ -115,8 +116,8 @@ protected:
// State
BlockOfCode& code;
ExceptionHandler exception_handler;
std::unordered_map<IR::LocationDescriptor, BlockDescriptor> block_descriptors;
std::unordered_map<IR::LocationDescriptor, PatchInformation> patch_information;
tsl::robin_map<IR::LocationDescriptor, BlockDescriptor> block_descriptors;
tsl::robin_map<IR::LocationDescriptor, PatchInformation> patch_information;
};
} // namespace Dynarmic::Backend::X64