Skip to content

Commit

Permalink
placeholder ExecutionManager contract; updates to RTS and Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdageek committed Aug 16, 2024
1 parent 8654711 commit 79bbf28
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/design/datacontracts/ExecutionManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Contracts used:
```csharp
```

**TODO** Methods

### NibbleMap

**TODO**
9 changes: 9 additions & 0 deletions docs/design/datacontracts/Loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ TargetPointer GetLoaderAllocator(ModuleHandle handle);
TargetPointer GetThunkHeap(ModuleHandle handle);
TargetPointer GetILBase(ModuleHandle handle);
ModuleLookupTables GetLookupTables(ModuleHandle handle);
TargetPointer GetModuleLookupMapElement(TargetPointer table, uint rid, out TargetNUInt flags);
bool IsCollectibleLoaderAllocator(ModuleHandle handle);

```

## Version 1
Expand All @@ -58,6 +61,10 @@ Data descriptors used:
| `Module` | `TypeDefToMethodTableMap` | Mapping table |
| `Module` | `TypeRefToMethodTableMap` | Mapping table |
| `ModuleLookupMap` | `TableData` | Start of the mapping table's data |
| `ModuleLookupMap` | `SupportedFlagsMask` | Mask for flag bits on lookup map entries |
| `ModuleLookupMap` | `Count` | Number of TargetPointer sized entries in this section of the map |
| `ModuleLookupMap` | `Next` | Pointer to next ModuleLookupMap segment for this map
| `LoaderAllocator` | `IsCollectible` | Flag indicating if this is loader allocator may be collected

``` csharp
ModuleHandle GetModuleHandle(TargetPointer modulePointer)
Expand Down Expand Up @@ -110,3 +117,5 @@ ModuleLookupTables GetLookupTables(ModuleHandle handle)
Module::MethodDefToILCodeVersioningState */));
}
```

**TODO* pseudocode for IsCollectibleLoaderAllocator and LookupTableMap element lookup
41 changes: 38 additions & 3 deletions docs/design/datacontracts/RuntimeTypeSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@ partial interface IRuntimeTypeSystem : IContract
// Return true if a MethodDesc represents an IL Stub dynamically generated by the runtime
// A IL Stub method is also a StoredSigMethodDesc, and a NoMetadataMethod
public virtual bool IsILStub(MethodDescHandle methodDesc);

// Return true if a MethodDesc is in a collectible module
public virtual bool IsCollectibleMethod(MethodDescHandle methodDesc);

// Return true if a MethodDesc is in a module that supports Edit-And-Continue
public virtual bool InEnCEnabledModule(MethodDescHandle methodDesc);

// Return true if a MethodDesc supports mulitiple code versions
public virtual bool IsVersionable(MethodDescHandle methodDesc);

// Return a pointer to the IL versioning state of the MethodDesc
public virtual TargetPointer GetMethodDescVersioningState(MethodDescHandle methodDesc);

// Return the MethodTable slot number of the MethodDesc
public virtual ushort GetSlotNumber(MethodDescHandle methodDesc);

// Return true if the MethodDesc has space associated with it for storing a pointer to a code block
public virtual bool HasNativeCodeSlot(MethodDescHandle methodDesc);

// Return the address of the space that stores a pointer to a code block associated with the MethodDesc
public virtual TargetPointer GetAddressOfNativeCodeSlot(MethodDescHandle methodDesc);

// Get an instruction pointer that can be called to cause the MethodDesc to be executed
public virtual TargetCodePointer GetNativeCode(MethodDescHandle methodDesc);

}
```

Expand Down Expand Up @@ -605,6 +630,7 @@ The version 1 `MethodDesc` APIs depend on the `MethodDescAlignment` global and t
| `MethodDescAlignment` | `MethodDescChunk` trailing data is allocated in multiples of this constant. The size (in bytes) of each `MethodDesc` (or subclass) instance is a multiple of this constant. |
| `MethodDescTokenRemainderBitCount` | Number of bits in the token remainder in `MethodDesc` |

**TODO** MethodDesc code pointers additions

In the runtime a `MethodDesc` implicitly belongs to a single `MethodDescChunk` and some common data is shared between method descriptors that belong to the same chunk. A single method table
will typically have multiple chunks. There are subkinds of MethodDescs at runtime of varying sizes (but the sizes must be mutliples of `MethodDescAlignment`) and each chunk contains method descriptors of the same size.
Expand All @@ -629,6 +655,15 @@ We depend on the following data descriptors:
| `StoredSigMethodDesc` | `ExtendedFlags` | Flags field for the `StoredSigMethodDesc` |
| `DynamicMethodDesc` | `MethodName` | Pointer to Null-terminated UTF8 string describing the Method desc |

**TODO** MethodDesc code pointers additions

The contract depends on the following other contracts

| Contract |
| --- |
| Loader |
| ReJIT |
| CodeVersions |

And the following enumeration definitions

Expand Down Expand Up @@ -708,9 +743,9 @@ And the various apis are implemented with the following algorithms
public uint GetMethodToken(MethodDescHandle methodDescHandle)
{
MethodDesc methodDesc = _methodDescs[methodDescHandle.Address];

TargetPointer methodDescChunk = // Using ChunkIndex from methodDesc, compute the wrapping MethodDescChunk
ushort Flags3AndTokenRemainder = // Read Flags3AndTokenRemainder field from MethodDesc contract using address methodDescHandle.Address
ushort FlagsAndTokenRange = // Read FlagsAndTokenRange field from MethodDescChunk contract using address methodDescChunk
Expand Down Expand Up @@ -819,4 +854,4 @@ And the various apis are implemented with the following algorithms
return ((DynamicMethodDescExtendedFlags)ExtendedFlags).HasFlag(DynamicMethodDescExtendedFlags.IsILStub);
}
```
**TODO(cdac)**
**TODO(cdac)** additional code pointers methods on MethodDesc

0 comments on commit 79bbf28

Please sign in to comment.