Commit Graph

53 Commits

Author SHA1 Message Date
Erik Corry c0404e4f23 Propagate this-specialization to regular (megamorphic) calls
R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2716593002 .
2017-02-27 13:28:54 +01:00
Martin Kustermann 20130a2d43 VM: [Kernel] Ensure we record [FieldLoadInstr]s in the ParsedFunction when using field guards
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2704623003 .
2017-02-17 13:10:20 +01:00
Florian Schneider d8f223560a Fix environment mismatch in AOT inlining.
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 .
2017-01-19 10:25:23 -08:00
Regis Crelier dc0605012f Move Null type to the Bottom in the VM (fixes #28025).
Fix wrong comments.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2608373002 .
2017-01-05 10:05:31 -08:00
Ryan Macnak 4607e38d28 Reapply "Save and restore feedback from JIT."
Ensure ICData is attached to the callee flow graph in the inliner when built from kernel IR, not just from source.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2572423004 .
2016-12-16 16:00:17 -08:00
Ryan Macnak 176d732cc3 Revert "Save and restore feedback from JIT."
This reverts commit 31ee20297e.

Review-Url: https://codereview.chromium.org/2579413002 .
2016-12-16 13:53:20 -08:00
Ryan Macnak 31ee20297e Save and restore feedback from JIT.
- 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 .
2016-12-16 10:21:40 -08:00
Florian Schneider 890bfa8015 AOT: Fix bug in receiver type propagation after unique selector calls.
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 .
2016-11-16 10:14:40 -08:00
Ryan Macnak e7040c86eb AOT: Speculate that bitwise operators will have Smi receivers and arguments.
Add shifts to CheckedSmiOps.

Fix invalid load forwarding across CheckedSmiOps and CheckedSmiComparisons.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2487873003 .
2016-11-11 13:33:43 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Florian Schneider 0294f8650d AOT: Enable branch merging for checked smi comparisons
This generates better code for smi comparisons in AOT code where the inputs
are not known smis: It avoids materializing the bool-value before branching.

Before:

;; v46 <- CheckedSmiOp:86(==, v35, v77)
;; Branch if StrictCompare:88(!==, v46, v38) goto (8, 9)
0x10e0c2ca3    f6c201                 testb rdx,1
0x10e0c2ca6    0f8526010000           jnz 0x10e0c2dd2
0x10e0c2cac    483bca                 cmpq rcx,rdx
0x10e0c2caf    0f8409000000           jz 0x10e0c2cbe
0x10e0c2cb5    498b5e58               movq rbx,[thr+0x58]   false
0x10e0c2cb9    e904000000             jmp 0x10e0c2cc2
0x10e0c2cbe    498b5e50               movq rbx,[thr+0x50]   true
0x10e0c2cc2    493b5e50               cmpq rbx,[thr+0x50]   true
0x10e0c2cc6    0f8429000000           jz 0x10e0c2cf5  ;; B9
;; B8

===
After:
;; Branch if CheckedSmiComparison:86(!=, v35, v77) goto (8, 9)
0x118b3ce15    f6c201                 testb rdx,1
0x118b3ce18    0f850c010000           jnz 0x118b3cf2a
0x118b3ce1e    483bca                 cmpq rcx,rdx
0x118b3ce21    0f8429000000           jz 0x118b3ce50  ;; B9
;; B8

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2466643002 .
2016-11-01 17:08:33 +01:00
Vyacheslav Egorov 0635b57d43 Reland "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This relands commit f4ec20abac.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2465793003 .
2016-11-01 16:49:02 +01:00
Vyacheslav Egorov 16e4f2f1c2 Revert "Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."""
This reverts commit e495e100dd.

Commit breaks bots that are using Android devices (SIMARM is unaffected).

R=rmacnak@google.com
BUG=

Review URL: https://codereview.chromium.org/2449013004 .
2016-10-26 16:53:32 +02:00
Vyacheslav Egorov e495e100dd Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern.""
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 .
2016-10-26 12:25:48 +02:00
Ryan Macnak 890f694de5 Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."
This reverts commit f4ec20abac.

Revert "Use ZoneHandle when creating ConstantInstr"

This reverts commit cb87f2d82f.

This change introduced crashes on AOT and runtime errors on the GN SDK build.

TBR=vegorov@google.com

Review URL: https://codereview.chromium.org/2451893002 .
2016-10-25 13:19:33 -07:00
Vyacheslav Egorov f4ec20abac Recognize 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

Review URL: https://codereview.chromium.org/2379733002 .
2016-10-25 10:03:06 +02:00
Florian Schneider e25461c151 VM Propagate receiver type from calls to unique selectors in AOT compilation.
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 .
2016-10-11 13:17:47 -07:00
Ryan Macnak 6137d020b9 AOT: Use a cid range check when possible to implement type tests.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2314133003 .
2016-09-08 15:25:08 -07:00
Florian Schneider 7d6f78b88f VM: More refactoring of recognized methods inlining.
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 .
2016-08-24 10:35:05 -07:00
Florian Schneider 8eaa762d4a VM: Remove more duplicate code between AOT and JIT compiler.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2265873005 .
2016-08-22 15:20:54 -07:00
Florian Schneider 1e7dc8a5e8 Move inlining of recognized SIMD methods to the flow-graph inliner.
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 .
2016-08-18 12:50:37 -07:00
Florian Schneider d3810213b0 VM: Array bounds checks that don't deoptimize for precompiled code.
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=rmacnak@google.com, vegorov@google.com

Review URL: https://codereview.chromium.org/2149023002 .

Committed: https://github.com/dart-lang/sdk/commit/4a5f651c4b2202013ab7c3db887fd95e2597e173
2016-07-15 10:07:41 -07:00
Lars Bak df4eb11184 Fixed the AOT compiler to understand the simpleInstanceOf.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2152693004 .
2016-07-14 13:38:36 -07:00
Ryan Macnak 2a535414bc Revert "VM: Array bounds checks that don't deoptimize for precompiled code."
This reverts commit 4a5f651c4b.

Review URL: https://codereview.chromium.org/2152683003 .
2016-07-14 13:28:23 -07:00
Florian Schneider 4a5f651c4b VM: Array bounds checks that don't deoptimize for precompiled code.
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 .
2016-07-14 10:48:50 -07:00
Florian Schneider c09e9ffc91 VM: Move inlining of _bitAndFromSmi to the flow graph inliner.
Also move the check for number of checks to a common place when
replacing recognized methods in the optimizer.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2127273002 .
2016-07-12 14:06:33 -07:00
Florian Schneider a3dcdb35aa Refactor inlining of recognized methods.
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 .
2016-06-28 11:25:21 -07:00
Florian Schneider 22828c58cb Improve inlining of recognized methods in AOT.
Also, assert that we don't repeatedly perform speculative inlining.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2097413002 .
2016-06-27 08:55:02 -07:00
Vyacheslav Egorov 31057dcec7 VM: [AOT] Make sure that we inline all resolved accessor invocations.
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 .
2016-06-27 17:15:28 +02:00
Vyacheslav Egorov 81451be421 VM: AOT optimizer does not need to check for overrides if receiver's cid is known.
Class ids inferred by the type propagator are always concrete: value is guaranteed to be an instance of inferred class and can't be an instance of a subclass.

R=fschneider@google.com
BUG=

Review URL: https://codereview.chromium.org/2087893004 .
2016-06-22 20:09:35 +02:00
Florian Schneider 220b040c4a Simplify and improve optimization of is-tests in the precompiler.
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 .
2016-06-16 08:54:27 -07:00
John McCutchan c0eb4d9dc0 Remember inside an ICData if it is for a static call or an instance call
- [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 .
2016-06-13 13:23:57 -07:00
Vyacheslav Egorov ec9b1c385a VM: Improve specialization of calls on receiver in AOT mode.
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 .
2016-06-10 18:12:49 +02:00
Florian Schneider c88a8a648c Remove unused code from aot optimizer.
FLAG_polymophic_with_deopt is always false when generating precompiled code,
so this function is not needed.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2047433005 .
2016-06-07 13:30:46 -07:00
Florian Schneider 9ee5dfb245 Fix speculative inlining in precompilation.
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 .
2016-06-06 16:37:39 -07:00
Vyacheslav Egorov 6bb73bd2e4 Background compiler should validate CHA decisions before committing the code.
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 .
2016-05-20 13:48:29 +02:00
Florian Schneider 39a1a30415 VM: Another fix for precompiling with >1 iterations.
Corrected VM entry points.

Fixed collection of unique function names.

Removed wrong assertion.

Clean up unused code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1969843002 .
2016-05-12 09:32:31 +02:00
Florian Schneider c1e6aef400 VM: Optimized code for all of [External]{One|Two}ByteString::codeUnitAt.
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 .
2016-05-11 09:29:28 +02:00
Florian Schneider 1217e539e9 VM: Remove _leftShiftWithMask32.
It was used for the Javascript integer overflow warnings which were already
removed from the VM.

BUG=
R=regis@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1900863004 .
2016-04-19 19:06:53 +02:00
Ryan Macnak e048774776 Precompilation: Specialize instance calls when the call receiver is the method receiver and the method class has a small number of concrete subclasses (currently 5).
CompileOnceHelloHtml (ARMv7HF) +17.194%
DeltaBlueClosures (ARMv7HF) +28.379%
DeltaBlue (ARMv7HF) +30.190%

precompiled dart2js arm 19071745 -> 19504726 (+2.3%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1867913004 .
2016-04-11 12:52:28 -07:00
Florian Schneider 2783afd607 VM: Fix receiver type propagation in presence of try-catch.
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 .
2016-03-30 15:55:11 -07:00
Florian Schneider 6d27476cd1 VM: Fix a couple of issues in the AOT optimizer, add fast path smi multiply.
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 .
2016-03-25 08:52:15 -07:00
Regis Crelier ba69c8a898 Enumerate URIs of all types in type errors in order to help the user diagnose
the error (it was previously only printed for types with identical names).
Cleanup and simplify construction of type errors.

R=hausner@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1778133002 .
2016-03-09 15:16:47 -08:00
Florian Schneider 2148815673 Add fast path smi comparison operators.
Only rudimentary support for now, gives around 15% speedup on richards, precompiled.

Branch-merging is not yet supported in this CL.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1773633002 .
2016-03-07 08:55:43 -08:00
Florian Schneider 72a815c39f VM: Add smi fast path operations for precompiled code
The non-smi case is handled in a slow-path deferred code path.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1756403002 .
2016-03-04 09:33:09 -08:00
Florian Schneider 69f39d0b83 VM: Don't do inline context allocation in precompiled code.
It saves almost 2% (dart2js) in generated snapshot size, and the performance
benefit is negligible in precompiled code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1760153003 .
2016-03-03 16:22:13 -08:00
Ivan Posva 8d18298fed - Remove Isolate::Flags structure and store flags directly in isolate.
- Make enable_asserts, enable_type_checks, error_on_bad_override and
  error_on_bad_type release mode flags only.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1737693003 .
2016-02-25 18:06:56 -08:00
Florian Schneider d8677964a3 Move precompilation-related flags to flags list.
They become compile-time constants in the precompiled runtime, and in product mode.

In precompiled product mode, the precompiled value has precedence.

BUG=
R=rmacnak@google.com

Committed: https://github.com/dart-lang/sdk/commit/5c9f18c6c87284395564051a052cc4acc9b6f59a

Review URL: https://codereview.chromium.org/1731743003 .
2016-02-25 07:53:39 -08:00
Ryan Macnak bd85deaf4e Revert "Move precompilation-related flags to flags list."
The default value of print_stop_message was architecture specific.

TBR=fschneider@google.com

Review URL: https://codereview.chromium.org/1739593002 .
2016-02-24 18:08:01 -08:00
Florian Schneider 5c9f18c6c8 Move precompilation-related flags to flags list.
They become compile-time constants in the precompiled runtime, and in product mode.

In precompiled product mode, the precompiled value has precedence.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1731743003 .
2016-02-24 17:31:08 -08:00