Skip to content

Commit 84a25fa

Browse files
committed
Merge remote-tracking branch 'dotnet/main' into fix-93513
2 parents 9cfc7fd + 4f64a8a commit 84a25fa

File tree

693 files changed

+26229
-11564
lines changed

Some content is hidden

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

693 files changed

+26229
-11564
lines changed

.devcontainer/wasm/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
5050
"DOTNET_MULTILEVEL_LOOKUP": "0",
5151
// Path to provisioned Emscripten SDK, for rebuilding the wasm runtime
52-
"EMSDK_PATH": "${containerWorkspaceFolder}/src/mono/wasm/emsdk",
52+
"EMSDK_PATH": "${containerWorkspaceFolder}/src/mono/browser/emsdk",
5353
},
5454

5555
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.

docs/design/coreclr/botr/clr-abi.md

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ For non-rude thread abort, the VM walks the stack, running any catch handler tha
207207

208208
For example:
209209

210-
```
210+
```cs
211211
try { // try 1
212212
try { // try 2
213213
System.Threading.Thread.CurrentThread.Abort();
@@ -223,7 +223,7 @@ L:
223223

224224
In this case, if the address returned in catch 2 corresponding to label L is outside try 1, then the ThreadAbortException re-raised by the VM will not be caught by catch 1, as is expected. The JIT needs to insert a block such that this is the effective code generation:
225225

226-
```
226+
```cs
227227
try { // try 1
228228
try { // try 2
229229
System.Threading.Thread.CurrentThread.Abort();
@@ -240,7 +240,7 @@ L:
240240

241241
Similarly, the automatic re-raise address for a ThreadAbortException can't be within a finally handler, or the VM will abort the re-raise and swallow the exception. This can happen due to call-to-finally thunks marked as "cloned finally", as described above. For example (this is pseudo-assembly-code, not C#):
242242

243-
```
243+
```cs
244244
try { // try 1
245245
try { // try 2
246246
System.Threading.Thread.CurrentThread.Abort();
@@ -256,7 +256,7 @@ L:
256256

257257
This would generate something like:
258258

259-
```
259+
```asm
260260
// beginning of 'try 1'
261261
// beginning of 'try 2'
262262
System.Threading.Thread.CurrentThread.Abort();
@@ -281,7 +281,7 @@ Finally1:
281281

282282
Note that the JIT must already insert a "step" block so the finally will be called. However, this isn't sufficient to support ThreadAbortException processing, because "L1" is marked as "cloned finally". In this case, the JIT must insert another step block that is within "try 1" but outside the cloned finally block, that will allow for correct re-raise semantics. For example:
283283

284-
```
284+
```asm
285285
// beginning of 'try 1'
286286
// beginning of 'try 2'
287287
System.Threading.Thread.CurrentThread.Abort();
@@ -399,7 +399,7 @@ To implement this requirement, for any function with EH, we create a frame-local
399399

400400
Note that the since a slot on x86 is 4 bytes, the minimum size is 16 bytes. The idea is to have 1 slot for each handler that could be possibly be invoked at the same time. For example, for:
401401

402-
```
402+
```cs
403403
try {
404404
...
405405
} catch {
@@ -419,7 +419,7 @@ When calling a finally, we set the appropriate level to 0xFC (aka "finally call"
419419

420420
Thus, calling a finally from JIT generated code looks like:
421421

422-
```
422+
```asm
423423
mov dword ptr [L_02+0x4 ebp-10H], 0 // This must happen before the 0xFC is written
424424
mov dword ptr [L_02+0x8 ebp-0CH], 252 // 0xFC
425425
push G_M52300_IG07
@@ -430,7 +430,7 @@ In this case, `G_M52300_IG07` is not the address after the 'jmp', so a simple 'c
430430

431431
The code this finally returns to looks like this:
432432

433-
```
433+
```asm
434434
mov dword ptr [L_02+0x8 ebp-0CH], 0
435435
jmp SHORT G_M52300_IG05
436436
```
@@ -479,7 +479,7 @@ Because a main function body will **always** be on the stack when one of its fun
479479

480480
There is one "corner case" in the VM implementation of WantsReportOnlyLeaf model that has implications for the code the JIT is allowed to generate. Consider this function with nested exception handling:
481481

482-
```
482+
```cs
483483
public void runtest() {
484484
try {
485485
try {
@@ -804,3 +804,29 @@ In addition to the usual registers it also preserves all float registers and `rc
804804
`CORINFO_HELP_DISPATCH_INDIRECT_CALL` takes the call address in `rax` and it reserves the right to use and trash `r10` and `r11`.
805805
The JIT uses the dispatch helper on x64 whenever possible as it is expected that the code size benefits outweighs the less accurate branch prediction.
806806
However, note that the use of `r11` in the dispatcher makes it incompatible with VSD calls where the JIT must fall back to the validator and a manual call.
807+
808+
# Notes on Memset/Memcpy
809+
810+
Generally, `memset` and `memcpy` do not provide any guarantees of atomicity. This implies that they should only be used when the memory being modified by `memset`/`memcpy` is not observable by any other thread (including GC), or when there are no atomicity requirements according to our [Memory Model](../../specs/Memory-model.md). It's especially important when we modify heap containing managed pointers - those must be updated atomically, e.g. using pointer-sized `mov` instruction (managed pointers are always aligned) - see [Atomic Memory Access](../../specs/Memory-model.md#Atomic-memory-accesses). It's worth noting that by "update" it's implied "set to zero", otherwise, we need a write barrier.
811+
812+
Examples:
813+
814+
```cs
815+
struct MyStruct
816+
{
817+
long a;
818+
string b;
819+
}
820+
821+
void Test1(ref MyStruct m)
822+
{
823+
// We're not allowed to use memset here
824+
m = default;
825+
}
826+
827+
MyStruct Test2()
828+
{
829+
// We can use memset here
830+
return default;
831+
}
832+
```

0 commit comments

Comments
 (0)