Skip to content

Commit e1654bb

Browse files
authored
Merge branch 'main' into fix-interp-kg
2 parents e74e1b1 + 995409f commit e1654bb

File tree

949 files changed

+28646
-16551
lines changed

Some content is hidden

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

949 files changed

+28646
-16551
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": "9.0.0-prerelease.24168.2",
18+
"version": "9.0.0-prerelease.24203.1",
1919
"commands": [
2020
"xharness"
2121
]

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ This section describes the conventions the JIT needs to follow when generating c
177177

178178
## Funclets
179179

180-
For all platforms except Windows/x86, all managed EH handlers (finally, fault, filter, filter-handler, and catch) are extracted into their own 'funclets'. To the OS they are treated just like first class functions (separate PDATA and XDATA (`RUNTIME_FUNCTION` entry), etc.). The CLR currently treats them just like part of the parent function in many ways. The main function and all funclets must be allocated in a single code allocation (see hot cold splitting). They 'share' GC info. Only the main function prolog can be hot patched.
180+
For all platforms except Windows/x86 on CoreCLR, all managed EH handlers (finally, fault, filter, filter-handler, and catch) are extracted into their own 'funclets'. To the OS they are treated just like first class functions (separate PDATA and XDATA (`RUNTIME_FUNCTION` entry), etc.). The CLR currently treats them just like part of the parent function in many ways. The main function and all funclets must be allocated in a single code allocation (see hot cold splitting). They 'share' GC info. Only the main function prolog can be hot patched.
181181

182182
The only way to enter a handler funclet is via a call. In the case of an exception, the call is from the VM's EH subsystem as part of exception dispatch/unwind. In the non-exceptional case, this is called local unwind or a non-local exit. In C# this is accomplished by simply falling-through/out of a try body or an explicit goto. In IL this is always accomplished via a LEAVE opcode, within a try body, targeting an IL offset outside the try body. In such cases the call is from the JITed code of the parent function.
183183

184-
For Windows/x86, all handlers are generated within the method body, typically in lexical order. A nested try/catch is generated completely within the EH region in which it is nested. These handlers are essentially "in-line funclets", but they do not look like normal functions: they do not have a normal prolog or epilog, although they do have special entry/exit and register conventions. Also, nested handlers are not un-nested as for funclets: the code for a nested handler is generated within the handler in which it is nested.
184+
For Windows/x86 on CoreCLR, all handlers are generated within the method body, typically in lexical order. A nested try/catch is generated completely within the EH region in which it is nested. These handlers are essentially "in-line funclets", but they do not look like normal functions: they do not have a normal prolog or epilog, although they do have special entry/exit and register conventions. Also, nested handlers are not un-nested as for funclets: the code for a nested handler is generated within the handler in which it is nested.
185+
186+
For Windows/x86 on NativeAOT and Linux/x86, funclets are used just like on other platforms.
185187

186188
## Cloned finallys
187189

docs/design/coreclr/jit/profile-count-reconstruction.md

Lines changed: 288 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Contract Descriptor
2+
3+
## Summary
4+
5+
The [data contracts design](./datacontracts_design.md) is a mechanism that allows diagnostic tooling
6+
to understand the behavior of certain .NET runtime subsystems and data structures. In a typical
7+
scenario, a diagnostic tool such as a debugger may have access to a target .NET process (or a memory
8+
dump of such a process) from which it may request to read and write certain regions of memory.
9+
10+
This document describes a mechanism by which a diagnostic tool may acquire the following information:
11+
* some details about the target process' architecture
12+
* a collection of types and their sizes and/or the offsets of certain fields within each type
13+
* a collection of global values
14+
* a collection of /algorithmic contracts/ that are satisfied by the target process
15+
16+
## Contract descriptor
17+
18+
The contract descriptor consists of the follow structure. All multi-byte values are in target architecture endianness.
19+
20+
```c
21+
struct DotNetRuntimeContractDescriptor
22+
{
23+
uint64_t magic;
24+
uint32_t flags;
25+
uint32_t descriptor_size;
26+
const char *descriptor;
27+
uint32_t aux_data_count;
28+
uint32_t pad0;
29+
uintptr_t *aux_data;
30+
};
31+
```
32+
33+
The `magic` is `0x44_4e_43_43_44_41_43_00` ("DNCCDAC\0") stored using the target architecture
34+
endianness. This is sufficient to discover the target architecture endianness by comparing the
35+
value in memory to `0x44_4e_43_43_44_41_43_00` and to `0x00_43_41_44_43_43_4e_44`.
36+
37+
The following `flags` bits are defined:
38+
39+
| Bits 31-2 | Bit 1 | Bit 0 |
40+
| --------- | ------- | ----- |
41+
| Reserved | ptrSize | 1 |
42+
43+
If `ptrSize` is 0, the architecture is 64-bit. If it is 1, the architecture is 32-bit. The
44+
reserved bits should be written as zero. Diagnostic tooling may ignore non-zero reserved bits.
45+
46+
The `descriptor` is a pointer to a UTF-8 JSON string described in [data descriptor physical layout](./data_descriptor.md#Physical_JSON_descriptor). The total number of bytes is given by `descriptor_size`.
47+
48+
The auxiliary data for the JSON descriptor is stored at the location `aux_data` in `aux_data_count` pointer-sized slots.
49+
50+
### Architecture properties
51+
52+
Although `DotNetRuntimeContractDescriptor` contains enough information to discover the target
53+
architecture endianness pointer size, it is expected that in all scenarios diagnostic tooling will
54+
already have this information available through other channels. Diagnostic tools may use the
55+
information derived from `DotNetRuntimeContractDescriptor` for validation.
56+
57+
### Compatible contracts
58+
59+
The `descriptor` is a JSON dictionary that is used for storing the [in-memory data descriptor](./data_descriptor.md#Physical_JSON_Descriptor)
60+
and the [compatible contracts](./datacontracts_design.md#Compatible_Contract).
61+
62+
The compatible contracts are stored in the top-level key `"contracts"`. The value will be a
63+
dictionary that contains each contract name as a key. Each value is the version of the contract as
64+
a JSON integer constant.
65+
66+
**Contract example**:
67+
68+
``` jsonc
69+
{"Thread":1,"GCHandle":1,...}
70+
```
71+
72+
**Complete in-memory data descriptor example**:
73+
74+
``` jsonc
75+
{
76+
"version": "0",
77+
"baseline": "example-64",
78+
"types":
79+
{
80+
"Thread": { "ThreadId": 32, "ThreadState": 0, "Next": 128 },
81+
"ThreadStore": { "ThreadCount": 32, "ThreadList": 8 }
82+
},
83+
"globals":
84+
{
85+
"FEATURE_COMINTEROP": 0,
86+
"s_pThreadStore": [ 0 ] // indirect from aux data offset 0
87+
},
88+
"contracts": {"Thread": 1, "GCHandle": 1, "ThreadStore": 1}
89+
}
90+
```
91+
92+
## Contract symbol
93+
94+
To aid in discovery, the contract descriptor should be exported by the module hosting the .NET
95+
runtime with the name `DotNetRuntimeContractDescriptor` using the C symbol naming conventions of the
96+
target platform.
97+
98+
In scenarios where multiple .NET runtimes may be present in a single process, diagnostic tooling
99+
should look for the symbol in each loaded module to discover all the runtimes.
100+

0 commit comments

Comments
 (0)