Commit Graph

63 Commits

Author SHA1 Message Date
johnniwinther@google.com 986ce5c39c Support default constructors in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43652 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 15:18:36 +00:00
johnniwinther@google.com 827e265786 Revert "Add sharedfrontend package"
This reverts commit r43635.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43637 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 11:32:18 +00:00
johnniwinther@google.com d7118339b5 Add sharedfrontend package
- initial element model includes Element, LibraryElement and ClassElement
- AccessSemantics moved to sharedfrontend to be utilized from both analyzer2dart and dart2js.

BUG=
R=brianwilkerson@google.com, paulberry@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43635 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 10:44:56 +00:00
johnniwinther@google.com b964042fcd Support instance methods in analyzer2dart.
BUG=
R=paulberry@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43555 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-06 14:59:18 +00:00
paulberry@google.com 1ce826e0c2 Add Iterable type to mock SDK for analyzer2dart.
Analyzer now needs the Iterable type to exist because it is used in
static type checking of "yield" statements.

TBR=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43421 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-03 19:28:13 +00:00
kmillikin@google.com 31fc0e5a8e Rename ClosureVariable, use separate IR forms for declaration and assignment.
I plan to use ClosureVariable for the variables assigned in try, so
the name will become incorrect.  They are renamed to MutableVariable.

Use separate IR forms for declaration of MutableVariable (LetMutable)
and for assignment to mutable variables (SetMutableVariable).  This
distinction doesn't do much in this change other than make the tree a
bit more well-formed, but I plan to make LetMutable take a list of
variables and values (e.g. all the variables mutated in a try).

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43396 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-03 14:18:13 +00:00
paulberry@google.com f7fdfdde67 Fix mock SDK used by analyzer2dart.
Revision 43366 makes analyzer depend on Future having exactly one type
parameter.

TBR=brianwilkerson@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43373 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-02 23:31:15 +00:00
kmillikin@google.com d729e9a9b5 dart2dart: Remove the list of closureVariables from FunctionDefinitions.
Function definitions had a list of closure variables (which was always
empty in the JS backend).  This list has no code generation semantics
because it is ignored by the Tree IR builder.  Instead, when translating
to Tree IR, a reference to an unbound closure variable implicitly
'declares' it.

The closure variables were however used for the S-expression serialized
representation.  They can be eliminated here as well by using the same
trick as the Tree IR builder.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43337 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-30 13:20:23 +00:00
johnniwinther@google.com 6fb90bc36c Support constructor declarations in analyzer2dart.
BUG=
R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43271 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-29 07:57:57 +00:00
kmillikin@google.com 5f57d08cb8 Reapply "Add a shrinking reduction for dead continuation parameters."
This reapplies SVN revision r43093 with bug fixes.  A failing assert
was fixed, and continuation eta-reduction was restricted to not change
non-call continuations into call continuations.  If these were to
occur, they risk duplicating code and so are not always on
optimization.

BUG=
R=asgerf@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43135 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-26 13:51:37 +00:00
kmillikin@google.com c74e16c5d5 Revert "Add a shrinking reduction for dead continuation parameters."
This reverts svn revision r43093, due to failures in dart2dart.  It
clashes with the commit just before it which has changed the type of
FunctionDefinition parameters.

Also, continuation eta-reduction can destroy a dead parameter
reduction.  In this case, it's not obvious which reduction we actually
want.  So though the fixes are simple, I will back this change out and
reevaluate it.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43105 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 13:44:41 +00:00
kmillikin@google.com bdba8f356b Add a shrinking reduction for dead continuation parameters.
Continuation parameters that have no uses can be eliminated.  This is
similar to the reduction for dead values except that that continuation
invocations need to be adjusted.

Performing a dead parameter reduction can create other dead parameter
redexes, dead value redexes, or continuation eta-redexes.  Detection
of these redexes does not fit the existing model, where an entire
deleted subterm is visited after being eliminated from the whole term.
Instead, they are detected explicit as part of the reduction
implementation.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43093 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-23 10:27:46 +00:00
kmillikin@google.com 41897d3517 Reapply "Allow LetCont to bind multiple continuations."
This reapplies svn revision r42945 with bugfixes.  There was an
invalid assertion in the shrinking reduction pass and a stray left
parenthesis in one of the input IR expressions.

Some of the logic in the shrinking reduction pass has been cleaned up.

R=asgerf@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42988 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-19 12:49:52 +00:00
sigurdm@google.com b0d465cfa0 Revert "Allow LetCont to bind multiple continuations."
This reverts commit r42945.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42948 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-16 10:09:01 +00:00
kmillikin@google.com 16d72e35e0 Allow LetCont to bind multiple continuations.
LetCont can now bind multiple continuations in the same scope.  As an
example, the 'then' and 'else' continuations of a branch are siblings
in the expression, and neither is in the scope of the other.  None of
the LetCont-bound continuations are in scope for any of the
continuation bodies.  Recursive continuations are still recursive
values, not recursive bindings, so there is no direct way to have
mutually recursive continuations.  This matches the JavaScript
semantics.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42945 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-16 08:55:20 +00:00
asgerf@google.com 73d063e5f4 Fix some bugs that blocked optimizations in the new IRs.
- Bad reference counting in tree IR builder.
- Incorrect visit order in StatementRewriter.visitSetField.
- Bad hint assigned in IR builder for GetClosureVariable.

BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42913 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-15 15:50:36 +00:00
kmillikin@google.com e79c7e72bf Make scoping more prominent in the CPS IR's printed representation.
Before: LetPrim and LetCont had "internal define" scoping, extending to
the end of the body they were in.  After: they have "let" scoping, with a
body as a subexpression.

This change makes it easier to see scoping in the printed representation.
It also makes the printed representation more closely resemble the
internal representation.  Finally, it is an advantage if writing the IR
by hand because expressions are balanced (Emacs, for example, can copy or
cut a balances S-expression).

Argument lists are changed to be always nested (enclosed by parentheses).
The basic rule of thumb is that the syntactic forms of the IR should all
have fixed arity (matching the internal representation), so that variable
arity parts such as arguments are represented as a single list.

BUG=
R=asgerf@google.com, floitsch@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42630 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-06 12:49:28 +00:00
paulberry@google.com dc884601e0 Add AccessSemantics support for calling typenames.
This adds AccessSemantics support for constructions like:

  class C {}
  main() {
    C();
  }

Even though this will always lead to a runtime error, it only produces
a warning at compile time.  Therefore AccessSemantics needs to
classify it correctly in order to allow the compilation back-end to
produce the correct runtime error.

R=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42480 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-18 21:58:58 +00:00
kmillikin@google.com 9eac6999aa Change the S-expression representation of constant values.
Before we called toStructuredString, which made no guarantee to
produce something that could be parsed as an S-expression.  Instead
implement our own conversion to S-expressions.

R=karlklose@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42438 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-17 15:18:59 +00:00
kmillikin@google.com 09ae999a45 Clean up FunctionDefinition in the IR S-expression representation.
Separate value parameters from the continuation for symmetry with
function invocations.  Do not make closure variables optional.  Do not
use '{' or '}', since it makes parsing more difficult and probably
screws up other tools that work with S-expressions.

Move closure variables after the parameters and just before the body,
since they are not part of the signature, do not appear at call sites,
and the implicit box creation happens at the beginning of the body
anyway.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42395 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-16 14:30:43 +00:00
asgerf@google.com cc4d2af55d Refactored treatment of closure variables in dart2js CPS.
Closure variables are now represented by a ClosureVariable object.
Previously they were identified by a LocalElement.

Parameters to a FunctionDefinition are now a mix of Parameter and
ClosureVariable. FunctionDefinitions also have a list of all the closure
variables they declare.

This change is a step toward supporting field initializers that modify or
capture function parameters.

BUG=
R=johnniwinther@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42164 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-08 14:06:23 +00:00
johnniwinther@google.com 4ff78cf3c6 Support top-level field declaration and assignment in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42043 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-01 14:23:19 +00:00
paulberry@google.com cc14b09855 Fix AccessSemantics for function typedefs and "dynamic".
R=johnniwinther@google.com, scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41669 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-11 16:48:00 +00:00
paulberry@google.com 346ee76510 Add support for type references to AccessSemantics.
We now handle references to toplevel classes, e.g.:

  class C {}
  Type t = C;

And references to type parameters, e.g.:

  class C<T> {
    f() {
      Type t = T;
    }
  }

R=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41643 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-10 19:14:00 +00:00
johnniwinther@google.com 6e6362efd4 Support local functions in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41600 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-07 12:33:35 +00:00
johnniwinther@google.com 09fbe78e71 Move dart2js from sdk/lib/_internal/compiler to pkg/compiler
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41514 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-05 08:51:01 +00:00
johnniwinther@google.com 8637cfd322 Revert "Move dart2js from sdk/lib/_internal/compiler to pkg/compiler"
This reverts commit r41512.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41513 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-05 08:15:26 +00:00
johnniwinther@google.com 2b336e17f0 Move dart2js from sdk/lib/_internal/compiler to pkg/compiler
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41512 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-05 07:09:04 +00:00
johnniwinther@google.com dadff8c117 Support for-in in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41491 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-04 14:53:18 +00:00
paulberry@google.com 35c6e351da Fix access semantics for foreach loops.
In a statement like:

  for (x in ...) { ... }

"x" needs to be considered to be in setter context, not getter
context.

R=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41460 260f80e4-7a28-3924-810f-c04153c831b5
2014-11-03 16:47:28 +00:00
johnniwinther@google.com e19de8c272 Support is/as expressions in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41438 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-31 14:16:22 +00:00
johnniwinther@google.com f15e787d9c Support map and list literals in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41391 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-29 10:05:56 +00:00
johnniwinther@google.com 8c86fa4003 Support while loop in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41390 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-29 08:15:23 +00:00
johnniwinther@google.com fcc99ec62c Support for loops in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41355 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-28 12:53:15 +00:00
johnniwinther@google.com e7745afc89 Support assignment of locals in analyzer2dart.
BUG=
R=paulberry@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41352 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-28 09:06:01 +00:00
johnniwinther@google.com e08abd6a6f Support constructor invocation in analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41310 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-27 09:03:08 +00:00
johnniwinther@google.com 02662a97c3 Support unreachable code in blocks in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41256 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-23 06:57:44 +00:00
johnniwinther@google.com be1198cf2e Add SExpression test and share tests between dart2dart and analyzer2dart.
BUG=
R=paulberry@google.com, sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41255 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-23 06:45:04 +00:00
paulberry@google.com fd91baa6a1 Add tree shaker support for setters and field writes.
R=scheglov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41229 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-21 15:17:06 +00:00
johnniwinther@google.com 551b0c6943 Support conditional expressions in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41188 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 12:27:21 +00:00
johnniwinther@google.com bcf6565dfe Support if-statements in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41186 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-20 10:21:13 +00:00
johnniwinther@google.com 6e7481e4af Support binary expressions in analyzer2dart.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41167 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-17 12:28:53 +00:00
johnniwinther@google.com 0496f8f2a1 Support dynamic get/invocation in analyzer2dart.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41164 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-17 11:55:07 +00:00
johnniwinther@google.com 8b1c404c16 Support local variables in analyzer2dart.
BUG=
R=floitsch@google.com, paulberry@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41146 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-16 13:09:05 +00:00
johnniwinther@google.com 15995eb9f5 Don't emit /* new backend */ comment by default.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41127 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-15 12:54:40 +00:00
paulberry@google.com e4e554e65c Propertly tree shake factory constructors.
An invocation of a factory constructor on class A does not necessarily
cause class A to be instantiated--it may redirect to a related or
unrelated class, or instantiate nothing at all.

We handle this by treating constructors similar to static function
calls--when a constructor invocation is found, the constructor element
is added to the queue; later, when the constructor element is
analyzed, we determine whether it instantiates the class or not based
on what kind of constructor it is.

R=brianwilkerson@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40899 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-03 15:53:48 +00:00
johnniwinther@google.com 3b241b9c69 Support static field access in analyzer2dart.
Static field declaration is not currently supported in the CPS IR.

I've injected the SemanticVisitor as a common superclass of the TypeShakerVisitor and CpsGeneratingVisitor to reuse the classifyX handling.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40761 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-29 10:38:11 +00:00
paulberry@google.com 4ef74c9e49 Classify method and property accesses semantically.
R=brianwilkerson@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40597 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-23 17:52:01 +00:00
scheglov@google.com 778536d97c Issue 19682. New analyzer snapshot that fixes an inline refactoring problem.
R=brianwilkerson@google.com
BUG= https://code.google.com/p/dart/issues/detail?id=19682

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40193 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-11 22:47:29 +00:00
johnniwinther@google.com bf8dc4d549 Support parameter access in analyzer2dart.
BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40142 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-11 11:30:39 +00:00