whiteblackgoose / codegenanalysis Goto Github PK
View Code? Open in Web Editor NEWLibrary for obtaining and analyzing the codegen of JIT for .NET. Can be used for both tests (assertions) and making reports (benchmarks).
License: MIT License
Library for obtaining and analyzing the codegen of JIT for .NET. Can be used for both tests (assertions) and making reports (benchmarks).
License: MIT License
CodegenAnalyzers.GetBranches(CodegenInfo ci) -> IEnumerable<int>
CodegenAnalyzers.GetCalls(CodegenInfo ci) -> IEnumerable<int>
CodegenAnalyzers.GetLoops(CodegenInfo ci) -> IEnumerable<(int Start, int End)>
CodegenAnalyzers.GetStaticallyAllocatedStackMemory(CodegenInfo ci) -> int?
Merge of symbols in visualizer
Instead of hard-coded one, this one will detect the runtime version and adjust the tier to the best (with TC it will be tier1, otherwise default)
That one is just the core. It has the CodegenInfo
object, and everything to get it.
var ci = CodegenInfoResolver.GetCodegen(() => Add(4, 5));
Console.WriteLine(ci);
That one is a test suite: it has multiple assertions to verify the behaviour of JIT.
AssertCodegen.BranchesLessThan(5, () => Add(3, 5));
This one will build a report based on a codegen.
CodegenBenchmarkRunner.Run<Bench>();
class Bench
{
[Benchmark]
[Input(3, 5)]
public void Add(int a, int b) => a + b;
[Benchmark]
[Input(3, 5, 6)]
public void Add(int a, int b, int c) => a + b + c;
}
Output:
Method | Code size | Branches | Calls | Stack allocated memory | Backward jumps (loops) |
---|---|---|---|---|---|
SomeMethod | 43 B | 3 | - | - | 2 |
OtherMethod | 164 B | 7 | 11 | 164 B | - |
(and prints the codegen)
Similarly to ashmind/SharpLab#894
Currently the forwarded method must be public, otherwise a mysterious NRE is thrown.
if
s)To use [Benchmark]
and [GlobalSetup]
things by name
E. g. for CodegenDoesNotHaveBranches
it could look like this:
27382 mov rax, rdx
> 27385 test rax, rax
27387 jz 27382
29233 call aaaa
> 23928 cmp rdx, rax
20393 jg 29033
Line 125 in benchmark runner. Should produce something...
In EntryPointsListener
To allow investigating inner methods, e. g.
[CAAnalyze(5)]
[CASubject("CallA")]
public void SomeMethod(int a)
{
CallA(CallB(a));
}
The full arguments are
string methodName, Type[] typeArgs, Type[] parameterTypes
Where methodName
is
Method
SomeType.Method
SomeNamespace.SomeType.Method
A method with CAAnalyze
that forwards disassembling to another via CASubject
will only reach the first forwarded method. If that target method contains another CASubject
, it will be ignored. In other words, recursive method forwarding is not supported.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.