Skip to content

Add support for "extended" layouts in the runtimes and add CStruct layout #116082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cdfb3d4
Add TypeAttribute and LayoutKind values
jkoritzinsky Feb 25, 2025
a0b5bfa
Update ilasm
jkoritzinsky May 28, 2025
37de415
Don't block loading extended layout types
jkoritzinsky May 28, 2025
62289ae
Update SRE support for ExtendedLayout
jkoritzinsky May 28, 2025
084bc47
Add support in the managed type system for extended layout
jkoritzinsky May 28, 2025
b066bd6
Implement CStruct layout support in NAOT
jkoritzinsky May 28, 2025
858a9a8
Implement CStruct in CoreCLR
jkoritzinsky May 28, 2025
106f590
Implement CStruct in Mono
jkoritzinsky May 28, 2025
f4c7fc7
Add tests for ExtendedLayout(CStruct)
jkoritzinsky May 28, 2025
19c4a60
Get tests passing on CoreCLR
jkoritzinsky May 28, 2025
0db4b1d
Fix handling for type without ExtendedLayoutAttribute
jkoritzinsky May 28, 2025
82119fc
Remove preamble emitted into grammar file
jkoritzinsky May 28, 2025
62d7083
Define ExtendedLayoutAttribute in corelib
jkoritzinsky May 29, 2025
0e58822
Add reference to Microsoft.Bcl.Memory for ILVerification.csproj
jkoritzinsky May 29, 2025
a6e5f24
Don't allow empty CStruct types.
jkoritzinsky May 29, 2025
a8bc97e
Add missing var
jkoritzinsky May 30, 2025
5d86388
Collapse together the different "get class layout related info" metho…
jkoritzinsky Jun 4, 2025
d028bea
PR feedback
jkoritzinsky Jun 11, 2025
05085e3
Add missing impl
jkoritzinsky Jun 12, 2025
1cb8206
Merge branch 'main' into extended-layout
jkoritzinsky Jun 14, 2025
e941e1e
PR feedback
jkoritzinsky Jun 16, 2025
f6933ca
Add more `in`
jkoritzinsky Jun 17, 2025
ad7c1ca
Adjust test
jkoritzinsky Jun 17, 2025
26627ba
Fix test build and asserts. Adjust SRE tests and NativeAOT
jkoritzinsky Jun 18, 2025
f6de91b
PR feedback
jkoritzinsky Jun 19, 2025
a6533ba
A few more adjustments
jkoritzinsky Jun 19, 2025
6088772
More adjustments
jkoritzinsky Jun 19, 2025
9de3904
Fix build failures. Add ildasm support for extended layout.
jkoritzinsky Jun 19, 2025
50b4bfe
Fix inherited layout types in NativeAOT
jkoritzinsky Jun 19, 2025
58cde80
Fix mono tests and align behavior for InlineArray+ExtendedLayout
jkoritzinsky Jun 20, 2025
e3cea23
Make CStruct types blittable in NAOT
jkoritzinsky Jun 20, 2025
1d3f493
Update MarshalUtils.cs
jkoritzinsky Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<SystemValueTupleVersion>4.6.1</SystemValueTupleVersion>
<!-- Libraries dependencies -->
<MicrosoftBclAsyncInterfacesVersion>6.0.0</MicrosoftBclAsyncInterfacesVersion>
<MicrosoftBclMemoryVersion>9.0.5</MicrosoftBclMemoryVersion>
<MicrosoftWin32RegistryVersion>5.0.0</MicrosoftWin32RegistryVersion>
<StyleCopAnalyzersVersion>1.2.0-beta.556</StyleCopAnalyzersVersion>
<SystemComponentModelAnnotationsVersion>5.0.0</SystemComponentModelAnnotationsVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,6 @@ private void VerifyTypeAttributes(TypeAttributes attr)
}
}

// Verify that the layout mask is valid.
if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout))
{
throw new ArgumentException(SR.Argument_BadTypeAttrInvalidLayout);
}

// Check if the user attempted to set any reserved bits.
if ((attr & TypeAttributes.ReservedMask) != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,7 @@ internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType? caType)
case TypeAttributes.ExplicitLayout: layoutKind = LayoutKind.Explicit; break;
case TypeAttributes.AutoLayout: layoutKind = LayoutKind.Auto; break;
case TypeAttributes.SequentialLayout: layoutKind = LayoutKind.Sequential; break;
case TypeAttributes.ExtendedLayout: layoutKind = LayoutKind.Extended; break;
default: Debug.Fail("Unreachable code"); break;
}

Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/ilasm/asmparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

%token VALUE_ VALUETYPE_ NATIVE_ INSTANCE_ SPECIALNAME_ FORWARDER_
%token STATIC_ PUBLIC_ PRIVATE_ FAMILY_ FINAL_ SYNCHRONIZED_ INTERFACE_ SEALED_ NESTED_
%token ABSTRACT_ AUTO_ SEQUENTIAL_ EXPLICIT_ ANSI_ UNICODE_ AUTOCHAR_ IMPORT_ ENUM_
%token ABSTRACT_ AUTO_ SEQUENTIAL_ EXPLICIT_ EXTENDED_ ANSI_ UNICODE_ AUTOCHAR_ IMPORT_ ENUM_
%token VIRTUAL_ NOINLINING_ AGGRESSIVEINLINING_ NOOPTIMIZATION_ AGGRESSIVEOPTIMIZATION_ UNMANAGEDEXP_ BEFOREFIELDINIT_ ASYNC_
%token STRICT_ RETARGETABLE_ WINDOWSRUNTIME_ NOPLATFORM_
%token METHOD_ FIELD_ PINNED_ MODREQ_ MODOPT_ SERIALIZABLE_ PROPERTY_ TYPE_
Expand Down Expand Up @@ -260,6 +260,7 @@ id : ID { $$ = $1; }
| NOOPTIMIZATION_ { $$ = newString("nooptimization"); }
| AGGRESSIVEOPTIMIZATION_ { $$ = newString("aggressiveoptimization"); }
| ASYNC_ { $$ = newString("async"); }
| EXTENDED_ { $$ = newString("extended"); }
| SQSTRING { $$ = $1; }
;

Expand Down Expand Up @@ -444,6 +445,7 @@ classAttr : /* EMPTY */ { $$ = (CorRegTypeAt
| classAttr AUTO_ { $$ = (CorRegTypeAttr) (($1 & ~tdLayoutMask) | tdAutoLayout); }
| classAttr SEQUENTIAL_ { $$ = (CorRegTypeAttr) (($1 & ~tdLayoutMask) | tdSequentialLayout); }
| classAttr EXPLICIT_ { $$ = (CorRegTypeAttr) (($1 & ~tdLayoutMask) | tdExplicitLayout); }
| classAttr EXTENDED_ { $$ = (CorRegTypeAttr) (($1 & ~tdLayoutMask) | tdExtendedLayout); }
| classAttr ANSI_ { $$ = (CorRegTypeAttr) (($1 & ~tdStringFormatMask) | tdAnsiClass); }
| classAttr UNICODE_ { $$ = (CorRegTypeAttr) (($1 & ~tdStringFormatMask) | tdUnicodeClass); }
| classAttr AUTOCHAR_ { $$ = (CorRegTypeAttr) (($1 & ~tdStringFormatMask) | tdAutoClass); }
Expand Down
9,550 changes: 4,792 additions & 4,758 deletions src/coreclr/ilasm/prebuilt/asmparse.cpp

Large diffs are not rendered by default.

Loading
Loading