diff options
author | LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> | 2020-06-16 20:28:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 20:28:02 +0200 |
commit | 5e724cf24e3d696b95be859c055a617e5d37bf80 (patch) | |
tree | bda92e3f1618cfad804f31ea3b00d7569501bc96 /ARMeilleure/Instructions/InstEmitFlowHelper.cs | |
parent | fa286d353595aa91ad0bda6671d8d87e0700846f (diff) |
Add Profiled Persistent Translation Cache. (#769)
* Delete DelegateTypes.cs
* Delete DelegateCache.cs
* Add files via upload
* Update Horizon.cs
* Update Program.cs
* Update MainWindow.cs
* Update Aot.cs
* Update RelocEntry.cs
* Update Translator.cs
* Update MemoryManager.cs
* Update InstEmitMemoryHelper.cs
* Update Delegates.cs
* Nit.
* Nit.
* Nit.
* 10 fewer MSIL bytes for us
* Add comment. Nits.
* Update Translator.cs
* Update Aot.cs
* Nits.
* Opt..
* Opt..
* Opt..
* Opt..
* Allow to change compression level.
* Update MemoryManager.cs
* Update Translator.cs
* Manage corner cases during the save phase. Nits.
* Update Aot.cs
* Translator response tweak for Aot disabled. Nit.
* Nit.
* Nits.
* Create DelegateHelpers.cs
* Update Delegates.cs
* Nit.
* Nit.
* Nits.
* Fix due to #784.
* Fixes due to #757 & #841.
* Fix due to #846.
* Fix due to #847.
* Use MethodInfo for managed method calls.
Use IR methods instead of managed methods about Max/Min (S/U).
Follow-ups & Nits.
* Add missing exception messages.
Reintroduce slow path for Fmov_Vi.
Implement slow path for Fmov_Si.
* Switch to the new folder structure.
Nits.
* Impl. index-based relocation information. Impl. cache file version field.
* Nit.
* Address gdkchan comments.
Mainly:
- fixed cache file corruption issue on exit; - exposed a way to disable AOT on the GUI.
* Address AcK77 comment.
* Address Thealexbarney, jduncanator & emmauss comments.
Header magic, CpuId (FI) & Aot -> Ptc.
* Adaptation to the new application reloading system.
Improvements to the call system of managed methods.
Follow-ups.
Nits.
* Get the same boot times as on master when PTC is disabled.
* Profiled Aot.
* A32 support (#897).
* #975 support (1 of 2).
* #975 support (2 of 2).
* Rebase fix & nits.
* Some fixes and nits (still one bug left).
* One fix & nits.
* Tests fix (by gdk) & nits.
* Support translations not only in high quality and rejit.
Nits.
* Added possibility to skip translations and continue execution, using `ESC` key.
* Update SettingsWindow.cs
* Update GLRenderer.cs
* Update Ptc.cs
* Disabled Profiled PTC by default as requested in the past by gdk.
* Fix rejit bug. Increased number of parallel translations. Add stack unwinding stuffs support (1 of 2).
Nits.
* Add stack unwinding stuffs support (2 of 2). Tuned number of parallel translations.
* Restored the ability to assemble jumps with 8-bit offset when Profiled PTC is disabled or during profiling.
Modifications due to rebase.
Nits.
* Limited profiling of the functions to be translated to the addresses belonging to the range of static objects only.
* Nits.
* Nits.
* Update Delegates.cs
* Nit.
* Update InstEmitSimdArithmetic.cs
* Address riperiperi comments.
* Fixed the issue of unjustifiably longer boot times at the second boot than at the first boot, measured at the same time or reference point and with the same number of translated functions.
* Implemented a simple redundant load/save mechanism.
Halved the value of Decoder.MaxInstsPerFunction more appropriate for the current performance of the Translator.
Replaced by Logger.PrintError to Logger.PrintDebug in TexturePool.cs about the supposed invalid texture format to avoid the spawn of the log.
Nits.
* Nit.
Improved Logger.PrintError in TexturePool.cs to avoid log spawn.
Added missing code for FZ handling (in output) for fp max/min instructions (slow paths).
* Add configuration migration for PTC
Co-authored-by: Thog <me@thog.eu>
Diffstat (limited to 'ARMeilleure/Instructions/InstEmitFlowHelper.cs')
-rw-r--r-- | ARMeilleure/Instructions/InstEmitFlowHelper.cs | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/ARMeilleure/Instructions/InstEmitFlowHelper.cs b/ARMeilleure/Instructions/InstEmitFlowHelper.cs index 7b244296..e99afa75 100644 --- a/ARMeilleure/Instructions/InstEmitFlowHelper.cs +++ b/ARMeilleure/Instructions/InstEmitFlowHelper.cs @@ -2,6 +2,7 @@ using ARMeilleure.Decoders; using ARMeilleure.IntermediateRepresentation; using ARMeilleure.State; using ARMeilleure.Translation; +using ARMeilleure.Translation.PTC; using System; using static ARMeilleure.Instructions.InstEmitHelper; @@ -223,6 +224,7 @@ namespace ARMeilleure.Instructions public static void EmitTailContinue(ArmEmitterContext context, Operand address, bool allowRejit = false) { bool useTailContinue = true; // Left option here as it may be useful if we need to return to managed rather than tail call in future. (eg. for debug) + if (useTailContinue) { if (context.HighCq) @@ -230,7 +232,7 @@ namespace ARMeilleure.Instructions // If we're doing a tail continue in HighCq, reserve a space in the jump table to avoid calling back to the translator. // This will always try to get a HighCq version of our continue target as well. EmitJumpTableBranch(context, address, true); - } + } else { if (allowRejit) @@ -238,11 +240,11 @@ namespace ARMeilleure.Instructions address = context.BitwiseOr(address, Const(CallFlag)); } - Operand fallbackAddr = context.Call(new _U64_U64(NativeInterface.GetFunctionAddress), address); + Operand fallbackAddr = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFunctionAddress)), address); EmitNativeCall(context, fallbackAddr, true); } - } + } else { context.Return(address); @@ -260,7 +262,7 @@ namespace ARMeilleure.Instructions private static void EmitBranchFallback(ArmEmitterContext context, Operand address, bool isJump) { address = context.BitwiseOr(address, Const(address.Type, (long)CallFlag)); // Set call flag. - Operand fallbackAddr = context.Call(new _U64_U64(NativeInterface.GetFunctionAddress), address); + Operand fallbackAddr = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFunctionAddress)), address); EmitNativeCall(context, fallbackAddr, isJump); } @@ -290,12 +292,12 @@ namespace ARMeilleure.Instructions }; // Currently this uses a size of 1, as higher values inflate code size for no real benefit. - for (int i = 0; i < JumpTable.DynamicTableElems; i++) + for (int i = 0; i < JumpTable.DynamicTableElems; i++) { if (i == JumpTable.DynamicTableElems - 1) { emitTableEntry(fallbackLabel); // If this is the last entry, avoid emitting the additional label and add. - } + } else { Operand nextLabel = Label(); @@ -339,7 +341,18 @@ namespace ARMeilleure.Instructions int entry = context.JumpTable.ReserveDynamicEntry(isJump); int jumpOffset = entry * JumpTable.JumpTableStride * JumpTable.DynamicTableElems; - Operand dynTablePtr = Const(context.JumpTable.DynamicPointer.ToInt64() + jumpOffset); + + Operand dynTablePtr; + + if (Ptc.State == PtcState.Disabled) + { + dynTablePtr = Const(context.JumpTable.DynamicPointer.ToInt64() + jumpOffset); + } + else + { + dynTablePtr = Const(context.JumpTable.DynamicPointer.ToInt64(), true, Ptc.DynamicPointerIndex); + dynTablePtr = context.Add(dynTablePtr, Const((long)jumpOffset)); + } EmitDynamicTableCall(context, dynTablePtr, address, isJump); } @@ -349,8 +362,17 @@ namespace ARMeilleure.Instructions int jumpOffset = entry * JumpTable.JumpTableStride + 8; // Offset directly to the host address. - // TODO: Relocatable jump table ptr for AOT. Would prefer a solution to patch this constant into functions as they are loaded rather than calculate at runtime. - Operand tableEntryPtr = Const(context.JumpTable.JumpPointer.ToInt64() + jumpOffset); + Operand tableEntryPtr; + + if (Ptc.State == PtcState.Disabled) + { + tableEntryPtr = Const(context.JumpTable.JumpPointer.ToInt64() + jumpOffset); + } + else + { + tableEntryPtr = Const(context.JumpTable.JumpPointer.ToInt64(), true, Ptc.JumpPointerIndex); + tableEntryPtr = context.Add(tableEntryPtr, Const((long)jumpOffset)); + } Operand funcAddr = context.Load(OperandType.I64, tableEntryPtr); |