Commit 28deeb4
Refactor ObjectDataInterner to support pluggable deduplicators and enable for ReadyToRun (#126112)
> [!NOTE]
> This PR was generated with the help of GitHub Copilot.
## Summary
Refactors `ObjectDataInterner` to accept a set of pluggable
`IObjectDataDeduplicator` strategies instead of hard-coding method body
deduplication logic, then extends the infrastructure to ReadyToRun.
## Changes
### Pluggable deduplicator interface
- Introduced `IObjectDataDeduplicator` with a single `DeduplicatePass`
method.
- `ObjectDataInterner` now accepts `params IObjectDataDeduplicator[]`
and delegates each convergence-loop iteration to them.
- Moved `ObjectDataInterner` to `Common/Compiler/` so both NativeAOT and
ReadyToRun can share it.
### Method body deduplication (NativeAOT)
- Extracted all `MethodDesc`/`IMethodBodyNode`-specific logic
(`CanFold`, `MethodInternKey`, `MethodInternComparer`) into a new
`MethodBodyDeduplicator : IObjectDataDeduplicator` class.
- Added a `virtual bool CanFold(MethodDesc)` on the base `NodeFactory`
(returns `false`), overridden in `RyuJitNodeFactory` to delegate to
`MethodBodyDeduplicator`.
### Copied method IL deduplication (ReadyToRun)
- Added `CopiedMethodILDeduplicator : IObjectDataDeduplicator` in
`ILCompiler.ReadyToRun` that deduplicates `CopiedMethodILNode` instances
by comparing their raw IL bytes.
- Added `ObjectDataInterner` property to the ReadyToRun `NodeFactory`,
wired up with the new deduplicator.
- Added `Values` property to the ReadyToRun `NodeCache<TKey, TValue>` to
enable enumeration.
- Removed the `#if !READYTORUN` guards around
`ObjectInterner.GetDeduplicatedSymbol` calls in the common
`ObjectWriter`, so deduplication now runs uniformly for both pipelines.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com>1 parent 8c4e839 commit 28deeb4
File tree
11 files changed
+240
-81
lines changed- src/coreclr/tools
- Common/Compiler
- ObjectWriter
- aot
- ILCompiler.Compiler
- Compiler
- DependencyAnalysis
- ILCompiler.ReadyToRun
- Compiler
- DependencyAnalysis
- ReadyToRun
- ILCompiler.RyuJit/Compiler
- DependencyAnalysis
11 files changed
+240
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
Lines changed: 7 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
398 | | - | |
| 396 | + | |
399 | 397 | | |
400 | | - | |
401 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
402 | 404 | | |
403 | | - | |
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
| |||
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
560 | | - | |
561 | 561 | | |
562 | 562 | | |
563 | | - | |
564 | 563 | | |
565 | 564 | | |
566 | 565 | | |
| |||
579 | 578 | | |
580 | 579 | | |
581 | 580 | | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | 581 | | |
586 | | - | |
587 | 582 | | |
588 | 583 | | |
589 | 584 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
| |||
1138 | 1140 | | |
1139 | 1141 | | |
1140 | 1142 | | |
1141 | | - | |
| 1143 | + | |
1142 | 1144 | | |
1143 | 1145 | | |
1144 | 1146 | | |
| |||
1204 | 1206 | | |
1205 | 1207 | | |
1206 | 1208 | | |
1207 | | - | |
| 1209 | + | |
1208 | 1210 | | |
1209 | 1211 | | |
1210 | 1212 | | |
| |||
Lines changed: 26 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
19 | | - | |
20 | | - | |
21 | | - | |
| 17 | + | |
22 | 18 | | |
23 | | - | |
| 19 | + | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
27 | 23 | | |
28 | 24 | | |
29 | 25 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 26 | | |
34 | 27 | | |
35 | 28 | | |
| |||
39 | 32 | | |
40 | 33 | | |
41 | 34 | | |
42 | | - | |
| 35 | + | |
43 | 36 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 37 | + | |
53 | 38 | | |
54 | | - | |
| 39 | + | |
55 | 40 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 41 | + | |
| 42 | + | |
60 | 43 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
69 | 47 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
74 | 52 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
84 | 57 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
97 | 63 | | |
98 | | - | |
| 64 | + | |
99 | 65 | | |
100 | 66 | | |
101 | 67 | | |
| |||
218 | 184 | | |
219 | 185 | | |
220 | 186 | | |
221 | | - | |
| 187 | + | |
222 | 188 | | |
223 | 189 | | |
224 | 190 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
| 507 | + | |
507 | 508 | | |
508 | 509 | | |
509 | 510 | | |
| |||
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments