Commit Graph

792 Commits

Author SHA1 Message Date
Kevin Millikin f31b6d5e2c Reland "Track the 'awaiter return' call stack..."
Original CL: https://codereview.chromium.org/2692803006/

Original commit message:
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2725623003 .
2017-02-28 16:13:41 +01:00
Kevin Millikin a0965a641f Revert "Track the 'awaiter return' call stack..."
Revert a pair of commits that cause failure of the Kernel continuation
transformer:

  cba7e3e79a
  4fe4f177de

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2718353002 .
2017-02-28 12:46:31 +01:00
John McCutchan cba7e3e79a Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

Fixes #27242

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2692803006 .
2017-02-27 14:16:15 -08:00
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 9ea0dbcab1 VM: Remove unused optimization of merging of sin/cos.
It was only implemented on ia32/x64, and has been disabled
for a long time (broken on Windows).

Fixes #22504.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2658733002 .
2017-01-26 12:42:54 -08: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
Vyacheslav Egorov 67576af5f2 VM: [Cleanup] Delete legacy code associated with BranchInstr.
1) BranchInstr::is_checked() was introduced back in the day when unoptimized
IR could contain comparisons like RelationalOp - these days unoptimized IR
can only contain StrictCompareInstr, other comparisons are represented as
calls and can't be merged into the branch, making BranchInstr::is_checked()
obsolete.

2) Constrained type support is no longer used: we deleted parts of the flow graph type propagator that propagated non-nullable types down from comparison with null (due to LICM issue).

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2640993003 .
2017-01-18 23:58:58 +01: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
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
Ryan Macnak 26245de7a5 Support unaligned integer loads on ARM and MIPS.
Fixes SDK build with SIMARM/SIMARM64/SIMMIPS.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2452453002 .
2016-10-31 17:41:53 -07:00
Florian Schneider b1dfa2aee1 VM: Enable branch merging of isnan, isinf.
More general ComparisonInstr by introducing TemplateComparison.

R=zra@google.com

Review URL: https://codereview.chromium.org/2463593002 .
2016-10-31 20:21:19 +01:00
Martin Kustermann e984271b94 Add support for OSR in kernel-based FlowGraphBuilder
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2464953002 .
2016-10-31 19:12:09 +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
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07: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
Zachary Anderson 088347fd9d Reland "Add DoubleTestOp instruction"
Fixes DoubteTestOpInstr::AttributesEqual()

Review URL: https://codereview.chromium.org/2433813002 .
2016-10-18 22:46:36 -07:00
Zachary Anderson f6296cc91b Revert "Add DoubleTestOp instruction"
Review URL: https://codereview.chromium.org/2432903002 .
2016-10-18 21:57:05 -07:00
Zachary Anderson fa855cf1c2 Add DoubleTestOp instruction
This gives a ~5% bump to the Flutter layout benchmark
in checked mode.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2423843002 .
2016-10-18 21:24:12 -07:00
Vyacheslav Egorov f67ce21068 VM support for running Kernel binaries.
BUG=
R=asiva@google.com, fschneider@google.com

Review URL: https://codereview.chromium.org/2411823003 .
2016-10-15 22:48:46 +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
Florian Schneider 7ca3da1a3a Fix lazy deoptimization in the presence of exceptions
Catch block entries need to be considered when doing lazy deoptimization.

In addition to the return, also patch all catch entry blocks in a function scheduled for lazy deoptimization.

Also, move restoring the pool pointer to the jump-to-handler stub to simplify patching the catch entry.

BUG=#27419
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2357343003 .
2016-09-26 16:24:23 -07:00
Ryan Macnak 326af5e9d7 Move Zone's destructor out of a header file.
This unburdens users of StackZone from needing to include handles_impl.h. A new use of StackZone was recently added to heap.cc without a include of handles_impl.h, and this caused link-time errors on some versions of gcc.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2362573002 .
2016-09-22 13:16:36 -07:00
Ryan Macnak 1bc2b04198 Fix bug in AOT compiler where we would propogate a result type for instances calls where the target is not known.
Interacted with cid range checks to incorrectly reduce

foo(x) => (x * 1.0) is double;

to

foo(x) { x * 1.0; return true; }

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2325753002 .
2016-09-08 14:36:28 -07:00
Florian Schneider 442fa8e7bc VM: Remove unecessary dead code from flow-graph builder.
We already recognize typed list factories and mark them
using is_known_list_constructor_.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2293103002 .
2016-08-30 11:14:40 -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 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
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
Zachary Anderson 1c783dea87 DBC: Remove special case from CheckClassInstr. Cleanup.
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2111803003 .
2016-07-01 10:19:21 -07:00
Siva Annamalai 006bab2c47 Land Ivan's change of 'Remove support for verified memory handling'
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2112043002 .
2016-07-01 09:21:01 -07:00
Florian Schneider 28c0ab16f2 Canonicalize CheckedSmiOp if compile type turns out to be smi.
Certain CheckedSmiOp operations can be specialized later during optimization
when the compile type turns out to be smi, and we know that the operation
can't deoptimize.

BUG=#26761
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2094613003 .
2016-06-23 10:31:23 -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
Ryan Macnak 2e9c5f9a91 Reapply "VM: Add result cid information for recognized methods."
- _HashVMBase._index is nullable
 - _HashVMBase._data is a regular Array
 - DBC fixes from Zach.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2033553002 .
2016-06-02 09:59:48 -07:00
Ryan Macnak 907a6b1c3b Revert "VM: Add result cid information for recognized methods."
In Flutter, this caused

  RangeError (index): Index out of range: index should be less than null: 0
  Uint32List.[]= (dart:typed_data)
  _HashVMBase&MapMixin&&_LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart)

This reverts commit 0ae4ae5033.

TBR=fschneider@google.com

Review URL: https://codereview.chromium.org/2023423002 .
2016-06-01 14:08:48 -07:00
Florian Schneider 0ae4ae5033 VM: Add result cid information for recognized methods.
We already had this for recognized factories. This CL adds a result cid
for the remaining recognized methods.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2018363004 .
2016-06-01 09:42:48 +02:00
Vyacheslav Egorov 655bc90489 Enable optimizer pipeline for DBC.
Most of the infrastructure is fixed to work with DBC stack layout:

- register allocator allocates DBC registers with the limitation that we allocate only 20 registers and bail out if anything needs spilling (there is no use implementing spilling on DBC because registers are memory locations themselves). We should be able to bump number of CPU registers on DBC up to 256 but this requires major surgery in some parts - so I postponed this;
- lazy deoptimization is implemented, eager deoptimization is not - because we don't emit any code that actually requires it. it's a minor change to support it once we have a target;
- stack scanning respects stack maps built by registers allocator;

We bailout from all unsupported instructions.

R=zra@google.com

Review URL: https://codereview.chromium.org/1992963002 .
2016-05-24 14:35:50 +02:00
Florian Schneider cb6b40d62b Preserve LICM information for check instructions during assertion strengthening.
This fixes potential excessive deoptimizations in checked mode.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2002823002 .
2016-05-21 19:31:53 +02:00
Florian Schneider baaea63e0a VM: Fix bug that can causes infinite opt/deopt loop.
When deoptimizing on a hoisted TestCids instruction, we must mark the
function to that this instruction does not get hoisted the next time
the function gets optimized.

BUG=dartbug.com/26500
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1999043002 .
2016-05-20 13:43:02 +02:00
Harry Terkelsen 1745ba77f5 fix all instances of "the the"
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1980573003 .
2016-05-13 12:38:25 -07: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 f54c8d89fa VM: Remove PushTempInstr, simplify SSA renaming.
BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1950553002 .
2016-05-04 10:54:03 +02:00
Florian Schneider 6ff337f724 Revert "VM: Improve phi-elimination to improve code inside of try-catch."
This reverts commit 6d537d7e61.

Need more time to investigate test failures that occur with this CL.

TBR=vegorov@google.com

BUG=

Review URL: https://codereview.chromium.org/1922953002 .
2016-04-26 17:24:35 +02:00