Skip to content

Commit

Permalink
Differentiate between IMPL_LIMITATION and NO_WAY (#43070)
Browse files Browse the repository at this point in the history
Differentiate between `IMPL_LIMITATION` and `NO_WAY` in the JIT by making `IMPL_LIMITATION` return `CORJIT_IMPLLIMITATION` and handle that value such that crossgen2 behavior behaves better in the presence of an `IMPL_LIMITATION`.

Also, change a `NO_WAY` in the X86 JIT to `IMPL_LIMITATION` to better reflect the issue in code.

The effect of these changes is that a test which encounters an `IMPL_LIMITATION` while running crossgen2 in our test suite will not cause the test to fail, but instead will only cause it to fail if the limitation is also present at runtime. This addresses the last issue known to cause the Pri0 X86 Crossgen2 tests to fail.
  • Loading branch information
davidwrighton authored Oct 9, 2020
1 parent faae224 commit d984ab7
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/coreclr/src/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ TODO: Talk about initializing strutures before use
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////

constexpr GUID JITEEVersionIdentifier = { /* a5eec3a4-4176-43a7-8c2b-a05b551d4f49 */
0xa5eec3a4,
0x4176,
0x43a7,
{0x8c, 0x2b, 0xa0, 0x5b, 0x55, 0x1d, 0x4f, 0x49}
constexpr GUID JITEEVersionIdentifier = { /* 062114d0-bd20-483f-8a3e-c4ee39706ae8 */
0x062114d0,
0xbd20,
0x483f,
{0x8a, 0x3e, 0xc4, 0xee, 0x39, 0x70, 0x6a, 0xe8}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum CorJitResult
CORJIT_INTERNALERROR = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 3),
CORJIT_SKIPPED = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 4),
CORJIT_RECOVERABLEERROR = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 5),
CORJIT_IMPLLIMITATION= MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 6),
};

/*****************************************************************************/
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,7 @@ void Compiler::compShutdown()
fprintf(fout, "---------------------------------------------------\n");
fprintf(fout, " badCode: %u\n", fatal_badCode);
fprintf(fout, " noWay: %u\n", fatal_noWay);
fprintf(fout, " implLimitation: %u\n", fatal_implLimitation);
fprintf(fout, " NOMEM: %u\n", fatal_NOMEM);
fprintf(fout, " noWayAssertBody: %u\n", fatal_noWayAssertBody);
#ifdef DEBUG
Expand Down Expand Up @@ -6822,7 +6823,9 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd,

result = param.result;

if (!inlineInfo && (result == CORJIT_INTERNALERROR || result == CORJIT_RECOVERABLEERROR) && !jitFallbackCompile)
if (!inlineInfo &&
(result == CORJIT_INTERNALERROR || result == CORJIT_RECOVERABLEERROR || result == CORJIT_IMPLLIMITATION) &&
!jitFallbackCompile)
{
// If we failed the JIT, reattempt with debuggable code.
jitFallbackCompile = true;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11003,6 +11003,7 @@ extern Histogram genTreeNsizHist;
#if MEASURE_FATAL
extern unsigned fatal_badCode;
extern unsigned fatal_noWay;
extern unsigned fatal_implLimitation;
extern unsigned fatal_NOMEM;
extern unsigned fatal_noWayAssertBody;
#ifdef DEBUG
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/src/jit/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#if MEASURE_FATAL
unsigned fatal_badCode;
unsigned fatal_noWay;
unsigned fatal_implLimitation;
unsigned fatal_NOMEM;
unsigned fatal_noWayAssertBody;
#ifdef DEBUG
Expand Down Expand Up @@ -65,6 +66,16 @@ void DECLSPEC_NORETURN noWay()
fatal(CORJIT_INTERNALERROR);
}

/*****************************************************************************/
void DECLSPEC_NORETURN implLimitation()
{
#if MEASURE_FATAL
fatal_implLimitation += 1;
#endif // MEASURE_FATAL

fatal(CORJIT_IMPLLIMITATION);
}

/*****************************************************************************/
void DECLSPEC_NORETURN NOMEM()
{
Expand Down
15 changes: 11 additions & 4 deletions src/coreclr/src/jit/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern void debugError(const char* msg, const char* file, unsigned line);
extern void DECLSPEC_NORETURN badCode();
extern void DECLSPEC_NORETURN badCode3(const char* msg, const char* msg2, int arg, __in_z const char* file, unsigned line);
extern void DECLSPEC_NORETURN noWay();
extern void DECLSPEC_NORETURN implLimitation();
extern void DECLSPEC_NORETURN NOMEM();
extern void DECLSPEC_NORETURN fatal(int errCode);

Expand Down Expand Up @@ -118,12 +119,22 @@ extern void RecordNowayAssertGlobal(const char* filename, unsigned line, const c

#define NOWAY_MSG(msg) noWayAssertBodyConditional(msg, __FILE__, __LINE__)

// IMPL_LIMITATION is called when we encounter valid IL that is not
// supported by our current implementation because of various
// limitations (that could be removed in the future)
#define IMPL_LIMITATION(msg) (debugError(msg, __FILE__, __LINE__), implLimitation())

#else // !DEBUG

#define NO_WAY(msg) noWay()
#define BADCODE(msg) badCode()
#define BADCODE3(msg, msg2, arg) badCode()

// IMPL_LIMITATION is called when we encounter valid IL that is not
// supported by our current implementation because of various
// limitations (that could be removed in the future)
#define IMPL_LIMITATION(msg) implLimitation()

#ifdef FEATURE_TRACELOGGING
#define NOWAY_ASSERT_BODY_ARGUMENTS __FILE__, __LINE__
#else
Expand All @@ -145,10 +156,6 @@ extern void RecordNowayAssertGlobal(const char* filename, unsigned line, const c

#endif // !DEBUG

// IMPL_LIMITATION is called when we encounter valid IL that is not
// supported by our current implementation because of various
// limitations (that could be removed in the future)
#define IMPL_LIMITATION(msg) NO_WAY(msg)

#if 1 // All platforms currently enable NYI; this should be a tighter condition to exclude some platforms from NYI

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void Compiler::lvaInitArgs(InitVarDscInfo* varDscInfo)
but it will be very difficult for fully interruptible code */

if (compArgSize != (size_t)(unsigned short)compArgSize)
NO_WAY("Too many arguments for the \"ret\" instruction to pop");
IMPL_LIMITATION("Too many arguments for the \"ret\" instruction to pop");
#endif
}

Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ private void CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, Method
{
ThrowHelper.ThrowInvalidProgramException();
}
if (result == CorJitResult.CORJIT_IMPLLIMITATION)
{
#if READYTORUN
throw new RequiresRuntimeJitException("JIT implementation limitation");
#else
ThrowHelper.ThrowInvalidProgramException();
#endif
}
if (result != CorJitResult.CORJIT_OK)
{
#if SUPPORT_JIT
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/src/tools/Common/JitInterface/CorInfoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,8 @@ public enum CorJitResult
CORJIT_OUTOFMEM = unchecked((int)0x80000002)/*MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 2)*/,
CORJIT_INTERNALERROR = unchecked((int)0x80000003)/*MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 3)*/,
CORJIT_SKIPPED = unchecked((int)0x80000004)/*MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 4)*/,
CORJIT_RECOVERABLEERROR = unchecked((int)0x80000005)/*MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 5)*/
CORJIT_RECOVERABLEERROR = unchecked((int)0x80000005)/*MAKE_HRESULT(SEVERITY_ERROR, FACILITY_NULL, 5)*/,
CORJIT_IMPLLIMITATION = unchecked((int)0x80000006)/*MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 6)*/,
};

public enum TypeCompareState
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/src/tools/aot/jitinterface/jitwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class CORJIT_FLAGS
uint64_t corJitFlags;
};

static const GUID JITEEVersionIdentifier = { /* a5eec3a4-4176-43a7-8c2b-a05b551d4f49 */
0xa5eec3a4,
0x4176,
0x43a7,
{0x8c, 0x2b, 0xa0, 0x5b, 0x55, 0x1d, 0x4f, 0x49}
static const GUID JITEEVersionIdentifier = { /* 062114d0-bd20-483f-8a3e-c4ee39706ae8 */
0x062114d0,
0xbd20,
0x483f,
{0x8a, 0x3e, 0xc4, 0xee, 0x39, 0x70, 0x6a, 0xe8}
};

class Jit
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12694,6 +12694,7 @@ void ThrowExceptionForJit(HRESULT res)
break;

case CORJIT_BADCODE:
case CORJIT_IMPLLIMITATION:
default:
COMPlusThrow(kInvalidProgramException);
break;
Expand Down

0 comments on commit d984ab7

Please sign in to comment.