Commit Graph

5559 Commits

Author SHA1 Message Date
Paul Berry 62f7ac8c5d Fix handling of nested typedefs (for real this time).
This is a re-fix of dartbug.com/21912, which I previously fixed
incorrectly.  Previously, our approach to avoiding infinite loops when
comparing types was to maintain a set of typedefs being expanded on
the stack, and prune the comparison whenever an attempt was made to
expand a typedef that was already being expanded.  However, this was
too strict, since there are legal (non-circular) types which invole
expanding a given typedef in reentrant fashion; we can't prune these
types without producing incorrect semantics.  An example (from the bug
report) is the type of f in the code below:

    typedef T Function2<S, T>(S z);
    Function2<Function2<A, B>, Function2<B, A>> f;

The solution is to maintain the list of typedefs being expanded inside
each FunctionTypeImpl object (and InterfaceTypeImpl object) rather
than on the stack during the comparison; this allows us to distinguish
the situations where we need to prune (those having to do exclusively
with expansion of a typedef) from the situations where we shouldn't
prune (those having to do with substitution of a type parameter).

A beneficial side effect of this change is that code that interacts
with types no longer needs to worry about typedef circularities, since
the circularities will automatically be pruned while exploring the
type definitions.  This simplifies the implementation of
isAssignableTo, isSubtypeOf, operator==, and hashCode.  (Note,
however, that code still needs to cope with circularities in the
inheritance hierarchy).

BUG=dartbug.com/21912
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1143003007
2015-06-01 12:45:27 -07:00
Asger Feldthaus bd4e1d726f dart2js cps: Track underlying value of interceptors in type propagation.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1154173002
2015-06-01 11:19:36 +02:00
Karl Klose b1c1c34029 Update dart2js-cps_ir test expectations.
TBR=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1165703002
2015-06-01 11:00:02 +02:00
Regis Crelier 601da25b92 Fix issue 23500
BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1146993003
2015-05-29 13:31:16 -07:00
Sigmund Cherem 013897fe29 Add support for null-aware operators to the CPS-IR.
R=johnniwinther@google.com, kmillikin@google.com

Review URL: https://codereview.chromium.org//1160833003
2015-05-29 12:01:42 -07:00
Karl Klose 993338408e cps_ir: Handle malformed type arguments and type checks.
R=asgerf@google.com

Review URL: https://codereview.chromium.org//1156373008
2015-05-29 09:53:35 +02:00
Asger Feldthaus 5f97e22d80 dart2js cps: Change how type variables are accessed in constructors.
Previously there was a problem with type variables referenced inside
a closure inside a field initializer, like so:

class Foo<T> {
	var field = () => T;
}

The type variable cannot be accessed on 'this' because the closure is
created before 'this'. It also cannot be accessed as a parameter.

It is now properly treated as an unboxed free variable, and at
closure creation the value is taken from the constructor parameter
holding the type variable.

As with everything else during constructor build-up, the type variables
are now held in the IR builder's environment. It has proven to be a
robust way of doing things so far.

This simplifies the IR builder's role in this. The builder will not
detect how a type variable should be accessed (i.e. "if inside
a closure inside a field..."). If the type variable is in the
environment that's the one it will use, otherwise it defaults to
extract it from the receiver object.

Also, the closure conversion phase now detects type variables
mentioned in "on T catch()" clauses.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1158693003
2015-05-28 14:46:36 +02:00
Asger Feldthaus c29b7c6461 dart2js cps: 'is'-check directly against type variables.
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1160763002
2015-05-28 12:30:00 +02:00
Karl Klose 6bb3084fd3 Add dart2js-cps_ir test expectation for new test regress_23498_test.
Also sort expectations again and remove some whitespace.

R=kmillikin@google.com

Review URL: https://codereview.chromium.org//1143153012
2015-05-28 10:26:13 +02:00
Regis Crelier 1761a60735 Fix restoring of async try context in catch clause (issue 23498).
Add regression test.

Merge branch 'master' into dart1

Fix issue 23498

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1160663004
2015-05-27 13:58:57 -07:00
Paul Berry 1350b724b1 Fix analyzer status file for bug 23461.
This test previously passed due to a flaw in the test, which was fixed
in a8db3278e2.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1151113003
2015-05-27 13:20:48 -07:00
Asger Feldthaus f1bbc3bb2d dart2js cps: 'is' checks on types with type arguments.
R=karlklose@google.com

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

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

Review URL: https://codereview.chromium.org//1161683002
2015-05-27 14:14:07 +02:00
Asger Feldthaus f0c4e31174 Revert "dart2js cps: 'is' checks on types with type arguments."
This reverts commit 00c33fb134.

TBR=karlklose@google.com

BUG=

Review URL: https://codereview.chromium.org//1161793002
2015-05-27 13:54:07 +02:00
Asger Feldthaus 00c33fb134 dart2js cps: 'is' checks on types with type arguments.
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1161683002
2015-05-27 13:45:39 +02:00
Asger Feldthaus f42a0ef25c dart2js cps: Always use interceptors and type tags for 'is' checks.
"x is Foo" will become getInterceptor(x).$isFoo

Testing against a type with type arguments is still a giveup().

This test always works, but is not very fast. For instance, testing
against an int should be "typeof x === 'number' && Math.floor(x) === x".

Following an offline discussion with Karl, the plan is to rewrite
'is'-checks to more fine-grained tests in a CPS optimization pass,
probably the type propagator.

Concretely, we plan to introduce IR nodes like TypeOfTest, FloorTest,
InstanceofTest, etc, which optimization phases can introduce under the
right circumstances. That way, the code generation phase remains simple.

BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1144163004
2015-05-26 17:50:48 +02:00
Karl Klose 7962c37755 Update dart2js_cps-ir test expectations.
- Add suppressions for crashing dart2js_extra tests after addition of null-aware operators (a8db3278e2).
- Change suppressions in the cps-ir section to tool-friendly format.
- Add suppressions for new io/platform_executable tests (52f9548d58).

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1159553004
2015-05-26 10:38:23 +02:00
Sigmund Cherem a8db3278e2 Implementation of null-aware operators.
This CL adds the implementation of all null-aware operators to dart2js. In
particular:

* a?.b: represented as 'isConditional' in the Send ast, and dispatched
  separately by the semantic visitor using visitIfNotNull* methods.

* a ?? b: represented as an operator, and dispatched separately by the semantic
  visitor using the `visitIfNull` method.

* a ??= b: represented as a compound operator.

All except 2 tests are passing with the SSA backend (those 2 tests fail for
unrelated reasons). I've marked the CPS ir tests as failing for now.

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

Review URL: https://codereview.chromium.org//1151163004
2015-05-22 15:44:41 -07:00
Johnni Winther 4013583d3f Test (and fix some) invalid assignments.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1154743004
2015-05-22 15:00:07 +02:00
Karl Klose 5eb93a602e Update dart2js-cps_ir language status file.
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1149083002
2015-05-21 09:42:25 +02:00
Asger Feldthaus 40fd8a0bcf dart2js cps: Fix default values for forwarding constructors.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1150523003
2015-05-20 14:31:31 +02:00
Asger Feldthaus 341b346f0e dart2js cps: Fix in how type variables are accessed.
BUG=
R=karlklose@google.com

Review URL: https://codereview.chromium.org//1151443002
2015-05-20 14:12:02 +02:00
Johnni Winther 8b715cc94b Refactor handling of compounds.
BUG=
R=asgerf@google.com, karlklose@google.com

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

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

Review URL: https://codereview.chromium.org//1126173002
2015-05-20 13:52:32 +02:00
Asger Feldthaus 28484b2c6f dart2js cps: Stack trace should be obtained from raw exception value.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org//1134753007
2015-05-20 13:44:49 +02:00
Asger Feldthaus 8cf80adb30 dart2js cps: Fix status file.
BUG=
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//1147973003
2015-05-20 13:29:34 +02:00
Asger Feldthaus 5f2726b451 dart2js cps: Fix for try/catch.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org//1128903012
2015-05-20 10:57:06 +02:00
Asger Feldthaus 036f50d6aa Fix evaluation field initialization order for forwarding constructors.
Intestingly, the VM, dart2js/SSA and dart2js/CPS all fail the new test
in three different ways.

This CL fixed the SSA and CPS backends, and leaves a status line for
the VM.

When a constructor A redirects to B, it is B that should evaluate
declaration-site initializers (unless B also redirects).
Thus, this should happen after the arguments to B have been computed.

In SSA: Fields were initialized at A instead of B
(i.e. before redirect).

In CPS: Fields were initialized at both places, just horrible.

In VM: There seems to be a problem with redirecting constructors
called using super().

VM bug report: https://code.google.com/p/dart/issues/detail?id=23488

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1129693006
2015-05-20 10:05:53 +02:00
Johnni Winther c4d65452e0 Ensure ErroneousElement for static getter with no setter.
BUG=
R=herhut@google.com

Review URL: https://codereview.chromium.org//1142933003
2015-05-20 09:54:45 +02:00
Asger Feldthaus ccee558a5b dart2js cps: Access to lazily initialized fields.
R=kmillikin@google.com

Review URL: https://codereview.chromium.org//1136843006
2015-05-19 10:05:09 +02:00
karlklose@google.com 9b32c9e673 Implement raw list checks.
R=asgerf@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45762 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-13 11:58:45 +00:00
asgerf@google.com f5f1eb643d dart2js cps: Introduce GetStatic/SetStatic.
The GetStatic is used for reading static fields and tearing off
static methods.

Invoking a static getter/setter (not from a field) is still an
InvokeStatic, which IMO is the way it should remain.

BUG=
R=karlklose@google.com

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

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45738 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-12 14:19:40 +00:00
asgerf@google.com 961c805398 Revert "dart2js cps: Introduce GetStatic/SetStatic."
This reverts commit 28e4518df87c72cb8e23fe6d73b7750ad0f2183a.

TBR=karlklose@google.com

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45737 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-12 13:53:15 +00:00
asgerf@google.com 2c90643171 dart2js cps: Introduce GetStatic/SetStatic.
The GetStatic is used for reading static fields and tearing off
static methods.

Invoking a static getter/setter (not from a field) is still an
InvokeStatic, which IMO is the way it should remain.

BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45735 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-12 13:35:49 +00:00
karlklose@google.com a31ba4242c Adjust test expectations for dart2js_cps-ir.
TBR=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45705 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 18:33:14 +00:00
floitsch@google.com f4a1b28077 Move isolate tests to lib/isolate.
Moves most tests that require dart:isolate to the isolate-directory in the tests section.

Also enables the string_from_environment_default_value_test which didn't have "_test" in its name.

R=lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45701 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 17:59:51 +00:00
johnniwinther@google.com ec774a1b36 Fix status.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45699 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 17:43:43 +00:00
karlklose@google.com 0eaa4d4717 cps-ir: Support compilation of methods that use interceptor calling convention.
This is a modified version of sra@'s CL https://codereview.chromium.org/1020243002/ with kmillikin@'s comments addressed.

R=sigurdm@google.com, kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45680 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 12:38:14 +00:00
asgerf@google.com 9630163eaf dart2js cps: Handle error cases.
A new IR node CreateInvocationMirror has been introduced, which is
needed for creating calls to noSuchMethod. The main reason for this node
is that the JS constructor for Invocation objects require the internal
(minified) name of the target, which the builder does not know.
I don't think the IR pipeline should depend on the Namer, so the IR node
is preserved all the way to codegen.

R=floitsch@google.com, kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45678 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 09:06:12 +00:00
sigurdm@google.com 0dd351d9eb Avoid using multitest.
This test did not work as a multitest, because the
deferred_redirecting_factory_lib1.dart imports the main file - it will not
find it after the splitting and renaming.

Luckily it is not strictly required for the test (though somewhat cleaner)
to have a multitest.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45643 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 12:09:41 +00:00
sigurdm@google.com 0eb21fe240 Fix status file
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45640 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 10:28:13 +00:00
sigurdm@google.com 1ce5158350 Insert the right checks for redirecting factories to deferred constructors.
BUG=https://code.google.com/p/dart/issues/detail?id=23399
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45637 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 09:18:00 +00:00
kmillikin@google.com 638a5ba35f Support 'on T' catch clauses and multiple clauses.
The sequence of clauses is translated into the corresponding nested if-else
statements.  The last else is the catch-all clause (no 'on T') if there is
one or implicitly 'rethrow' otherwise.

If there is a catch-all clause (no 'on T'), then any clauses after it
are unreachable.  The language specification allows such unreachable
clauses without an error.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45634 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 08:49:26 +00:00
ricow@google.com e92f697236 Remove dart2dart support from testing scripts and status files
I will leave it to the dart2js people to remove the support from the dart2js tools (there is also a bunch of comments still in code, do a git grep)

R=kustermann@google.com, floitsch@google.com, kmillikin@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45588 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-07 11:29:55 +00:00
herhut@google.com d63b7df4aa dart2js: Update status of deferred_inheritance_constraints test, again.
BUG=
TBR=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45562 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 11:40:54 +00:00
herhut@google.com aab9414511 dart2js: Update status of deferred_inheritance_constraints test.
BUG=
TBR=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45561 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 11:00:42 +00:00
herhut@google.com 3fd132b658 Add test for calling an empty function from unloaded deferred library.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45560 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 10:28:55 +00:00
paulberry@google.com 7138d01444 In constant evaluation, handle final vars initialized at declaration site.
Previously final variables initialized at the declaration site
would simply be ignored, causing some checked-mode compile time
errors to be missed, and causing the analyzer to produce
incorrect values for any such constants.

BUG=dartbug.com/23292
R=brianwilkerson@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45494 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 16:21:54 +00:00
johnniwinther@google.com af1b401714 Handle default values on constant redirecting factories.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45490 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 13:39:14 +00:00
paulberry@google.com 34d8b562be Make sure to visit function annotations in ElementBuilder.
Since r44861, ElementBuilder is responsible for creating the
ConstantInstanceCreationHandle objects associated with
InstanceCreationExpressions.  Since InstanceCreationExpressions may
appear inside annotations, we must make sure the ElementBuilder visits
all annotations.  Previous to this change, it didn't visit function
annotations.

BUG=dartbug.com/23354
R=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45489 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 13:25:08 +00:00
karlklose@google.com 6abb79a95b cps-ir: Implement type tests for interface types without type arguments.
R=sigurdm@google.com, kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45484 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 07:58:38 +00:00
sigurdm@google.com 1e723f68d1 Allow use of deferred type-literals in non-constant contexts.
BUG= dartbug.com/22893
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45459 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-30 11:38:54 +00:00