Skip to content

Commit

Permalink
Update Get/SetFieldValue to Account for EnC (#90446)
Browse files Browse the repository at this point in the history
* update Get/SetFieldValue

* get the address of the instance

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
  • Loading branch information
mikelle-rogers and jkotas authored Aug 15, 2023
1 parent 1eb702c commit 337e95e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/coreclr/vm/invokeutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,13 @@ void InvokeUtil::SetValidField(CorElementType fldType,
{
void* pFieldData;
if (pField->IsStatic())
{
pFieldData = pField->GetCurrentStaticAddress();
}
else
pFieldData = (*((BYTE**)target)) + pField->GetOffset() + sizeof(Object);
{
pFieldData = pField->GetInstanceAddress(*target);
}

if (*valueObj == NULL)
InitValueClass(pFieldData, pMT);
Expand Down Expand Up @@ -1049,9 +1053,12 @@ OBJECTREF InvokeUtil::GetFieldValue(FieldDesc* pField, TypeHandle fieldType, OBJ
GCPROTECT_BEGIN(obj);
// calculate the offset to the field...
if (pField->IsStatic())
{
p = pField->GetCurrentStaticAddress();
else {
p = (*((BYTE**)target)) + pField->GetOffset() + sizeof(Object);
}
else
{
p = pField->GetInstanceAddress(*target);
}
GCPROTECT_END();

Expand Down

0 comments on commit 337e95e

Please sign in to comment.