Commit Graph

1586 Commits

Author SHA1 Message Date
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
Florian Loitsch 5cb3da473b Update messages, and fix typing in test.
Review URL: https://codereview.chromium.org/1625213003 .
2016-01-25 13:41:03 +01:00
Florian Loitsch c849a62744 Generate dart2js and analyzer files for shared messages.
R=brianwilkerson@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1582903003 .
2016-01-25 13:08:40 +01:00
Kevin Millikin cabf28ce87 dart2js: Turn the CPS inlining cache into a general compilation cache.
Cache function definition terms just before specializing them for their
arguments.  Use these cached terms for subsequent specializations and for
generic (non-specialized) compilation.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1608953002 .
2016-01-25 12:02:53 +01:00
Kevin Millikin b1c627be70 dart2js: Flatten the code generation visitor a little bit.
Do not call visitStatement in tail position, do not call
List.generate (which calls its argument).

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1608483004 .
2016-01-25 12:01:12 +01:00
Johnni Winther e333e631f3 Base JavaScript code position computation on JavaScript tracer.
Trace computation added in position_information.dart
Diff view tool added in diff_view.dart that utilizes the new computation and show coverage stats.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1617083002.
2016-01-25 11:17:24 +01:00
Asger Feldthaus cc1111e23b dart2js cps: Tolerate refinements in more cases.
Useless branch elimination looks past dead refinements in the branches.

Redundant phi elimination ignores refinements, but is followed by an
UpdateRefinements pass to restore refinements again.

This is a step towards being able to land:
https://codereview.chromium.org/1576063003/

FIXES #25448

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1620873003 .
2016-01-22 16:44:16 -08:00
Sigmund Cherem 7778f54141 Add missing parent pointers in CopyingVisitor
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1626603002 .
2016-01-22 13:40:54 -08:00
Asger Feldthaus 762c41f9e4 dart2js cps: More rewritings for compound assignments.
Compound assignments are now generated for:

- SetStatic, previously only supported for SetField, SetIndex, and
  variable uses.

- SetField and SetIndex when the receiver is 'this', previously only
  supported for variable uses.

- String concatenation with >2 arguments, previously only supported
  with exactly 2 arguments.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1613853003 .
2016-01-22 11:22:03 -08:00
Stephen Adams 33ac12a5a4 Lower map literals to constructor or function calls in builder
Remove LiteralMap from cps_ir and tree_ir.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1616143003 .
2016-01-21 19:32:13 -08:00
Sigmund Cherem f466f30fdb dart2js: improve performance of TypeMask.intersection
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1611783003 .
2016-01-21 11:12:12 -08:00
Stephen Adams ffa96cdeac Avoid using wrong 'adaptor' for native methods.
The Dart arity adaptor was adding default arguments to the call instead of calling with the given number of arguments.
The best way to fix this is to implement Issue 25548.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1612773002 .
2016-01-21 08:44:22 -08:00
Sigmund Cherem e17d3d39ab Implement TypeMask.isDisjoint instead of using intersection.
R=sra@google.com

Review URL: https://codereview.chromium.org/1604333002 .
2016-01-20 14:18:16 -08:00
Stephen Adams d43365998d dart2js: switching isolate is not 'PURE'
R=asgerf@google.com

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

Reverted.

Review URL: https://codereview.chromium.org/1607373002 .
2016-01-20 12:59:24 -08:00
Stephen Adams ccd383309d Revert "dart2js: switching isolate is not 'PURE'"
TBR=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1607413002 .
2016-01-20 12:38:26 -08:00
Stephen Adams bbd105f106 dart2js: switching isolate is not 'PURE'
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1607373002 .
2016-01-20 12:34:08 -08:00
Stephen Adams 94c08cfc27 Mark ForeignCode as isSafeForElimination when it has no effects or exceptions.
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1609993002 .
2016-01-20 07:40:43 -08:00
Stephen Adams 905a1c862c Re-flow comment to force rebuild
TBR=sigmund@google.com

Review URL: https://codereview.chromium.org/1608773003 .
2016-01-19 18:35:53 -08:00
Stephen Adams 68c7404c4a Remove useless branches in shrinking_reductions.
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1601863005 .
2016-01-19 17:41:02 -08:00
Asger Feldthaus aba2e1ea99 dart2js cps: Fix bug in pulling of assignments into a var.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1609943002 .
2016-01-19 16:55:45 -08:00
Asger Feldthaus b36e28171e dart2js cps: Update null checks when updating refinements.
Also run UpdateRefinements before second type propagation.

This cleans up a lot of redundant null checks in the output.

BUG=
R=sigmund@google.com

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

Review URL: https://codereview.chromium.org/1583263007 .
2016-01-19 14:56:58 -08:00
Asger Feldthaus 75f17171ce Revert "dart2js cps: Update null checks when updating refinements."
This reverts commit e5498d1500.

BUG=

Review URL: https://codereview.chromium.org/1605203002 .
2016-01-19 14:48:16 -08:00
Asger Feldthaus 07f43b5480 dart2js cps: Handle unsafe .length calls in bounds check elimination.
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1600973003 .
2016-01-19 14:37:31 -08:00
Asger Feldthaus 0b157e2963 dart2js cps: Fix codegen for instanceof checks.
With certain optimizations disabled the codegen would sometimes register
an unresolved class as being instantiated.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1595783002 .
2016-01-19 14:17:41 -08:00
Asger Feldthaus 4d93612ca7 dart2js cps: Fix return type for native functions.
Native functions would be translated into a ForeignCode instruction,
but the type mask was not set, so its return type was assumed to be
dynamic.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1607993002 .
2016-01-19 13:56:58 -08:00
Asger Feldthaus e5498d1500 dart2js cps: Update null checks when updating refinements.
Also run UpdateRefinements before second type propagation.

This cleans up a lot of redundant null checks in the output.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1583263007 .
2016-01-19 13:44:24 -08:00