You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cdac] Handle hot/cold map lookup in ExecutionManager.ReadyToRunJitManager.GetMethodInfo (#110087)
Implement the hot/cold lookup logic for `ExecutionManager.ReadyToRunJitManager.GetMethodInfo`. Basic logic is now:
1. Check if the address is in a thunk for READYTORUN_HELPER_DelayLoad_MethodCall
2. Find the runtime function entry corresponding to the address
- If the runtime function entry is cold code, find the runtime function entry for the corresponding hot part
3. Look up the MethodDesc for the entry point using the ReadyToRunInfo's hash map
4. Compute the relative offset based the function's start address
- If the runtime function has a cold part and the address is in the cold part, compute the relative offset based on the size of the hot part and the offset from the start of the cold part
Sub-bullets of 2 and 4 are the parts added by this change.
Add tests for `ExecutionManager` for getting code blocks and method desc in R2R with hot/cold splitting, runtime functions lookup functionality, and hot/cold map lookup logic.
- Pull out helper for RuntimeFunctions mock memory
- `ExecutionManagerTests` just uses one specific runtime function / unwind info layout
- The `RuntimeFunctionsTests` handle testing the matrix of different layouts
The `RuntimeFunction` and `UnwindInfo` structures are different depending on the platform. This matters for calculating the function length. To facilitate testing, I pulled out the runtime functions lookup into a helper class. This change puts reading the hot/cold map in a helper class `HotColdLookup`. Having separate helpers (similarly, HashMapLookup and NibbleMap) should let us mock them out for testing if we want - there'd still be some work for how they are created (for example, tests need to be able to provide some instance instead of the contract directly creating the class), but it puts us in a reasonable position.
Manually validated with `!ip2md` (temporarily commented out throwing not implemented for rejit ID requests) for an app published with R2R `--hot-cold-splitting` that we correctly map addresses in cold/hot blocks to hot/cold parts, determine their start addresses and sizes, and return the correct method desc.
Copy file name to clipboardexpand all lines: docs/design/datacontracts/ExecutionManager.md
+45-51
Original file line number
Diff line number
Diff line change
@@ -56,15 +56,20 @@ Data descriptors used:
56
56
|`Module`|`ReadyToRunInfo`| Pointer to the `ReadyToRunInfo` for the module |
57
57
|`ReadyToRunInfo`|`CompositeInfo`| Pointer to composite R2R info - or itself for non-composite |
58
58
|`ReadyToRunInfo`|`NumRuntimeFunctions`| Number of `RuntimeFunctions`|
59
-
|`ReadyToRunInfo`|`RuntimeFunctions`| Pointer to an array of `RuntimeFunctions`|
59
+
|`ReadyToRunInfo`|`RuntimeFunctions`| Pointer to an array of `RuntimeFunctions` - [see R2R format](../coreclr/botr/readytorun-format.md#readytorunsectiontyperuntimefunctions)|
60
+
|`ReadyToRunInfo`|`NumHotColdMap`| Number of entries in the `HotColdMap`|
61
+
|`ReadyToRunInfo`|`HotColdMap`| Pointer to an array of 32-bit integers - [see R2R format](../coreclr/botr/readytorun-format.md#readytorunsectiontypehotcoldmap-v80)|
60
62
|`ReadyToRunInfo`|`DelayLoadMethodCallThunks`| Pointer to an `ImageDataDirectory` for the delay load method call thunks |
61
63
|`ReadyToRunInfo`|`EntryPointToMethodDescMap`|`HashMap` of entry point addresses to `MethodDesc` pointers |
62
64
|`ImageDataDirectory`|`VirtualAddress`| Virtual address of the image data directory |
63
65
|`ImageDataDirectory`|`Size`| Size of the data |
64
66
|`RuntimeFunction`|`BeginAddress`| Begin address of the function |
67
+
|`RuntimeFunction`|`EndAddress`| End address of the function. Only exists on some platforms |
68
+
|`RuntimeFunction`|`UnwindData`| Pointer to the unwind info for the function |
65
69
|`HashMap`|`Buckets`| Pointer to the buckets of a `HashMap`|
66
70
|`Bucket`|`Keys`| Array of keys of `HashMapSlotsPerBucket` length |
67
71
|`Bucket`|`Values`| Array of values of `HashMapSlotsPerBucket` length |
72
+
|`UnwindInfo`|`FunctionLength`| Length of the associated function in bytes. Only exists on some platforms |
68
73
69
74
Global variables used:
70
75
| Global Name | Type | Purpose |
@@ -80,103 +85,84 @@ Contracts used:
80
85
| --- |
81
86
|`PlatformMetadata`|
82
87
83
-
The bulk of the work is done by the `GetCodeBlockHandle` API that maps a code pointer to information about the containing jitted method.
88
+
The bulk of the work is done by the `GetCodeBlockHandle` API that maps a code pointer to information about the containing jitted method. This relies the [range section lookup](#rangesectionmap).
Copy file name to clipboardexpand all lines: src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IExecutionManager.cs
0 commit comments