Skip to content

Add few interpreter bringup diagnostic improvements #116699

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

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 16 additions & 2 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ void DECLSPEC_NORETURN Interp_NOMEM()
throw std::bad_alloc();
}

void AssertOpCodeNotImplemented(const uint8_t *ip, size_t offset)
{
fprintf(stderr, "IL_%04x %-10s - opcode not supported yet\n",
(int32_t)(offset),
CEEOpName(CEEDecodeOpcode(&ip)));
assert(!"opcode not implemented");
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Consider providing a more descriptive error message in the assert call (e.g., including opcode value or context) to facilitate easier debugging when an unsupported opcode is encountered.

Suggested change
assert(!"opcode not implemented");
assert((fprintf(stderr, "Assertion failed: IL_%04x %-10s - opcode not supported yet\n", (int32_t)(offset), CEEOpName(CEEDecodeOpcode(&ip))), false));

Copilot uses AI. Check for mistakes.

}

// GCInfoEncoder needs an IAllocator implementation. This is a simple one that forwards to the Compiler.
class InterpIAllocator : public IAllocator
{
Expand Down Expand Up @@ -4559,8 +4567,11 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
break;
}
default:
assert(0);
{
const uint8_t *ip = m_ip - 1;
AssertOpCodeNotImplemented(ip, ip - m_pILCode);
break;
}
}
break;

Expand Down Expand Up @@ -5059,8 +5070,10 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
break;
}
default:
assert(0);
{
AssertOpCodeNotImplemented(m_ip, m_ip - m_pILCode);
break;
}
}
}

Expand All @@ -5084,6 +5097,7 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)

return CORJIT_OK;
exit_bad_code:
assert(!m_hasInvalidCode);
return CORJIT_BADCODE;
}

Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/interpreter/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@

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

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