diff options
author | Michal Strehovsky <michals@microsoft.com> | 2018-07-23 10:23:45 +0300 |
---|---|---|
committer | Michal Strehovsky <michals@microsoft.com> | 2018-07-23 10:23:45 +0300 |
commit | 045a28051c6b85b82fe42e944fcb2267768ebbe2 (patch) | |
tree | 007e9d069f087ef48bb6270ccc710a555cef7d1a /src/Native | |
parent | 67ea31d51ad529912b00ad8bc7a29aa9621413db (diff) |
Make generic composition details relative addresses
I'm looking at size regressions between .NET Native 1.7 and the current mainline branch. A thing that stood out is universally bigger EETypes. A contributor to this was getting rid of GenericInstanceDescs between 1.7 and 2.0 and replacing them by direct references to generic composition details from the EEType. Size-wise, this was mostly a wash, but we can actually do better - these new fields are not critical to be pointer-sized.
This change turns them into relative pointers. This saves 33 kB on a hello world app. I expect around 100 kB savings on the UWP People app based on my back-of-the-envelope calculation.
Project N baggage:
1. Update pntestcl build configuration to compile it with a C# compiler that is not 8 years old
2. Disable metadata validation transform on class libraries. This is hitting what appears to be a CCI metadata validator bug (Validator.cs:796) where it thinks a modified type should have the same interned key as the unmodified version of it. The act of resolving a modified type strips off the modifier. This ticks off the validator.
3. Fix a Reducer bug where it wasn't marking non-interface constraints as necessary. The C# unmanaged constraint is expressed as [modreq UnmanagedType] ValueType. We were not marking UnmanagedType as necessary.
4. Update checked in binder because this is a file format change
[tfs-changeset: 1708263]
Diffstat (limited to 'src/Native')
-rw-r--r-- | src/Native/Runtime/inc/eetype.h | 16 | ||||
-rw-r--r-- | src/Native/Runtime/inc/eetype.inl | 60 |
2 files changed, 5 insertions, 71 deletions
diff --git a/src/Native/Runtime/inc/eetype.h b/src/Native/Runtime/inc/eetype.h index 39949b5eb..48431726a 100644 --- a/src/Native/Runtime/inc/eetype.h +++ b/src/Native/Runtime/inc/eetype.h @@ -568,23 +568,7 @@ public: bool HasDynamicallyAllocatedDispatchMap() { return (get_RareFlags() & HasDynamicallyAllocatedDispatchMapFlag) != 0; } - // Retrieve the generic type definition EEType for this generic instance - void set_GenericDefinition(EEType *pTypeDef); - - // Retrieve the generic type definition EEType for this generic instance - EETypeRef & get_GenericDefinition(); - inline void set_GenericComposition(GenericComposition *); - inline GenericComposition *get_GenericComposition(); - - // Retrieve the number of generic arguments for this generic type instance - UInt32 get_GenericArity(); - - // Retrieve the generic arguments to this type - EETypeRef * get_GenericArguments(); - - // Retrieve the generic variance associated with this type - GenericVarianceType* get_GenericVariance(); // Retrieve template used to create the dynamic type EEType * get_DynamicTemplateType(); diff --git a/src/Native/Runtime/inc/eetype.inl b/src/Native/Runtime/inc/eetype.inl index e26d53dba..38e4ad89a 100644 --- a/src/Native/Runtime/inc/eetype.inl +++ b/src/Native/Runtime/inc/eetype.inl @@ -372,65 +372,15 @@ inline UInt8 EEType::GetNullableValueOffset() return pOptFields->GetNullableValueOffset(0) + 1; } -inline void EEType::set_GenericDefinition(EEType *pTypeDef) -{ - ASSERT(IsGeneric()); - - UInt32 cbOffset = GetFieldOffset(ETF_GenericDefinition); - - *(EEType**)((UInt8*)this + cbOffset) = pTypeDef; -} - -inline EETypeRef & EEType::get_GenericDefinition() -{ - ASSERT(IsGeneric()); - - UInt32 cbOffset = GetFieldOffset(ETF_GenericDefinition); - - return *(EETypeRef *)((UInt8*)this + cbOffset); -} - inline void EEType::set_GenericComposition(GenericComposition *pGenericComposition) { - ASSERT(IsGeneric()); + ASSERT(IsGeneric() && IsDynamicType()); UInt32 cbOffset = GetFieldOffset(ETF_GenericComposition); *(GenericComposition **)((UInt8*)this + cbOffset) = pGenericComposition; } -inline GenericComposition *EEType::get_GenericComposition() -{ - ASSERT(IsGeneric()); - - UInt32 cbOffset = GetFieldOffset(ETF_GenericComposition); - - GenericComposition *pGenericComposition = *(GenericComposition **)((UInt8*)this + cbOffset); - - return pGenericComposition; -} - -inline UInt32 EEType::get_GenericArity() -{ - GenericComposition *pGenericComposition = get_GenericComposition(); - - return pGenericComposition->GetArity(); -} - -inline EETypeRef* EEType::get_GenericArguments() -{ - GenericComposition *pGenericComposition = get_GenericComposition(); - - return pGenericComposition->GetArguments(); -} - -inline GenericVarianceType* EEType::get_GenericVariance() -{ - GenericComposition *pGenericComposition = get_GenericComposition(); - - return pGenericComposition->GetVariance(); -} - inline EEType * EEType::get_DynamicTemplateType() { ASSERT(IsDynamicType()); @@ -570,7 +520,7 @@ inline DynamicModule * EEType::get_DynamicModule() + (fRequiresOptionalFields ? sizeof(UIntTarget) : 0) + (fRequiresNullableType ? sizeof(UIntTarget) : 0) + (fHasSealedVirtuals ? sizeof(Int32) : 0) - + (fHasGenericInfo ? sizeof(UIntTarget)*2 : 0); + + (fHasGenericInfo ? sizeof(UInt32)*2 : 0); } #if !defined(BINDER) && !defined(DACCESS_COMPILE) @@ -673,7 +623,7 @@ __forceinline UInt32 EEType::GetFieldOffset(EETypeField eField) return cbOffset; } if (IsGeneric()) - cbOffset += sizeof(UIntTarget); + cbOffset += (IsDynamicType() ? sizeof(UIntTarget) : sizeof(UInt32)); if (eField == ETF_GenericComposition) { @@ -681,7 +631,7 @@ __forceinline UInt32 EEType::GetFieldOffset(EETypeField eField) return cbOffset; } if (IsGeneric()) - cbOffset += sizeof(UIntTarget); + cbOffset += (IsDynamicType() ? sizeof(UIntTarget) : sizeof(UInt32)); if (eField == ETF_DynamicModule) { @@ -795,7 +745,7 @@ __forceinline UInt32 EEType::GetFieldOffset(EETypeField eField) { return cbOffset; } - cbOffset += sizeof(UIntTarget); + cbOffset += sizeof(UInt32); if (eField == ETF_GenericComposition) { |