Commit Graph

4835 Commits

Author SHA1 Message Date
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
Stephen Adams aec20f4a5b dart2js: Guard against imprecise inferred types
For some reason html.Element's   static const _tagsForWhichCreateContextualFragmentIsNotSupported is inferred to dynamic instead of a ContainerTypeMask.

This change will also 'do the right thing' if we turn off type inference.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1490923003 .
2015-12-02 14:04:24 -08:00
Johnni Winther 1328c98cc2 This CL:
- renames the existing AbstractValue in cps_ir/type_propagation.dart to AbstractConstant
- introduces AbstractValue as an empty superinterface of TypeMask, and
- lift the interface of TypeMaskSystem to the superinterface AbstractValueDomain.

In follow-ups:
- change simple uses from TypeMask(System) to AbstractValue(Domain)
- update names and comment in AbstractValueDomain to more precisely reflect the abstraction
- update the complex uses (mainly type_propagation.dart) to use AbstractValue(Domain)

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1415883005.
2015-12-02 13:52:10 +01:00
Asger Feldthaus 91e2862a98 dart2js cps: Emit 'return' after throwing call to assist VM analysis.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1476293003 .
2015-12-02 12:40:19 +01:00
Stephen Adams 670f5b637c Propagate types of static const variables.
R=asgerf@google.com

Review URL: https://codereview.chromium.org/1486023002 .
2015-12-01 12:03:32 -08:00
Asger Feldthaus ab37dac248 dart2js cps: Add more constraint rules to bounds-check elimination.
The sign of a +/- operation is computed, which can help in cases where
the result could not be proven to be within 53-bit range.

Also added rules for ~/, %, >>, &, and unary negation operators.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1479193002 .
2015-12-01 17:20:16 +01:00
Stephen Adams 0e4ac0b7e4 dart2js: Type inferrence: Account for implicit null test in '??' and '??='.
http://dartbug.com/25043

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1469353008 .
2015-11-30 18:18:59 -08:00
Sigmund Cherem b837d63d47 Require jsInteropObject type to be resolved before we use it in native behaviors
This fixes a failing interop test in the bots.

R=sra@google.com

Review URL: https://codereview.chromium.org/1484273002 .
2015-11-30 17:37:02 -08:00
Sigmund Cherem 3fa0cae192 Alternative fix for the js-interop crash.
R=sra@google.com

Review URL: https://codereview.chromium.org/1457383003 .
2015-11-30 16:46:14 -08:00
Asger Feldthaus f77a6815c6 dart2js cps: Clean up and avoid processing unreachable code.
Primitives now have a getter 'hasValue' to distinguish primitives that
don't return a value, such as SetField.

The interceptor for TypeTestViaFlag is now inserted on-demand.

Non-instantiated intercepted classes are removed the set of
intercepted classes. This avoids an assertion failure, although it
would be better to avoid adding them in the first place.

The type of closure fields for boxes and type variables no longer go
through the global type inference.

A test fails because the type inference infers an empty type for a
closure field for a torn-off `.call` method. It's an existing problem
that we now have at least one failing test for.

CreateFunction has been removed from CPS and Tree.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1474713002 .
2015-11-30 15:28:45 +01:00
Asger Feldthaus 94ed2c3a7d dart2js cps: Better runtime null checks for primitive operators.
Calls to numeric operators where the receiver might be null will now
insert a specialized null check, like this:

    if (typeof x !== 'number') return x.$lt();

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1474373002 .
2015-11-30 12:08:38 +01:00
Asger Feldthaus e2a1b39037 dart2js cps: Disable a bad optimization.
An optimization would remove redundant == null checks from branch
conditions, but this slows the check.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1476303003 .
2015-11-30 11:30:19 +01:00
Johnni Winther 1dabe1f8e9 Register super field set explicitly in the universe.
Closes #24781

R=sra@google.com

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

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

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

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

Review URL: https://codereview.chromium.org/1435053002.
2015-11-30 11:16:06 +01:00
Stephen Adams 17c9c97705 dart2js cps: Add CharCodeAt builtin.
1. String.codeUnitAt is lowered to a bounds check and a CharCodeAt.
2. Constant-fold String.codeUnitAt.

R=asgerf@google.com

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

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

Investigating:
tools/test.py -mrelease -cdart2js -rd8 --cps-ir language/invocation_mirror_invoke_on2_test

Review URL: https://codereview.chromium.org/1437373002 .
2015-11-27 13:40:13 -08:00
Asger Feldthaus 09a5ed9134 dart2js cps: Fix bug in bounds check elimination.
The cycle detection assumed that positive-weight cycles could safely be
ignored while searching for a negative-weight cycle, but this broke the
memoization in the DFS.

Do not try to use DFS to find shortest paths in cyclic graphs.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1474133002 .
2015-11-27 14:15:29 +01:00
Asger Feldthaus 3b289d4436 dart2js cps: Extend type masks to handle reflective invocations.
BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1430453002 .
2015-11-27 10:48:37 +01:00
Stephen Adams 6db18cbbd8 Revert "dart2js cps: Add CharCodeAt builtin."
This test fails:

tools/test.py -mrelease -cdart2js -rd8 --cps-ir language/invocation_mirror_invoke_on2_test

The reason is unrelated: because String.codeUnitAt, the only reference
is the call on Proxy. There appears to be a bug with recognizing this.

TBR=asgerf@google.com

Review URL: https://codereview.chromium.org/1475513009 .
2015-11-25 17:44:07 -08:00
Stephen Adams 9b580e5e10 dart2js cps: Add CharCodeAt builtin.
1. String.codeUnitAt is lowered to a bounds check and a CharCodeAt.
2. Constant-fold String.codeUnitAt.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1437373002 .
2015-11-25 15:20:36 -08:00
Stephen Adams 43c886d752 cps_ir: Constant fold lengths of constants
Replace GetLength of constant String and List values with the length.
This treats constants in line with known length container masks.

R=asgerf@google.com

Review URL: https://codereview.chromium.org/1477683003 .
2015-11-25 10:15:22 -08:00
Johnni Winther ac122ffe92 Restrict backend misuse
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1469353004.
2015-11-25 15:49:32 +01:00
Asger Feldthaus 84b164a52b dart2js cps: Global value numbering and loop-invariant code motion.
There is a new pass for doing GVN and LICM.

The 'share interceptors' pass previously GVN'ed and LICM'ed interceptors
but now only constifies them and lets GVN handle the rest.  The pass
has been renamed to optimize_interceptors.

The 'share final fields' pass has been removed since GVN does the same.

A new pass 'remove redundant refinements' removes some refinement nodes
that contribute no information.  These would sometimes block code motion
for no good reason.  This pass is should go away once GVN is able to
hoist expressions across refinement guards.

BUG=
R=sra@google.com

Review URL: https://codereview.chromium.org/1444363002 .
2015-11-24 12:45:32 +01:00
Johnni Winther 8a4995dfb7 Remove WorldImpact from caches when no longer needed.
BUG=
R=sigurdm@google.com

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

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

This test fails:
python tools/test.py -mrelease -cdart2js -rd8 --minified --dart2js-batch --host-checked -t960 dart2js_extra/deferred/deferred_function_test

Review URL: https://codereview.chromium.org/1464773002.
2015-11-23 15:51:48 +01:00
Asger Feldthaus cb8d7994ce dart2js cps: Refactor CallExpressions into Primitives.
(Work-in-progress, but mostly done)

InvokeMethod and friends no longer take a continuation, but are instead
primitives bound by LetPrim.

This touches a lot of code. Some general housekeeping came along in the
process.

InvokeMethod has a "calling convention" enum on it to enable
dartReceiver and getDartArgument convenience methods.

There is a new UnsafePrimitive class to help type propagation
constant-fold InvokeMethods.  I expect the class will go away after
some changes to type propagation.

Most optimizations work exactly as before, but not all are 100%
consistent.  The consecutive push rewrite was removed entirely because
V8 does not like that.

BUG=
R=kmillikin@google.com, sra@google.com

Review URL: https://codereview.chromium.org/1458703007 .
2015-11-23 12:29:43 +01:00
Stephen Adams b28df3dc5d Revert "Remove WorldImpact from caches when no longer needed."
Revert while breakage can be investigated

TBR=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1467733002 .
2015-11-20 15:23:14 -08:00
Johnni Winther ecea5e5dc0 Remove WorldImpact from caches when no longer needed.
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1464773002.
2015-11-20 15:16:26 +01:00
Johnni Winther 4c0c3e54e1 Revert "Register super field set explicitly in the universe."
This reverts commit 2345d845f5.

BUG=

Review URL: https://codereview.chromium.org/1462333002.
2015-11-20 14:11:20 +01:00