DescriptionRecognize and optimize a.runtimeType == b.runtimeType pattern.
Start by removing all get:runtimeType overrides in the patch files to have a single point computing the runtime type - Object.get:runtimeType. Handle string, double and integer types inside both intrinsic and runtime call to unify their handling and guarantee that code works even with intrinsifier disabled.
With overrides removed we can easily check that get:runtimeType is unique function name within the application that is being precompiled and use that to convert InstanceCall(get:runtimeType, ...) into StaticCall even nothing is known about the receiver.
This enables us to check if both left side and right side of comparison are StaticCall(Object.get:runtimeType, ...) when specializing InstanceCall(==, x, y). If they are we convert InstanceCall(==, StaticCall(get:runtimeType, a), StaticCall(get:runtimeType, b)) into StaticCall(Object._hasSameRuntimeType, a, b). A canonicalization rule will later delete unused get:runtimeType invocations.
Object._hasSameRuntimeType is implemented in C++ and intrinsified. It operates without creating new runtime types (except for Closures - where it does for simplicity). Cases of different class ids (i.e. a.[cid] != b.[cid]) and non-parameterized types are handled completely in the intrinsic. The rest is handled in the runtime code.
Microbenchmarking results:
Same parameterized classes: 15x improvement
Different parameterized classes: 300x improvement
Different/same non-parameterized classes: 2x improvement
BUG=
R=fschneider@google.com, regis@google.com
Committed: https://github.com/dart-lang/sdk/commit/f4ec20abac2286604565e9d5a6d1d744849c964d
Patch Set 1 #Patch Set 2 : Done #Patch Set 3 : Done #
Total comments: 21
Patch Set 4 : Support polymorphic inlining of Object.get:runtimeType #
Total comments: 6
Patch Set 5 : Address Florian's comment re VisitInstanceCall #Patch Set 6 : port to all arch, make AOT opt non-speculative #
Total comments: 23
Patch Set 7 : fix lint #
Messages
Total messages: 21 (4 generated)
|