PowerPC: Rework CPUThreadGuard handling in Expression.cpp
See https://github.com/dolphin-emu/dolphin/pull/11554#discussion_r1113949572.
This commit is contained in:
parent
f682225c15
commit
ae5311d6e6
|
@ -81,9 +81,10 @@ static double HostReadFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||||
{
|
{
|
||||||
if (vec_len(args) != 1)
|
if (vec_len(args) != 1)
|
||||||
return 0;
|
return 0;
|
||||||
const auto* guard = reinterpret_cast<const Core::CPUThreadGuard*>(c);
|
|
||||||
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 0)));
|
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 0)));
|
||||||
return Common::BitCast<T>(HostRead<U>(*guard, address));
|
|
||||||
|
Core::CPUThreadGuard guard;
|
||||||
|
return Common::BitCast<T>(HostRead<U>(guard, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U = T>
|
template <typename T, typename U = T>
|
||||||
|
@ -91,10 +92,11 @@ static double HostWriteFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||||
{
|
{
|
||||||
if (vec_len(args) != 2)
|
if (vec_len(args) != 2)
|
||||||
return 0;
|
return 0;
|
||||||
const auto* guard = reinterpret_cast<const Core::CPUThreadGuard*>(c);
|
|
||||||
const T var = static_cast<T>(expr_eval(&vec_nth(args, 0)));
|
const T var = static_cast<T>(expr_eval(&vec_nth(args, 0)));
|
||||||
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 1)));
|
const u32 address = static_cast<u32>(expr_eval(&vec_nth(args, 1)));
|
||||||
HostWrite<U>(*guard, Common::BitCast<U>(var), address);
|
|
||||||
|
Core::CPUThreadGuard guard;
|
||||||
|
HostWrite<U>(guard, Common::BitCast<U>(var), address);
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,10 +114,12 @@ static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
||||||
const auto* guard = reinterpret_cast<const Core::CPUThreadGuard*>(c);
|
{
|
||||||
bool success = Dolphin_Debugger::GetCallstack(Core::System::GetInstance(), *guard, stack);
|
Core::CPUThreadGuard guard;
|
||||||
if (!success)
|
bool success = Dolphin_Debugger::GetCallstack(Core::System::GetInstance(), guard, stack);
|
||||||
return 0;
|
if (!success)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
double num = expr_eval(&vec_nth(args, 0));
|
double num = expr_eval(&vec_nth(args, 0));
|
||||||
if (!std::isnan(num))
|
if (!std::isnan(num))
|
||||||
|
@ -158,11 +162,11 @@ static double StreqFunc(expr_func* f, vec_expr_t* args, void* c)
|
||||||
if (vec_len(args) != 2)
|
if (vec_len(args) != 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const auto* guard = reinterpret_cast<const Core::CPUThreadGuard*>(c);
|
|
||||||
std::array<std::string, 2> strs;
|
std::array<std::string, 2> strs;
|
||||||
|
Core::CPUThreadGuard guard;
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
std::optional<std::string> arg = ReadStringArg(*guard, &vec_nth(args, i));
|
std::optional<std::string> arg = ReadStringArg(guard, &vec_nth(args, i));
|
||||||
if (arg == std::nullopt)
|
if (arg == std::nullopt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -266,13 +270,7 @@ double Expression::Evaluate() const
|
||||||
{
|
{
|
||||||
SynchronizeBindings(SynchronizeDirection::From);
|
SynchronizeBindings(SynchronizeDirection::From);
|
||||||
|
|
||||||
double result;
|
double result = expr_eval(m_expr.get());
|
||||||
{
|
|
||||||
Core::CPUThreadGuard guard;
|
|
||||||
m_expr->param.func.context = &guard;
|
|
||||||
result = expr_eval(m_expr.get());
|
|
||||||
m_expr->param.func.context = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SynchronizeBindings(SynchronizeDirection::To);
|
SynchronizeBindings(SynchronizeDirection::To);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue