Skip to content

Commit 5d80fa9

Browse files
committed
Move XIP exception handling to interrupt handler
The previous solution in HyperCPU::CPU::Run() method could lead to performance degradation. Signed-off-by: Ivan Movchan <ivan.movchan.07@gmail.com>
1 parent f225eb9 commit 5d80fa9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Emulator/Core/CPU/CPU.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,6 @@ void HyperCPU::CPU::Run() {
253253
continue;
254254
}
255255

256-
if ((*xip) >= binary_size) {
257-
halted = true;
258-
break;
259-
}
260-
261256
buffer = m_decoder->FetchAndDecode();
262257

263258
switch (buffer.m_opcode) {

src/Emulator/Core/CPU/Interrupts/InterruptHandler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "PCH/CStd.hpp"
77

88
void HyperCPU::CPU::TriggerInterrupt(HyperCPU::cpu_exceptions exception) {
9+
if (*xip >= binary_size) {
10+
spdlog::error("XIP exceeded the binary size, aborting!");
11+
std::abort();
12+
}
13+
914
if (!ivt_initialized || pending_interrupt.has_value()) {
1015
spdlog::error("Interrupt was triggered, but failed to execute handler! XIP: {}", *xip);
1116
std::abort();

0 commit comments

Comments
 (0)