Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Determine desciptor for pointer-sized fields based on target not host…
Browse files Browse the repository at this point in the history
… pointer size.
  • Loading branch information
jkoritzinsky committed Aug 23, 2019
1 parent 1560c11 commit a811d96
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/vm/fieldmarshaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ VOID ParseNativeType(Module* pModule,
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_BLITTABLE_INTEGER, sizeof(INT32), alignof(INT32));
break;
case MarshalInfo::MARSHAL_TYPE_GENERIC_8:
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_BLITTABLE_INTEGER, sizeof(INT64), alignof(INT64));
#if defined(_TARGET_X86_) && defined(UNIX_X86_ABI)
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_BLITTABLE_INTEGER, sizeof(INT64), 4);
#else
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_BLITTABLE_INTEGER, sizeof(INT64), sizeof(INT64));
#endif
break;
case MarshalInfo::MARSHAL_TYPE_ANSICHAR:
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_INTEGER_LIKE, sizeof(CHAR), sizeof(CHAR));
Expand All @@ -126,7 +130,11 @@ VOID ParseNativeType(Module* pModule,
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_R4, sizeof(float), sizeof(float));
break;
case MarshalInfo::MARSHAL_TYPE_DOUBLE:
#if defined(_TARGET_X86_) && defined(UNIX_X86_ABI)
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_R8, sizeof(double), 4);
#else
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_R8, sizeof(double), sizeof(double));
#endif
break;
case MarshalInfo::MARSHAL_TYPE_CURRENCY:
*pNFD = NativeFieldDescriptor(NATIVE_FIELD_CATEGORY_COM_STRUCT, sizeof(CY), sizeof(CY));
Expand Down
24 changes: 20 additions & 4 deletions src/vm/mlinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,11 @@ MarshalInfo::MarshalInfo(Module* pModule,
m_resID = IDS_EE_BADMARSHAL_I;
IfFailGoto(E_FAIL, lFail);
}
m_type = (sizeof(LPVOID) == 4 ? MARSHAL_TYPE_GENERIC_4 : MARSHAL_TYPE_GENERIC_8);
#ifdef _TARGET_64BIT_
m_type = MARSHAL_TYPE_GENERIC_8;
#else
m_type = MARSHAL_TYPE_GENERIC_4;
#endif
break;

case ELEMENT_TYPE_U:
Expand All @@ -1930,7 +1934,11 @@ MarshalInfo::MarshalInfo(Module* pModule,
m_resID = IDS_EE_BADMARSHAL_I;
IfFailGoto(E_FAIL, lFail);
}
m_type = (sizeof(LPVOID) == 4 ? MARSHAL_TYPE_GENERIC_U4 : MARSHAL_TYPE_GENERIC_8);
#ifdef _TARGET_64BIT_
m_type = MARSHAL_TYPE_GENERIC_8;
#else
m_type = MARSHAL_TYPE_GENERIC_4;
#endif
break;


Expand Down Expand Up @@ -1962,7 +1970,11 @@ MarshalInfo::MarshalInfo(Module* pModule,
m_resID = IDS_EE_BADMARSHAL_PTR;
IfFailGoto(E_FAIL, lFail);
}
m_type = ( (sizeof(void*)==4) ? MARSHAL_TYPE_GENERIC_4 : MARSHAL_TYPE_GENERIC_8 );
#ifdef _TARGET_64BIT_
m_type = MARSHAL_TYPE_GENERIC_8;
#else
m_type = MARSHAL_TYPE_GENERIC_4;
#endif
break;

case ELEMENT_TYPE_FNPTR:
Expand All @@ -1979,7 +1991,11 @@ MarshalInfo::MarshalInfo(Module* pModule,
m_resID = IDS_EE_BADMARSHAL_FNPTR;
IfFailGoto(E_FAIL, lFail);
}
m_type = ( (sizeof(void*)==4) ? MARSHAL_TYPE_GENERIC_4 : MARSHAL_TYPE_GENERIC_8 );
#ifdef _TARGET_64BIT_
m_type = MARSHAL_TYPE_GENERIC_8;
#else
m_type = MARSHAL_TYPE_GENERIC_4;
#endif
break;

case ELEMENT_TYPE_OBJECT:
Expand Down
6 changes: 5 additions & 1 deletion src/vm/mlinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,11 @@ class ArrayMarshalInfo
else if (IsAMIExport64Bit(m_flags))
return 8;
else
return sizeof(LPVOID);
#ifdef _TARGET_64BIT_
return 8;
#else
return 4;
#endif
}

protected:
Expand Down

0 comments on commit a811d96

Please sign in to comment.