uint8_t buffer[maxElementSize] = {0};
if (info.compCompHnd->getObjectContent(obj, buffer, size, (int)byteOffset))
{
- ValueNum vn = vnStore->VNForGenericCon(tree->TypeGet(), buffer);
- assert(!vnStore->IsVNObjHandle(vn));
- tree->gtVNPair.SetBoth(vn);
- return true;
+ // If we have IND<size_t>(frozenObj) then it means we're reading object type
+ // so make sure we report the constant as class handle
+ if ((size == TARGET_POINTER_SIZE) && (byteOffset == 0))
+ {
+ // In case of 64bit jit emitting 32bit codegen this handle will be 64bit
+ // value holding 32bit handle with upper half zeroed (hence, "= NULL").
+ // It's done to match the current crossgen/ILC behavior.
+ CORINFO_CLASS_HANDLE rawHandle = NULL;
+ memcpy(&rawHandle, buffer, TARGET_POINTER_SIZE);
+
+ void* pEmbedClsHnd;
+ void* embedClsHnd = (void*)info.compCompHnd->embedClassHandle(rawHandle, &pEmbedClsHnd);
+ if (pEmbedClsHnd == nullptr)
+ {
+ // getObjectContent doesn't support reading handles for AOT (NativeAOT) yet
+ tree->gtVNPair.SetBoth(vnStore->VNForHandle((ssize_t)embedClsHnd, GTF_ICON_CLASS_HDL));
+ return true;
+ }
+ }
+ else
+ {
+ ValueNum vn = vnStore->VNForGenericCon(tree->TypeGet(), buffer);
+ assert(!vnStore->IsVNObjHandle(vn));
+ tree->gtVNPair.SetBoth(vn);
+ return true;
+ }
}
}
}