From b085bfacb5eed105e3e55681f75c5413d91c1f86 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Thu, 5 Oct 2017 11:31:58 -0700 Subject: JIT: More type equality opts (#14317) * JIT: Wrap some runtime lookups in new node type Work based on the plan outlined in #14305. Introduce a new unary node type GT_RUNTIMELOOKUP that wraps existing runtime lookup trees created in `impLookupToTree` and holds onto the handle that inspired the lookup. Note there are other importer paths that create lookups directly that we might also want to wrap, though wrapping is not a requirement for correctness. Keep this node type around through morph, then unwrap and just use the wrapped node after that. * JIT: More enhancements to type equality testing The jit is now able to optimize some type equality checks in shared method instances where one or both of the types require runtime lookup, for instance comparing `T` to a value type, or comparing two different value types `V1` and `V2`. Add two new jit interface methods, one for testing for type equality and the other for type casting. These return Must/MustNot/Maybe results depending on whether or not the equality or cast can be resolved at jit time. Implement the equality check. Use this to enhance the type equality opts in the jit for both direct comparison and the checking done by unbox.any. --- src/jit/compiler.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/jit/compiler.hpp') diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp index 4a90760ce2..f357e6f5c8 100644 --- a/src/jit/compiler.hpp +++ b/src/jit/compiler.hpp @@ -1169,6 +1169,23 @@ inline GenTreePtr Compiler::gtNewAllocObjNode(unsigned int helper, return node; } +//------------------------------------------------------------------------ +// gtNewRuntimeLookup: Helper to create a runtime lookup node +// +// Arguments: +// hnd - generic handle being looked up +// hndTyp - type of the generic handle +// tree - tree for the lookup +// +// Return Value: +// New GenTreeRuntimeLookup node. +inline GenTree* Compiler::gtNewRuntimeLookup(CORINFO_GENERIC_HANDLE hnd, CorInfoGenericHandleType hndTyp, GenTree* tree) +{ + assert(tree != nullptr); + GenTree* node = new (this, GT_RUNTIMELOOKUP) GenTreeRuntimeLookup(hnd, hndTyp, tree); + return node; +} + /*****************************************************************************/ inline GenTreePtr Compiler::gtNewCodeRef(BasicBlock* block) -- cgit v1.2.3