Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1c98e2a
Fix dumping opcode
josesimoes Apr 21, 2026
45710ad
Fix initializing field from local vars when variable is MVAR
josesimoes Apr 22, 2026
ec2f4ed
Fix output and processing of VAR type when resolving a token
josesimoes Apr 22, 2026
394e1b2
InlineFrame now stores generic TypeSpec
josesimoes Apr 22, 2026
7077384
Implement CEE_CONSTRAINED
josesimoes Apr 22, 2026
e1e37a8
Fix BuildTypeName for MVAR processing
josesimoes Apr 22, 2026
28e41b8
Fix BuildMethodName to deal with MVAR resolution
josesimoes Apr 22, 2026
a9b1393
Fix resolving token for TypeDef Instance for VAR and SZArrayHelper
josesimoes Apr 22, 2026
f5857f9
Fix PushInline for call and callvirt
josesimoes Apr 22, 2026
246b1e1
Fix newobj to properly resolve MVAR constructors
josesimoes Apr 22, 2026
e0d9d82
Improve comment
josesimoes Apr 22, 2026
30eb6fc
Code style fix
josesimoes Apr 22, 2026
a48de44
Fix resolving token for TypeDef instance when dealing with MVAR
josesimoes Apr 22, 2026
869cc70
Code style fixes
nfbot Apr 22, 2026
43aba2e
Merge pull request #117 from nanoframework/nfbot/clang-format-fix/1db…
josesimoes Apr 22, 2026
4e3cc6e
Fixed CEE_CALLVIRT gate and unconditional clear constrainedTypeToken
josesimoes Apr 22, 2026
8041eb1
Fix InitializeFromSignatureToken for TypeDesc
josesimoes Apr 22, 2026
9247376
Add normalization of stack frame for generic types
josesimoes Apr 22, 2026
14c303e
Code style fixes
josesimoes Apr 22, 2026
38497ee
Various fixes from code review
josesimoes Apr 22, 2026
855f56e
Fix with invalid generic type in resolving token in TypeDef instance
josesimoes Apr 23, 2026
04394bf
Use contextTypeSpec when resolving VARs nested inside MethodSpec argu…
josesimoes Apr 23, 2026
58c6026
Code style fixes
nfbot Apr 23, 2026
4573cb1
Merge pull request #118 from nanoframework/nfbot/clang-format-fix/2be…
josesimoes Apr 23, 2026
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
43 changes: 37 additions & 6 deletions src/CLR/Core/CLR_RT_StackFrame.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -95,11 +95,12 @@ HRESULT CLR_RT_StackFrame::Push(CLR_RT_Thread *th, const CLR_RT_MethodDef_Instan
// CLR_UINT32 m_flags;
//
stack->m_call = *callInstPtr; // CLR_RT_MethodDef_Instance m_call;
//
// CLR_RT_MethodHandler m_nativeMethod;
// CLR_PMETADATA m_IPstart; // ANY HEAP - DO RELOCATION -
// CLR_PMETADATA m_IP; // ANY HEAP - DO RELOCATION -
//
stack->m_call.Normalize(*callInstPtr);
//
// CLR_RT_MethodHandler m_nativeMethod;
// CLR_PMETADATA m_IPstart; // ANY HEAP - DO RELOCATION -
// CLR_PMETADATA m_IP; // ANY HEAP - DO RELOCATION -
//
stack->m_locals =
stack->m_extension; // CLR_RT_HeapBlock* m_locals; // EVENT HEAP - NO RELOCATION -
stack->m_evalStack =
Expand Down Expand Up @@ -329,13 +330,21 @@ bool CLR_RT_StackFrame::PushInline(
m_inlineFrame->m_frame.m_locals = m_locals;
m_inlineFrame->m_frame.m_args = m_arguments;
m_inlineFrame->m_frame.m_call = m_call;
m_inlineFrame->m_frame.m_call.Normalize(m_call);
m_inlineFrame->m_frame.m_evalStack = m_evalStack;
m_inlineFrame->m_frame.m_evalPos = pThis;
m_inlineFrame->m_frame.m_localAllocCount = m_localAllocCount;
for (CLR_INT32 i = 0; i < c_Max_Localloc_Count; i++)
{
m_inlineFrame->m_frame.m_localAllocs[i] = m_localAllocs[i];
}
m_inlineFrame->m_frame.m_genericTypeSpecStorage = m_genericTypeSpecStorage;
// Normalize: if the saved m_call.genericType was pointing at the live frame's storage,
// redirect it to the copy inside the inline frame so the saved context is self-contained.
if (m_call.genericType == &m_genericTypeSpecStorage)
{
m_inlineFrame->m_frame.m_call.genericType = &m_inlineFrame->m_frame.m_genericTypeSpecStorage;
}

// increment the evalPos pointer so that we don't corrupt the real stack
evalPos++;
Expand All @@ -345,6 +354,7 @@ bool CLR_RT_StackFrame::PushInline(
m_arguments = pThis;
m_locals = &m_evalStackEnd[-md->localsCount];
m_call = calleeInst;
m_call.Normalize(calleeInst);
m_evalStackEnd = m_locals;
m_evalStack = evalPos;
m_evalStackPos = evalPos + 1;
Expand Down Expand Up @@ -428,6 +438,7 @@ void CLR_RT_StackFrame::RestoreFromInlineStack()
m_locals = m_inlineFrame->m_frame.m_locals;
m_evalStackEnd += m_call.target->localsCount;
m_call = m_inlineFrame->m_frame.m_call;
m_call.Normalize(m_inlineFrame->m_frame.m_call);
m_IP = m_inlineFrame->m_frame.m_IP;
m_IPstart = m_inlineFrame->m_frame.m_IPStart;
m_evalStack = m_inlineFrame->m_frame.m_evalStack;
Expand All @@ -437,13 +448,20 @@ void CLR_RT_StackFrame::RestoreFromInlineStack()
{
m_localAllocs[i] = m_inlineFrame->m_frame.m_localAllocs[i];
}
m_genericTypeSpecStorage = m_inlineFrame->m_frame.m_genericTypeSpecStorage;
// If the restored m_call.genericType pointed into m_genericTypeSpecStorage, fix the pointer.
if (m_call.genericType == &m_inlineFrame->m_frame.m_genericTypeSpecStorage)
{
m_call.genericType = &m_genericTypeSpecStorage;
}
}

void CLR_RT_StackFrame::RestoreStack(CLR_RT_InlineFrame &frame)
{
m_arguments = frame.m_args;
m_locals = frame.m_locals;
m_call = frame.m_call;
m_call.Normalize(frame.m_call);
m_IP = frame.m_IP;
m_IPstart = frame.m_IPStart;
m_evalStack = frame.m_evalStack;
Expand All @@ -454,13 +472,20 @@ void CLR_RT_StackFrame::RestoreStack(CLR_RT_InlineFrame &frame)
{
m_localAllocs[i] = frame.m_localAllocs[i];
}
m_genericTypeSpecStorage = frame.m_genericTypeSpecStorage;
// Normalize: if the restored m_call.genericType pointed at the saved frame storage, fix it up.
if (m_call.genericType == &frame.m_genericTypeSpecStorage)
{
m_call.genericType = &m_genericTypeSpecStorage;
}
}

void CLR_RT_StackFrame::SaveStack(CLR_RT_InlineFrame &frame)
{
frame.m_args = m_arguments;
frame.m_locals = m_locals;
frame.m_call = m_call;
frame.m_call.Normalize(m_call);
frame.m_IP = m_IP;
frame.m_IPStart = m_IPstart;
frame.m_evalPos = m_evalStackPos;
Expand All @@ -470,6 +495,12 @@ void CLR_RT_StackFrame::SaveStack(CLR_RT_InlineFrame &frame)
{
frame.m_localAllocs[i] = m_localAllocs[i];
}
frame.m_genericTypeSpecStorage = m_genericTypeSpecStorage;
// Normalize: redirect saved genericType pointer to the frame's own storage copy.
if (m_call.genericType == &m_genericTypeSpecStorage)
{
frame.m_call.genericType = &frame.m_genericTypeSpecStorage;
}
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/CLR/Core/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,9 +2127,9 @@ HRESULT CLR_RT_ExecutionEngine::InitializeReference(
}
else if (dt == DATATYPE_MVAR)
{
_ASSERTE(true);

goto process_datatype;
// MVAR cannot be resolved without method-spec context in InitializeReference.
// Treat as an object reference (null) so local initialization can proceed.
dt = DATATYPE_OBJECT;
}
else if (dt == DATATYPE_GENERICINST)
{
Expand Down
Loading