Commit Graph
37 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 6d122f416e Keep JIT block entries and replacement hooks out of PSP memory
The JITs used to find a block by overwriting its first instruction with an "emuhack" holding
the offset into the code space, and replacement functions installed their own emuhack the same
way. Anything that read code (savestates, the debugger, memory dumps, cheats, the function
hasher, games reading their own code) had to translate them back.

Blocks now live in a block shadow: one u32 per guest instruction, indexed by the PC masked with
BLOCK_SHADOW_MASK (1GB on 64-bit, folding the kernel and uncached mirrors; 256MB on 32-bit, iOS
and Switch, where address space is short), with the low bits cleared so a misaligned PC can't
read across two entries. Only the ranges under memory views are committed, so a bad PC still
faults in the dispatcher, and the shadow is reserved before the memory map so it can't land in
a gap of the 4GB window. Entries hold full 32-bit offsets, lifting the 16MB limit. The
dispatchers on every backend, and the IR interpreter's loop, look blocks up there.

A hooked instruction without a compiled block gets the JIT's hook value in its entry: the offset
of the dispatcher's compile path (1 for the interpreters, the IR arena keeping that offset
empty), so dispatching there compiles a block, and the frontends substitute the hook. Compiling
replaces the entry with the block's, and destroying the block puts the hook value back. The hook
value is rewritten when the JIT changes or regenerates its dispatcher.

Hooks live in a map keyed by the masked address, and are dropped when the game overwrites the
hooked instruction, or when an icache invalidation finds the function's hash (immediates masked,
as when matching it) changed. Those checks run when queued invalidations are processed, since
cheats and the debugger queue them before writing. Installing and removing hooks invalidates
deferred, as it happens in HLE calls that can run inside a block. The cache instruction goes
through MIPSState, so it drops changed hooks too.

With clean memory, the save/clear/restore around savestates, memory reads and dumps goes away,
as do the source-range invalidations in the memcpy replacements, sceDmac and the cheats.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:33:30 +02:00
Henrik Rydgård 5ce4cbc18a Fix some function name shenanigans 2026-08-14 14:55:06 +02:00
Henrik Rydgård 4e25f44eef Rename some module-related functions to include HLE where appropriate 2025-03-31 11:17:50 +02:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Unknown W. Brackets 5b1235537f Debugger: Make disasm more thread safe. 2023-04-29 09:56:17 -07:00
Unknown W. Brackets 6da10463f9 Debugger: Make reg names safer, stop using v000.
Better to use S000, etc. as that's more clear throughout.
2023-04-29 09:48:33 -07:00
Unknown W. Brackets 46101581c0 Core: Cleanup disasm buffer usage. 2023-04-29 09:07:25 -07:00
Unknown W. Brackets 5233a3bc84 Debugger: Cleanup some sign extends in disassembly. 2023-04-09 10:36:20 -07:00
Unknown W. Brackets 6df939034a Core: Cleanup some sign extensions for clarity. 2023-04-05 17:16:51 -07:00
Unknown W. Brackets 63e623ecb2 Build: Fix some format truncation warnings.
Generally all should be safe already, but better to be sure.
2021-12-11 10:45:27 -08:00
Unknown W. Brackets 5d60fa0d0d Common: Maintain C++11 support in sign extend. 2021-01-31 08:44:02 -08:00
Unknown W. Brackets 1b00da2f3a Common: Sign extend w/func not chained casts.
Should be clearer to read and easier to get right.
2021-01-31 01:25:52 -08:00
Unknown W. Brackets 7bfe100b0f Fix some unused variable warnings.
The CheckAlpha one looks like it will matter.
2015-11-25 16:11:53 -08:00
Henrik Rydgard 75a9420b21 Reduce the number of places we include JitCommon.h. Update native. 2014-12-12 23:49:08 +01:00
Unknown W. Brackets 78296d15c6 Don't recurse when disasming an emuhack.
Although, should this happen?  Apparently does in Peace Walker.
2014-08-17 18:43:59 -07:00
Unknown W. Brackets ac94dbcc69 Show the replaced instruction in disassembly.
Useful while debugging.
2014-08-03 19:23:29 -07:00
Unknown W. Brackets abd1f4e58a Disassemble bne/etc. using rs, rt order.
The order makes more logical sense from game disassembly, and matches the
assembler.  Fixes #6632.
2014-08-03 19:22:18 -07:00
Unknown W. Brackets 737c96eced More cstring includes, grr. 2014-03-15 12:03:33 -07:00
lioncash b9886942a7 Fix some vertical alignments in misc Core source files. 2014-03-03 11:16:53 -05:00
Henrik Rydgard 1e300447e1 Fix some replace-related bugs. Add "jal" replace inlining, not activated. 2013-12-18 16:27:23 +01:00
Henrik Rydgard 2d8429ac48 Assorted cleanup in the MIPS emulation 2013-12-10 13:15:16 +01:00
Unknown W. Brackets 2e8ef3027f Write the retaddr to rd, not always ra, in jalr.
Thanks go entirely to @Kingcom for pointing this out.

Don't know of any games not using RA as the rd.
2013-10-17 07:39:33 -07:00
Kingcom 480c766776 Fix rotrv (dis)assembly 2013-10-13 10:36:43 +02:00
Kingcom 46c9142406 Correct move pseudo opcode 2013-09-01 10:23:12 +02:00
adrian17 06a015983a Fixed some doubled semicolons 2013-08-25 19:43:18 +02:00
Unknown W. Brackets 109ad17ac6 Use a typesafe struct for opcodes.
Also, correctly read delayslots using Read_Instruction on ARM.
2013-08-24 15:36:24 -07:00
Unknown W. Brackets 1ed8edb0d3 Avoid some dangerous hex constant widths. 2013-08-22 23:23:48 -07:00
Unknown W. Brackets 243c8c7a34 Clean up disasm immediates.
They were still a bit wrong.
2013-03-11 23:45:29 -07:00
Unknown W. Brackets f7e476e72e Correct sign in disasm for immediates.
Fixes #943.
2013-03-11 08:55:33 -07:00
StorMyu 282e5be93e Update Core/MIPS/MIPSDis.cpp 2013-02-20 22:10:54 +01:00
StorMyu 197e5fc630 Change %i/%d to %X
Cause it's just an easier read for every instruction to do Hexadecimal operation on Hexadecimal Immediate.
2013-02-20 21:04:19 +01:00
Lioncash eb84b00a3d Fix a duplicate branch in MIPS/MIPSDis.cpp
Copypaste error for beql.

Thanks go out to [Unknown] for specifying the correct value of o.
2013-01-25 17:57:12 -05:00
Sacha 3c903dda24 Improve portability to future platforms. Make use of new USING_GLES2 define throughout PPSSPP. Also use ARM definition where suitable. Remove some redundancy with includes. 2012-11-26 13:25:14 +10:00
Henrik Rydgard a385ec6056 MIPSDis cleanup, allow mfv zero, 255 (appears to be used to flush VFPU state or something) 2012-11-23 10:35:28 +01:00
Sacha 41f5abab31 PPSSPP ported to Blackberry10
Now builds on Playbook and Dev Alpha
Make emulator more compatible with other OS (case sensitivity, defines, includes)
Uses Android's code paths and backend
2012-11-05 23:09:49 +10:00
Henrik Rydgard 64cc573703 Switch to "GPL 2.0 or later" for various reasons. I wrote most of the code I imported from Dolphin (which is GPL2-but-not-later), so it should be OK. 2012-11-04 23:24:00 +01:00
Henrik Rydgard 4f7ad15758 Add snapshot of the whole source code. 2012-11-01 16:19:01 +01:00