Commit Graph

4835 Commits

Author SHA1 Message Date
kmillikin@google.com 028d0b63c7 Streamline the CPS IR Visitor interface.
Previously, the visitor interface combined two things: (1) the
interface for visiting concrete IR instruction classes and (2) a
default implementation that called the visit function for the
superclass explicitly (but not through super).  For most classes that
extended Visitor this inherited implementation was used to throw an
exception if a visit method for a new class was forgotten.

Instead, it's better to make this class purely an interface which will
give a static warning when a visit method is forgotten.  This change
forces us to implement methods that previously had an inherited (not
necessary correct) implementation.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44235 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 14:31:59 +00:00
asgerf@google.com 2c2b61bddb Changed construction of 'for' loops so that bindings introduced in
enterLoopBody are in scope in the update part.

BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44233 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 13:49:18 +00:00
floitsch@google.com 497505f0dc Add "force inline" to internal annotations.
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44232 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 13:37:06 +00:00
asgerf@google.com 1f11691e88 Fix reference counting bugs in StatementRewriter.
BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44231 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 13:32:03 +00:00
floitsch@google.com dace64cbb7 dart2js: Allow to encode side-effects in the spec-string of JS and similar built-ins.
This patch prepares a shift towards two builtins. We currently have ~20 foreign functions that must be caught by the resolver, type-inferrer, builder, ...
In the future there will be only two:
JS(...), and JS_BUILTIN(...)

The JS_BUILTIN function would take a string or enum as second argument (after the spec-string) which would be shared between the runtime and the compiler.
This makes it easier to ensure that no builtin is forgotten in the places where they need to be handled.

This patch also gives more flexibility to the implementor.
For example `JS('bool', 'typeof self["foo"] != "undefined"')` would currently trigger a "depends on index store". With this patch the developer could override the automatic side-effect analysis and force the dependency to be empty.

Note: in theory we could make "JS" a BUILTIN itself, but, given its importance, I prefer to keep it separate.

Note2: with the "ForceInline" CL [0] we can keep the old functions (like "JS_GET_FLAG") and just forward to JS_BUILTIN:

@ForceInline()
bool JS_GET_FLAG(String name) {
  // Given: a shared enum `Builtin`.
  return JS_BUILTIN('bool', Builtin.getFlag, name);
}

[0] https://chromiumcodereview.appspot.com/962703004/

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44229 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 13:20:00 +00:00
sigurdm@google.com 649796355b Copy the parameters to a sync* function for each invocation of .iterator
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44227 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-04 13:09:24 +00:00
het@google.com 239fc78cb4 Sets the native name of static native methods by using the @JSName with the @Native tag of the enclosing class.
BUG=22483
R=sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44201 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 21:51:12 +00:00
sigurdm@google.com d5614f5a76 Missing named parameter.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44171 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 14:23:30 +00:00
sigurdm@google.com ef983cd0ee Fix problems with default-cases in async code.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44170 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 14:20:17 +00:00
sigurdm@google.com e9e1a5ffff Fix of https://codereview.chromium.org//964553004 .
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44168 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 13:31:08 +00:00
sigurdm@google.com 6787beb0f6 Analyze locals in await for loops as inside a try-finally.
Otherwise they do not get the right boxing behavior.

BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44166 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 12:41:10 +00:00
zarah@google.com 0c6213e97e dart2js: don't emit unneeded native info.
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44164 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 11:18:40 +00:00
sigurdm@google.com f82faf5bb7 Support for a dart2js dartDeferredLoader hook.
Also move deferred loading special casing of d8 and jsshell to
preambles.

BUG=
R=floitsch@google.com, lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44163 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 10:12:09 +00:00
sigurdm@google.com 4e5078f2e7 Move the dart_precompiled function inside scoping function.
Also make it a property of init.

This is also done for deferred hunks, allowing deferred loading to work
in CSP mode.

Long term I would like the precompiled function to go away, and move
the generated functions into the library-initializer when they are
 needed.

BUG=16898
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44162 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 09:31:29 +00:00
asgerf@google.com 63db65942b IR tracer for try statements.
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44161 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 09:23:10 +00:00
zarah@google.com 3f5640a31b dart2Js: bailout early when using the new emitter with mirrors.
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44160 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 08:59:27 +00:00
floitsch@google.com a74cc4f5df Fix order of box and types for constructor-body invocations.
BUG= http://dartbug.com/22590
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44130 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-02 14:57:49 +00:00
johnniwinther@google.com 5a5cfc18a2 Typecheck return with respect to async.
BUG=http://dartbug.com/22552
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44128 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-02 13:04:43 +00:00
johnniwinther@google.com 143b5d31fc Pass SourceInformation through the CPS IR.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44126 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-02 11:44:37 +00:00
asgerf@google.com b28886229a Added VariableUse expression to tree IR.
Variable is no longer an Expression. It must be referenced through a
VariableUse.

This makes it possible to reference a specific occurrence of a variable
in the tree, which is useful for things like finding the first or last
occurrence of a variable.

BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44125 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-02 10:20:49 +00:00
asgerf@google.com 96b77b5be9 dart2js: Refactoring, documentation, and a few bugfixes in Namer class.
See long doc comment in namer.dart.

BUG=
R=floitsch@google.com

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

Reverted: https://code.google.com/p/dart/source/detail?r=43590
(to avoid rebase conflicts for people pushing to trunk)

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

Reverted: https://code.google.com/p/dart/source/detail?r=43739
(red bots)

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44092 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-27 14:20:49 +00:00
sigurdm@google.com 0f41a29315 Let CSP-mode-flag be available as a foreign_helper constant.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44091 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-27 13:05:04 +00:00
floitsch@google.com 0974ab5b7e dart2js: simplify constant expression generation.
R=johnniwinther@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44089 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-27 12:34:58 +00:00
floitsch@google.com 098de0210f dart2js: Don't emit nsm handlers if nobody needs them in the new emitter.
R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44088 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-27 12:33:43 +00:00
sigurdm@google.com fa4dcd2b82 Refactor rewrite_async
Split AsyncRewriter into a base class and threee subclasses.

Avoid using -name variables everywhere.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44085 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-27 09:55:15 +00:00
kmillikin@google.com 1bfb7768ed dart2dart: Implementation of simple try/catch.
A LetHandler form is introduced to the CPS IR.  It binds an exception
handler continuation which is in scope for its body.  LetHandler is
translated to try/catch when translating back to direct style.

Optimizations in the CPS and Tree languages that move code have to be
careful when moving code into or out of the scope of an exception
handler.  This change prohibits such code motion, though it might be
sometimes provably safe.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44047 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-26 13:24:58 +00:00
rmacnak@google.com 8b6a6a1e4f Add ClassMirror.isEnum.
BUG=http://dartbug.com/21718
R=asiva@google.com, gbracha@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44035 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-26 01:13:50 +00:00
karlklose@google.com 45322c5765 Reapply "Use an enum in embedded_names as input to JS_GET_NAME."
Original CL: https://codereview.chromium.org/929313002/
Reverted in: https://code.google.com/p/dart/source/detail?r=43943

R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44020 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-25 10:34:07 +00:00
sra@google.com 07f1d4dacc Extends shortened representation of numbers to negative numbers.
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44015 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-25 03:06:36 +00:00
sra@google.com fe756ad5cd Move js_ast library to its own package under pkg
IT IS NECESSARY TO REBUILD AFTER SYNCING TO THIS CL.
Rebuilding creates a needed symlink in out/... for the new js_ast package.

R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44012 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-25 01:27:01 +00:00
sra@google.com 4930144c17 Delete IterableMixinWorkaround
Most code in IterableMixinWorkaround was unused.  The remaining O(20)
methods have been moved to their only use on JSArray.

I looked into using ListMixin on JSArray.  The code was clearly worse
- nearly 1% bloat on swarm and some less precise inference.  I think
it is reasonable to have the JSArray methods special-cased for
performance reasons.

R=lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44006 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 22:57:28 +00:00
sigurdm@google.com 8dccbae46f Use more js templates in async rewrite.
Also switch some js '==' to '==='.

BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43986 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 13:30:08 +00:00
karlklose@google.com 263d7f3874 Share the JavaScript based LinkedHashMap implementation between constant maps and the LinkedHashMap patch.
This fixes performance a performance issue with using enums, because their backing map required runtime type information before (due to a lack of precision on the analysis of factory constructors).

R=johnniwinther@google.com

bug= dartbug.com/22495

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43984 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 11:12:54 +00:00
zarah@google.com 3927b11265 Initialize "next" variable in async rewrite whenever there is a finally.
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43983 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 10:42:52 +00:00
floitsch@google.com 6147a54e87 Revert "dart2js: Avoid escaping in strings if it's not necessary."
This reverts commit r43979.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43981 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 10:37:29 +00:00
floitsch@google.com 0dfaae2f07 dart2js: Better big-number shortening.
R=sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43980 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 10:22:14 +00:00
floitsch@google.com 45bc3c917c dart2js: Avoid escaping in strings if it's not necessary.
BUG= http://dartbug.com/22145
R=johnniwinther@google.com, lrn@google.com, sra@google.com

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43979 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-24 09:50:09 +00:00
floitsch@google.com a2babb87a7 Revert "dart2js: Avoid escaping in strings if it's not necessary."
This reverts commit r43967.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43969 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 18:42:50 +00:00
floitsch@google.com 543b359beb dart2js: Avoid escaping in strings if it's not necessary.
BUG= http://dartbug.com/22145
R=johnniwinther@google.com, lrn@google.com, sra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43967 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 18:36:55 +00:00
floitsch@google.com 61bd144f76 Revert "Avoid printing braces for one-statement blocks in js-printer."
This reverts commit r43956.

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43964 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 17:19:14 +00:00
floitsch@google.com 33896aef2d dart2js: Don't emit fields that are named "eval" or "arguments".
R=zarah@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43961 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 16:24:53 +00:00
ahe@google.com 560747e2c9 Work around Safari for-in bug.
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43959 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 15:39:40 +00:00
sigurdm@google.com 69c64615f9 Avoid printing braces for one-statement blocks in js-printer.
BUG=
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43956 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 14:50:57 +00:00
zarah@google.com a0d0b963ae Initialize "nextWhenCanceled" variable in async rewrite.
R=floitsch@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43955 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 13:39:52 +00:00
asgerf@google.com 3d1bb0bbec Propagate pseudo-constants expressions separately in tree rewriter.
Two constants would fail to swap places even though there clearly is no
danger of swapping side effects. Moreover, a constant would prevent other
expressions from propagating.

Example:
var z = foo();
var y = 1;
bar('x', y, z); // neither foo() or 1 propagates past 'x'

This change may be made redundant in the future by a more sophisticated
side-effect analysis.

But for now, it helps debugging since the code is more readable and
it's easier to see if other rewritings are working when they are not
blocked by redundant variable assignments.

BUG=
R=kmillikin@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43953 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 12:57:34 +00:00
zarah@google.com 4fd3777f74 dart2js: remove optimization when computing required type checks.
R=floitsch@google.com, herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43950 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 11:46:01 +00:00
asgerf@google.com 3275d74ffe cps2js: Clean up some obsolete TODOs.
Also added DartSpecificNode interface for CPS and tree nodes that are
specific to the Dart backend.

BUG=
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43949 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 11:35:17 +00:00
asgerf@google.com 23f8f67f36 cps2js: Fix translation of captured 'this'.
Building the constructor call for a closure that captures 'this' would
fail because the ThisLocal is not bound in the enclosing environment.

BUG=
R=karlklose@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43945 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 09:38:14 +00:00
karlklose@google.com f43854ff8b Revert "Use an enum in embedded_names as input to JS_GET_NAME."
This reverts commit r43869.

BUG= http://dartbug.com/22495
R=sigurdm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43943 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-23 08:29:40 +00:00
floitsch@google.com cef3704d8e dart2js: don't emit big integers as integer, but instead use their exponential representation.
BUG= http://dartbug.com/16600
R=herhut@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43913 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-20 14:29:46 +00:00