Commit Graph

4835 Commits

Author SHA1 Message Date
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
Florian Loitsch f02074dc9e dart2js: Create program_builder directory and move corresponding files.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1207343003 .
2015-07-07 14:56:27 +02:00
Florian Loitsch 7833348429 dart2js: Remove unneeded getters in full emitter.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1227643002 .
2015-07-07 14:55:42 +02:00
Florian Loitsch 908865c47e dart2js: Rename emitters.
The "old" and "new" name was not helpful.

R=herhut@google.com

Review URL: https://codereview.chromium.org//1220333003 .
2015-07-07 14:47:33 +02:00
Asger Feldthaus fb8c42cbdb dart2js cps: Ensure definitions are specialized before their uses.
Specializing a node may depend on how its operands are defined, but
they may no longer depend on how its result is used.

Patterns that depended on its result being converted to a boolean
violated this rule, but fortunately they could be refactored to
satisfy the rule, by matching the node doing doing the boolean
conversion.

By processing definitions before their uses, we avoid creating new
redexes for a node that has already been processed.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1220123004.
2015-07-07 13:28:54 +02:00
Karl Klose a26a536d86 Rewrite code to avoid dead code hints during build.
R=whesse@google.com

Review URL: https://codereview.chromium.org//1221243009.
2015-07-07 10:50:19 +02:00
Stephan Herhut ff442643fc dart2js: Move functionThatReturnsNull to Isolate.
BUG=
R=karlklose@google.com
TBR=floitsch@google.com

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

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

Review URL: https://codereview.chromium.org//1224693004.
2015-07-07 10:25:46 +02:00
Florian Loitsch 8d0b368669 Move nativeInfo encoding into NativeGenerator.
R=herhut@google.com

Review URL: https://codereview.chromium.org//1215463006.
2015-07-06 18:10:26 +02:00
Stephan Herhut 3570e3199e Revert "dart2js: Move functionThatReturnsNull to Isolate."
This reverts commit 84e6d695ab.

BUG=
TBR=floitsch@google.com

Review URL: https://codereview.chromium.org//1226853002.
2015-07-06 17:00:13 +02:00
Stephan Herhut 84e6d695ab dart2js: Move functionThatReturnsNull to Isolate.
BUG=
TBR=floitsch@google.com

Review URL: https://codereview.chromium.org//1224693004.
2015-07-06 16:24:53 +02:00
Stephan Herhut c6eb91b438 dart2js: Use separate namespace for constants.
BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1224603002.
2015-07-06 15:00:01 +02:00
Asger Feldthaus 208e48ab7a dart2js cps: Do not build type casts for casting to 'dynamic'.
Code generation assumes such redundant nodes do not occur.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1215713005.
2015-07-06 14:35:08 +02:00
Asger Feldthaus 535ed4042f dart2js cps: Do not rewrite calls on torn-off intercepted methods.
For example:
  getInterceptor(foo).get$toString(foo).call$0()

Should be rewritten to:
  getInterceptor(foo).toString$0(foo)

But would erroneously be rewritten to:
  getInterceptor(foo).toString$0()

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1222763003.
2015-07-06 13:08:34 +02:00
Johnni Winther 8aa5245b14 Support serialization of the compiler backbone.
BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1192103002.
2015-07-06 11:30:51 +02:00
Asger Feldthaus 0220393797 dart2js cps: Bugfix in operator specialization.
Binary operators were always replaced with string concatenation if both
operands were strings.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1210403008.
2015-07-06 11:15:02 +02:00
Asger Feldthaus dbd197acdd dart2js cps: Fuse tear-off and call invocation.
For example:
  new Foo().bar.call(123)
    ==>
  new Foo().bar(123)

This does not trigger much right now, but it will matter when forEach
is rewritten to a loop in a later CL.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1220193003.
2015-07-03 14:44:47 +02:00
Asger Feldthaus 61f47e7384 dart2js cps: Ensure JSArray is emitted when we see a type cast.
This is a workaround to resolve an issue that is affecting a lot
of tests.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1214123003.
2015-07-03 14:32:01 +02:00
Stephan Herhut 9fa33e4e72 dart2js: Implement frequency based naming.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org//1212613009.
2015-07-03 13:06:35 +02:00
Stephan Herhut 5c4749ac92 dart2js: Give the globals holder for deferred loading a fixed name.
R=floitsch@google.com, sigurdm@google.com
BUG=

Review URL: https://codereview.chromium.org//1220233003.
2015-07-03 12:46:54 +02:00
Asger Feldthaus 4660cd6833 dart2js cps: Fix bug in assignment propagation.
BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1222673002.
2015-07-02 18:13:40 +02:00