Skip to content
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
25 changes: 22 additions & 3 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3863,13 +3863,32 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
int32_t token = getI4LittleEndian(m_ip + 1);
void *str;
InfoAccessType accessType = m_compHnd->constructStringLiteral(m_compScopeHnd, token, &str);
DeclarePointerIsString(str);
Comment thread
kg marked this conversation as resolved.
assert(accessType == IAT_VALUE);
// str should be forever pinned, so we can include its ref inside interpreter code
AddIns(INTOP_LDPTR);
m_pLastNewIns->data[0] = GetDataItemIndex(str);

if (accessType == IAT_PVALUE)
{
Comment thread
kg marked this conversation as resolved.
// IAT_PVALUE means str is a `ref string` not a `String` so the LDPTR produced an I
PushInterpType(InterpTypeI, nullptr);
int tempVar = m_pStackPointer[-1].var;
m_pLastNewIns->SetDVar(tempVar);

// Now we generate an LDIND_I to get the actual string out of the ref
AddIns(INTOP_LDIND_I);
// LDIND offset
m_pLastNewIns->data[0] = 0;
m_pLastNewIns->SetSVar(tempVar);
m_pStackPointer--;
}
else
{
assert(accessType == IAT_VALUE);
DeclarePointerIsString(str);
}

PushInterpType(InterpTypeO, m_compHnd->getBuiltinClass(CLASSID_STRING));
m_pLastNewIns->SetDVar(m_pStackPointer[-1].var);
m_pLastNewIns->data[0] = GetDataItemIndex(str);
m_ip += 5;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/interpreter/intops.def
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ OPDEF(INTOP_LDIND_I4, "ldind.i4", 4, 1, 1, InterpOpInt)
OPDEF(INTOP_LDIND_I8, "ldind.i8", 4, 1, 1, InterpOpInt)
OPDEF(INTOP_LDIND_R4, "ldind.r4", 4, 1, 1, InterpOpInt)
OPDEF(INTOP_LDIND_R8, "ldind.r8", 4, 1, 1, InterpOpInt)
OPDEF(INTOP_LDIND_O, "ldind.o", 4, 1, 1, InterpOpInt)
// No LDIND_O, use LDIND_I
OPDEF(INTOP_LDIND_VT, "ldind.vt", 5, 1, 1, InterpOpTwoInts)

OPDEF(INTOP_STIND_I1, "stind.i1", 4, 0, 2, InterpOpInt)
Expand Down
Loading