Skip to content

Commit

Permalink
Merge pull request #18247 from hrydgard/jit-exit-fixes
Browse files Browse the repository at this point in the history
Jit: Assert on bad exit numbers, allow two more exits per block
  • Loading branch information
hrydgard committed Sep 26, 2023
2 parents c0ee711 + dd2b1ac commit 8baae83
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Core/MIPS/ARM/ArmJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ void ArmJit::UpdateRoundingMode(u32 fcr31) {
void ArmJit::WriteExit(u32 destination, int exit_num)
{
// TODO: Check destination is valid and trigger exception.
_assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination);

WriteDownCount();
//If nobody has taken care of this yet (this can be removed when all branches are done)
JitBlock *b = js.curBlock;
Expand Down
3 changes: 3 additions & 0 deletions Core/MIPS/ARM64/Arm64Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ void Arm64Jit::UpdateRoundingMode(u32 fcr31) {
// though, as we need to have the SUBS flag set in the end. So with block linking in the mix,
// I don't think this gives us that much benefit.
void Arm64Jit::WriteExit(u32 destination, int exit_num) {
// TODO: Check destination is valid and trigger exception.
_assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination);

// TODO: Check destination is valid and trigger exception.
WriteDownCount();
//If nobody has taken care of this yet (this can be removed when all branches are done)
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/JitCommon/JitBlockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "Core/MIPS/MIPS.h"

#if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64)
const int MAX_JIT_BLOCK_EXITS = 2;
const int MAX_JIT_BLOCK_EXITS = 4;
#else
const int MAX_JIT_BLOCK_EXITS = 8;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Core/MIPS/x86/Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ static void HitInvalidBranch(uint32_t dest) {
}

void Jit::WriteExit(u32 destination, int exit_num) {
_dbg_assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num");
_assert_msg_(exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num. dest=%08x", destination);

if (!Memory::IsValidAddress(destination) || (destination & 3) != 0) {
ERROR_LOG_REPORT(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc);
Expand Down

0 comments on commit 8baae83

Please sign in to comment.