interface: Allow ClearCache to be called at any time
This commit is contained in:
parent
78f584c50a
commit
711b3e29d3
2 changed files with 21 additions and 5 deletions
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the code cache of all compiled code.
|
* Clears the code cache of all compiled code.
|
||||||
* Cannot be called from a callback.
|
* Can be called at any time. Halts execution if called within a callback.
|
||||||
*/
|
*/
|
||||||
void ClearCache();
|
void ClearCache();
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ struct Jit::Impl {
|
||||||
EmitX64 emitter;
|
EmitX64 emitter;
|
||||||
const UserCallbacks callbacks;
|
const UserCallbacks callbacks;
|
||||||
|
|
||||||
|
bool clear_cache_required = false;
|
||||||
|
|
||||||
size_t Execute(size_t cycle_count) {
|
size_t Execute(size_t cycle_count) {
|
||||||
u32 pc = jit_state.Reg[15];
|
u32 pc = jit_state.Reg[15];
|
||||||
bool TFlag = Common::Bit<5>(jit_state.Cpsr);
|
bool TFlag = Common::Bit<5>(jit_state.Cpsr);
|
||||||
|
@ -90,6 +92,13 @@ struct Jit::Impl {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearCache() {
|
||||||
|
block_of_code.ClearCache();
|
||||||
|
emitter.ClearCache();
|
||||||
|
jit_state.ResetRSB();
|
||||||
|
clear_cache_required = false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EmitX64::BlockDescriptor GetBasicBlock(Arm::LocationDescriptor descriptor) {
|
EmitX64::BlockDescriptor GetBasicBlock(Arm::LocationDescriptor descriptor) {
|
||||||
auto block = emitter.GetBasicBlock(descriptor);
|
auto block = emitter.GetBasicBlock(descriptor);
|
||||||
|
@ -120,14 +129,21 @@ size_t Jit::Run(size_t cycle_count) {
|
||||||
cycles_executed += impl->Execute(cycle_count - cycles_executed);
|
cycles_executed += impl->Execute(cycle_count - cycles_executed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (impl->clear_cache_required) {
|
||||||
|
impl->ClearCache();
|
||||||
|
}
|
||||||
|
|
||||||
return cycles_executed;
|
return cycles_executed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Jit::ClearCache() {
|
void Jit::ClearCache() {
|
||||||
ASSERT(!is_executing);
|
if (is_executing) {
|
||||||
impl->block_of_code.ClearCache();
|
impl->jit_state.halt_requested = true;
|
||||||
impl->emitter.ClearCache();
|
impl->clear_cache_required = true;
|
||||||
impl->jit_state.ResetRSB();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl->ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Jit::Reset() {
|
void Jit::Reset() {
|
||||||
|
|
Loading…
Reference in a new issue