Compare commits

..

1 Commits

Author SHA1 Message Date
Lioncash
0797657bc0 gl_shader_decompiler: Remove redundant Subroutine construction in AddSubroutine()
We don't need to toss away the Subroutine instance after the find() call
and reconstruct another instance with the same data right after it.
Particularly give Subroutine contains a std::set.
2018-07-22 03:30:35 -04:00
4 changed files with 14 additions and 18 deletions

View File

@@ -86,9 +86,7 @@ public:
}
void AddTicks(u64 ticks) override {
if (parent.IsMainCore()) {
CoreTiming::AddTicks(ticks - num_interpreted_instructions);
}
CoreTiming::AddTicks(ticks - num_interpreted_instructions);
num_interpreted_instructions = 0;
}
u64 GetTicksRemaining() override {
@@ -130,9 +128,8 @@ void ARM_Dynarmic::Step() {
cb->InterpreterFallback(jit->GetPC(), 1);
}
ARM_Dynarmic::ARM_Dynarmic(size_t core_index)
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), jit(MakeJit(cb)),
core_index(core_index) {
ARM_Dynarmic::ARM_Dynarmic()
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), jit(MakeJit(cb)) {
ARM_Interface::ThreadContext ctx;
inner_unicorn.SaveContext(ctx);
LoadContext(ctx);

View File

@@ -14,7 +14,7 @@ class ARM_Dynarmic_Callbacks;
class ARM_Dynarmic final : public ARM_Interface {
public:
ARM_Dynarmic(size_t core_index);
ARM_Dynarmic();
~ARM_Dynarmic();
void MapBackingMemory(VAddr address, size_t size, u8* memory,
@@ -46,10 +46,6 @@ public:
void ClearInstructionCache() override;
void PageTableChanged() override;
const bool IsMainCore() const {
return core_index == 0;
}
private:
friend class ARM_Dynarmic_Callbacks;
std::unique_ptr<ARM_Dynarmic_Callbacks> cb;
@@ -57,5 +53,4 @@ private:
ARM_Unicorn inner_unicorn;
Memory::PageTable* current_page_table = nullptr;
size_t core_index;
};

View File

@@ -53,7 +53,7 @@ Cpu::Cpu(std::shared_ptr<CpuBarrier> cpu_barrier, size_t core_index)
if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64
arm_interface = std::make_shared<ARM_Dynarmic>(core_index);
arm_interface = std::make_shared<ARM_Dynarmic>();
#else
cpu_core = std::make_shared<ARM_Unicorn>();
LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");

View File

@@ -78,14 +78,18 @@ private:
/// Adds and analyzes a new subroutine if it is not added yet.
const Subroutine& AddSubroutine(u32 begin, u32 end, const std::string& suffix) {
auto iter = subroutines.find(Subroutine{begin, end, suffix});
if (iter != subroutines.end())
return *iter;
Subroutine subroutine{begin, end, suffix, ExitMethod::Undetermined, {}};
const auto iter = subroutines.find(subroutine);
if (iter != subroutines.end()) {
return *iter;
}
Subroutine subroutine{begin, end, suffix};
subroutine.exit_method = Scan(begin, end, subroutine.labels);
if (subroutine.exit_method == ExitMethod::Undetermined)
if (subroutine.exit_method == ExitMethod::Undetermined) {
throw DecompileFail("Recursive function detected");
}
return *subroutines.insert(std::move(subroutine)).first;
}