Commit Graph

4698 Commits

Author SHA1 Message Date
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
Johnni Winther 2345d845f5 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

Review URL: https://codereview.chromium.org/1435053002.
2015-11-20 13:10:34 +01:00
Asger Feldthaus 392bed583c dart2js: Recanonicalize selectors in static fields between runs.
This fixes a bug in batch-mode.

Selectors are canonicalized upon construction, so two equal selectors
are always the same object.

To avoid memory leaks in batch mode, the compiler clears the canonical
cache before each run.

However, some selectors were stored in static fields and thus shared
between runs.  These selectors lost their canonical status when the
cache was cleared.  This patch "fixes" that by reinserting them in
the cache after clearing it.

BUG=
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1457733002 .
2015-11-18 13:55:15 +01:00
Johnni Winther aa16622d8d Handle prefix as expression in SendSet.
Closes #23611

BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1449343003.
2015-11-17 13:45:13 +01:00
Johnni Winther 25aeab3c40 Revert "Limit interceptedElements to instantiated members only."
This reverts commit c71f758cba.

BUG=

Review URL: https://codereview.chromium.org/1450843002.
2015-11-16 13:16:55 +01:00
Johnni Winther c71f758cba Limit interceptedElements to instantiated members only.
BUG=
R=asgerf@google.com, sra@google.com

Review URL: https://codereview.chromium.org/1418643008.
2015-11-16 12:46:09 +01:00
Stephen Adams 2b30d5919a Revert "Register super field set explicitly in the universe."
Havlak benchmark tanked to 1/3.

There are a lot of crashes, e.g

python tools/test.py -mrelease -cdart2js -rd8 -aia32 --use-sdk --write-debug-log --write-test-outcome-log --clear_browser_cache --checked --dart2js-batch --host-checked -t1920 dart2js_native/native_class_with_dart_methods_frog_test

python tools/test.py -mrelease -cdart2js -rd8 -aia32 --use-sdk --write-debug-log --write-test-outcome-log --clear_browser_cache --checked --dart2js-batch -t120 co19/LibTest/html/IFrameElement/insertBefore_A01_t01

TBR=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1441853005 .
2015-11-13 17:15:29 -08:00
Stephen Adams df5bc72927 Register super field set explicitly in the universe.
Closes #24781

R=sra@google.com

Review URL: https://codereview.chromium.org/1435053002 .
2015-11-13 15:52:32 -08:00
Stephen Adams 77483ae5d3 dart2js: Forbid # placeholders in JS function bodies.
This enforces one of the guidelines that is described in the documentation for 'JS' in js_runtime/lib/foreign_helper.dart

The JS code should be rewritten to explicitly capture the values in JS.

    // Dart 'a' might change after it is closed over.
    JS('', 'function(){return #;}', a);

-->

    // Immediately bind Dart 'a' to JS 'a' and then close over JS 'a':
    //
    JS('', '(function(a){return function(){return a;};})(#)', a);

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1436263002 .
2015-11-12 15:38:12 -08:00
Harry Terkelsen 9a56c7ee56 dart2js: report output unit imports to dump-info
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1434103004 .
2015-11-12 14:10:49 -08:00
Harry Terkelsen 0df916cce0 dart2js: use WorldImpact for dump_info
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1422323007 .
2015-11-11 17:33:50 -08:00
Stephan Herhut 1fdcb882d5 Fix a bug in type inference for locals in switch statements.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1439603002 .
2015-11-11 16:03:19 +01:00
Asger Feldthaus c10bc94937 dart2js cps: Do not propagate expressions into foreign code.
BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1436833002 .
2015-11-11 14:56:57 +01:00
Johnni Winther 8b0817c839 Register closures using StaticUse.
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1435853002.
2015-11-11 12:59:00 +01:00
Johnni Winther 9cfba28da1 Compute NewStructure in resolution.
Closes #21134

R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1437463005.
2015-11-11 11:46:08 +01:00
Johnni Winther 686faebf70 Canonicalize BackendImpact
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1431983003.
2015-11-10 11:24:56 +01:00
Johnni Winther 0133786ae0 Use DiagnosticMessage in MockCompiler.
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1415463022.
2015-11-10 11:12:51 +01:00
Johnni Winther f92416c2b6 Use Feature directly in resolution.
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1438453002.
2015-11-10 10:47:02 +01:00
Asger Feldthaus d730063475 dart2js cps: Do not propagate InvokeMethodDirectly receiver.
The target function might not exist before the class has been
instantiated for the first time, so the receiver must be evaluated
before the callee expression.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1408353009 .
2015-11-09 15:50:54 +01:00
Johnni Winther e9c53271c5 Improve messages and static use for super/this-calls.
BUG=
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1423623008.
2015-11-09 13:24:38 +01:00
Johnni Winther 7b458eb1d6 Normalize type masks to use the least upper instantiated subclass/type.
BUG=
R=sigurdm@google.com

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

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

Review URL: https://codereview.chromium.org/1413613010.
2015-11-06 15:37:14 +01:00
Asger Feldthaus a32a12f900 dart2js: Change how super tear-offs are registered.
Previously, torn off super methods would be registered by emulating a
dynamic getter call using an exact TypeMask for the super class as the
receiver.

If the super class was abstract (or just not instantiated), using an
exact TypeMask is absurd since there are no objects with that exact
class.

Now, methods that have been registered as "needing super getter" are
always considered to have their getter invoked, removing the need to
emulate the dynamic getter call.

BUG=
R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1418573011 .
2015-11-06 11:49:05 +01:00
Asger Feldthaus eb7befc3d9 dart2js cps: Propagate container types for lists.
Container type masks depend on the allocation site of an object, but the
allocation site "key" is an AST node. We need to assign types to nodes
in the type propagation pass where the AST nodes are (and should be)
inaccessible, so we cannot directly query the type inference from there.

The key could be changed to an opaque "AllocationSiteID" object with no
members (just a key), but for now, we're just preserving the type mask
for container types from build-time.

Also has some other type propagation improvements related to containers.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1416723008 .
2015-11-06 11:29:26 +01:00
Lasse R.H. Nielsen 3c41869d3c Make dart2js accept constant null values in string interpolations.
Fixes issue #24839.
BUG= http://dartbug.com/24839
R=sigurdm@google.com

Review URL: https://codereview.chromium.org/1425823004 .
2015-11-06 10:58:06 +01:00
Kevin Millikin 45004655a1 Mark returns from inside the try of a try/catch as ones that exit the try.
At construction time, jumps from within the try block of a try/catch are
marked as ones that exit the try block.  This is relied on for correctness.
Specifically, it prevents moving code from outside the try into the scope of
the try.

Return jumps were from within the try were not marked because it was
unnecessary.  In the presence of inlining, returns are turned into jumps to a
local join-point continuation.  These jumps must be marked for correctness.

R=asgerf@google.com
BUG=

Review URL: https://codereview.chromium.org/1414043011 .
2015-11-06 09:31:07 +01:00
Stephen Adams 9efe59cc02 Fix for 23806 - don't optimize out Array allocation that may throw
BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1431513012 .
2015-11-05 18:11:23 -08:00