Skip to content

Commit

Permalink
Use jit interface thunkgen tech for more files (#45044)
Browse files Browse the repository at this point in the history
- Reduce the boilerplate logic when modifying the jit ee interface
 - 3 new files in superpmi are now autogenerated as well as 2 files in the jit directory are now autogenerated
- Reduce to only having one copy of the jit-ee interface guid
  • Loading branch information
davidwrighton authored Dec 2, 2020
1 parent 3c39a5d commit e9a47b7
Show file tree
Hide file tree
Showing 19 changed files with 4,353 additions and 4,838 deletions.
8 changes: 4 additions & 4 deletions docs/project/updating-jitinterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ The JitInterface serves two purposes:

There are several components that consume the JIT outside of the runtime. Since those components don't consume the JIT using the header, changes to the JIT have to be ported manually.

The JitInterface is versioned by a GUID. Any change to JitInterface is required to update the JitInterface GUID located in corinfo.h (look for `JITEEVersionIdentifier`). Not doing so has consequences that are sometimes hard to debug.
The JitInterface is versioned by a GUID. Any change to JitInterface is required to update the JitInterface GUID located in jiteeversionguid.h (look for `JITEEVersionIdentifier`). Not doing so has consequences that are sometimes hard to debug.

If a method was added or modified in ICorStaticInfo or ICorDynamicInfo, port the change to src/coreclr/src/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt. Functions must be in the same order in ThunkInput.txt as they exist in corinfo.h and corjit.h. Run gen.bat or gen.sh to regenerate CorInfoBase.cs, jitinterface.h, ICorJitInfo_API_names.h, ICorJitInfo_API_wrapper.hpp, superpmi-shared\icorjitinfoimpl.h, superpmi-shim-counter\icorjitinfo.cpp, and superpmi-shim-simple\icorjitinfo.cpp from ThunkInput.txt. Provide a managed implementation of the method in CorInfoImpl.cs.

## Porting JitInterface changes to crossgen2

Crossgen2 is the AOT compiler for CoreCLR. It generates native code for .NET apps ahead of time and uses the JIT to do that. Since crossgen2 is written in managed code, it doesn't consume the C++ headers and maintains a managed copy of them. Changes to JitInterface need to be ported managed code.

1. If an enum/struct was modified or added, port the change to CorInfoTypes.cs.
2. If a method was added or modified in ICorStaticInfo or ICorDynamicInfo, port the change to ThunkInput.txt.
Run gen.bat or gen.sh to regenerate CorInfoBase.cs and jitinterface.h from ThunkInput.txt. Provide a managed implementation of the method in CorInfoImpl.cs. If the managed implementation is specific to CoreCLR ReadyToRun (and doesn't apply to full AOT compilation), provide the implementation in CorInfoImpl.ReadyToRun.cs instead.
3. Update JitInterface GUID in jitwrapper.cpp.
2. If a method was added or modified in ICorStaticInfo or ICorDynamicInfo, if the managed implementation is specific to CoreCLR ReadyToRun (and doesn't apply to full AOT compilation), provide the implementation in CorInfoImpl.ReadyToRun.cs instead or CorInfoImpl.cs.

1,591 changes: 622 additions & 969 deletions src/coreclr/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h

Large diffs are not rendered by default.

1,376 changes: 540 additions & 836 deletions src/coreclr/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp

Large diffs are not rendered by default.

1,359 changes: 540 additions & 819 deletions src/coreclr/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp

Large diffs are not rendered by default.

40 changes: 4 additions & 36 deletions src/coreclr/src/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,42 +184,9 @@ TODO: Talk about initializing strutures before use
#ifndef _COR_INFO_H_
#define _COR_INFO_H_

#include <corhdr.h>
#include "corhdr.h"
#include <specstrings.h>

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
//
// #JITEEVersionIdentifier
//
// This GUID represents the version of the JIT/EE interface. Any time the interface between the JIT and
// the EE changes (by adding or removing methods to any interface shared between them), this GUID should
// be changed. This is the identifier verified by ICorJitCompiler::getVersionIdentifier().
//
// You can use "uuidgen.exe -s" to generate this value.
//
// **** NOTE TO INTEGRATORS:
//
// If there is a merge conflict here, because the version changed in two different places, you must
// create a **NEW** GUID, not simply choose one or the other!
//
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

constexpr GUID JITEEVersionIdentifier = { /* 0d235fe4-65a1-487a-8553-c845496da901 */
0x0d235fe4,
0x65a1,
0x487a,
{0x85, 0x53, 0xc8, 0x45, 0x49, 0x6d, 0xa9, 0x01}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// END JITEEVersionIdentifier
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "jiteeversionguid.h"

// For System V on the CLR type system number of registers to pass in and return a struct is the same.
// The CLR type system allows only up to 2 eightbytes to be passed in registers. There is no SSEUP classification types.
Expand Down Expand Up @@ -2758,8 +2725,9 @@ class ICorStaticInfo
// to interface functions that may throw exceptions without needing to be aware of
// the EH ABI, exception types, etc. Returns true if the given function completed
// successfully and false otherwise.
typedef void (*errorTrapFunction)(void*);
virtual bool runWithErrorTrap(
void (*function)(void*), // The function to run
errorTrapFunction function, // The function to run
void* parameter // The context parameter that will be passed to the function and the handler
) = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/src/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#ifndef _COR_JIT_H_
#define _COR_JIT_H_

#include <corinfo.h>
#include "corinfo.h"

#include <stdarg.h>

#include <corjitflags.h>
#include "corjitflags.h"

/*****************************************************************************/
// These are error codes returned by CompileMethod
Expand Down
39 changes: 39 additions & 0 deletions src/coreclr/src/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
//
// #JITEEVersionIdentifier
//
// This GUID represents the version of the JIT/EE interface. Any time the interface between the JIT and
// the EE changes (by adding or removing methods to any interface shared between them), this GUID should
// be changed. This is the identifier verified by ICorJitCompiler::getVersionIdentifier().
//
// You can use "uuidgen.exe -s" to generate this value.
//
// See docs/project/updating-jitinterface.md for details
//
// **** NOTE TO INTEGRATORS:
//
// If there is a merge conflict here, because the version changed in two different places, you must
// create a **NEW** GUID, not simply choose one or the other!
//
// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

constexpr GUID JITEEVersionIdentifier = { /* 0d235fe4-65a1-487a-8553-c845496da901 */
0x0d235fe4,
0x65a1,
0x487a,
{0x85, 0x53, 0xc8, 0x45, 0x49, 0x6d, 0xa9, 0x01}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// END JITEEVersionIdentifier
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////
8 changes: 6 additions & 2 deletions src/coreclr/src/jit/ICorJitInfo_API_names.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// DO NOT EDIT THIS FILE! IT IS AUTOGENERATED
// To regenerate run the gen script in src/coreclr/src/tools/Common/JitInterface/ThunkGenerator
// and follow the instructions in docs/project/updating-jitinterface.md
DEF_CLR_API(getMethodAttribs)
DEF_CLR_API(setMethodAttribs)
DEF_CLR_API(getMethodSig)
Expand All @@ -26,6 +29,8 @@ DEF_CLR_API(isCompatibleDelegate)
DEF_CLR_API(methodMustBeLoadedBeforeCodeIsRun)
DEF_CLR_API(mapMethodDeclToMethodImpl)
DEF_CLR_API(getGSCookie)
DEF_CLR_API(setPatchpointInfo)
DEF_CLR_API(getOSRInfo)
DEF_CLR_API(resolveToken)
DEF_CLR_API(tryResolveToken)
DEF_CLR_API(findSig)
Expand Down Expand Up @@ -153,19 +158,18 @@ DEF_CLR_API(MethodCompileComplete)
DEF_CLR_API(getTailCallHelpers)
DEF_CLR_API(convertPInvokeCalliToCall)
DEF_CLR_API(notifyInstructionSetUsage)
DEF_CLR_API(getMemoryManager)
DEF_CLR_API(allocMem)
DEF_CLR_API(reserveUnwindInfo)
DEF_CLR_API(allocUnwindInfo)
DEF_CLR_API(allocGCInfo)
DEF_CLR_API(yieldExecution)
DEF_CLR_API(setEHcount)
DEF_CLR_API(setEHinfo)
DEF_CLR_API(logMsg)
DEF_CLR_API(doAssert)
DEF_CLR_API(reportFatalError)
DEF_CLR_API(allocMethodBlockCounts)
DEF_CLR_API(getMethodBlockCounts)
DEF_CLR_API(getLikelyClass)
DEF_CLR_API(recordCallSite)
DEF_CLR_API(recordRelocation)
DEF_CLR_API(getRelocTypeHint)
Expand Down
Loading

0 comments on commit e9a47b7

Please sign in to comment.