Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use jit interface thunkgen tech for more files #45044

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

35 changes: 4 additions & 31 deletions src/coreclr/src/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,37 +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}
};

#include "jiteeversionguid.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the "END JITEEVersionIdentifier" comment needs to be in the jiteeversionguid.h file.

We probably should have big, unmiss-able, comments at the top of all the JIT-EE interface files pointing to the JIT-EE version, but that's somewhat unrelated; this system only works when code reviewers know to ask for an interface GUID change.

Maybe the jiteeversionguid.h file should also point to the updating-jitinterface.md documentation.

//
// END JITEEVersionIdentifier
Expand Down Expand Up @@ -2758,8 +2730,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
28 changes: 28 additions & 0 deletions src/coreclr/src/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this file also need a license notice?

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing trailing end-of-line character?

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