Commit Graph

776 Commits

Author SHA1 Message Date
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
Florian Schneider 6d537d7e61 VM: Improve phi-elimination to improve code inside of try-catch.
Since we don't have precise liveness information inside try-catch blocks,
there are often redundant phis inside try-catch of the form

v <- phi(v, v, ..., R, v, v, ...)

This CL finds these redundant phis and replaces them with R.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1918913002 .
2016-04-26 12:50:25 +02:00
Stephen Adams cceadc20d9 Canonicalize TestCidsInstr
This reduces Uri.toString() in dart2js from 514 lines to 345 lines.
(lines are instructions or code comments).

I noticed the following:

Uri.toString() has a statement: sb.write('//');

This was lined two levels deep, with effectively the following code
for the inlining of interoplateSingle:

    TestCids on constant '//':
       _OneByteString  -> return '//';
       Uri -> fallthrough;
       Message -> fallthrough;
       else deopt;

    if ('//' is not Uri) deopt;
    String s = Uri.toString('//');
    if (s is !_OneByteString) deopt;
    return s;

With canonicalization of TestCidsInstr, this whole thing clears up
eliminate interoplateSingle.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1891353003 .
2016-04-20 10:26:59 -07:00
Florian Schneider 66fa897507 VM: Avoid smi-check when loading class-ids from known non-smi values.
The code for LoadClassId is a lot smaller when we know that the value can't be a smi.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1897983002 .
2016-04-19 12:45:39 +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
Ryan Macnak 34e4107c0d Add flag to disable string externalization, allowing the compiler to rely on string class checks remaining valid across calls.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1859273002 .
2016-04-07 13:24:44 -07:00
Florian Schneider 21e069a009 Reland "VM: Improve single-target polymorphic calls."
This reverts commit 53e92a31ae.

Reverted to check if this CL had anything to do with Dartium test failures. Turns out it does not.

TBR=srdjan@google.com,

BUG=

Review URL: https://codereview.chromium.org/1853003002 .
2016-04-02 18:08:32 -07:00
Florian Schneider 4b5d05e12f Fix bug in receiver-phi computation.
This fixes a bug in my previous CL (https://codereview.chromium.org/1841073003/)

Computes the is-receiver property on demand, but for all phis at once using a worklist-approach.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1851653002 .
2016-04-02 13:51:02 -07:00
Florian Schneider 53e92a31ae Revert "VM: Improve single-target polymorphic calls."
This reverts commit f6c19ee595.

Likely cause of Dartium test failures.

TBR=rmacnak

BUG=

Review URL: https://codereview.chromium.org/1852433006 .
2016-04-01 15:09:51 -07:00
Florian Schneider f6c19ee595 VM: Improve single-target polymorphic calls.
Use the existing class-id check for dense ranges in more places.
Previously we would fall back to megamorphic lookup with >4 cids,
even though we can check cid ranges up to word-size efficiently.

Next step is to generalize the dense class id checks to multiple
word-sizes.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1847293002 .
2016-04-01 09:59:27 -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 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
Srdjan Mitrovic 20c17d9e41 More fixes for background compilation
BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1745453002 .
2016-02-26 10:58:17 -08:00
Florian Schneider df4f508483 Rename FlowGraphOptimizer -> JitOptimizer, clean up optimizer code.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1732483002 .
2016-02-24 07:18:12 -08:00
Vyacheslav Egorov b2994a4f55 Unwrap TypeRef returned by InstantiateFrom in AssertAssignableInstr::Canonicalize.
Runtime system does not expect to see TypeRef as a destination type for a
type check: type references should only appear in the type arguments of
recursive types.

Reorganize canonicalization code to make it more readable and assertions to
catch this issue earlier.

BUG=http://dartbug.com/25782
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1701963002 .
2016-02-16 13:44:08 +01:00
Florian Schneider 56861fb0ee VM: Use BlockIterator in the optimizer consistently for iterating the flow graph
BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1695253002 .
2016-02-15 13:42:46 +01:00
Regis Crelier bb649318e4 Remove support for Javascript warnings in the VM.
This cl is a clone of cl https://codereview.chromium.org/1683363002/ deleted by
accident. Already LGTM'ed.

Review URL: https://codereview.chromium.org/1690903003 .
2016-02-11 09:16:06 -08:00