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

Adding ValidateTypeIsBlittable SpanHelper method and rename constant #24626

Merged
merged 5 commits into from
Oct 18, 2017

Conversation

ahsonkhan
Copy link

@ahsonkhan ahsonkhan commented Oct 13, 2017

Addressing leftover feedback from #24400 (review)

cc @weshaggard, @KrzysztofCwalina, @jkotas

ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
}
#endif
SpanHelpers.ValidateTypeIsBlittable<T>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeHelpers.IsReferenceOrContainsReferences<T> needs to be called directly, not via wrapper method. The JIT won't be able to inline the wrapper method in all cases. This is introducing performance regression.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the JIT be able to inline the helper method as well? If not would it be able to handle it if it didn't wrap the exception throwing as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All generic methods wrapping other generic methods are problematic. They do not always inline well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I will revert this change. Is there any way to avoid having the #ifdef in multiple places (whenever I need to call IsReferenceOrContainsReferences) without a performance regression?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put the whole thing in separate files. (I do not think it is an improvement.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK @ahsonkhan thanks for trying to apply my feedback feel free to undo this part of the change and just do the other 2 pieces.

@@ -7,7 +7,7 @@
<CLSCompliant>false</CLSCompliant>
<DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'uap'">true</IsPartialFacadeAssembly>
<DefineConstants Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(DefineConstants);IsPartialFacade</DefineConstants>
<DefineConstants Condition="'$(IsPartialFacadeAssembly)' == 'true'">$(DefineConstants);FEATURE_FASTSPAN</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the define may rather be netstandard, with the condition inverted. It would be more similar to what we do in other places.

@@ -98,7 +98,7 @@ public static ulong ReverseEndianness(ulong value)
public static T ReadMachineEndian<T>(ReadOnlySpan<byte> buffer)
where T : struct
{
#if IsPartialFacade
#if netstandard
Copy link
Member

@jkotas jkotas Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of if/else blocks need to be switched too.

@ahsonkhan
Copy link
Author

@dotnet-bot test Linux x64 Release Build
@dotnet-bot test Windows x64 Debug Build

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Thanks

@ahsonkhan ahsonkhan merged commit 5c8af50 into dotnet:master Oct 18, 2017
@ahsonkhan ahsonkhan deleted the FixingNits branch October 18, 2017 01:39
@karelz karelz added this to the 2.1.0 milestone Oct 28, 2017
pjanotti pushed a commit to pjanotti/corefx that referenced this pull request Oct 31, 2017
…otnet#24626)

* Adding ValidateTypeIsBlittable SpanHelper method and rename constant.

* Reverting SpanHelper change and renaming const to netstandard

* Removing extra spaces.

* Remove unnecessary new lines

* Addressing PR feedback.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…otnet/corefx#24626)

* Adding ValidateTypeIsBlittable SpanHelper method and rename constant.

* Reverting SpanHelper change and renaming const to netstandard

* Removing extra spaces.

* Remove unnecessary new lines

* Addressing PR feedback.


Commit migrated from dotnet/corefx@5c8af50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants