Skip to content

Commit 168626d

Browse files
committed
Merge branch 'main' into issue-20234
2 parents 1fe2043 + 3d74b00 commit 168626d

File tree

932 files changed

+19372
-17449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

932 files changed

+19372
-17449
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"microsoft.dotnet.xharness.cli": {
18-
"version": "1.0.0-prerelease.22270.1",
18+
"version": "1.0.0-prerelease.22305.1",
1919
"commands": [
2020
"xharness"
2121
]

docs/design/coreclr/jit/first-class-structs.md

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ Current Representation of Struct Values
7070

7171
These struct-typed nodes are created by the importer, but transformed in morph, and so are not
7272
encountered by most phases of the JIT:
73-
* `GT_INDEX`: This is transformed to a `GT_IND`
74-
* Currently, the IND is marked with `GTF_IND_ARR_INDEX` and the node pointer of the `GT_IND` acts as a key
75-
into the array info map.
76-
* Proposed: This should be transformed into a `GT_OBJ` when it represents a struct type, and then the
77-
class handle would no longer need to be obtained from the array info map.
7873
* `GT_FIELD`: This is transformed to a `GT_LCL_VAR` by the `Compiler::fgMarkAddressExposedLocals()` phase
7974
if it's a promoted struct field, or to a `GT_LCL_FLD` or GT_IND` by `fgMorphField()`.
8075
* Proposed: A non-promoted struct typed field should be transformed into a `GT_OBJ`, so that consistently all struct
@@ -90,9 +85,7 @@ encountered by most phases of the JIT:
9085
### Struct “objects” as lvalues
9186

9287
* The lhs of a struct assignment is a block or local node:
93-
* `GT_OBJ` nodes represent the “shape” info via a struct handle, along with the GC info
94-
(location and type of GC references within the struct).
95-
* These are currently used only to represent struct values that contain GC references (although see below).
88+
* `GT_OBJ` nodes represent struct types with a handle, and store a pointer to the `ClassLayout` object.
9689
* `GT_BLK` nodes represent struct types with no GC references, or opaque blocks of fixed size.
9790
* These have no struct handle, resulting in some pessimization or even incorrect
9891
code when the appropriate struct handle can't be determined.
@@ -101,12 +94,12 @@ encountered by most phases of the JIT:
10194
[#21705](https://github.com/dotnet/coreclr/pull/21705) they are no longer large nodes.
10295
* `GT_STORE_OBJ` and `GT_STORE_BLK` have the same structure as `GT_OBJ` and `GT_BLK`, respectively
10396
* `Data()` is op2
104-
* `GT_DYN_BLK` and `GT_STORE_DYN_BLK` (GenTreeDynBlk extends GenTreeBlk)
97+
* `GT_STORE_DYN_BLK` (GenTreeStoreDynBlk extends GenTreeBlk)
10598
* Additional child `gtDynamicSize`
106-
* Note that these aren't really struct types; they represent dynamically sized blocks
99+
* Note that these aren't really struct stores; they represent dynamically sized blocks
107100
of arbitrary data.
108-
* For `GT_LCL_FLD` nodes, we don't retain shape information, except indirectly via the `FieldSeqNode`.
109-
* For `GT_LCL_VAR` nodes, the`ClassLayout` is obtained from the `LclVarDsc`.
101+
* For `GT_LCL_FLD` nodes, we store a pointer to `ClassLayout` in the node.
102+
* For `GT_LCL_VAR` nodes, the `ClassLayout` is obtained from the `LclVarDsc`.
110103

111104
### Struct “objects” as rvalues
112105

@@ -131,10 +124,6 @@ After morph, a struct-typed value on the RHS of assignment is one of:
131124
* `GT_CALL`
132125
* `GT_LCL_VAR`
133126
* `GT_LCL_FLD`
134-
* Note: With `compDoOldStructRetyping()`, a GT_LCL_FLD` with a primitive type of the same size as the struct
135-
is used to represent a reference to the full struct when it is passed in a register.
136-
This forces the struct to live on the stack, and makes it more difficult to optimize these struct values,
137-
which is why this mechanism is being phased out.
138127
* `GT_SIMD`
139128
* `GT_OBJ` nodes can also be used as rvalues when they are call arguments
140129
* Proposed: `GT_OBJ` nodes can be used in any context where a struct rvalue or lvalue might occur,
@@ -173,8 +162,7 @@ There are three main phases in the JIT that make changes to the representation o
173162
registers. The necessary transformations for correct code generation would be
174163
made in `Lowering`.
175164

176-
* With `compDoOldStructRetyping()`, if it is passed in a single register, it is morphed into a
177-
`GT_LCL_FLD` node of the appropriate primitive type.
165+
* If it is passed in a single register, it is morphed into a `GT_LCL_FLD` node of the appropriate primitive type.
178166
* This may involve making a copy, if the size cannot be safely loaded.
179167
* Proposed: This would remain a `GT_OBJ` and would be appropriately transformed in `Lowering`,
180168
e.g. using `GT_BITCAST`.
@@ -310,22 +298,13 @@ This would be enabled first by [Defer ABI-specific transformations to Lowering](
310298
for block copies. See [\#21711 Improve init/copy block codegen](https://github.com/dotnet/coreclr/pull/21711).
311299

312300
* This also includes cleanup of the block morphing methods such that block nodes needn't be visited multiple
313-
times, such as `fgMorphBlkToInd` (may be simply unneeded), `fgMorphBlkNode` and `fgMorphBlkOperand`.
301+
times, such as `fgMorphBlkNode` and `fgMorphBlkOperand`.
314302
These methods were introduced to preserve old behavior, but should be simplified.
315303

316-
* Somewhat related is the handling of struct-typed array elements. Currently, after the `GT_INDEX` is transformed
317-
into a `GT_IND`, that node must be retained as the key into the `ArrayInfoMap`. For structs, this is then
318-
wrapped in `OBJ(ADDR(...))`. We should be able to change the IND to OBJ and avoid wrapping, and should also be
319-
able to remove the class handle from the array info map and instead used the one provided by the `GT_OBJ`.
320-
321304
### Miscellaneous Cleanup
322305

323306
These are all marked with `TODO-1stClassStructs` or `TODO-Cleanup` in the last case:
324307

325-
* The handling of `DYN_BLK` is unnecessarily complicated to duplicate previous behavior (i.e. to enable previous
326-
refactorings to be zero-diff). These nodes are infrequent so the special handling should just be eliminated
327-
(e.g. see `GenTree::GetChild()`).
328-
329308
* The checking at the end of `gtNewTempAssign()` should be simplified.
330309

331310
* When we create a struct assignment, we use `impAssignStruct()`. This code will, in some cases, create

docs/design/specs/Ecma-335-Augments.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This is a list of additions and edits to be made in ECMA-335 specifications. It
1616
- [Ref field support](#ref-fields)
1717
- [Rules for IL rewriters](#rules-for-il-rewriters)
1818
- [Checked user-defined operators](#checked-user-defined-operators)
19+
- [Atomic reads and writes](#atomic-reads-and-writes)
1920

2021
## Signatures
2122

@@ -1013,3 +1014,9 @@ Section "I.10.3.3 Conversion operators" of ECMA-335 adds *op_CheckedExplicit* as
10131014
implementing checked explicit conversion operator.
10141015

10151016
A checked user-defined operator is expected to throw an exception when the result of an operation is too large to represent in the destination type. What does it mean to be too large actually depends on the nature of the destination type. Typically the exception thrown is a System.OverflowException.
1017+
1018+
## Atomic reads and writes
1019+
1020+
Section "I.12.6.6 Atomic reads and writes" adds clarification that the atomicity guarantees apply to built-in primitive value types and pointers only.
1021+
1022+
A conforming CLI shall guarantee that read and write access of *built-in primitive value types and pointers* to properly aligned memory locations no larger than the native word size (the size of type native int) is atomic (see §I.12.6.2) when all the write accesses to a location are the same size.

0 commit comments

Comments
 (0)