Commit Graph

4698 Commits

Author SHA1 Message Date
Sigurd 253ffeed4a Deferred loading track type-dependencies for is, as and type-annotations.
BUG=
R=johnniwinther@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org//1245583002 .
2015-07-22 11:05:41 +02:00
Johnni Winther 2526ef6b4b Add SubclassNode to prepare for optimized queries on ClassWorld.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1234053002.
2015-07-21 16:30:02 +02:00
Karl Klose 50bcad9d0b dart2js cps: Cleanup type annotations in type propagation and remove code to handle null continuation on foreign code node.
R=asgerf@google.com

Review URL: https://codereview.chromium.org//1250473004 .
2015-07-21 15:59:49 +02:00
Johnni Winther 4439c480b2 Add access the Message in CompilerDiagnostics.report.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1247773002.
2015-07-21 14:36:46 +02:00
Florian Loitsch 39d3812bc0 dart2js: Support checked setters in the program builder.
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1245833003 .
2015-07-21 14:13:52 +02:00
Asger Feldthaus c9733e22ce dart2js cps: Remove NonTailThrow.
The builder instead creates a LetCont with an unused continuation to
hold the unreachable code following the non-tail throw.

This removes the cleanup pass after building and removes an awkward
CPS node.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1243063002.
2015-07-21 11:07:28 +02:00
Asger Feldthaus 6e0a210da0 dart2js cps: Share interceptors by default and propagate to use later.
We now only introduce one getInterceptor call per primitive.

(The main use for GVN seemed to be cleaning up these calls, but we
might as well not introduce them in the first place).

To propagate single-used interceptors to their use, propagation of
constant-like expressions has changed.

There is a new CPS pass, let sinking, which sinks single-used pure
primitives to their use when the use is not inside a loop.

Conversely, the tree IR's assignment propagation has been made less
aggressive to compensate for things now handled by let sinking.

R=floitsch@google.com

Review URL: https://codereview.chromium.org//1238163003.
2015-07-20 16:53:27 +02:00
Asger Feldthaus 4d933a2d0d dart2js cps: Streamline expressions and primitives.
SetStatic, SetField, and SetMutableVariable are now primitives instead
of interior expressions. They are valueless primitives, i.e. they are
bound by LetPrim but their value is never referenced.

This should simplify basic block traversal, since there are now fewer
types of interior expressions.

The four remaining interior expressions are: LetPrim, LetCont,
LetHandler, and LetMutable. Incidentally, these are exactly the four
expressions that can bind definitions.

GetMutableVariable and SetMutableVariable have also been renamed
to GetMutable and SetMutable to be uniform with LetMutable.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1240263002.
2015-07-20 15:59:41 +02:00
Florian Loitsch fb4633a1c5 dart2js: Use JS_GET_NAME instead of magic constant for catch-all function.
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1245573002 .
2015-07-20 14:53:59 +02:00
Florian Loitsch 5cf1f59843 Accept 'null' as document.contentScript.
When running as a content script in a Chrome extension `document.contentScript` is set to `null`. We should take that value instead of trying to compute another one based on script tags (the work-around we have for IE). Since content-scripts are not part of the page, it might be that there aren't even any other scripts and the work-around mechanism simply fails (thus not starting the main function).

R=karlklose@google.com

Review URL: https://codereview.chromium.org//1224363004 .
2015-07-20 12:54:02 +02:00
Johnni Winther 6f92dfe8ff Handle deferred access as pre-step in SemanticSendVisitor.
BUG=
R=floitsch@google.com, sigurdm@google.com

Review URL: https://codereview.chromium.org//1238783003.
2015-07-20 11:18:18 +02:00
Florian Loitsch 79645ebd9d dart2js: Add boilerplate strings for the startup-emitter.
R=sigmund@google.com

Review URL: https://codereview.chromium.org//1229913003 .
2015-07-17 20:00:00 +02:00
Florian Loitsch 784e244111 dart2js: add isConstantsHolder to Holder class.
R=sigmund@google.com

Review URL: https://codereview.chromium.org//1233263003 .
2015-07-17 19:27:29 +02:00
Sigmund Cherem 4ad37a6107 dart2js: fix dependency tracking for deferred loading when types are only used
in type arguments by the main fragment. (fix #23853)

R=floitsch@google.com

Review URL: https://codereview.chromium.org//1244513003 .
2015-07-17 08:46:00 -07:00
Florian Loitsch 0d1ca80570 dart2js: Fix check for support of reflection.
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1244473002 .
2015-07-17 15:16:40 +02:00
Florian Loitsch 41f898e426 dart2js: Support mock compilation in the program builder.
This enables mock compilation support for the emitters that use the program-builder's invoke-main code. So far that's only the lazy- and startup-emitter.

R=sigmund@google.com

Review URL: https://codereview.chromium.org//1239953003 .
2015-07-17 15:07:05 +02:00
Florian Loitsch 547a0c4c04 dart2js: More documentation for embedded globals and shared property names.
R=sigmund@google.com

Review URL: https://codereview.chromium.org//1236033006 .
2015-07-16 14:57:30 +02:00
Sigurd Meldgaard a466b6bd39 Allow return <expr> in sync* and async* javascript.
BUG=
R=floitsch@google.com

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

Patch from Sigurd Meldgaard <sigurdm@google.com>.
2015-07-15 16:59:05 +02:00
Sigmund Cherem baf00c1919 dart2js: check for the full getter/setter prefixes (fix #23828)
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1232423004 .
2015-07-14 07:43:01 -07:00
Florian Loitsch 9c2195e814 dart2js: add FragmentEmitter for startup-emitter.
R=sigmund@google.com

Review URL: https://codereview.chromium.org//1229913002 .
2015-07-14 11:23:51 +02:00
Asger Feldthaus 562825e161 dart2js cps: Rewrite mutable variables to continuation parameters.
To assist basic block traversal, expressions now belong to one of three
categories:
- InteriorExpression
- CallExpression
- TailExpression

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1234753003.
2015-07-14 11:18:57 +02:00
Florian Loitsch 434bae898a dart2js: add skeleton of startup-emitter.
R=sigmund@google.com

Review URL: https://codereview.chromium.org//1225293002 .
2015-07-14 11:16:33 +02:00
Karl Klose 04dacd24f4 Remove functions white-listed for use of try-finally and switch, add JS_SET_CURRENT_ISOLATE.
R=asgerf@google.com

Review URL: https://codereview.chromium.org//1237573002 .
2015-07-14 10:26:38 +02:00
Johnni Winther 0da5b34305 Add interfaces for a new compiler API.
Main changes are in the added files, compiler/compiler.dart, src/compiler.dart and src/apiimpl.dart.

Start by looking at compiler/compiler_new.dart and compiler/compiler.dart.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1235563003.
2015-07-13 21:15:23 +02:00
Johnni Winther 12e232dca7 Refactoring handle type literals.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1232613003.
2015-07-13 12:57:41 +02:00
Florian Loitsch ec398a7385 dart2js: Rename "current isolate" to "static state (holder)".
R=herhut@google.com

Review URL: https://codereview.chromium.org//1232463007 .
2015-07-10 19:08:11 +02:00
Asger Feldthaus 306b627a05 dart2js cps: Redundant join elimination.
There is a new pass that optimizes for continuations that branch on a
parameter, where every invocation passes a constant as that parameter.

This avoids unnecessary boolean flags that can arise from specializing a
call to a method that returns a boolean.

A current short-coming is that this lives in its own pass.
I believe shrinking reductions and redundant joins elimination can
trigger redexes of each other, so in theory we may still get redundant
joins in the output. The two passes might need to be reorganized at
some point.

R=karlklose@google.com

Review URL: https://codereview.chromium.org//1229893002.
2015-07-10 16:32:53 +02:00
Johnni Winther 73572dc3f1 Generated source mapping through CPS.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1229673006.
2015-07-10 15:32:36 +02:00
Asger Feldthaus 9a7d77604b dart2js cps: Rewrite iterator/moveNext/current into JS array accesses.
For example, the code (assuming 'list' is a native list):

  for (var x in list) {
    print(x);
  }

Becomes:

  var i = 0, x = null, $length = list.length, v0;
  while (true) {
    if (i < list.length) {
      x = list[i];
      i = i + 1;
      v0 = true;
    } else {
      x = null;
      v0 = false;
    }
    if (!v0)
      return null;
    P.print(x);
    if ($length !== list.length)
      H.throwConcurrentModificationError(list);
  }

This is clearly in need of redundant join elimination, which is an
optimization that I plan to land separately.

After redundant join elimination it becomes:

  var i = 0, x = null, $length = list.length;
  while (i < list.length) {
    x = list[i];
    i = i + 1;
    P.print(x);
    if ($length !== list.length)
      H.throwConcurrentModificationError(list);
  }
  x = null;

There is still room for improvement regarding redundant assignemnts
to 'x'. They occur because x is a MutableVariable. Rewriting these
into "SSA variables" (continuation parameters) is another optimization
we may want to implement.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1229563005.
2015-07-10 15:22:00 +02:00
Stephan Herhut 22ce26bffa dart2js: Fix checked mode error in nameForGetOneShotInterceptor.
BUG=
TBR=karlklose@google.com

Review URL: https://codereview.chromium.org//1235593002 .
2015-07-10 15:04:08 +02:00
Stephan Herhut 374f9e3941 dart2js: Take named arguments into account (again) when naming one-shot interceptors.
R=karlklose@google.com
BUG=

Review URL: https://codereview.chromium.org//1235463004 .
2015-07-10 14:32:59 +02:00
Asger Feldthaus fe2c4c5d97 dart2js cps: Emit unlabeled breaks and continues when possible.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1232083002.
2015-07-10 12:25:51 +02:00
Florian Loitsch 2b1e0999c4 dart2js: Update library names for the lazy emitter.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1230793004 .
2015-07-10 11:31:34 +02:00
Asger Feldthaus 5a20c361b9 dart2js cps: Bugfix in assignment propagation into branch conditions.
Assignment propagation traverses the tree backwards, and should therefore
visit the branch condition of an 'if' after its two branches.

It happened to work (in the sense of not breaking the code) but
only for very subtle reasons.

This fixes an optimization bug that prevented assignments from
propagating to their first use when the first use was in a branch
condition.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1226353003.
2015-07-09 17:04:55 +02:00
Johnni Winther 6b36c8acc6 Refactor handling of library prefixes.
Closes #13632

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1227353002.
2015-07-09 16:28:06 +02:00
Florian Loitsch cf4eca0975 dart2js: Rename old emitter to full emitter and make it its own library.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1223293002 .
2015-07-09 15:54:38 +02:00
Florian Loitsch d5343f4ebe dart2js: Remove oldEmitter field in emitter-task.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1226733010 .
2015-07-09 15:52:53 +02:00
Florian Loitsch c45c5c8578 dart2js: Move field-visiting code to the program-builder.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1221333015 .
2015-07-09 15:51:53 +02:00
Karl Klose 3fe9309c96 dart2js cps: Implement compilation of redirecting factory constructors for reflection.
Without reflection, redirecting factory constructor invocations are shortcut at the instantiation site.  With reflection, code like
  reflectClass(Foo).newInstance(const Symbol(''), [])
can hit a redirecting factory constructor and we need to emit a function that does the redirection and type substitution.

R=asgerf@google.com

Review URL: https://codereview.chromium.org//1227873004 .
2015-07-09 14:54:23 +02:00
Sigurd 5d2b0b07f5 Remove flag for enabling null-aware operators. They are now on by default.
This solves #23791

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1225273002 .
2015-07-09 13:49:45 +02:00
Anders Johnsen 7054159b90 Remove 'async-await' usage from the dart2js compiler.
BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1226323002 .
2015-07-09 13:41:07 +02:00
Stephan Herhut 0799e538c3 dart2js: Emit static const fields if accessible by reflections.
BUG= http://dartbug.com/23811
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1225083004.
2015-07-09 13:28:23 +02:00
Johnni Winther 06514d1573 Remove ClassWorld.subclassesOf and ClassWorld.subtypesOf.
Closes #23664

BUG=
R=herhut@google.com

Review URL: https://codereview.chromium.org//1224753002.
2015-07-09 10:51:11 +02:00
Sigmund Cherem 12b1b4f6a4 dart2js: include 'any' and 'every' as possibly escaping the values in the collection (fix #23804)
R=herhut@google.com

Review URL: https://codereview.chromium.org//1230463003.
2015-07-08 11:09:50 -07:00
Asger Feldthaus 6698031d9b dart2js cps: Bugfix in redundant phi elimination.
We now split a LetCont before moving it, so we do not move other
continuation bindings.

The bug surfaced when working on redundant join elimination.
I don't think it can be reproduced with the current set of
optimizations, so the fix is not visible in the tests.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1222913009.
2015-07-08 14:46:52 +02:00
Asger Feldthaus 895283c21a dart2js cps: Direct access on JS arrays.
length, forEach, [], and []= are rewritten to direct array access nodes.
There are more methods to specialize, which will be added in separate
CLs.

This CL also contains a class CpsFragment to help build CPS code.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1223813006.
2015-07-08 14:33:00 +02:00
Florian Loitsch 21b3463d81 dart2js: Move most of the code_emitter_task code into the program-builder.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1227643003 .
2015-07-08 12:53:42 +02:00
Asger Feldthaus 11b2ae1307 dart2js cps: Generate direct field accesses a build-time.
The world will refuse to emit getters and setters for field it thinks
will be accessed directly.

Rewriting getter/setter calls to field accesses must happen at
build-time so we do not rely on an optimization for correctness.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1227543008.
2015-07-07 16:17:35 +02:00
Karl Klose 71e2bec0a5 dart2js cps: Support JS_CURRENT_ISOLATE.
R=asgerf@google.com

Review URL: https://codereview.chromium.org//1222913003 .
2015-07-07 15:55:13 +02:00
Florian Loitsch 46d7004fe8 dart2js: Make it more obvious how rti-only needed classes work.
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1214723010 .
2015-07-07 15:51:29 +02:00