Skip to content

Commit d85eb92

Browse files
committed
Open source SuperPMI
OVERVIEW ======== This directory contains the SuperPMI tool used for testing the .NET just-in-time (JIT) compiler. SuperPMI has two uses: 1. Verification that a JIT code change doesn't cause any asserts. 2. Finding test code where two JIT compilers generate different code, or verifying that the two compilers generate the same code. Case dotnet#1 is useful for doing quick regression checking when making a source code change to the JIT compiler. The process is: (a) make a JIT source code change, (b) run that newly built JIT through a SuperPMI run to verify no asserts have been introduced. Case dotnet#2 is useful for generating assembly language diffs, to help analyze the impact of a JIT code change. SuperPMI works in two phases: collection and playback. In the collection phase, the system is configured to collect SuperPMI data. Then, run any set of .NET managed programs. When these managed programs invoke the JIT compiler, SuperPMI gathers and captures all information passed between the JIT and its .NET host. In the playback phase, SuperPMI loads the JIT directly, and causes it to compile all the functions that it previously compiled, but using the collected data to provide answers to various questions that the JIT needs to ask. The .NET execution engine (EE) is not invoked at all. TOOLS ========== There are two native executable tools: superpmi and mcs. There is a .NET Core C# program that is built as part of the coreclr repo tests build called superpmicollect.exe. All will show a help screen if passed -?. COLLECTION ========== Set the following environment variables: SuperPMIShimLogPath=<full path to an empty temporary directory> SuperPMIShimPath=<full path to clrjit.dll, the "standalone" JIT> COMPlus_AltJit=* COMPlus_AltJitName=superpmi-shim-collector.dll (On Linux, use libclrjit.so and libsuperpmi-shim-collector.so. On Mac, use libclrjit.dylib and libsuperpmi-shim-collector.dylib.) Then, run some managed programs. When done running programs, un-set these variables. Now, you will have a large number of .mc files. Merge these using the mcs tool: mcs -merge base.mch *.mc One benefit of SuperPMI is the ability to remove duplicated compilations, so on replay only unique functions are compiled. Use the following to create a "unique" set of functions: mcs -removeDup -thin base.mch unique.mch Note that -thin is not required. However, it will delete all the compilation result collected during the collection phase, which makes the resulting MCH file smaller. Those compilation results are not required for playback. Use the superpmicollect.exe tool to automate and simplify this process. PLAYBACK ======== Once you have a merged, de-duplicated MCH collection, you can play it back using: superpmi unique.mch clrjit.dll You can do this much faster by utilizing all the processors on your machine, and replaying in parallel, using: superpmi -p unique.mch clrjit.dll REMAINING WORK ============= The basic of assembly diffing are there, using the "coredistools" package. The open source build needs to be altered to use this package to wire up the correct build steps. [tfs-changeset: 1623347]
1 parent 9518103 commit d85eb92

File tree

164 files changed

+35499
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+35499
-1
lines changed

src/ToolBox/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
add_subdirectory(SOS)
1+
add_subdirectory(SOS)
2+
add_subdirectory(superpmi)

src/ToolBox/superpmi/.gitmirror

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Only contents of this folder, excluding subfolders, will be mirrored by the Git-TFS Mirror.

src/ToolBox/superpmi/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_subdirectory(superpmi)
2+
add_subdirectory(mcs)
3+
add_subdirectory(superpmi-shim-collector)
4+
add_subdirectory(superpmi-shim-counter)
5+
add_subdirectory(superpmi-shim-simple)

src/ToolBox/superpmi/mcs/.gitmirror

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Only contents of this folder, excluding subfolders, will be mirrored by the Git-TFS Mirror.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
project(mcs)
2+
3+
remove_definitions(-DUNICODE)
4+
remove_definitions(-D_UNICODE)
5+
6+
add_definitions(-DFEATURE_NO_HOST)
7+
add_definitions(-DSELF_NO_HOST)
8+
9+
if(WIN32)
10+
#use static crt
11+
add_definitions(-MT)
12+
endif(WIN32)
13+
14+
include_directories(.)
15+
include_directories(../superpmi-shared)
16+
17+
set(MCS_SOURCES
18+
commandline.cpp
19+
mcs.cpp
20+
verbasmdump.cpp
21+
verbconcat.cpp
22+
verbdump.cpp
23+
verbdumpmap.cpp
24+
verbdumptoc.cpp
25+
verbfracture.cpp
26+
verbildump.cpp
27+
verbinteg.cpp
28+
verbmerge.cpp
29+
verbremovedup.cpp
30+
verbsmarty.cpp
31+
verbstat.cpp
32+
verbstrip.cpp
33+
verbtoc.cpp
34+
../superpmi-shared/asmdumper.cpp
35+
../superpmi-shared/callutils.cpp
36+
../superpmi-shared/compileresult.cpp
37+
../superpmi-shared/errorhandling.cpp
38+
../superpmi-shared/logging.cpp
39+
../superpmi-shared/mclist.cpp
40+
../superpmi-shared/methodcontext.cpp
41+
../superpmi-shared/methodcontextiterator.cpp
42+
../superpmi-shared/methodcontextreader.cpp
43+
../superpmi-shared/simpletimer.cpp
44+
../superpmi-shared/spmiutil.cpp
45+
../superpmi-shared/tocfile.cpp
46+
../superpmi-shared/typeutils.cpp
47+
)
48+
49+
add_precompiled_header(
50+
standardpch.h
51+
../superpmi-shared/standardpch.cpp
52+
MCS_SOURCES
53+
)
54+
55+
add_executable(mcs
56+
${MCS_SOURCES}
57+
)
58+
59+
if(CLR_CMAKE_PLATFORM_UNIX)
60+
target_link_libraries(mcs
61+
utilcodestaticnohost
62+
mscorrc_debug
63+
coreclrpal
64+
palrt
65+
)
66+
else()
67+
target_link_libraries(mcs
68+
advapi32.lib
69+
${STATIC_MT_CRT_LIB}
70+
${STATIC_MT_CPP_LIB}
71+
)
72+
73+
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/mcs.pdb DESTINATION PDB)
74+
endif(CLR_CMAKE_PLATFORM_UNIX)
75+
76+
install (TARGETS mcs DESTINATION .)

0 commit comments

Comments
 (0)