forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Span<T> to ease implementation of JIT intrinsics (dotnet/cor…
…eclr#8497) - Introduce internal ByReference<T> type for byref fields and change Span to use it - Generalize handling of byref-like types in the type loader - Make DangerousGetPinnableReference public while I was on it Commit migrated from dotnet/coreclr@64c2ad1
- Loading branch information
Showing
15 changed files
with
123 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace System | ||
{ | ||
// ByReference<T> is meant to be used to represent "ref T" fields. It is working | ||
// around lack of first class support for byref fields in C# and IL. The JIT and | ||
// type loader has special handling for it that turns it into a thin wrapper around ref T. | ||
internal struct ByReference<T> | ||
{ | ||
private IntPtr _value; | ||
|
||
public ByReference(ref T value) | ||
{ | ||
// TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead | ||
unsafe { _value = (IntPtr)Unsafe.AsPointer(ref value); } | ||
} | ||
|
||
public ref T Value | ||
{ | ||
get | ||
{ | ||
// TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead | ||
unsafe { return ref Unsafe.As<IntPtr, T>(ref *(IntPtr*)_value); } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.