diff --git a/src/Benchmarks/Arch/X86/X86DisassemblerBenchmarks.cs b/src/Benchmarks/Arch/X86/X86DisassemblerBenchmarks.cs new file mode 100644 index 0000000000..533e2d1bba --- /dev/null +++ b/src/Benchmarks/Arch/X86/X86DisassemblerBenchmarks.cs @@ -0,0 +1,48 @@ +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using Reko.Arch.X86; +using Reko.Core; +using Reko.Core.Memory; +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Reko.Benchmarks.Arch.X86 +{ + [Config(typeof(Config))] + public class X86DisassemblerBenchmarks + { + private readonly ByteMemoryArea machineCode; + private readonly X86ArchitectureFlat32 arch; + + public X86DisassemblerBenchmarks() + { + var mem = new byte[4096]; + var rnd = new Random(0x142621A2); + rnd.NextBytes(mem); + this.machineCode = new ByteMemoryArea(Address.Ptr32(0x10000), mem); + this.arch = new X86ArchitectureFlat32(new ServiceContainer(), "x86-protected-32", new()); + } + + [Benchmark] + public void DisassembleBytes() + { + var rdr = arch.CreateImageReader(machineCode, 0); + var dasm = arch.CreateDisassembler(rdr); + foreach (var instr in dasm) + ; + } + + public class Config : ManualConfig + { + public Config() + { + AddDiagnoser(MemoryDiagnoser.Default); + } + } + } +} diff --git a/src/Benchmarks/Arch/X86/X86RewriterBenchmarks.cs b/src/Benchmarks/Arch/X86/X86RewriterBenchmarks.cs new file mode 100644 index 0000000000..5b658838a3 --- /dev/null +++ b/src/Benchmarks/Arch/X86/X86RewriterBenchmarks.cs @@ -0,0 +1,51 @@ +using BenchmarkDotNet.Attributes; +using Reko.Arch.X86; +using Reko.Core.Memory; +using Reko.Core; +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using System.Reflection; + +namespace Reko.Benchmarks.Arch.X86 +{ + [Config(typeof(Config))] + public class X86RewriterBenchmarks + { + private readonly ByteMemoryArea machineCode; + private readonly X86ArchitectureFlat32 arch; + + public X86RewriterBenchmarks() + { + var mem = new byte[4096]; + var rnd = new Random(0x142621A2); + rnd.NextBytes(mem); + this.machineCode = new ByteMemoryArea(Address.Ptr32(0x10000), mem); + this.arch = new X86ArchitectureFlat32(new ServiceContainer(), "x86-protected-32", new()); + } + + [Benchmark] + public void LiftMachineCode() + { + var rdr = arch.CreateImageReader(machineCode, 0); + var rw = arch.CreateRewriter(rdr, arch.CreateProcessorState(), new StorageBinder(), new NullRewriterHost()); + foreach (var rtlc in rw) + ; + } + + public class Config : ManualConfig + { + public Config() + { + AddDiagnoser(MemoryDiagnoser.Default); + } + } + + + } +} diff --git a/subjects/regression.log b/subjects/regression.log index 01eb15d179..beb8e1a50c 100644 --- a/subjects/regression.log +++ b/subjects/regression.log @@ -1327,7 +1327,8 @@ finish: error: An error occurred while renaming variables. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Reko.Analysis.SsaLivenessAnalysis.LiveOutAtBlock(Block b, SsaIdentifier v) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 170 at Reko.Analysis.SsaLivenessAnalysis.BuildInterferenceGraph(SsaIdentifierCollection ssaIds) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 100 - at Reko.Analysis.LiveCopyInserter..ctor(SsaState ssa) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 43 + at Reko.Analysis.SsaLivenessAnalysis..ctor(SsaState ssa) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 62 + at Reko.Analysis.LiveCopyInserter..ctor(SsaState ssa) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 41 at Reko.Analysis.WebBuilder.Worker.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\WebBuilder.cs:line 136 l00401628: warning: Non-integral switch expression l00401614: warning: Non-integral switch expression @@ -1428,7 +1429,6 @@ fn0800_1CF6: error: An error occurred while renaming variables. The given key 'l0800_1D54' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Reko.Analysis.SsaLivenessAnalysis.IsLiveIn(Identifier id, Statement stm) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 129 - at Reko.Analysis.LiveCopyInserter.IsLiveAtCopyPoint(Identifier id, Block b) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 91 at Reko.Analysis.LiveCopyInserter.Transform(Statement stm, PhiAssignment phi) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 119 at Reko.Analysis.LiveCopyInserter.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 106 at Reko.Analysis.WebBuilder.Worker.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\WebBuilder.cs:line 136 @@ -1436,7 +1436,6 @@ fn0800_67BF: error: An error occurred while renaming variables. The given key 'l0800_6A7C' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Reko.Analysis.SsaLivenessAnalysis.IsLiveIn(Identifier id, Statement stm) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 129 - at Reko.Analysis.LiveCopyInserter.IsLiveAtCopyPoint(Identifier id, Block b) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 91 at Reko.Analysis.LiveCopyInserter.Transform(Statement stm, PhiAssignment phi) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 119 at Reko.Analysis.LiveCopyInserter.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 106 at Reko.Analysis.WebBuilder.Worker.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\WebBuilder.cs:line 136 @@ -1444,7 +1443,6 @@ fn0800_4F2C: error: An error occurred while renaming variables. The given key 'l0800_4F67' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Reko.Analysis.SsaLivenessAnalysis.IsLiveIn(Identifier id, Statement stm) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 129 - at Reko.Analysis.LiveCopyInserter.IsLiveAtCopyPoint(Identifier id, Block b) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 91 at Reko.Analysis.LiveCopyInserter.Transform(Statement stm, PhiAssignment phi) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 119 at Reko.Analysis.LiveCopyInserter.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 106 at Reko.Analysis.WebBuilder.Worker.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\WebBuilder.cs:line 136 @@ -1452,7 +1450,6 @@ fn0800_C177: error: An error occurred while renaming variables. The given key 'l0800_C22D' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Reko.Analysis.SsaLivenessAnalysis.IsLiveIn(Identifier id, Statement stm) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\SsaLiveness.cs:line 129 - at Reko.Analysis.LiveCopyInserter.IsLiveAtCopyPoint(Identifier id, Block b) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 91 at Reko.Analysis.LiveCopyInserter.Transform(Statement stm, PhiAssignment phi) in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 119 at Reko.Analysis.LiveCopyInserter.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\LiveCopyInserter.cs:line 106 at Reko.Analysis.WebBuilder.Worker.Transform() in c:\dev\uxmal\reko\master\src\Decompiler\Analysis\WebBuilder.cs:line 136 @@ -2399,4 +2396,4 @@ PE Debug type 14 not supported yet. === PE\x86\VCExeSample\VCExeSample Signature of 'Microsoft Visual C++ 8' detected. -Decompiled 96 binaries in 47.93 seconds. +Decompiled 96 binaries in 58.97 seconds.