Skip to content

Instantly share code, notes, and snippets.

@EgorBo
Last active January 16, 2023 18:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EgorBo/a72bfa70f08a4d890241037c0fc1fb93 to your computer and use it in GitHub Desktop.
Save EgorBo/a72bfa70f08a4d890241037c0fc1fb93 to your computer and use it in GitHub Desktop.
jit-diffs for changes in C# code.md

How to run jit-diffs for changes in the managed code

All commands are in powershell, should be pretty much the same for bash and non-windows platforms

  1. build everything we're going to need:
.\build.cmd Clr+Libs -c Release ;; .\build.cmd Clr -c Checked ;; cd .\src\tests\ ;; .\build.cmd Release generatelayoutonly ;; cd ..\..
  1. Make a copy of the test core_root (will be a baseline):
Copy-Item .\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root -Destination .\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root_base -Recurse
  1. Apply your changes to the corelib or any managed library and rebuild them, e.g. change String.IsNullOrEmpty impl and do:
.\build.cmd Clr.CoreLib -c Release
  1. Copy your lib to the "diff" core_root:
Copy-Item .\artifacts\bin\coreclr\windows.x64.Release\IL\System.Private.CoreLib.dll -Destination artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root

Now we can run some jit-diffs:

New-Item -ItemType Directory -Force -Path C:\prj\jit-diffs

jit-diff diff --output C:\prj\jit-diffs --corelib --core_root C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root_base --base C:\prj\runtime\artifacts\bin\coreclr\windows.x64.Checked --crossgen C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root_base\crossgen2\crossgen2.exe

jit-diff diff --output C:\prj\jit-diffs --corelib --core_root C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root --base C:\prj\runtime\artifacts\bin\coreclr\windows.x64.Checked --crossgen C:\prj\runtime\artifacts\tests\coreclr\windows.x64.Release\Tests\Core_Root\crossgen2\crossgen2.exe

jit-analyze -b C:\prj\jit-diffs\dasmset_1\base -d C:\prj\jit-diffs\dasmset_2\base -r -c 100

NOTE: I'd recommend to clear C:\prj\jit-diffs content before every run (this script is hardcoded to dasmset_1 and dasmset_2)

NOTE2: replace --corelib with -f if you want to run diffs for the whole BCL

@gfoidl
Copy link

gfoidl commented Mar 29, 2022

๐Ÿ‘ comes in very handy (will need it the next days ๐Ÿ˜‰).
Can you move this (helpful) information to runtime/docs? It's easier findable there, than here or in jitutils-repo.
Or just supplement https://github.com/dotnet/jitutils/blob/main/doc/diffs.md?

@EgorBo
Copy link
Author

EgorBo commented Mar 29, 2022

๐Ÿ‘ comes in very handy (will need it the next days ๐Ÿ˜‰). Can you move this (helpful) information to runtime/docs? It's easier findable there, than here or in jitutils-repo. Or just supplement https://github.com/dotnet/jitutils/blob/main/doc/diffs.md?

Sure! ๐Ÿ™‚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment