Skip to content
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

Update Get/SetFieldValue to Account for EnC #90446

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions src/coreclr/vm/invokeutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@ void InvokeUtil::SetValidField(CorElementType fldType,
// call the <cinit>
OBJECTREF Throwable = NULL;

OBJECTREF obj = NULL;

jkotas marked this conversation as resolved.
Show resolved Hide resolved
MethodTable * pDeclMT = NULL;
if (!declaringType.IsNull())
{
Expand Down Expand Up @@ -905,10 +907,17 @@ void InvokeUtil::SetValidField(CorElementType fldType,
MethodTable *pMT = fldTH.AsMethodTable();
{
void* pFieldData;
fldTH.AsMethodTable()->EnsureActive();
obj = fldTH.AsMethodTable()->Allocate();
GCPROTECT_BEGIN(obj);
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
if (pField->IsStatic())
pFieldData = pField->GetCurrentStaticAddress();
else
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
pFieldData = (*((BYTE**)target)) + pField->GetOffset() + sizeof(Object);
{
OBJECTREF objRef = ObjectToOBJECTREF(obj);
pFieldData = pField->GetAddress(OBJECTREFToObject(objRef));
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
}
GCPROTECT_END();

if (*valueObj == NULL)
InitValueClass(pFieldData, pMT);
Expand Down Expand Up @@ -1051,7 +1060,8 @@ OBJECTREF InvokeUtil::GetFieldValue(FieldDesc* pField, TypeHandle fieldType, OBJ
if (pField->IsStatic())
p = pField->GetCurrentStaticAddress();
else {
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
p = (*((BYTE**)target)) + pField->GetOffset() + sizeof(Object);
OBJECTREF objRef = ObjectToOBJECTREF(obj);
p = pField->GetAddress(OBJECTREFToObject(objRef));
mikelle-rogers marked this conversation as resolved.
Show resolved Hide resolved
}
GCPROTECT_END();

Expand Down