Commit Graph

4835 Commits

Author SHA1 Message Date
karlklose@google.com 9e154bc62a Allow access to type variables as expressions in factory constructors.
BUG= http://dartbug.com/22700
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45328 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-22 09:11:14 +00:00
sigmund@google.com 667173800b Visit arguments of invalid TypeLiteralSends during inference
BUG= http://dartbug.com/23264
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45315 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-21 15:36:22 +00:00
johnniwinther@google.com 1ef811ab2b Refactor DartTypeVisitor and ElementVisitor.
This enables more patterns of use.

BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45314 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-21 13:46:58 +00:00
johnniwinther@google.com af8a0dcdca Add SourceInformationFactory.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45312 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-21 12:07:51 +00:00
sra@google.com f1ab388015 Rewrite for-in loop on JavaScript indexable arrays as indexing loop
for (E variable in a) <body>

is generated as:

  _end = a.length;
  for (_i = 0; _i < a.length; a.length == _end || (0, H.throwConcurrentModificatiionError)(a), ++_i) {
    variable = a[_i];
    <body>;
  }

or, when the list is known to be fixed length:

  for (_i = 0; _i < a.length; ++_i) {
    variable = a[_i];
    <body>;
  }

R=floitsch@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45270

Reverted: https://code.google.com/p/dart/source/detail?r=45271

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45309 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-21 03:13:36 +00:00
zarah@google.com 3210ee4967 Revert "dart2js: add type arguments to constructor in case the class needs rti."
This reverts commit r45277.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45281 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 12:32:49 +00:00
herhut@google.com 0297c82c7a dart2js: allow empty main fragment in emitter.
BUG=
TBR=zarah@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45280 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 11:51:43 +00:00
kmillikin@google.com edaccdaa86 Make the mutable variables local to an IR builder instead of global.
When translating a try block, variables become mutable on entry and stop
being mutable on exit.  Make the set of set of mutable variables local to an
IR builder instead of global for a whole function, so that the translation
does not depend so heavily on the order of visiting subparts of the input.

Since JS code can have mutable variables (i.e., not boxed in the heap), move
them to the backend-independent IR builder state.  This fixes a bug in the
JS translation of try-catch where the environment would contain duplicated
bindings for mutable variables.  The right binding happened to 'win' so it
was not observable other than an assertion failure.

BUG=
R=asgerf@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45272

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45279 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 11:44:25 +00:00
zarah@google.com b204a67fa9 dart2js: add type arguments to constructor in case the class needs rti.
R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45277 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 11:00:47 +00:00
herhut@google.com a0172bc7b5 dart2js: fully assemble program before emitting it.
BUG=
R=karlklose@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45237

Reverted: https://code.google.com/p/dart/source/detail?r=45239

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45276 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 10:43:55 +00:00
kmillikin@google.com c6b5cae96f Revert "Make the mutable variables local to an IR builder instead of global."
This reverts SVN revsion 45272.  It breaks dart2dart and the S-expression
parsing tests.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45273 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 09:28:19 +00:00
kmillikin@google.com 640331c516 Make the mutable variables local to an IR builder instead of global.
When translating a try block, variables become mutable on entry and stop
being mutable on exit.  Make the set of set of mutable variables local to an
IR builder instead of global for a whole function, so that the translation
does not depend so heavily on the order of visiting subparts of the input.

Since JS code can have mutable variables (i.e., not boxed in the heap), move
them to the backend-independent IR builder state.  This fixes a bug in the
JS translation of try-catch where the environment would contain duplicated
bindings for mutable variables.  The right binding happened to 'win' so it
was not observable other than an assertion failure.

BUG=
R=asgerf@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45272 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 09:00:14 +00:00
sra@google.com 541fbcd32e Rewrite for-in loop on JavaScript indexable arrays as indexing loop
for (E variable in a) <body>

is generated as:

  _end = a.length;
  for (_i = 0; _i < a.length; a.length == _end || (0, H.throwConcurrentModificatiionError)(a), ++_i) {
    variable = a[_i];
    <body>;
  }

or, when the list is known to be fixed length:

  for (_i = 0; _i < a.length; ++_i) {
    variable = a[_i];
    <body>;
  }

R=floitsch@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45270

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45271 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 02:44:07 +00:00
sra@google.com 24478da6bc Rewrite for-in loop on JavaScript indexable arrays as indexing loop
for (E variable in a) <body>

is generated as:

  _end = a.length;
  for (_i = 0; _i < a.length; a.length == _end || (0, H.throwConcurrentModificatiionError)(a), ++_i) {
    variable = a[_i];
    <body>;
  }

or, when the list is known to be fixed length:

  for (_i = 0; _i < a.length; ++_i) {
    variable = a[_i];
    <body>;
  }

R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45270 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 02:08:12 +00:00
sigmund@google.com 0189a4b353 Better hints for await in non-async functions
BUG=23234
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45256 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 20:58:59 +00:00
sigmund@google.com 6a98437e2d Fix tests in bots (handle 'is' as an invalid binary operator)
TBR=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45251 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 19:20:52 +00:00
sigmund@google.com ea5c8193c1 Make super.foo= erroneous if they are not assignable.
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45250 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 18:34:29 +00:00
johnniwinther@google.com 77be26cdd7 Use UnaryOperator and BinaryOperator in ConstantSystem.
BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45248 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 17:52:20 +00:00
sigmund@google.com 20d96e83d2 Fix dumpInfo: include information for methods that are not in the generated
output (because of inlining, orelse)

R=sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45247 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 17:51:55 +00:00
johnniwinther@google.com 62167b954f Move constant systems into their own libraries.
BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45241 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 16:29:44 +00:00
kmillikin@google.com 5d95a09836 Repair a CPS integrity violation.
If replacing a use with another one will orphan the original, then it needs
to be unlinked from the CPS term graph.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45240 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 13:02:20 +00:00
karlklose@google.com e5f493f841 Revert "dart2js: fully assemble program before emitting it."
This reverts commit r45237.

TBR=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45239 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 12:58:05 +00:00
herhut@google.com 0ad79339c5 dart2js: fully assemble program before emitting it.
BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45237 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 11:47:57 +00:00
kmillikin@google.com 00e4ba52ea CPS implementation of throw and rethrow.
Throw and rethrow are implemented as CPS expressions in tail position.

The CPS translation assumes that all expressions translate to a primitive
that is the value of the expression, and throw is an expression in Dart.
For simplicity of the translation, a non-tail throw Primitive is sometimes
used as a placeholder during the translation and removed immediately
afterward.

Both throw and rethrow are represented in the Tree IR.  In the Dart backend,
throw translates to throw and rethrow translates to rethrow.  In the JS
backend, throw translates to JS throw of a wrapped value.  Rethrow is not
currently implemented for the JS backend, it bails out of the compiler.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45235 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 11:15:45 +00:00
herhut@google.com b859f5a11d Do not emit stubName for static functions.
BUG=
R=zarah@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45232 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 10:24:25 +00:00
herhut@google.com d8b3272512 dart2js: reify type variables as result of class enqueueing.
BUG=
R=zarah@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45229 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-17 09:51:46 +00:00
asgerf@google.com a68db11570 cps-ir: Replace getter-invocation methods in IR builder.
The IR builder is poorly equipped to decide the order in which to
evaluate things.

ISSUE=https://code.google.com/p/dart/issues/detail?id=23229
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45209 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 14:02:57 +00:00
asgerf@google.com 3f2263aad7 tree-ir bugfix: Count unseen uses instead of seen uses.
Keeping track of the number of "seen uses" of a variable is too fragile
since it needs bookkeeping whenever we merge two variable uses.

I've changed it to track the number of unseen uses instead. The
bookkeeping is simpler because we aren't going to transform an unseen
use.

BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45207 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 13:03:09 +00:00
zarah@google.com 00f73c4988 dart2js: don't reify type variables for reflectable typedefs.
R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45206 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 12:39:48 +00:00
karlklose@google.com 37defc4573 Add a command line option to use the new CPS based backend.
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45203 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 11:22:02 +00:00
asgerf@google.com f1f81f6a7e cps-ir: Clean-ups in type propagator.
R=karlklose@google.com, kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45195 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 08:12:04 +00:00
johnniwinther@google.com 26a5f52a81 Use templates for BulkMixin messages.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45194 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 08:01:36 +00:00
sigmund@google.com fd35f3cbfe Add fatal-warnings flag, that turns warnings into compilation errors (the name
fatal-warnings was choosen to match the flag in dartanalyzer)

BUG= http://dartbug.com/8803
R=johnniwinther@google.com, karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45190 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 23:17:21 +00:00
sigmund@google.com 5d6b64dc49 Do not use erroneouselement unless the member is static
R=het@google.com, johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45187 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 23:10:06 +00:00
floitsch@google.com a004ca0767 Revert "dart2js: add compiler builtins to the core-runtime."
This reverts commit r45176.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45177 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 19:30:09 +00:00
floitsch@google.com dfbe06beba dart2js: add compiler builtins to the core-runtime.
WIP.

R=johnniwinther@google.com, sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45176 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 19:17:57 +00:00
kmillikin@google.com 1eea5f8799 Revert "Remove an unused field from one of the CPS translation classes."
This reverts SVN revision 45168.  The return value of
IrBuilder.buildFunctionHeader is used in the JS backend for constructor type
parameters.  It should be possible to do it a different way but it's too
tangled for a quick fix.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45171 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 16:10:36 +00:00
kmillikin@google.com e375dac705 Remove an unused field from one of the CPS translation classes.
BUG=
R=asgerf@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45168 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 15:13:22 +00:00
asgerf@google.com 99963809f5 tree-ir: Always declare captured variables.
BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45166 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 13:36:20 +00:00
johnniwinther@google.com 19efd2cc96 Improve precision of JS printer callbacks (2nd try)
BUG=
R=floitsch@google.com, sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45164 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 12:09:15 +00:00
asgerf@google.com 609e75a009 tree-ir: Treat getInterceptor and identical as effectively constant.
Calls to getInterceptor would often block another expression from
propagating, which in turn can block other optimizations.

Before:

  while (true) {
    v0 = foo();
    if (P.identical(J.getInterceptor$n(i).$lt(i, v0), true)) { S1 }
    else { S2 [no continue] }

The call to J.getInterceptor prevents v0 = foo() from inlining.

After:

  while(P.identical(J.getInterceptor$n(i).$lt(i, foo()), true)) {
     S1
  }
  S2

BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45161 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 11:24:31 +00:00
asgerf@google.com 9fc58ee004 tree-ir: Do not merge captured parameters with other variables.
BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45160 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 11:19:44 +00:00
sigurdm@google.com 507e85ab61 Dart2js deferred loading. Follow types of functions when calculating dependencies.
This fixes part of dartbug.com/22995

Turns out that synthesized constructors not always have a type.

BUG=
R=johnniwinther@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45086

Reverted in r45086

Committed: https://code.google.com/p/dart/source/detail?r=45101

Reverted in 45106

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45159 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 10:55:39 +00:00
floitsch@google.com 1fd10697a8 dart2js: use Es6 maps when available.
R=herhut@google.com, sra@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45105
Reverted: https://code.google.com/p/dart/source/detail?r=45107

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45158 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 10:44:54 +00:00
johnniwinther@google.com 99f632049a Deprecate visitAssertSend and visitTypePrefixSend
BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45157 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 10:44:13 +00:00
kmillikin@google.com 16fd8a7896 Make continuations last in CPS IR constructors.
Continuations are last in both printed representations, but first in
the IR constructors.  For uniformity, make them last in the IR
constructors as well.  This is a cosmetic refactoring.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45155 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 09:21:16 +00:00
kmillikin@google.com f79bc25ed8 Implement try/catch in the JS backend.
In the CPS IR, exception handlers initially have two parameters for
the exception and the stack trace.  In JavaScript:

1. Unwrap the caught value to get the exception that was thrown and
   use the unwrapped value in place of the exception parameter.

2. Get the stack trace from the (unwrapped) exception that was thrown.

3. Remove the stack trace parameter.

BUG=
R=asgerf@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45152 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 07:56:41 +00:00
johnniwinther@google.com 8d6dd9cb48 Use CallStructure instead of Selector in SemanticSendVisitor.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45150 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 07:43:07 +00:00
johnniwinther@google.com a0613471aa Handle SendSet and NewExpression through NewResolvedVisitor.
This allows for the handling assignment and new expression through the SemanticSendVisitor methods in SsaBuilder and InferrerVisitor(s).

BUG=
R=karlklose@google.com

Committed: https://code.google.com/p/dart/source/detail?r=45091

Reverted: https://code.google.com/p/dart/source/detail?r=45093

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45138 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-14 12:56:33 +00:00
asgerf@google.com ae1cf9f6d0 cps-ir: Register instantiated type at InvokeConstructor.
This is a symptom of a larger issue that will arise when we try to
inline InvokeConstructor invocations. I've left a TODO to consider when
we start to look at inlining.

BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45135 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-14 12:29:01 +00:00