Commit graph

34215 commits

Author SHA1 Message Date
Sintendo
defe7162f5 Jit64: divwx - Simplify divisor == -1 case
Suggested by @MerryMage. Thanks!

Co-authored-by: merry <MerryMage@users.noreply.github.com>
2021-03-07 18:29:12 +01:00
Sintendo
83f38388a1 Jit64: divwx - Micro-optimize default case
Both the normal path and the overflow path end with the same
instruction, so their tails can be merged.

Before:
41 8B C7             mov         eax,r15d
45 85 C0             test        r8d,r8d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 F8 FF          cmp         r8d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B F0             mov         r14d,eax
EB 07                jmp         done
normal_path:
99                   cdq
41 F7 F8             idiv        eax,r8d
44 8B F0             mov         r14d,eax
done:

After:
41 8B C7             mov         eax,r15d
45 85 C0             test        r8d,r8d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0B                jne         normal_path
41 83 F8 FF          cmp         r8d,0FFFFFFFFh
75 05                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
EB 04                jmp         done
normal_path:
99                   cdq
41 F7 F8             idiv        eax,r8d
done:
44 8B F0             mov         r14d,eax
2021-03-07 18:29:12 +01:00
Sintendo
1865035798 Jit64: divwx - Optimize division by 2
...and let's optimize a divisor of 2 ever so slightly for good measure.
I wouldn't have bothered, but most GameCube games seem to hit this on
launch.

- Division by 2
Before:
41 BE 02 00 00 00    mov         r14d,2
41 8B C2             mov         eax,r10d
45 85 F6             test        r14d,r14d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 FE FF          cmp         r14d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B F0             mov         r14d,eax
EB 07                jmp         done
normal_path:
99                   cdq
41 F7 FE             idiv        eax,r14d
44 8B F0             mov         r14d,eax
done:

After:
45 8B F2             mov         r14d,r10d
41 C1 EE 1F          shr         r14d,1Fh
45 03 F2             add         r14d,r10d
41 D1 FE             sar         r14d,1
2021-03-07 18:29:12 +01:00
Sintendo
0637a7ec59 Jit64: divwx - Optimize power-of-two divisors
Power-of-two divisors can be done more elegantly, so handle them
separately.

- Division by 4
Before:
41 BD 04 00 00 00    mov         r13d,4
41 8B C0             mov         eax,r8d
45 85 ED             test        r13d,r13d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 FD FF          cmp         r13d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B E8             mov         r13d,eax
EB 07                jmp         done
normal_path:
99                   cdq
41 F7 FD             idiv        eax,r13d
44 8B E8             mov         r13d,eax
done:

After:
45 85 C0             test        r8d,r8d
45 8D 68 03          lea         r13d,[r8+3]
45 0F 49 E8          cmovns      r13d,r8d
41 C1 FD 02          sar         r13d,2
2021-03-07 18:29:12 +01:00
Sintendo
530475dce8 Jit64: divwx - Micro-optimize certain divisors
When the multiplier is positive (which is the most common case), we can
generate slightly better code.

- Division by 30307
Before:
49 63 C5             movsxd      rax,r13d
48 69 C0 65 6B 32 45 imul        rax,rax,45326B65h
4C 8B C0             mov         r8,rax
48 C1 E8 3F          shr         rax,3Fh
49 C1 F8 2D          sar         r8,2Dh
44 03 C0             add         r8d,eax

After:
49 63 C5             movsxd      rax,r13d
4C 69 C0 65 6B 32 45 imul        r8,rax,45326B65h
C1 E8 1F             shr         eax,1Fh
49 C1 F8 2D          sar         r8,2Dh
44 03 C0             add         r8d,eax
2021-03-07 18:29:12 +01:00
Sintendo
95698c5ae1 Jit64: divwx - Optimize constant divisor
Optimize division by a constant into multiplication. This method is also
used by GCC and LLVM.

We also add optimized paths for divisors 0, 1, and -1, because they
don't work using this method. They don't occur very often, but are
necessary for correctness.

- Division by 1
Before:
41 BF 01 00 00 00    mov         r15d,1
41 8B C5             mov         eax,r13d
45 85 FF             test        r15d,r15d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 FF FF          cmp         r15d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B F8             mov         r15d,eax
EB 07                jmp         done
normal_path:
99                   cdq
41 F7 FF             idiv        eax,r15d
44 8B F8             mov         r15d,eax
done:

After:
45 8B FD             mov         r15d,r13d

- Division by 30307
Before:
41 BA 63 76 00 00    mov         r10d,7663h
41 8B C5             mov         eax,r13d
45 85 D2             test        r10d,r10d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 FA FF          cmp         r10d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B C0             mov         r8d,eax
EB 07                jmp         done
normal_path:
99                   cdq
41 F7 FA             idiv        eax,r10d
44 8B C0             mov         r8d,eax
done:

After:
49 63 C5             movsxd      rax,r13d
48 69 C0 65 6B 32 45 imul        rax,rax,45326B65h
4C 8B C0             mov         r8,rax
48 C1 E8 3F          shr         rax,3Fh
49 C1 F8 2D          sar         r8,2Dh
44 03 C0             add         r8d,eax

- Division by 30323
Before:
41 BA 73 76 00 00    mov         r10d,7673h
41 8B C5             mov         eax,r13d
45 85 D2             test        r10d,r10d
74 0D                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0E                jne         normal_path
41 83 FA FF          cmp         r10d,0FFFFFFFFh
75 08                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
44 8B C0             mov         r8d,eax
EB 07                jmp         00000000161737E7
normal_path:
99                   cdq
41 F7 FA             idiv        eax,r10d
44 8B C0             mov         r8d,eax
done:

After:
49 63 C5             movsxd      rax,r13d
4C 69 C0 19 25 52 8A imul        r8,rax,0FFFFFFFF8A522519h
49 C1 E8 20          shr         r8,20h
44 03 C0             add         r8d,eax
C1 E8 1F             shr         eax,1Fh
41 C1 F8 0E          sar         r8d,0Eh
44 03 C0             add         r8d,eax
2021-03-07 18:29:01 +01:00
Sintendo
5bb8798df6 JitCommon: Signed 32-bit division magic constants
Add a function to calculate the magic constants required to optimize
signed 32-bit division.

Since this optimization is not exclusive to any particular architecture,
JitCommon seemed like a good place to put this.
2021-03-07 18:27:36 +01:00
Sintendo
c9adc60d73 Jit64: divwx - Special case dividend == 0
Zero divided by any number is still zero. For whatever reason, this case
shows up frequently too.

Before:
B8 00 00 00 00       mov         eax,0
85 F6                test        esi,esi
74 0C                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0C                jne         normal_path
83 FE FF             cmp         esi,0FFFFFFFFh
75 07                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
8B F8                mov         edi,eax
EB 05                jmp         done
normal_path:
99                   cdq
F7 FE                idiv        eax,esi
8B F8                mov         edi,eax
done:

After:
Nothing!
2021-03-07 18:27:30 +01:00
Sintendo
c081e3f2b3 Jit64: divwx - Optimize constant dividend
When the dividend is known at compile time, we can eliminate some of the
branching and precompute the result for the overflow case.

Before:
B8 54 D3 E6 02       mov         eax,2E6D354h
85 FF                test        edi,edi
74 0C                je          overflow
3D 00 00 00 80       cmp         eax,80000000h
75 0C                jne         normal_path
83 FF FF             cmp         edi,0FFFFFFFFh
75 07                jne         normal_path
overflow:
C1 F8 1F             sar         eax,1Fh
8B F8                mov         edi,eax
EB 05                jmp         done
normal_path:
99                   cdq
F7 FF                idiv        eax,edi
8B F8                mov         edi,eax
done:

After:
85 FF                test        edi,edi
75 04                jne         normal_path
33 FF                xor         edi,edi
EB 0A                jmp         done
normal_path:
B8 54 D3 E6 02       mov         eax,2E6D354h
99                   cdq
F7 FF                idiv        eax,edi
8B F8                mov         edi,eax
done:

Fairly common with constant dividend of zero. Non-zero values occur
frequently in Ocarina of Time Master Quest.
2021-03-07 18:25:08 +01:00
Sintendo
2454bd5ba6 Jit64: Add optional argument to GenerateOverflow
This allows setting the overflow flag based on any condition code.
Defaults to NO (no overflow).
2021-03-05 17:14:45 +01:00
Léo Lam
5f7d935b0a
Merge pull request #9533 from sepalani/mmu-is-ram
MMU: Fix IsRAMAddress not working
2021-03-05 11:49:55 +01:00
JMC47
fc86e554e0
Merge pull request #9559 from iwubcode/gdb-stub-raii
Common / Core: add raii object that cleans up WSA on destruction in gdb-stub
2021-03-05 05:28:31 -05:00
Léo Lam
adcdeda372
Merge pull request #9565 from sepalani/qt-blocker
BreakpointWidget: Use QSignalBlocker
2021-03-05 10:44:44 +01:00
Léo Lam
a4de2502c5
Merge pull request #9550 from endrift/gba-flush
SI/DeviceGBA: Ensure data socket isn't backed up
2021-03-05 10:38:55 +01:00
Sepalani
1e6dfc6b91 BreakpointWidget: Use QSignalBlocker 2021-03-05 13:35:33 +04:00
Léo Lam
de30559862
Merge pull request #9564 from sepalani/bp-del
BreakpointWidget: Fix delete deleting both MBP and BP at address
2021-03-05 10:28:48 +01:00
Sepalani
fd7eeb7221 BreakpointWidget: Fix delete deleting both MBP and BP at address 2021-03-05 13:01:32 +04:00
Léo Lam
1e3e5680db
Merge pull request #9561 from sepalani/fix-watches
Watches: Fix Save and Load from strings
2021-03-05 00:57:40 +01:00
Léo Lam
19c5a19629
Merge pull request #9529 from JosJuice/android-broadcast-before-metadata
Android: Broadcast update before updating additional metadata
2021-03-05 00:48:04 +01:00
Léo Lam
5efd563b03
Merge pull request #9555 from JosJuice/android-jni-cleanup
Android: Some JNI cleanup
2021-03-05 00:47:36 +01:00
JosJuice
873d5f9852 Android: Broadcast update before updating additional metadata
In master, the game scanning process looks like this:

1. Scan for games
2. Scan for additional metadata (icon.png and meta.xml)
3. Save the cache if needed
4. Update the game list with the results

This change makes the game scanning process look like this:

1. Scan for games
2. Update the game list with the results
3. Scan for additional metadata (icon.png and meta.xml)
4. Update the game list with the results
5. Save the cache if needed

Updating the game list as soon as possible means the user
has to wait less before their games show up. The new behavior
matches what DolphinWX did before it was removed. (DolphinQt
has an even fancier approach where games get added one by one.)
2021-03-04 22:50:06 +01:00
JosJuice
d99d72f5a6 Android: Remove #ifdef __cplusplus checks
A C compiler would very much be unable to build this code anyway.
2021-03-04 22:47:23 +01:00
iwubcode
7d5052896d IOS: update network/ip/top to use the RAII winsock context 2021-03-04 13:55:20 -06:00
Léo Lam
6c23e163e1
Merge pull request #9563 from sepalani/bp-changed
BreakpointWidget: Emit BreakpointsChanged to update views
2021-03-04 20:49:54 +01:00
iwubcode
e4f74bea42 Core: Use RAII winsock object to cleanly create and destroy WSA in gdb-stub 2021-03-04 13:47:32 -06:00
iwubcode
00bc7e6b38 Common: Add RAII object that initializes and cleans up winsock 2021-03-04 13:44:12 -06:00
Sepalani
ef977123d5 BreakpointWidget: Emit BreakpointsChanged to update views 2021-03-04 21:10:37 +04:00
Sepalani
6786340a7c Watches: Fix Save and Load from strings 2021-03-04 17:55:52 +04:00
Léo Lam
be500a98e2
Merge pull request #8779 from sepalani/open-dump
NetworkWidget: Reorganise SSL options group box
2021-03-04 13:37:10 +01:00
Léo Lam
2aa1ff51bd
Merge pull request #9493 from nolange/stricter_compiler_flag_check
Stricter test for compiler flags
2021-03-04 12:47:33 +01:00
Léo Lam
794e093223
Merge pull request #9530 from JosJuice/android-loading-indicator
Android: Use SwipeRefreshLayout in MainActivity
2021-03-04 12:42:20 +01:00
Léo Lam
511e9dcd2f
Merge pull request #9542 from InusualZ/toggle-bp
BreakpointWidget: Allow breakpoints to be toggled between enable/disable
2021-03-04 12:34:03 +01:00
Léo Lam
48a5846aee
Merge pull request #9548 from AdmiralCurtiss/fastmem-active-regions
Core/Memmap: Memory mapping logic fixes.
2021-03-04 12:18:59 +01:00
Léo Lam
06a77493a4
Merge pull request #9547 from PatrickFerry/ini-fixes-1
Some Gameini Changes
2021-03-04 12:16:09 +01:00
Léo Lam
9c6c77351f
Merge pull request #9556 from JosJuice/cmake-msvc-latest
CMake: Build with -std:c++latest for MSVC
2021-03-04 12:12:06 +01:00
Léo Lam
00db622d50
Merge pull request #9560 from JosJuice/cmake-msvc-wil
CMake: Include WIL headers
2021-03-04 12:08:05 +01:00
JosJuice
2cb3f663bc CMake: Include WIL headers
MSBuild does this, so CMake should too. Fixes a Windows build error.
2021-03-04 10:26:31 +01:00
JosJuice
0cb71d3f47 CMake: Disable warning C5054 on DolphinQt
Same as 33c0abd.

Also removing -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING
to match MSBuild. Qt is no longer triggering that warning.
2021-03-04 09:29:30 +01:00
JosJuice
1c3f594087 CMake: Build with -std:c++latest for MSVC
Making CMake match MSBuild in this aspect will hopefully
reduce how often we accidentally break the MSVC CMake build.
2021-03-03 23:44:35 +01:00
JMC47
79ee6aae0a
Merge pull request #9395 from AdmiralCurtiss/most-wanted-turn-on-the-sun
GameSettings: Enable perf queries to fix sun in Need for Speed: Most Wanted.
2021-03-03 17:43:33 -05:00
Léo Lam
6bcef87f82
Merge pull request #9554 from Dentomologist/remove_unused_lambda_capture
DolphinQt: Removed unused this capture in lambda
2021-03-03 23:03:08 +01:00
JosJuice
ae5f8853a4 Android: Delete more references in IDCache.cpp
It's not causing any problems in practice so far, but let's fix it
before I add even more stuff without remembering to delete references.
2021-03-03 22:58:59 +01:00
Dentomologist
6e13d35026 DolphinQt: Removed unused this capture in lambda
The Host constructor sets a callback on a lambda that in turn calls
Host_UpdateDisasmDialog. Since that function is not a member function
capturing this is unnecessary.

Fixes -Wunused-lambda-capture warning on freebsd-x64.
2021-03-03 13:18:17 -08:00
JMC47
d2eb846e6a
Merge pull request #9549 from Dentomologist/ppcstate_off_to_s32
JitArm64: Fix unsigned/signed argument/parameter mismatch
2021-03-03 14:56:40 -05:00
JMC47
9843412440
Merge pull request #8996 from AdmiralCurtiss/memcard-save-import-export-refactor
Various improvements for the Memory Card Manager.
2021-03-03 14:51:31 -05:00
JMC47
a0be1c93ea
Merge pull request #9352 from Pokechu22/sw-line-point-width
Software: Implement line-width and point-width
2021-03-03 14:15:28 -05:00
JMC47
5342c40d55
Merge pull request #9546 from Miksel12/ini-changes5
INI Changes
2021-03-03 14:02:59 -05:00
JosJuice
2f0bab0192 Android: Add @Keep annotation to BooleanSupplier
I should at least follow the conventions I set myself... (See a8d385c)
2021-03-03 18:29:32 +01:00
InusualZ
5e1b3514f6 Allow to disable/enable from the BreakpointWidget
Added a context menu, for when a breakpoint is right-clicked
Removed the `itemClicked` behavior, since it would clash with the context menu
2021-03-03 15:55:22 +00:00
Vicki Pfau
f6e9003ddc SI/DeviceGBA: Ensure data socket isn't backed up
When reading a reply from a message sent to the data socket there is
the possibility that the other side gets sent multiple messages
before replying to any of them, which can lead to multiple replies
sent in a row. Though this only happens when things time out, it's
quite possible for these timeouts to happen or build up over time,
especially when initiating the connection.

This change makes sure to flush any pending bytes that have not been
read yet out of the socket after a successful POLL reply is received,
since that is the most common time when backups occur, and as well as
using the exact number of bytes in an expected reply, to ensure
the received data and the message it's replying to do not get out of
sync.
2021-03-02 18:53:44 -08:00