Add a brand new JIT CPU emulation engine for ARM! Special thanks to user @byte4byte from byte4byte.com for making this new feature!

- If you have an ARM processor, expect anywhere between 10% to 50% improvement to CPU emulation performance for most games.
- But it isn't quite for prime time just yet. There is a crashing bug related to munmap() at emit_core.cpp:93 that causes the app to crash when resetting the emulator after a game has already been run.
- The Cocoa port now enables the new ARM JIT engine for Macs running Apple Silicon processors, but only for dev+ builds. This is due to the crashing bug noted above.
This commit is contained in:
rogerman 2022-04-23 20:00:30 -07:00
parent 2e95dda3f5
commit f12a70f4b7
8 changed files with 8051 additions and 99 deletions

View File

@ -197,7 +197,7 @@ const char* ClientExecutionControl::GetCPUEmulationEngineName()
void ClientExecutionControl::SetCPUEmulationEngineByID(CPUEmulationEngineID engineID)
{
#if !defined(__i386__) && !defined(__x86_64__)
#if !defined(__i386__) && !defined(__x86_64__) && !defined(__aarch64__)
engineID = CPUEmulationEngineID_Interpreter;
#endif

View File

@ -1376,6 +1376,9 @@
AB405690169F5DCC0016AC3E /* x86operand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB405674169F5DCC0016AC3E /* x86operand.cpp */; };
AB405693169F5DCC0016AC3E /* x86util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB405676169F5DCC0016AC3E /* x86util.cpp */; };
AB407F371A6206FB00313213 /* xbrz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB47B52C18A3F722009A42AF /* xbrz.cpp */; };
AB46E54F2814F42500A4E3D6 /* arm_jit_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB46E54D2814F40800A4E3D6 /* arm_jit_arm.cpp */; };
AB46E5502814F42700A4E3D6 /* arm_jit_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB46E54D2814F40800A4E3D6 /* arm_jit_arm.cpp */; };
AB46E5522814F43300A4E3D6 /* arm_jit_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB46E54D2814F40800A4E3D6 /* arm_jit_arm.cpp */; };
AB47B52F18A45C35009A42AF /* xbrz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB47B52C18A3F722009A42AF /* xbrz.cpp */; };
AB4979BD27F2E97A00E8A244 /* KeyNames.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB02475B13886BF300E9F9AB /* KeyNames.plist */; };
AB4979BE27F2E97A00E8A244 /* Icon_MicrophoneGray_256x256.png in Resources */ = {isa = PBXBuildFile; fileRef = ABB0FBD81A9FD0260060C55A /* Icon_MicrophoneGray_256x256.png */; };
@ -3597,6 +3600,10 @@
AB405675169F5DCC0016AC3E /* x86operand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x86operand.h; sourceTree = "<group>"; };
AB405676169F5DCC0016AC3E /* x86util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = x86util.cpp; sourceTree = "<group>"; };
AB405677169F5DCC0016AC3E /* x86util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x86util.h; sourceTree = "<group>"; };
AB46E54B2814F40800A4E3D6 /* arm64_emit.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = arm64_emit.cpp; sourceTree = "<group>"; };
AB46E54C2814F40800A4E3D6 /* arm_emit.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = arm_emit.cpp; sourceTree = "<group>"; };
AB46E54D2814F40800A4E3D6 /* arm_jit_arm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = arm_jit_arm.cpp; sourceTree = "<group>"; };
AB46E54E2814F40800A4E3D6 /* emit_core.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = emit_core.cpp; sourceTree = "<group>"; };
AB47B52B18A3F722009A42AF /* xbrz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbrz.h; sourceTree = "<group>"; };
AB47B52C18A3F722009A42AF /* xbrz.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xbrz.cpp; sourceTree = "<group>"; };
AB497B1227F2E97A00E8A244 /* DeSmuME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeSmuME.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -4939,6 +4946,17 @@
path = OptimizationProfiles;
sourceTree = "<group>";
};
AB46E54A2814F40800A4E3D6 /* arm_jit */ = {
isa = PBXGroup;
children = (
AB46E54D2814F40800A4E3D6 /* arm_jit_arm.cpp */,
AB46E54E2814F40800A4E3D6 /* emit_core.cpp */,
AB46E54C2814F40800A4E3D6 /* arm_emit.cpp */,
AB46E54B2814F40800A4E3D6 /* arm64_emit.cpp */,
);
path = arm_jit;
sourceTree = "<group>";
};
AB796D7415CDD20E00C59155 /* AsmJit */ = {
isa = PBXGroup;
children = (
@ -5332,6 +5350,7 @@
ABD1FF1C1345ACBF00AF11D1 /* utils */ = {
isa = PBXGroup;
children = (
AB46E54A2814F40800A4E3D6 /* arm_jit */,
AB796D7415CDD20E00C59155 /* AsmJit */,
ABD1FF211345ACBF00AF11D1 /* decrypt */,
ABD1FF2E1345ACBF00AF11D1 /* libfat */,
@ -7398,6 +7417,7 @@
8C43E83027E3CD0100A35F65 /* wifi.cpp in Sources */,
8C43E83127E3CD0100A35F65 /* xstring.cpp in Sources */,
8C43E83227E3CD0100A35F65 /* main.m in Sources */,
AB46E54F2814F42500A4E3D6 /* arm_jit_arm.cpp in Sources */,
8C43E83327E3CD0100A35F65 /* rthreads.c in Sources */,
8C43E83427E3CD0100A35F65 /* cocoa_cheat.mm in Sources */,
8C43E83527E3CD0100A35F65 /* cocoa_core.mm in Sources */,
@ -7489,6 +7509,7 @@
8C43E92327E3CD4C00A35F65 /* ftbase.c in Sources */,
8C43E92427E3CD4C00A35F65 /* ftsynth.c in Sources */,
8C43E92527E3CD4C00A35F65 /* ftbitmap.c in Sources */,
AB46E5502814F42700A4E3D6 /* arm_jit_arm.cpp in Sources */,
8C43E92627E3CD4C00A35F65 /* ftgxval.c in Sources */,
8C43E92727E3CD4C00A35F65 /* ClientAVCaptureObject.cpp in Sources */,
8C43E92827E3CD4C00A35F65 /* AAFilter.cpp in Sources */,
@ -7795,6 +7816,7 @@
8CCD84A127E40B730024BDD5 /* MacMetalDisplayView.mm in Sources */,
8CCD84A227E40B730024BDD5 /* MacOGLDisplayView.mm in Sources */,
8CCD84A327E40B730024BDD5 /* cocoa_firmware.mm in Sources */,
AB46E5522814F43300A4E3D6 /* arm_jit_arm.cpp in Sources */,
8CCD84A427E40B730024BDD5 /* cocoa_input.mm in Sources */,
8CCD84A527E40B730024BDD5 /* cocoa_output.mm in Sources */,
8CCD84A627E40B730024BDD5 /* smooth.c in Sources */,

View File

@ -36,7 +36,7 @@
#define GL_SILENCE_DEPRECATION
#if defined(__i386__) || defined(__x86_64__)
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
#define HAVE_JIT
#endif

View File

@ -50980,86 +50980,6 @@ xcjGRsbDx0HHv8g9yLzJOsm5yjjKt8s2y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ
</object>
<int key="connectionID">8065</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="156454980"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="156454980"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8067</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="636878832"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="636878832"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8068</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="448306376"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="448306376"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8069</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="608656465"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="608656465"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8070</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="388438651"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="388438651"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8071</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">selectedTag: selection.cpuEmulationEngine</string>
@ -51080,22 +51000,6 @@ xcjGRsbDx0HHv8g9yLzJOsm5yjjKt8s2y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ
</object>
<int key="connectionID">8072</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnIntel</string>
<reference key="source" ref="321130061"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="321130061"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnIntel</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnIntel</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">8073</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">selectedTag: values.Emulation_CPUEmulationEngine</string>
@ -61002,6 +60906,264 @@ xcjGRsbDx0HHv8g9yLzJOsm5yjjKt8s2y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ
</object>
<int key="connectionID">12275</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="388438651"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17248">
<reference key="NSSource" ref="388438651"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12277</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="321130061"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17258">
<reference key="NSSource" ref="321130061"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12279</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="608656465"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17268">
<reference key="NSSource" ref="608656465"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12281</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="448306376"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17278">
<reference key="NSSource" ref="448306376"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12283</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="636878832"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17288">
<reference key="NSSource" ref="636878832"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12285</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled: isAppRunningOnPowerPC</string>
<reference key="source" ref="156454980"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector" id="17298">
<reference key="NSSource" ref="156454980"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled: isAppRunningOnPowerPC</string>
<string key="NSBinding">enabled</string>
<string key="NSKeyPath">isAppRunningOnPowerPC</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSValueTransformerName</string>
<string key="NS.object.0">NSNegateBoolean</string>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12287</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="321130061"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="321130061"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17258"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12288</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="156454980"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="156454980"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17298"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12289</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="636878832"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="636878832"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17288"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12290</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="388438651"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="388438651"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17248"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12291</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="608656465"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="608656465"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17268"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12292</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">enabled2: isDeveloperPlusBuild</string>
<reference key="source" ref="448306376"/>
<reference key="destination" ref="976324537"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="448306376"/>
<reference key="NSDestination" ref="976324537"/>
<string key="NSLabel">enabled2: isDeveloperPlusBuild</string>
<string key="NSBinding">enabled2</string>
<string key="NSKeyPath">isDeveloperPlusBuild</string>
<dictionary key="NSOptions">
<integer value="-1" key="NSMultipleValuesPlaceholder"/>
<integer value="-1" key="NSNoSelectionPlaceholder"/>
<integer value="-1" key="NSNotApplicablePlaceholder"/>
<integer value="-1" key="NSNullPlaceholder"/>
</dictionary>
<reference key="NSPreviousConnector" ref="17278"/>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">12293</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -88712,7 +88874,7 @@ xcjGRsbDx0HHv8g9yLzJOsm5yjjKt8s2y7bMNcy1zTXNtc42zrbPN8+40DnQutE80b7SP9LB00TTxtRJ
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">12275</int>
<int key="maxID">12293</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,208 @@
/*
Copyright (C) 2022 Patrick Herlihy - https://byte4byte.com
Copyright (C) 2022 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#define CHUNK_SIZE 6048*4
struct s_bytes {
struct s_bytes *next;
u8 data[CHUNK_SIZE];
};
typedef struct jumpmap {
int num_bytes; // bytes in function where jump is
int cond;
u32 *instruct_ptr;
} t_jumpmap;
typedef struct labelmap {
int num_bytes; // bytes in function where label is
std::vector<t_jumpmap> jumps;
} t_labelmap;
static std::map<int, t_labelmap> g_LABELS;
static int g_NUMJUMPS = 0;
static int g_TOTALBYTES = 0;
u32 *g_PTR = NULL;
t_bytes *g_currBlock = NULL;
std::map<JittedFunc, u_int> allFuncs;
static void* alloc_executable_memory(size_t size) {
#ifdef __APPLE__
void* ptr = mmap (NULL, size,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_JIT,
-1, 0);
#else
void* ptr = mmap(0, size,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
if (ptr == (void*)-1) {
return NULL;
}
if (! ptr) {
return NULL;
}
allFuncs.insert(std::pair<JittedFunc,int>((JittedFunc)ptr, size));
return ptr;
}
static char *g_curr_jit_block = NULL;
static char *g_curr_jit_ptr = NULL;
static int g_curr_jit_size = 0;
static void *armjitarm_alloc_func(size_t size) {
if (! g_curr_jit_block || (uintptr_t)((uintptr_t)g_curr_jit_ptr + (uintptr_t)size) > (uintptr_t)((uintptr_t)g_curr_jit_block + (uintptr_t)g_curr_jit_size)) {
if (g_curr_jit_block) {
printf("RESETTING JIT\n");
arm_jit_reset(1);
//return NULL;
}
int memsize = 4 * 10000000;
g_curr_jit_block = (char *)alloc_executable_memory(memsize);
if (! g_curr_jit_block) return NULL;
g_curr_jit_ptr = g_curr_jit_block;
g_curr_jit_size = memsize;
}
char *ptr = g_curr_jit_ptr;
g_curr_jit_ptr += size;
return ptr;
}
static void freeFuncs() {
std::map<JittedFunc, u_int>::iterator it;
for (it=allFuncs.begin(); it!=allFuncs.end(); ++it) {
// TODO: Calling munmap() causes a crash when resetting the emulator. Need to research why this happens.
//munmap((void *)it->first, (uintptr_t)it->second);
}
allFuncs.clear();
}
static void allocNewBlock() {
if (! g_currBlock) {
fprintf(stderr, "allocNewBlock failed\n");
exit(0);
}
g_currBlock->next = (t_bytes *)malloc(sizeof(t_bytes));
if (! g_currBlock->next) {
fprintf(stderr, "allocNewBlock failed\n");
exit(0);
}
g_currBlock = g_currBlock->next;
g_PTR = (u32*)&g_currBlock->data[0];
g_currBlock->next = NULL;
}
static void output_w32(t_bytes *bytes, u32 word) {
*g_PTR++ = word;
g_TOTALBYTES+=4;
if ((uintptr_t)g_PTR >= (uintptr_t)(&g_currBlock->data[0] + ((uintptr_t)CHUNK_SIZE))) {
allocNewBlock();
}
}
static void emit_label(t_bytes *bytes, u_int id) {
g_LABELS[id].num_bytes = g_TOTALBYTES + 4;
}
static void emit_branch_label(t_bytes *out, u_int id, int cond) {
u32 *instruct_adr = g_PTR;
output_w32(out, 0x00000000);
int num_bytes = g_TOTALBYTES;
t_jumpmap jm = {
num_bytes,
cond,
instruct_adr
};
g_LABELS[id].jumps.push_back(jm);
}
static t_bytes *g_last_bytes = NULL;
t_bytes *allocBytes() {
t_bytes *ret;
if (g_last_bytes) ret = g_last_bytes;
else ret = (t_bytes *)malloc(sizeof(t_bytes));
if (! ret) {
fprintf(stderr, "allocBytes failed\n");
exit(0);
}
ret->next = NULL;
g_currBlock = ret;
g_PTR = (u32*)&g_currBlock->data[0];
g_TOTALBYTES = 0;
g_LABELS.clear();
return ret;
}
void releaseBytes(t_bytes *bytes) {
g_last_bytes = bytes;
bytes = bytes->next;
while (bytes) {
t_bytes *next = bytes->next;
free(bytes);
bytes = next;
}
}
JittedFunc createFunc(t_bytes *bytes) {
for (auto const& lbl : g_LABELS) {
int nj = lbl.second.jumps.size();
for (int i = 0; i < nj; i++) {
MOD_JUMP(lbl.second.jumps[i].instruct_ptr, lbl.second.jumps[i].cond, lbl.second.num_bytes, lbl.second.jumps[i].num_bytes)
}
}
char *fn = (char *)armjitarm_alloc_func(g_TOTALBYTES);
char *fn_ptr = fn;
if (! fn) return NULL;
int tot_bytes_acum = 0;
t_bytes *curr_bytes = bytes;
while (curr_bytes) {
if (curr_bytes->next) {
memcpy(fn_ptr, curr_bytes->data, CHUNK_SIZE);
fn_ptr += CHUNK_SIZE;
tot_bytes_acum += CHUNK_SIZE;
}
else {
memcpy(fn_ptr, curr_bytes->data, g_TOTALBYTES-tot_bytes_acum);
break;
}
curr_bytes = curr_bytes->next;
}
__builtin___clear_cache(fn, fn+g_TOTALBYTES);
return (JittedFunc)fn;
}