Skip to content

Commit 0b1f401

Browse files
authored
Support IAT_PVALUE string literals in the interpreter (#119011)
* Support IAT_PVALUE string literals in the interpreter * Remove LDIND_O
1 parent 47b35bc commit 0b1f401

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,13 +3898,32 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
38983898
int32_t token = getI4LittleEndian(m_ip + 1);
38993899
void *str;
39003900
InfoAccessType accessType = m_compHnd->constructStringLiteral(m_compScopeHnd, token, &str);
3901-
DeclarePointerIsString(str);
3902-
assert(accessType == IAT_VALUE);
39033901
// str should be forever pinned, so we can include its ref inside interpreter code
39043902
AddIns(INTOP_LDPTR);
3903+
m_pLastNewIns->data[0] = GetDataItemIndex(str);
3904+
3905+
if (accessType == IAT_PVALUE)
3906+
{
3907+
// IAT_PVALUE means str is a `ref string` not a `String` so the LDPTR produced an I
3908+
PushInterpType(InterpTypeI, nullptr);
3909+
int tempVar = m_pStackPointer[-1].var;
3910+
m_pLastNewIns->SetDVar(tempVar);
3911+
3912+
// Now we generate an LDIND_I to get the actual string out of the ref
3913+
AddIns(INTOP_LDIND_I);
3914+
// LDIND offset
3915+
m_pLastNewIns->data[0] = 0;
3916+
m_pLastNewIns->SetSVar(tempVar);
3917+
m_pStackPointer--;
3918+
}
3919+
else
3920+
{
3921+
assert(accessType == IAT_VALUE);
3922+
DeclarePointerIsString(str);
3923+
}
3924+
39053925
PushInterpType(InterpTypeO, m_compHnd->getBuiltinClass(CLASSID_STRING));
39063926
m_pLastNewIns->SetDVar(m_pStackPointer[-1].var);
3907-
m_pLastNewIns->data[0] = GetDataItemIndex(str);
39083927
m_ip += 5;
39093928
break;
39103929
}

src/coreclr/interpreter/intops.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ OPDEF(INTOP_LDIND_I4, "ldind.i4", 4, 1, 1, InterpOpInt)
338338
OPDEF(INTOP_LDIND_I8, "ldind.i8", 4, 1, 1, InterpOpInt)
339339
OPDEF(INTOP_LDIND_R4, "ldind.r4", 4, 1, 1, InterpOpInt)
340340
OPDEF(INTOP_LDIND_R8, "ldind.r8", 4, 1, 1, InterpOpInt)
341-
OPDEF(INTOP_LDIND_O, "ldind.o", 4, 1, 1, InterpOpInt)
341+
// No LDIND_O, use LDIND_I
342342
OPDEF(INTOP_LDIND_VT, "ldind.vt", 5, 1, 1, InterpOpTwoInts)
343343

344344
OPDEF(INTOP_STIND_I1, "stind.i1", 4, 0, 2, InterpOpInt)

0 commit comments

Comments
 (0)