Skip to content

Commit 5e1973b

Browse files
authored
Add few interpreter bringup diagnostic improvements (#116699)
This change improves the diagnosability of the interpreter issues during the bringup. It prints out unsupported IL opcodes when we hit one and also makes the assert go through the assertAbort instead of the regular assert, since the regular one pops out a dialog, so it is bad for batch testing.
1 parent 4e454ff commit 5e1973b

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ void DECLSPEC_NORETURN Interp_NOMEM()
4747
throw std::bad_alloc();
4848
}
4949

50+
void AssertOpCodeNotImplemented(const uint8_t *ip, size_t offset)
51+
{
52+
fprintf(stderr, "IL_%04x %-10s - opcode not supported yet\n",
53+
(int32_t)(offset),
54+
CEEOpName(CEEDecodeOpcode(&ip)));
55+
assert(!"opcode not implemented");
56+
}
57+
5058
// GCInfoEncoder needs an IAllocator implementation. This is a simple one that forwards to the Compiler.
5159
class InterpIAllocator : public IAllocator
5260
{
@@ -4570,8 +4578,11 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
45704578
break;
45714579
}
45724580
default:
4573-
assert(0);
4581+
{
4582+
const uint8_t *ip = m_ip - 1;
4583+
AssertOpCodeNotImplemented(ip, ip - m_pILCode);
45744584
break;
4585+
}
45754586
}
45764587
break;
45774588

@@ -5070,8 +5081,10 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
50705081
break;
50715082
}
50725083
default:
5073-
assert(0);
5084+
{
5085+
AssertOpCodeNotImplemented(m_ip, m_ip - m_pILCode);
50745086
break;
5087+
}
50755088
}
50765089
}
50775090

@@ -5095,6 +5108,7 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
50955108

50965109
return CORJIT_OK;
50975110
exit_bad_code:
5111+
assert(!m_hasInvalidCode);
50985112
return CORJIT_BADCODE;
50995113
}
51005114

src/coreclr/interpreter/interpreter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@
2525

2626
#define ALIGN_UP_TO(val,align) ((((size_t)val) + (size_t)((align) - 1)) & (~((size_t)(align - 1))))
2727

28+
#ifdef _DEBUG
29+
extern "C" void assertAbort(const char* why, const char* file, unsigned line);
30+
#undef assert
31+
#define assert(p) (void)((p) || (assertAbort(#p, __FILE__, __LINE__), 0))
32+
#endif // _DEBUG

0 commit comments

Comments
 (0)