Open rakudrama opened 4 years ago
Note that we have a special optimization for x.runtimeType == y.runtimeType
- implemented in f4ec20abac2286604565e9d5a6d1d744849c964d
@mraleph Thanks for the reference to the VM optimization.
I notice in the new RuntimeType
benchmarks that AOT is 7x faster than VM.
What extra is AOT doing?
The runtimeType optimization above is AOT only, I never ported it to JIT
For JIT we only have:
runtimeType
if object is an instance of a non-parameterized typeruntimeType
if receiver type is known at compile time (e.g. due to type feedback based specialization).
b328cadaacb12fac16a1b173c48f53ac1ba1352d Added a benchmark for the
canUpdate
hot method:While the new Rti is quite a bit faster that the old rti, and faster than Dart JIT VM, the benchmark on dart2js on V8 still lags AOT VM by 3-4x.
The
Type
instance is cached on the_Rti
object.There are several things we can do:
runtimeType
getters for intercepted types, closures, arrays and regular Dart objects.canUpdate
code uses a one-shot interceptor, but only because the parameter type is nullable.null
becomes impossible.There are many
==
methods with the following pattern:runtimeType
is implicitthis.runtimeType
.runtimeType
test.Ideas:
==
has type parameters, and no class overridesruntimeType
,other.runtimeType != this.runtimeType
can be reduced to JavaScriptother.constructor !== this.constructor
.other
can be refined similar to an is-test:other
is known to to be a subtype of the declaring class, which often will allow the following 'is'-test to be eliminated.other.runtimeType == this.runtimeType
is equivalent to an is-test, e.g.other is CircleBorder
.The classes that override
get:runtimeType
are an impediment to the above ideas, especially for the argumentother
of==
which could be anything.