In the future, I would like to refactor HotkeyManager to give us a nice
way to have Android-exclusive hotkeys without relying on ifdefs. But I
want to get this one Android-exclusive hotkey into Dolphin before the
next release anyway, because this is one of the most requested hotkeys,
if not the most requested hotkey.
`RCConstraints::IsAnyConstraintActive()` was extremely inefficient.
It could be argued that, since it's only used in ASSERTs, they could have been changed to DEBUG_ASSERTs.
But with this, we can have them in release builds with little performance impact.
Also, the implementations of `RCConstraints` are moved to the header files, since they tend to be short and thus inline well.
All the low-hanging performance improvements for the register cache are now fixed, with profiling percentages being at expected values.
(Though more micro-optimizations are possible.)
Replace the "array of structure" design with a "structure of array". Boolean members are represented by a bitset.
The main benefit is that filtering the registers in regcache operations can be done in one simple bitwise instruction.
This is especially useful on `Flush`, as callers don't need anymore to limit the iterated registers for performance reasons.
The change only applies to the x86 regcache.
The register cache is inconsistent in using that or getting it from `GetDefaultLocation(preg_t preg)`.
Considering how simple that function is, let's only use that and remove some state.
Also add requirements for using range functions.
And micro-optimize testing if a bit is set (GCC and MSVC struggle to emit `bt` or `tbz`/`tbnz` with `bs & (1 << n)` compared to `(bs >> n) & 1`).
Since PR #14115, writeAddr is p_paddr | 0x80000000, so comparing it against
the physical RAM size skipped every segment and broke booting MIOS
(GameCube discs from the Wii Disc Channel).
Mask to the physical address before comparing.
Fixes https://bugs.dolphin-emu.org/issues/14176
All PowerPC add and subtract instructions compute a + b + carry_in,
with ~rA as a for the subtract forms. Helper_Add computes this sum in
64 bits and writes rD. Depending on its template parameters, it also
writes CA (bit 32 of the sum), and OV and CR0 as requested by the OE
and Rc bits.
This replaces the carry and overflow code of each instruction and
HasAddOverflowed. There is no behavior change.
With GCC -O3 on x86-64, each instruction compiles to the same number
of host instructions as before, or one fewer.
When XER[CA] was set, addme and subfme always cleared it.
Both instructions add 0xFFFFFFFF and CA to their operand (rA for addme,
~rA for subfme). With CA=1, this adds 2^32, so there is always a carry
out. With CA=0, there is a carry out unless the operand is 0.
This affected the interpreter, the cached interpreter and the JitArm64
fallbacks (addmeo/subfmeo). Jit64 already computes the right value.
`slice_length` is defined as an int, but was being zero-extended to 64
bits on x64. We should match what we do for ARM64 and sign-extend, as
discussed in PR #14944.
fctiw and fctiwz convert a NaN to 0x80000000, but FCVTZS returns 0
for a NaN. The interpreter and Jit64 (CVTPD2DQ) already return
0x80000000.
Fixes https://bugs.dolphin-emu.org/issues/14136.
Legacy savestate headers controlled both the compressed input length
and the decompression buffer size. The input was read into a fixed-size
buffer without validation, and the unsafe LZO API could write past its
output buffer.
Use the legacy block size as the output capacity, reject oversized
compressed blocks, and use the bounds-checking LZO decompressor.
FIFO logs control each memory update address and data size. Playback
masked only the start address into RAM or EXRAM, then copied the
complete update contiguously. An update reaching the end of a mapped
region could therefore write beyond host-mapped emulated memory.
Resolve the target through MemoryManager and reject updates larger than
the remaining valid span before copying them.