Commit Graph

4698 Commits

Author SHA1 Message Date
Stephen Adams 2847fbbf8a Add 'Math' to list of safe global JavaScript names.
TBR=asgerf@google.com

Review URL: https://codereview.chromium.org/1549603002 .
2015-12-22 14:24:05 -08:00
Kevin Millikin 75eb350abc Revert "dart2js: Initial implementation of inlining."
This reverts commit d63053fea8.

Reverted due to test failures for compiler expected output.  Those tests
need to be rebaselined to reflect the effects of inlining.

TBR=whesse@google.com
BUG=

Review URL: https://codereview.chromium.org/1542003003 .
2015-12-22 13:48:36 +01:00
Kevin Millikin d63053fea8 dart2js: Initial implementation of inlining.
Perform a depth-first postorder traversal of the call graph of known
functions.  Make an inlining decision based on the vector of argument
types at the call site, and cache inlining decisions.  For positive
inlining decisions, cache the optimized function body specialized to
the receiver and argument types at the call site.

Future work:
  * Real inlining heuristics.
  * Propagate result types of inlined calls.
  * Specialized for constant arguments when it makes sense.
  * Performance improvements.

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

Review URL: https://codereview.chromium.org/1537663002 .
2015-12-22 12:50:23 +01:00
Stephen Adams d2c403704c js_runtime tweaks for better code
1. Help type inference infer constant maps have a .length that is a non-null subtype of int. On some programs this means dynamic.length can be inferred as non-null int.

2. Make arity dispatch interceptor free by comparing constants-first (via a switch statement).

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1539033002 .
2015-12-21 13:30:24 -08:00
Asger Feldthaus 6857dc81e7 dart2js cps: Backward redundant null check removal.
Removes null checks that are follwed by an instruction which performs
the same check.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1538593003 .
2015-12-18 16:57:24 +01:00
Asger Feldthaus db00be6476 dart2js cps: Clone small constants to use site.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1526333002 .
2015-12-18 16:31:09 +01:00
Florian Loitsch 6ecea2f559 Add dart_messages package.
R=johnniwinther@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1514333002 .
2015-12-17 18:15:17 +01:00
Sigmund Cherem 913ca66834 Tweaks to improve performance of type-inference.
- short-circuit cases where join yields dynamic
- improve performance of some queries like `hasOnlySubclasses` and how `contains` is implemented in `flatten`. We could also add caching for `length`, but not sure if we want to just have a static map or precompute the data in the class-hierarchy nodes.

On my experiments this reduces inference times more than 50% on a large customer app, while small apps have almost no change.

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

Review URL: https://codereview.chromium.org/1528953002 .
2015-12-16 17:03:46 -08:00
Stephen Adams 042fcc9de0 Indexer one-shot fast path adjustment
If the index/key is not a number it is unlikely that the receiver is an Array-like JavaScript object.

This suggests that we should have a version of the one-shot with no fast-path to use at call sites where we can prove the (receiver, argument) combination does not benefit from the fast path.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1531453004 .
2015-12-16 15:07:21 -08:00
Johnni Winther 5d53b30151 Handle malformed elements in onElementResolved.
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1525423002.
2015-12-16 15:04:25 +01:00
Asger Feldthaus 488ffd8aac dart2js cps: Use oneshot interceptors and 'instanceof' expressions.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1525163002 .
2015-12-16 14:13:51 +01:00
Stephen Adams c5e9ab890f Constant-fold fields of constant objects.
SSA catch-up item.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1528673002 .
2015-12-15 10:44:02 -08:00
Stephen Adams 620257ffc0 cps_ir: Add JS checks, use argument nullability
- Add JS checks for wrong number or captured placeholders.

- Add list of nullability bits to allow generation of non-null placeholder expressions in place.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1526623004 .
2015-12-15 10:38:39 -08:00
Asger Feldthaus c6e2af11db dart2js cps: Replace GetLazyStatic with GetStatic.
Also fixes a bug in GVN that made it unable to GVN GetLazyStatic.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1521553003 .
2015-12-15 11:45:59 +01:00
Johnni Winther c5235fde7f Add token invariant to DiagnosticReporter
Closes #3675

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1520293002.
2015-12-15 11:35:55 +01:00
Johnni Winther 212ba4afbe Support optional package name arguments to --show-package-warnings
In response to dartbug.com/18661 and dartbug.com/21651.

Dart2js doesn't know pubspec.yaml or the directory structure but pub does. Next step is to pass arguments from pub.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1513263002.
2015-12-15 10:52:19 +01:00
Johnni Winther 6bb8cd8943 Introduce benign errors.
Closes #25204

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1525593002.
2015-12-15 10:17:00 +01:00
Stephen Adams dcf576a428 js_ast: Better escaping of strings in preparation for utf8 file encoding
- Choose between single and double quotes to reduce number of escapes.
- With "uft8: true", leave most characters for the file encoding.
- LINE SEPARATOR and PAGE SEPARATOR must always be \uXXXX encoded.
- Unpaired surrogates must be encoded as \uXXXX.
- Use \xXX rather than \u00XX where possible.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1520033002 .
2015-12-14 11:33:12 -08:00
Asger Feldthaus 22bf979646 dart2js cps: Retain refinement nodes and update refinements after GVN.
Refinement nodes are retained throughout the optimization pipeline.

GVN can improve refinements, so a new pass after GVN updated references
to use the best refinement in scope.  For example:

    x.f.g();
    x.f.h();

  ==>

    v0 = x.f;
    v0.g();
    v0.h();

The receiver of h() is known to be non-null after GVN because the two
uses of x.f were proven to be the same value.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1519513002 .
2015-12-14 15:01:32 +01:00
Asger Feldthaus f53ce36c3d dart2js cps: Add instruction for bounds checks.
The new instruction is expanded into low-level operations
in a new pass Finalize. The Finalize pass is mandatory.

The BoundsCheck returns the indexable object being checked
so it can be used to restrict code motion.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1512303002 .
2015-12-14 14:41:49 +01:00
Asger Feldthaus a28639d634 dart2js cps: Better GVN for fixed lengths and unmodified fields.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1518003002 .
2015-12-14 12:46:14 +01:00
Stephen Adams 04e3f8520c Don't constant fold large strings.
This fixes a 10k regression in swarm.  Marked with appropriate TODOs.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1519773002 .
2015-12-11 11:33:00 -08:00
Asger Feldthaus c5539316fb dart2js cps: Add instruction for null checks.
Currently we only instantiate the instruction for the null
checks inserted for numeric operators.

The corresponding instruction also exists in the tree IR,
partly because there is no way to say "x.toString" with the
current instruction set.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1507313006 .
2015-12-11 14:17:59 +01:00
Florian Loitsch af4983c6b2 dart2js: add support for configuration-specific imports.
R=johnniwinther@google.com, rnystrom@google.com

Committed: https://github.com/dart-lang/sdk/commit/64edfaf21af3153f32e1229dd97c9b3d40cbfb2b
Reverted: https://github.com/dart-lang/sdk/commit/f38b810d334900317ee6c919b45ebd0c673fdb02

Review URL: https://codereview.chromium.org/1388523002 .
2015-12-11 06:17:15 +01:00
Florian Loitsch f38b810d33 Revert "dart2js: add support for configuration-specific imports."
This reverts commit 64edfaf21a.

Review URL: https://codereview.chromium.org/1517013003 .
2015-12-11 00:49:38 +01:00
Florian Loitsch 64edfaf21a dart2js: add support for configuration-specific imports.
R=johnniwinther@google.com, rnystrom@google.com

Review URL: https://codereview.chromium.org/1388523002 .
2015-12-11 00:25:01 +01:00
Stephen Adams ae0da7de9c Canonical output ordering for constants.
Fix for: http://dartbug.com/24920

R=sigmund@google.com

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

Reverted.

Review URL: https://codereview.chromium.org/1491413008 .
2015-12-10 10:32:20 -08:00
Kevin Millikin ff1c630edc dart2js: Do not eliminate calls whose receiver can be null.
In the CPS backend's type propagation, try to avoid eliminating calls
whose receiver can be null.

This fixes a bug in the constant folding of indexed access.  e0[e1]
would be folded away if e0 could be null but type inference told us
that the elements had a known (specifically null) type.

tests/language/inference_list_or_null_test triggers the bug.

R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1515833003 .
2015-12-10 13:02:47 +01:00
Johnni Winther 8e467be6b0 Add missing compile-time errors for async/await.
Closes #22324
Closes #23716

R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1504403005.
2015-12-10 11:24:09 +01:00
Stephen Adams cfb97d053e Revert "Canonical output ordering for constants."
TBR=sigmund@google.com

Review URL: https://codereview.chromium.org/1511383002 .
2015-12-09 17:23:29 -08:00
Stephen Adams d15e5d5192 Canonical output ordering for constants.
Fix for: http://dartbug.com/24920

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1491413008 .
2015-12-09 17:05:51 -08:00
Florian Loitsch e802e26d7b Move messages out of dart2js.
The format of the shared messages is still valid Dart, but it is restricted, so that a JavaScript parser can easily parse it.

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1503053004 .
2015-12-10 01:35:22 +01:00
Stephen Adams cfd1654293 Constant folding of indexers
- Constant fold indexers.
- Use inferred types of elements of containers and dictionaries.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1492233002 .
2015-12-09 09:42:29 -08:00
Kevin Millikin 42809b52b1 dart2js: Fix an issue with erroneous for-in.
In the CPS backend, when a for-in loop has an erroneous variable (interpreted
as an unresolved static setter), then we should call NoSuchMethod and not try
to call the setter.  This is what the SSA backend does.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1518473002 .
2015-12-09 18:33:27 +01:00
Kevin Millikin 12d79f91a3 dart2js: Process arguments to direct invocations as if the target is known.
When a method is invoked directly the target is known.  Normalize the
arguments based on the known target at CPS-translation time.  If this is not
done, then the call may go indirectly through a stub which is not actually
generated.

R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1510193003 .
2015-12-09 16:27:13 +01:00
Johnni Winther 77b2f078af Make new of an ambiguous a warning.
Closes #21171

R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1508383002.
2015-12-09 15:54:41 +01:00
Johnni Winther 7716ef5da1 Report compile-time error on disallowed metadata values.
Closes #14548

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1510863004.
2015-12-09 15:48:38 +01:00
Kevin Millikin f4b80ff12e dart2js: Use correct call structures throughout the backend.
When translating to CPS, call arguments are normalized.  For known
targets, this means default values are passed for missing optional
arguments and named arguments are in a canonical order.  For unknown
targets, this means that passed named arguments are in a canonical
order.

However, the CallStructure recorded is one that describes the original
call.  This may have an incorrect number of passed argument or an
incorrect order for named arguments.  With this change, a new call
structure is created describing the call as it appears in the CPS IR.

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1491973002 .
2015-12-09 12:57:04 +01:00
Johnni Winther a48dbfefd8 Static/instance getter/setter override is a warning.
Closes #11496

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1508343002.
2015-12-09 11:57:20 +01:00
Johnni Winther 116a96bea5 Disallow const getters.
Closes #8750

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1512573002.
2015-12-09 10:46:04 +01:00
Johnni Winther 0413883e0c Show import for import of parts.
Closes #24366

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1511533002.
2015-12-09 10:04:44 +01:00
Florian Loitsch aae5517866 Initialize the deferred global for every fragment.
This makes it possible to concatenate commonly used fragments in front of the main fragment. For example, if an application knows that it will immediately load a fragment, it can prefix its main fragment with that fragment.

R=sra@google.com

Review URL: https://codereview.chromium.org/1508543003 .
2015-12-09 01:20:58 +01:00
Stephen Adams aebbd86e0f Safety analysis for JS template placeholders.
Determines how many expressions may be substituted for placeholders
without changing the order of the effects embedded in the expressions
or the JavaScript template.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1510633003 .
2015-12-08 13:57:13 -08:00
Kevin Millikin 5c9a554187 dart2js CPS: Evaluate the arguments to abstract class constructors.
Constructing an abstract class is a runtime error, but that error should be
thrown after the arguments are evaluated.

BUG=
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1506143002 .
2015-12-08 12:53:01 +01:00
Johnni Winther 73d269ad1f Handle const loop variable.
Closes #9824

R=karlklose@google.com

Review URL: https://codereview.chromium.org/1503063002.
2015-12-08 11:30:00 +01:00
Sigmund Cherem ffce70d0ae Minor cleanup in inferrer folder:
- divided parts into their own libraries
 - removed TypeMaskSystem (it was not really used except for one method)

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

Review URL: https://codereview.chromium.org/1498643002 .
2015-12-04 13:37:07 -08:00
Sigmund Cherem bb2c3a9350 Fix #25111: evaluate arguments before throwing errors about invoking invalid constructors
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1492823007 .
2015-12-04 13:33:28 -08:00
Sigmund Cherem 9b75b248ad AbstractClassInstantiationError beats NoSuchMethodError
When both errors are determined at compile time,
AbstractClassInstantiationError must win.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1499793002 .
2015-12-03 16:56:26 -08:00
Stephen Adams ce03676eba Make JS-form 'returns:' annotation imply 'creates:' unless otherwise specified
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1490103002 .
2015-12-02 18:45:43 -08:00
Stephen Adams 9a5640a7d2 Allow null in more 'special' type rules.
We get extra precision from including argument types that produce errors.
e.g. {int} + {int,null} --> {int}.

Nice improvement on some numerical benchmarks where the result is used as an index where we can now use the builtin indexer.

Review URL: https://codereview.chromium.org/1493673003 .
2015-12-02 15:43:42 -08:00