diff options
Diffstat (limited to 'ARMeilleure/CodeGen')
| -rw-r--r-- | ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs | 15 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/X86/CodeGenContext.cs | 15 | ||||
| -rw-r--r-- | ARMeilleure/CodeGen/X86/CodeGenerator.cs | 5 |
3 files changed, 14 insertions, 21 deletions
diff --git a/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs b/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs index 71739d43..cd36bdc0 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs @@ -50,6 +50,8 @@ namespace ARMeilleure.CodeGen.RegisterAllocators StackAlloc = stackAlloc; Masks = masks; + BitMapPool.PrepareBitMapPool(); + Active = BitMapPool.Allocate(intervalsCount); Inactive = BitMapPool.Allocate(intervalsCount); } @@ -73,7 +75,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators public void Dispose() { - BitMapPool.Release(); + BitMapPool.ResetBitMapPool(); } } @@ -84,7 +86,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { NumberLocals(cfg); - AllocationContext context = new AllocationContext(stackAlloc, regMasks, _intervals.Count); + using AllocationContext context = new AllocationContext(stackAlloc, regMasks, _intervals.Count); BuildIntervals(cfg, context); @@ -127,14 +129,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators InsertSplitCopies(); InsertSplitCopiesAtEdges(cfg); - AllocationResult result = new AllocationResult( - context.IntUsedRegisters, - context.VecUsedRegisters, - context.StackAlloc.TotalSize); - - context.Dispose(); - - return result; + return new AllocationResult(context.IntUsedRegisters, context.VecUsedRegisters, context.StackAlloc.TotalSize); } private void AllocateInterval(AllocationContext context, LiveInterval current, int cIndex) diff --git a/ARMeilleure/CodeGen/X86/CodeGenContext.cs b/ARMeilleure/CodeGen/X86/CodeGenContext.cs index da147cca..fa726f2f 100644 --- a/ARMeilleure/CodeGen/X86/CodeGenContext.cs +++ b/ARMeilleure/CodeGen/X86/CodeGenContext.cs @@ -2,6 +2,7 @@ using ARMeilleure.CodeGen.RegisterAllocators; using ARMeilleure.Common; using ARMeilleure.IntermediateRepresentation; using ARMeilleure.Translation.PTC; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -301,15 +302,13 @@ namespace ARMeilleure.CodeGen.X86 { Assembler assembler = new Assembler(codeStream, _ptcInfo); - byte[] buffer; - for (int index = 0; index < _jumps.Count; index++) { Jump jump = _jumps[index]; - buffer = new byte[jump.JumpPosition - _stream.Position]; + Span<byte> buffer = new byte[jump.JumpPosition - _stream.Position]; - _stream.Read(buffer, 0, buffer.Length); + _stream.Read(buffer); _stream.Seek(_ptcDisabled ? ReservedBytesForJump : jump.InstSize, SeekOrigin.Current); codeStream.Write(buffer); @@ -324,13 +323,7 @@ namespace ARMeilleure.CodeGen.X86 } } - buffer = new byte[_stream.Length - _stream.Position]; - - _stream.Read(buffer, 0, buffer.Length); - - codeStream.Write(buffer); - - _ptcInfo?.WriteCode(codeStream); + _stream.CopyTo(codeStream); return codeStream.ToArray(); } diff --git a/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/ARMeilleure/CodeGen/X86/CodeGenerator.cs index ca1f1ceb..3c14594d 100644 --- a/ARMeilleure/CodeGen/X86/CodeGenerator.cs +++ b/ARMeilleure/CodeGen/X86/CodeGenerator.cs @@ -190,6 +190,11 @@ namespace ARMeilleure.CodeGen.X86 byte[] code = context.GetCode(); + if (ptcInfo != null) + { + ptcInfo.Code = code; + } + Logger.EndPass(PassName.CodeGeneration); return new CompiledFunction(code, unwindInfo); |
