From 6d65e536642a7cff7afa34be10fdc8ca66a6e79c Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 19 Sep 2018 17:07:56 -0300 Subject: Remove cold methods from the CPU cache (#224) * Remove unused tracing functionality from the CPU * GetNsoExecutable -> GetExecutable * Unsigned comparison * Re-add cpu tracing * Config change * Remove cold methods from the translation cache on the cpu * Replace lock with try lock, pass new ATranslatorCache instead of ATranslator * Rebase fixups --- ChocolArm64/Translation/AILEmitterCtx.cs | 44 ++++++++++++-------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'ChocolArm64/Translation') diff --git a/ChocolArm64/Translation/AILEmitterCtx.cs b/ChocolArm64/Translation/AILEmitterCtx.cs index 48700715..cad0d323 100644 --- a/ChocolArm64/Translation/AILEmitterCtx.cs +++ b/ChocolArm64/Translation/AILEmitterCtx.cs @@ -10,7 +10,7 @@ namespace ChocolArm64.Translation { class AILEmitterCtx { - private ATranslator Translator; + private ATranslatorCache Cache; private Dictionary Labels; @@ -40,29 +40,14 @@ namespace ChocolArm64.Translation private const int Tmp5Index = -5; public AILEmitterCtx( - ATranslator Translator, - ABlock[] Graph, - ABlock Root, - string SubName) + ATranslatorCache Cache, + ABlock[] Graph, + ABlock Root, + string SubName) { - if (Translator == null) - { - throw new ArgumentNullException(nameof(Translator)); - } - - if (Graph == null) - { - throw new ArgumentNullException(nameof(Graph)); - } - - if (Root == null) - { - throw new ArgumentNullException(nameof(Root)); - } - - this.Translator = Translator; - this.Graph = Graph; - this.Root = Root; + this.Cache = Cache ?? throw new ArgumentNullException(nameof(Cache)); + this.Graph = Graph ?? throw new ArgumentNullException(nameof(Graph)); + this.Root = Root ?? throw new ArgumentNullException(nameof(Root)); Labels = new Dictionary(); @@ -147,7 +132,12 @@ namespace ChocolArm64.Translation return false; } - if (!Translator.TryGetCachedSub(CurrOp, out ATranslatedSub Sub)) + if (CurrOp.Emitter != AInstEmit.Bl) + { + return false; + } + + if (!Cache.TryGetSubroutine(((AOpCodeBImmAl)CurrOp).Imm, out ATranslatedSub Subroutine)) { return false; } @@ -157,7 +147,7 @@ namespace ChocolArm64.Translation EmitLdarg(Index); } - foreach (ARegister Reg in Sub.Params) + foreach (ARegister Reg in Subroutine.Params) { switch (Reg.Type) { @@ -167,9 +157,9 @@ namespace ChocolArm64.Translation } } - EmitCall(Sub.Method); + EmitCall(Subroutine.Method); - Sub.AddCaller(Root.Position); + Subroutine.AddCaller(Root.Position); return true; } -- cgit v1.2.3