When replacing _instanceOf with a cid range check, the
number of arguments passed as arguments changes.
The new environment must reflect this change.
The failing test is from #28431, but the bug itself has nothing to
do with checked mode.
R=rmacnak@google.com
Review-Url: https://codereview.chromium.org/2639273003 .
- Adjust fingerprints to be independent of the library's private key, which varies with load order.
- Use usage_counter in AOT inlining decisions if JIT feedback is available.
- Reduce inlining in cold functions.
dart2js product aot snapshot 15841351 -> 14436273 (-8.86%)
R=fschneider@google.com
Review-Url: https://codereview.chromium.org/2562693003 .
Insert Redefinition instructions to prohibit unsafe code motion. If we propagate
the receiver type downwards from a call to a unique selector, we must not hoist
instructions that were optimized using this type information across the call.
R=vegorov@google.com
Review URL: https://codereview.chromium.org/2498073004 .
This reverts commit 890f694de5.
Previous commit was passing field_type_map_ down in a place where it was not passed down before.
This caused some handles to be used across zones, which caused crashes.
BUG=
Review URL: https://codereview.chromium.org/2453463006 .
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
Review URL: https://codereview.chromium.org/2379733002 .
If there is no override of noSuchMethod in any class, we can
propagate the receiver type downwards from calls that call a unique
selector.
This speeds up dart2js by around 3%, a particle simulation benchmark by around 10%.
BUG=
R=rmacnak@google.com
Review URL: https://codereview.chromium.org/2412653002 .
Move inlining OneByteString._setAt, List constructor, Object constructor
and a few math function to the flow-graph inliner.
Enable inlining of trigonometric math functions in AOT that were previously not inlined.
BUG=
R=rmacnak@google.com
Review URL: https://codereview.chromium.org/2273943002 .
This allows inlining of these methods in the AOT optimizer.
Also fix missing inlining of some SIMD constructors (Float32x4FromInt32x4Bits and Int32x4FromFloat32x4Bits)
BUG=
R=rmacnak@google.com
Review URL: https://codereview.chromium.org/2254053002 .
1. Make CheckArrayBoundInstr also check the index for smi. This allows easy replacement
of the deoptimizing checks with the slow-path checks in the precompiler.
2. Add GenericCheckBoundInstr which has a slow-path attached for
handling check failures.
BUG=
R=vegorov@google.com
Review URL: https://codereview.chromium.org/2149023002 .
Move some common code into the FlowGraphInliner to avoid duplication.
Also, only emit the receiver class check when necessary in the first place.
There is more duplicate code in jit_optimizer.cc and aot_optimizer.cc which is
independent of the compilation mode. This CL is just a step.
Removed receiver class check for SIMD operations that require unboxing: The unbox operation already checks the argument type.
BUG=
R=vegorov@google.com
Review URL: https://codereview.chromium.org/2102663003 .
Previously we would just replace it with a static call and hope that inliner
handles it. However sometimes it happens too late in the pipeline and inliner
misses the opportunity.
Additionally drop some dead code from the aot_optimizer that was not doing
anything useful because FlowGraphInliner::TryInlineRecognizedMethod always
returns false in the AOT mode.
R=fschneider@google.com
BUG=
Review URL: https://codereview.chromium.org/2098643003 .
The optimizer now also deals with is-checks for num, double, _Smi in the
same way as it did for int before.
This CL eliminates many is-tests of constants that appear after inlining.
Also, make a better distinction between deoptimizing and non-deoptimizing
cases when replacing is-tests. e.g. InstanceOfInstr can't cause eager
deoptimization.
Also, improve tracing output when running e.g. --trace-inlining
Minor fix in raw_object.h.
BUG=
R=vegorov@google.com
Review URL: https://codereview.chromium.org/2074533002 .
- [x] Add an is static call bit to ICData
- [x] Rewrite the reset ICData iterators to rely on that bit rather than the function's ic data map
BUG=
Review URL: https://codereview.chromium.org/2064693003 .
When encountering call this.m(...) we can check if m resolves to the same
method in all concrete subclasses of the receiver class. If it does then
we don't need any checks and can just use a StaticCall instead of InstanceCall.
This is allows us to improve code quality for cases like:
class Base {
var _field;
foo() { _field = true; }
}
class A01 extends Base { }
...
class A16 extends Base { }
Previously AOT would generate InstanceCall(get:_field) in the method foo.
However with this change we generate StaticCall(...) which subsequently gets
handled by the inliner.
R=fschneider@google.com
BUG=
Review URL: https://codereview.chromium.org/2055263002 .
When optimistically inlining is-checks and as-casts, we have to guard
again repeated speculative attempts.
Also, add result cid information for recognized factories.
BUG=#26607
R=rmacnak@google.com
Review URL: https://codereview.chromium.org/2035073002 .
CHA::HasOverride skips non-finalized classes when looking for overrides which means that we will install incorrect code if some subclass with an override was finalized while compilation was in progress.
To catch situations like this we record the number of finalized subclasses that class had
when CHA made the first negative decision about it (e.g. that it has no subclasses or that it has no overrides for some function) and before installing the code we check that number of subclasses matches.
Additionally renamed "leaf classes" to "guarded classes" because those classes are not necessarily leaf.
R=fschneider@google.com
BUG=
Review URL: https://codereview.chromium.org/2002583002 .
Added support for external string using flow graph based intrinsics
which helps with precompiled code, but also polymorphic calls in jitted code.
I also added support for the missing cases in the flow graph optimizer.
BUG=
R=vegorov@google.com
Review URL: https://codereview.chromium.org/1961393002 .
With catch blocks appearing as additional function entry blocks,
there can be phis for the receiver (parameter 0).
This CL fixes the problem that the receiver type information
was lost in the presence of try-catch.
BUG=
R=vegorov@google.com
Review URL: https://codereview.chromium.org/1841073003 .
1. Add fast path smi multiply
2. Recognize more operands as likely smi: If they are the result
another CheckedSmiOp, or the result of a phi that has a known smi.
3. Fix guessing receiver cids of getters/setters based.
4. Try to specialize calls based on propagated receiver type first before
using guessed cids (which generates a call with checks + megamorphic slow path)
BUG=
Review URL: https://codereview.chromium.org/1824023002 .