Commit Graph

4698 Commits

Author SHA1 Message Date
Asger Feldthaus e839697d70 dart2js cps: Constant folding for "uint < 0" etc.
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1701733002 .
2016-02-17 13:20:37 +01:00
Asger Feldthaus e19ab63840 dart2js cps: Count size of JS expressions in inliner.
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1696163002 .
2016-02-17 12:39:29 +01:00
Asger Feldthaus 1c698c183b dart2js cps: Fix inlining of stringify.
The rewrite Stringify(x) -> x.toString() is only safe when the toString
method is known to return a string.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1697373002 .
2016-02-17 10:57:58 +01:00
Asger Feldthaus e12baf9394 dart2js cps: Combine integer type check with bounds check.
The lower bounds check can be combined with the argument check using a
uint32 check:

  if (i >>> 0 !== i || i >= array.length)
      return H.ioore(array, i);

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1699033003 .
2016-02-17 10:14:28 +01:00
Asger Feldthaus 64fa2ef505 dart2js cps: Do not inline string interpolation helper.
Inlining H.S(x) can lead to code like:
  x === 0 ? 1 / x < 0 ? "-0.0" : "" + x : "" + x

It does not help much to inline this and it can block more useful
inlinings because the extra code brings the caller over the inlining
threshold.

H.S(x) is replaced with x.toString$0(0) if x is a self-interceptor, and
the inliner is then allowed to continue inlining on that.

BUG=
R=kmillikin@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1689933002 .
2016-02-15 10:58:01 +01:00
Sigmund Cherem 48b0df5fa1 cpsir: insert guard and force specialization for [] and []=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1685893002 .
2016-02-12 09:21:52 -08:00
Sigmund Cherem 648be1a299 fix warnings/test failures due to analyzer warnings, update stauts to include
analyzer missing error.

TBR=jacobr@google.com

Review URL: https://codereview.chromium.org/1687283003 .
2016-02-11 13:49:58 -08:00
Sigmund Cherem a0c438a972 cpsir: implementation of jsinterop in cps ir
R=jacobr@google.com

Review URL: https://codereview.chromium.org/1688433006 .
2016-02-11 13:21:52 -08:00
Florian Loitsch d8467b7e2d Don't allow to iterate over strings.
BUG= https://github.com/dart-lang/dart-pad/issues/716
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1689783002 .
2016-02-10 23:21:56 +01:00
Kevin Millikin 35839c7840 Dart2js CPS: Implement 'await for'.
The implementation strategy is in terms of a loop over a StreamIterator,
similar to what is done in the dart2js SSA backend and in the Dart VM.

BUG=https://github.com/dart-lang/sdk/issues/24984
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1686973002 .
2016-02-10 15:28:03 +01:00
Asger Feldthaus aeb36c9314 dart2js cps: Set the return type on adapters.
The return type of an adapter function was not set, preventing
further inlining of methods whose receiver depends on the return value.

CLOSES #25725.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1685643002 .
2016-02-10 11:47:35 +01:00
Asger Feldthaus 3f8fdc2434 dart2js cps: Update status files.
BUG=

Review URL: https://codereview.chromium.org/1686733003 .
2016-02-10 11:21:11 +01:00
Johnni Winther fcad7b6b5b Introduce getPrefixEndToken to avoid too big context in messages.
R=ahe@google.com

Review URL: https://codereview.chromium.org/1661853005.
2016-02-10 09:27:30 +01:00
Asger Feldthaus 00ad00c98c dart2js cps: Do not count no-check bounds checks in size visitor.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1681953002 .
2016-02-09 17:56:47 +01:00
Asger Feldthaus 35b6203b9d dart2js cps: Remove interceptors in cases where type propagation fails.
After calling a non-intercepted method on an object, that object is
known to be self-interceptor:

  x.foo$1()
  getInterceptor(x).$eq(x, y)
    ==>
  x.foo$1()
  x.$eq(0, y)

Type propagation would handle this if TypeMasks could represent a
type containing all self-intercepting classes (see issue #25646).

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1655183002 .
2016-02-09 17:52:09 +01:00
Johnni Winther 059f44aa3b Fix super noSuchMethod handling.
Closes #25680

- This CL fixes the handling of inapplicable noSuchMethod methods on superclasses (see issue 25671) for both SSA and CPS.
- The CPS implementation for normal noSuchMethod calls on super was wrong is fixed with this CL, including the addition the missing visitUnresolvedSuperSet method  on the SemanticSendVisitor.
- An error (presumably in type inference) affecting SSA was found with the added tests (Issue 25716 filed)

R=asgerf@google.com, het@google.com

Committed: https://github.com/dart-lang/sdk/commit/756d95a372b5123193644f07b65b93c106a92078

Reverted: https://github.com/dart-lang/sdk/commit/a0d7b64fdefbd5e05b9ce7e80d7883f61a99102e

Review URL: https://codereview.chromium.org/1678053002.
2016-02-09 15:19:19 +01:00
Asger Feldthaus bbca76a5e2 dart2js cps: More aggressive operator specialization.
Inline more unsafe operator calls, and insert more checks accordingly.

When "num" is the only receiver that does not respond with NSM, insert
a check and use the builtin operator.  Previously we only did this when
the receiver was a number or null. For example:

  if (typeof x !== "number") return x.$lt();
  result = x < 4;

When the argument might have the wrong type, insert an argument check
and use the builtin operator.  Previously we never did this if the
argument might have the wrong type. For example:

  if (typeof x !== "number") return H.iae(x);
  result = 4 < x;

If both receiver and argument need checks, we join the two checks and
use a one-shot interceptor to throw the error:

  if (typeof x !== "number" || typeof y !== "number")
    return J.$lt(x, y);
  result = x < y;

NullCheck has been generalized to a ReceiverCheck instruction to
support "x.$lt()" above, that throws even if x is a non-null value.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1668913002 .
2016-02-09 13:34:37 +01:00
Johnni Winther a0d7b64fde Revert "Fix super noSuchMethod handling."
This reverts commit 756d95a372.

BUG=

Review URL: https://codereview.chromium.org/1677423002.
2016-02-09 13:02:31 +01:00
Asger Feldthaus 86f286a3eb dart2js cps: Pull SetFields into field initializer arguments.
For example:

    foo = new D.Foo(null, null);
    foo.x = 'a';
    foo.y = 'b';

becomes:

    foo = new D.Foo('a', 'b');

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1671073002 .
2016-02-09 12:33:18 +01:00
Johnni Winther 756d95a372 Fix super noSuchMethod handling.
Closes #25680

- This CL fixes the handling of inapplicable noSuchMethod methods on superclasses (see issue 25671) for both SSA and CPS.
- The CPS implementation for normal noSuchMethod calls on super was wrong is fixed with this CL, including the addition the missing visitUnresolvedSuperSet method  on the SemanticSendVisitor.
- An error (presumably in type inference) affecting SSA was found with the added tests (Issue 25716 filed)

R=asgerf@google.com, het@google.com

Review URL: https://codereview.chromium.org/1678053002.
2016-02-09 11:39:37 +01:00
Johnni Winther 1a4ba676ad Add Dart code to diff_view
+ update annotations to make nodes without information more visible
+ add annotation for unused source information
+ use source information from subnodes in variable declarations, assignments and expression statements (a fix triggered by showing unused information)
+ support source information for initial variable declarations
+ new source info is now comparable to the old; need to check source locations before  switch to the new

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1678043003.
2016-02-09 11:25:26 +01:00
Johnni Winther d97da6f225 Report error on JS-interop operator [] and []= methods.
R=floitsch@google.com, jacobr@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1651933002.
2016-02-08 12:57:15 +01:00
Florian Loitsch a9b8efcd0d Don't expose private libraries with dart.library.X.
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1674613002 .
2016-02-05 17:36:14 +01:00
Asger Feldthaus 703a7fcc6d dart2js cps: More type rules in type propagation.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1657613004 .
2016-02-05 12:10:23 +01:00
Florian Loitsch 6468ba5022 Share the first error messages.
R=brianwilkerson@google.com, johnniwinther@google.com

Review URL: https://codereview.chromium.org/1660703002 .
2016-02-04 12:52:39 +01:00
Florian Loitsch 2232803eae Don't use "var" to introduce the deferred_initializer.
R=het@google.com

Review URL: https://codereview.chromium.org/1653453002 .
2016-01-29 21:52:52 +01:00
Kevin Millikin b76ffa9505 dart2js CPS: Remove an invalid assertion in shrinking reductions.
Because we search for new redexes while performing reductions, we can't
always assert that a term is well-formed.

In this case, it's not true that all invocations of a continuation will have
the same number of arguments while we are in the middle of performing a dead
parameter reduction.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1641073003 .
2016-01-28 12:56:01 +01:00
Kevin Millikin 7db0c89e49 dart2js CPS: During shrinking reductions, mark deleted branches as deleted.
Shrinking reductions uses a null parent of a potential redex to detect that
the redex occurs in an already-deleted subterm, to avoid performing such
reductions.  (They are not safe because the term structure of deleted
subterms, e.g., use lists, might not be consistent.)

R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1645933002 .
2016-01-28 09:59:59 +01:00
Kevin Millikin fd9603d1d2 dart2js CPS: implement special handling of the Symbol constructor.
There is a 'const' Symbol constructor that is not expressible as a Dart
const constructor because it performs validation of its input.  This is
implemented in the libraries by using a dummy const constructor definition
that does not validate its input and replacing calls to 'new Symbol' with
calls to 'new Symbol.validated' in the compiler.

Without replacing calls to 'new Symbol', the non-validating dummy
implementation will be used, which is not correct.

Closes #24878.

R=asgerf@google.com
BUG=https://github.com/dart-lang/sdk/issues/24878

Review URL: https://codereview.chromium.org/1639313002 .
2016-01-28 08:55:35 +01:00
Stephen Adams e1386ce210 Store-forwarding for ReadTypeVariable
Example 1:

    var v0 = H.setRuntimeTypeInfo(new P.ListQueue(null, 0, 0, 0), [$E]);
    v0._table = J.JSArray_JSArray$list(8, H.getTypeArgumentByIndex(v0, 0));
-->
    var v0 = H.setRuntimeTypeInfo(new P.ListQueue(null, 0, 0, 0), [$E]);
    v0._table = J.JSArray_JSArray$list(8, $E);

Example 2 (enabling scalar replacement):

    this._historyTracking = W._EventStreamSubscription$(
        (v0 = H.setRuntimeTypeInfo(
              new W._EventStream(window, "popstate", false), [null]))._target,
        v0._eventType,
        handler,
        v0._useCapture,
        H.getTypeArgumentByIndex(v0, 0));
-->
    this._historyTracking = W._EventStreamSubscription$(
        window,
        "popstate",
        handler,
        false,
        null);

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1636193002 .
2016-01-27 15:46:34 -08:00
Stephen Adams 6a4903f201 Fix analyzer warnings for https://codereview.chromium.org/1642493002
TBR=asgerf@google.com

Review URL: https://codereview.chromium.org/1643783002 .
2016-01-27 15:07:20 -08:00
Stephen Adams 1673a64849 Add type info to JSArray.
JSArray<E>.typed has a specially generated body. We should be able to inline this. This makes all of the "new List.xxx()" paths work.

Literal lists are treated like maps - we generate a call to JSArray<E>.typed.  I need to change that to JSArray<E>.markGrowable.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1642493002 .
2016-01-27 13:47:12 -08:00
Stephen Adams 30f90c3dcd Fix analyzer warnings in assertions of the TypeExpression CL
TBR=asgerf@google.com

Review URL: https://codereview.chromium.org/1641883002 .
2016-01-27 12:38:22 -08:00
Stephen Adams 27b7999463 typeInformation in CreateInstance is a kind of TypeExpression
Use TypeExpression to create the 'headless flat' type term that is used for the instance's reified type.
This is a step towards placing the type term on JSArray.

There is also some modest GVN benefits where repeated terms are shared.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1637843002 .
2016-01-27 11:26:31 -08:00
Johnni Winther 8ab89a2653 Optimize subclass/subtype queries
BUG=
R=karlklose@google.com

Committed: https://github.com/dart-lang/sdk/commit/285400c7a73f98da3e3076038d91ddf3ecbbba9e

Reverted: https://github.com/dart-lang/sdk/commit/2affe22138c009a06be421d9f3ad3aa5d144e31e

Review URL: https://codereview.chromium.org/1627333002.
2016-01-27 14:33:57 +01:00
Kevin Millikin bc0bbb9c65 dart2js: Another bug fix in CPS term copying.
Correctly copy the type mask giving the type of ForeignCode.  This fixes a
performance regression when copied terms from the compilation cache are
used.

R=asgerf@google.com, sra@google.com
BUG=

Review URL: https://codereview.chromium.org/1639183004 .
2016-01-27 14:27:24 +01:00
Kevin Millikin 9879209bb9 Handle the 'integer' values INFINITY and -INIFINITY in range analysis.
Treating the values double.INFINITY and -double.INFINITY as if they were int
at compile time also affects the SSA compiler's range analysis pass.  This
change restores the former behavior that those values were unbounded ranges.

R=floitsch@google.com
BUG=

Review URL: https://codereview.chromium.org/1639193003 .
2016-01-27 13:06:41 +01:00
Kevin Millikin 9c79eb0d05 dart2js: Repair a failing assert.
Now there are more 'is int' doubles than just -0.0.

R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1638643003 .
2016-01-26 16:44:23 +01:00
Asger Feldthaus 6c9a7ec967 dart2js cps: Debugging utility and fix idempotency in shrinking reducer.
Shrinking reductions would miss some redexes that were created during
a reduction.  It now finds more redexes and has a self-checking mode
that can be enabled when working on the pass.

Also adds some general debugging utility functions to the CPS IR.

The root class Node now has "debugString" and "debugPrint" methods for
conveniently getting its SExpression.

The CpsFunctionCompiler now has a method "debugCpsPass" which runs
a CPS pass while checking that it is idempotent for that input. Most passes
are not yet idempotent, but this utility should help us get there.

BUG=

Review URL: https://codereview.chromium.org/1616673002 .
2016-01-26 16:37:31 +01:00
Kevin Millikin ba884f7f9f dart2js: Match the runtime int is check semantics at compile time.
BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1635053002 .
2016-01-26 16:10:54 +01:00
Asger Feldthaus 28ce0ee8ac dart2js cps: Bugfix in FlatTypeMask.isDisjoint.
The predicate would answer incorrectly when asked if subclasses of A
is disjoint from subtypes of B, where B is a subtype of A.

Example from the compiler:

  abstract class _MinifiedFieldNamer implements Namer

  class MinifyNamer extends Namer with _MinifiedFieldNamer

[subclass=Namer] vs [subtype=_MinifiedFieldNamer] were found to be
disjoint, even though the MinifyNamer class exists.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1631093004 .
2016-01-26 15:41:53 +01:00
Johnni Winther 2affe22138 Revert "Optimize subclass/subtype queries"
This reverts commit 285400c7a7.

BUG=

Review URL: https://codereview.chromium.org/1638863002.
2016-01-26 15:24:36 +01:00
Johnni Winther 285400c7a7 Optimize subclass/subtype queries
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org/1627333002.
2016-01-26 14:44:25 +01:00
Johnni Winther 735e0e60f8 Remove warning for inherited noSuchMethod.
Closes #25580

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1635533003.
2016-01-26 13:39:57 +01:00
Asger Feldthaus a1121d1488 dart2js cps: Make register allocation prioritize phi elimination.
The variable merger pass now prioritizes register allocations that
remove a moving assignment "v1 = v2" or enable a compoundable assignment
"v1 = v2 + E" to become "v1_2 += E".

When minifying, we now allow merging differently named variables.
Previously, preserving the variable names was important to get a good
register allocation, but that heuristic is no longer needed.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1625643002 .
2016-01-26 12:28:26 +01:00
Florian Loitsch bbde44f7cc Move license to the top.
R=lrn@google.com

Review URL: https://codereview.chromium.org/1636443002 .
2016-01-26 11:35:02 +01:00
Kevin Millikin 091d807d71 dart2js: Fix checked mode test failures due to type annotation.
R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1624383007 .
2016-01-26 10:37:20 +01:00
Asger Feldthaus 719c1d227a dart2js cps: Translate identity placeholders to refinement nodes.
This avoids emberrasing code like "x = x", and improves GVN, BCE, type
refinement etc, since all the optimizations now know that the input
and output values are the same.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1576063003 .
2016-01-26 09:58:26 +01:00
Kevin Millikin 65ae116a01 dart2js: CPS translation of switches with continue to their labels.
Implement switches with continue to their labels by a first 'non-recursive'
switch followed by a second (only) 'recursive' switch inside a loop.
Continue is implemented by assignment to a state variable that the second
switch switches over.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1585503002 .
2016-01-26 09:43:13 +01:00
Stephen Adams 4a01c6a1cf List constructor sentinel must not implement 'int' (extend JSInt).
Having a regular object that 'is' a number was causing horrible problems for type inference and generated code quality.

To get this to work required fixes in type inference and the collection of reified default argument values.

Fixes issue https://github.com/dart-lang/sdk/issues/25566

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1629553002 .
2016-01-25 20:40:39 -08:00