-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
This is a follow-up to #341.
The jit currently expands runtime lookups in the importer (impRuntimeLookupToTree). The optimal expansion requires introducing control flow either via GT_QMARK or via IndirectCallTransformer.
The tail call via helpers mechanism introduced in #341 also needs to insert runtime lookups. The expansion of tail calls via helpers happens in morph and it's impossible to change control flow there the way it's done in the importer. Because of that the runtime lookups introduced in morph use the slower helper call expansion:
runtime/src/coreclr/src/jit/morph.cpp
Lines 8032 to 8040 in e1ffadd
| // If the first condition is true, runtime lookup tree is available only via the run-time helper function. | |
| // TODO-CQ If the second or third condition is true, we are always using the slow path since we can't | |
| // introduce control flow at this point. See impRuntimeLookupToTree for the logic to avoid calling the helper. | |
| // The long-term solution is to introduce a new node representing a runtime lookup, create instances | |
| // of that node both in the importer and here, and expand the node in lower (introducing control flow if | |
| // necessary). | |
| return gtNewRuntimeLookupHelperCallNode(pRuntimeLookup, | |
| getRuntimeContextTree(pLookup->lookupKind.runtimeLookupKind), | |
| compileTimeHandle); |
The suggested solution is to move the expansion of runtime lookups to lower so that both the importer and morph can just create and insert a new node representing a runtime lookup and have lower expand it in an optimal way. This will involve teaching optimization phases (e.g., value numbering) about the new runtime lookup node.
category:cq
theme:helpers
skill-level:intermediate
cost:medium