Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions docs/design/coreclr/botr/readytorun-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ The following section types are defined and described later in this document:
| MethodIsGenericMap | 121 | Assembly (Added in V9.0)
| EnclosingTypeMap | 122 | Assembly (Added in V9.0)
| TypeGenericInfoMap | 123 | Assembly (Added in V9.0)
| ExternalTypeMaps | 124 | Assembly (added in V18.3, extended in V28)
| ProxyTypeMaps | 125 | Assembly (added in V18.3, extended in V28)
| TypeMapAssemblyTargets | 126 | Assembly (added in V18.3)

## ReadyToRunSectionType.CompilerIdentifier

Expand Down Expand Up @@ -762,6 +765,82 @@ TypeGenericInfoMap entries have 4 bits representing 3 different sets of informat
2. Are there any constraints on the generic parameters? (This is the 3rd bit of the entry)
3. Do any of the generic parameters have co or contra variance? (This is the 4th bit of the entry)

## ReadyToRunSectionType.ExternalTypeMaps (v18.3+)

This optional section contains precomputed external type maps. It is a native hashtable keyed by the version-resilient hash code of the type map group. Each value has the following layout:

```text
GroupTypeFixup
State
[ExternalTypeMapHashtable]
[NamedEntries]
```

`GroupTypeFixup` is a fixup reference encoded as the import section index followed by the fixup row index. `State` is a compressed unsigned integer with one of these values:

| State | Name | Remaining layout |
|------:|:-----|:-----------------|
| 0 | Runtime attribute fallback | No precomputed map data. The runtime processes the type map attributes instead. |
| 1 | Precomputed fixups | `ExternalTypeMapHashtable` only. |
| 2 | Precomputed fixups and type names | `ExternalTypeMapHashtable` followed immediately by `NamedEntries`. Added in V28. |

`ExternalTypeMapHashtable` is a native hashtable keyed by the name hash code of the external type map key. Each value contains:

```text
KeyString
TargetTypeFixup
```

`TargetTypeFixup` has the same import-section-index and fixup-row-index encoding as `GroupTypeFixup`.

In state 2, `NamedEntries` is a native sequence: a compressed unsigned count followed by that many inline pairs. Each pair contains:

```text
KeyString
SerializedTargetTypeName
```

These entries represent target types that cannot be encoded as ReadyToRun fixups. The endpoint stored in the final bucket-offset cell of `ExternalTypeMapHashtable` identifies the start of `NamedEntries`; a hashtable lookup therefore does not enumerate the string sequence.

## ReadyToRunSectionType.ProxyTypeMaps (v18.3+)

This optional section contains precomputed proxy type maps. Its outer native hashtable and per-group `GroupTypeFixup` and `State` fields use the same layout as `ExternalTypeMaps`:

```text
GroupTypeFixup
State
[ProxyTypeMapHashtable]
[NamedEntries]
```

`ProxyTypeMapHashtable` is keyed by the version-resilient hash code of the source type. Each value contains:

```text
SourceTypeFixup
ProxyTypeFixup
```

In state 2, `NamedEntries` begins immediately after `ProxyTypeMapHashtable` and contains a compressed unsigned count followed by that many inline pairs:

```text
SerializedSourceTypeName
SerializedProxyTypeName
```

If either type in a proxy mapping cannot be encoded as a ReadyToRun fixup, both types are represented by their serialized names in `NamedEntries`.

## ReadyToRunSectionType.TypeMapAssemblyTargets (v18.3+)

This optional section is a native hashtable keyed by the version-resilient hash code of the type map group. Each value contains the group type fixup followed by a native sequence of module fixups:

```text
GroupTypeFixup
TargetModuleCount
TargetModuleFixup[TargetModuleCount]
```

Each type or module fixup is encoded as an import section index followed by a fixup row index.

# Native Format

Native format is set of encoding patterns that allow persisting type system data in a binary format that is
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
// If you update this, ensure you run `git grep MINIMUM_READYTORUN_MAJOR_VERSION`
// and handle pending work.
#define READYTORUN_MAJOR_VERSION 27
#define READYTORUN_MINOR_VERSION 0x0001
#define READYTORUN_MAJOR_VERSION 28
#define READYTORUN_MINOR_VERSION 0x0000

#define MINIMUM_READYTORUN_MAJOR_VERSION 26

Expand Down Expand Up @@ -68,7 +68,7 @@
// R2R Version 26 changes ARM64 NativeVarInfo register encoding to include V0-V31
// R2R Version 26.1 adds READYTORUN_FIXUP_StoreMultiCallableAddrOfCode for storing a method's MultiCallableAddrOfCode into a location in the R2R image (used on WebAssembly)
// R2R Version 27 redefines READYTORUN_FIXUP_DeclaringTypeHandle to be encoded as a method signature instead of a pair of type signatures
// R2R Version 27.1 adds precompiled unboxing stubs to the InstanceMethodEntryPoints table. They share the metadata token, owner type and instantiation of the method they wrap and are distinguished only by READYTORUN_METHOD_SIG_UnboxingStub.
// R2R Version 28 allows entries in the ExternalTypeMaps and ProxyTypeMaps sections to append a sequence of serialized (string, string) type map entries after the per-group NativeHashtable.

struct READYTORUN_CORE_HEADER
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct ReadyToRunHeaderConstants
{
static const uint32_t Signature = 0x00525452; // 'RTR'

static const uint32_t CurrentMajorVersion = 27;
static const uint32_t CurrentMinorVersion = 1;
static const uint32_t CurrentMajorVersion = 28;
static const uint32_t CurrentMinorVersion = 0;
};

struct ReadyToRunHeader
Expand Down
Loading
Loading