Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Kestrel Dasm #1058

Closed
benaadams opened this issue Aug 20, 2016 · 5 comments
Closed

Kestrel Dasm #1058

benaadams opened this issue Aug 20, 2016 · 5 comments
Milestone

Comments

@benaadams
Copy link
Contributor

benaadams commented Aug 20, 2016

Produced this while looking at something else; might be interesting

Its ngen'd so caveats apply; Vector paths aren't taken and readonly statics aren't consts etc...
https://aoa.blob.core.windows.net/aspnet/Microsoft.AspNetCore.Server.Kestrel.dasm.txt

But should give flavour for what's inlined what's not, how things expand, what is converted to registers what not and why etc...

/cc @davidfowl @halter73 @CesarBS

@halter73
Copy link
Member

Cool. How did you create the ngen dasm?

@benaadams
Copy link
Contributor Author

Twist on dotnet/coreclr#6634 (comment)

Prep

  1. Build coreclr Checked
  2. Build jitutils https://github.com/dotnet/jitutils
  3. Build standalone app and publish (So it has all the dlls)
  4. Copy clrjit.dll from coreclr Checked (coreclr\bin\Product\Windows_NT.x64.Checked) over the one in publish dir

Iterations

  1. Build app, or lib (e.g. Kestrel)
  2. Copy dlls you want to examine over the ones in app publish dir
  3. at cmd set set COMPlus_JitPrintInlinedMethods=1
  4. run jit-dasm on publish directory (see below)
  5. Check the output text file

The command:

jit-dasm --platform MyApp\bin\Release\netcoreapp1.0\win7-x64\publish --base MyApp\bin\Release\netcoreapp1.0\win7-x64\publish\crossgen.exe --output M:\output\KDNEW MyApp\bin\Release\netcoreapp1.0\win7-x64\publish\Microsoft.AspNetCore.Server.Kestrel.dll

Would create a dasm file for Microsoft.AspNetCore.Server.Kestrel in M:\output\KDNEW\base

@benaadams
Copy link
Contributor Author

New info... so if you do the standalone app + publish, then copy the checked clrjit.dll over (Prep)

Then you can just set the set COMPlus_JitPrintInlinedMethods=1 flag and it will output all the inlines when you run it (won't do the dasm though).

Since its actually running it will take the vectors paths etc...

@muratg muratg added this to the Discussions milestone Sep 23, 2016
@benaadams
Copy link
Contributor Author

Also if you set set COMPlus_JitDisasm=* it will dump out all the jitted code when you run normally (using the checked clrjit.dll and everything else from clr Release)

@benaadams
Copy link
Contributor Author

benaadams commented Oct 5, 2016

Ok simplest path... Build coreclr checked and release (can keep using these till you want an new update of coreclr)

coreclr> build all x64 Checked Release skiptests

Build test app as win7-x64 standalone and publish

Copy all files from coreclr\bin\Product\Windows_NT.x64.Release and pdb to your standalone publish directory e.g. bin\Release\netcoreapp1.0\win7-x64\publish

Copy clrjit.dll over from checked coreclr\bin\Product\Windows_NT.x64.Checked into the same publish directory.

Set the enviorment vars
set COMPlus_JitPrintInlinedMethods=1
set COMPlus_JitDisasm=*

Run your standalone exe from the publish directory probably piping its output to a file > dasm.txt

You can also get the jit to only output a certain disassembly e.g. set COMPlus_JitDisasm=System.Generic.*

The jit will work in parallel, so wait for start up to complete before you try loading a page or the output will get interleaved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants