Commit Graph

309 Commits

Author SHA1 Message Date
Alexander Markov 095bd354d4 [vm/kernel/bytecode] Fix handling of function type arguments parameter
This CL fixes number of fixed parameters in EntryOptional bytecode
and adds generation of CheckFunctionTypeArgs bytecode.

Change-Id: I3f9ccc86cb622291b2c58b5a4dbf47bb614380f2
Reviewed-on: https://dart-review.googlesource.com/62963
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-29 00:01:58 +00:00
Alexander Markov 5f0c0dcfbc [vm/kernel/bytecode] Omit source positions from bytecode when testing
Bytecode for 'assert' statement includes source positions, which are
different on Linux and Windows due to different newline characters.
This causes bytecode generator tests to fail on Windows, as expected
output includes source positions calculated on Linux.

To avoid these failures, new flag 'omitSourcePositions' is added
to bytecode generator and used in the bytecode generator test.

Change-Id: I296c9a70fa5f389b30a8982152513fdd57447c08
Reviewed-on: https://dart-review.googlesource.com/62880
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-28 17:59:27 +00:00
Alexander Markov 0e7e0c945a [vm/kernel/bytecode] Generate argument checks after allocating initial context
Argument type checks could use receiver to get instantiator type
arguments. Receiver could be captured and allocated in a context.
So initial context should be allocated before doing argument type
checks.

This CL also removes useless storing of uninitialized (null) context into
'parent' when allocating initial context.

Change-Id: Iec41f1bd474ba8cfccc360b96b3461fe760edddb
Reviewed-on: https://dart-review.googlesource.com/62706
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-27 21:51:41 +00:00
Alexander Markov c53952a46d [vm/kernel/bytecode] Generate bytecode for assertions, bool checks
In addition:

* Use InstanceCall1 instead of InstanceCall2 for now as InstanceCall2
  requires ICData objects with 2 checked arguments.

* Remove try-catch around bytecode generation as all operations are
  supported and silent fallback is no longer needed.

Change-Id: Iead5a4997450cc47ef3bb3221647e733b7a72b62
Reviewed-on: https://dart-review.googlesource.com/62443
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-26 23:07:18 +00:00
Alexander Markov a93e303f3f [vm/kernel/bytecode] Bytecode generation for rarely used operations
Change-Id: Ie5154207b4763d950707b267803a688d4b3e0487
Reviewed-on: https://dart-review.googlesource.com/62002
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-25 17:51:44 +00:00
Alexander Markov fa19575a54 [vm/kernel/bytecode] Inline list of types into TypeArgumentsForInstanceAllocation constant pool entry
Change-Id: I24a2fda84aa04a081c27427a7c84077101594421
Reviewed-on: https://dart-review.googlesource.com/61308
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-20 23:52:12 +00:00
Alexander Markov f6871d2305 [vm/kernel/bytecode] Fix generation of InstantiateTypeArgumentsTOS bytecode
Change-Id: I1c4f503cc664d678815e45628a8a14044b00f55f
Reviewed-on: https://dart-review.googlesource.com/61312
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-20 22:24:52 +00:00
Alexander Markov 6182b7215d [vm/kernel/bytecode] Fix passing of type arguments
* Argument count corrected when calling generic instance method
  (type arguments should be counted in a total arguments count in
  InstanceCall1 instruction).

* Argument count corrected in ArgDesc when calling Map._fromLiteral
  factory constructor.

* Type parameters of a factory constructor are treated as class type
  parameters to ensure that instantiator type arguments are pushed.
  This is needed as VM converts type parameters of factory constructors
  into the class type parameters (they are distinct in kernel).

* Implicit parameter for passing type arguments to factory constructors
  is now handled separately from function type arguments.
  It is used as instantiator type arguments for instantiating types.
  Unlike function type arguments, this parameter can be captured.

Change-Id: I25086a0df9cebca0b01e837e1c81b7f18b2d2270
Reviewed-on: https://dart-review.googlesource.com/61115
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-20 21:02:52 +00:00
Alexander Markov 23f87d54c6 [vm/kernel/bytecode] Implement strong mode type checks in bytecode
This includes argument type checks and implicit type checks inserted
by front-end.

Also, lookup of getter functions is fixed for StaticICData constant
pool entry to include non-static getters (StaticICData is used for
all kinds of direct calls including super calls).

Change-Id: Ic265ea6a7fca2bfcc9a96e4ede268ec8e693ff41
Reviewed-on: https://dart-review.googlesource.com/60822
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-19 16:58:33 +00:00
Alexander Markov 33feee3b03 [vm/kernel/bytecode] Fix arguments passing in native factory constructors
VM requires to pass null type arguments to factory constructors of
non-generic classes. This includes native implementation of native
factory constructors.

Bytecode generation for bodies of native factory constructors is fixed
to push this extra argument for NativeCall.

Change-Id: I741a783c6964da88ecd0bfd1d2ec4aa3b1868708
Reviewed-on: https://dart-review.googlesource.com/60200
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-13 22:28:04 +00:00
Alexander Markov 828a168622 [vm/kernel/bytecode] Generate bytecode for native methods
Change-Id: If47ef9ef4ff5ac3cb3f4f6737590370b647fc9ff
Reviewed-on: https://dart-review.googlesource.com/59180
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-13 01:16:03 +00:00
Alexander Markov d52d060950 [vm/kernel/bytecode] Count type arguments argument for factory calls
Implicit argument for type arguments vector is not counted
in the number of arguments in ArgumentsDescriptor when calling
generic functions, but VM requires it to be counted
when calling factory constructors.

Bytecode generator is adjusted to cope with this discrepancy.

Change-Id: Id041563dfc68491b87593bcb6dff5cae64bfedc6
Reviewed-on: https://dart-review.googlesource.com/58961
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-06-07 17:24:08 +00:00
Alexander Markov e285bc52d7 [vm/kernel/bytecode] Optimize instantiation of types and type arguments
This CL contains 2 optimizations:

* instantiator type arguments are reused if possible;

* instantiator and function type arguments are not loaded if they are
  not needed for a particular type being instantiated.

Change-Id: Id1f6e5385051044b3b9f78cef884a917e65e801d
Reviewed-on: https://dart-review.googlesource.com/58680
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-06 22:03:54 +00:00
Alexander Markov c3b5939965 [vm] Remove --limit-ints-to-64-bits option and old _Bigint class
Closes https://github.com/dart-lang/sdk/issues/33306

Change-Id: I7088d8b7143edbe24f5cefe4be037ad2006e0625
Reviewed-on: https://dart-review.googlesource.com/58101
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-06-04 20:10:40 +00:00
Kevin Millikin 6ac6baae8e Record interfaceTargets for calls on dynamic receivers
When calling Object methods on dynamic receivers, record the
interfaceTarget it Kernel.  Back ends will use this to treat the call
as a statically typed one.  This is half of the problem in
https://github.com/dart-lang/sdk/issues/33293

Bug: https://github.com/dart-lang/sdk/issues/33293
Change-Id: I8d05903e5b85370a4e697ad3afc494cbc14bcc6a
Reviewed-on: https://dart-review.googlesource.com/57820
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-06-04 09:47:21 +00:00
Alexander Markov d319d3eda4 [vm/kernel/bytecode] Do not generate bytecode for external (native) members
Change-Id: I5887893528b8b0d4c93ef5e1088e229e0338ecef
Reviewed-on: https://dart-review.googlesource.com/58040
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-01 22:13:19 +00:00
Alexander Markov b7266fa3b3 [vm/kernel/bytecode] Support async/async*/sync* in bytecode generator
Change-Id: If164289608322647c0ee5d1f1ed35eb2562b1a03
Reviewed-on: https://dart-review.googlesource.com/56627
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-01 21:57:44 +00:00
Kevin Millikin b62b438e8a Infer Object members for dynamic receivers
For method, getter, and setter invocations with names of methods on
Object on expressions with static type `dynamic`, if the invocation
cannot possibly be an invocation of noSuchMethod, infer the type of
the invocation using the type of the member of Object.

This implements the feature spec
https://github.com/dart-lang/sdk/commit/472ec7780f1bb38f049d0fcc903a69bfb8ef9133

Fixes https://github.com/dart-lang/sdk/issues/32414

Change-Id: I135156346fe1468561d56a01cf3c5f0efde30739
Reviewed-on: https://dart-review.googlesource.com/56942
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-31 12:43:22 +00:00
Alexander Markov 377eb52f5a [vm/kernel/bytecode] Add library reference and invocation kind to ConstantICData
Library reference is added for private names in order to resolve them correctly.
Invocation kind byte supersedes VM-specific name mangling and makes
ConstantICData more uniform with ConstantStaticICData.

Change-Id: I66542356209d98b3d0cf0e6b8eb19bda052c6b7e
Reviewed-on: https://dart-review.googlesource.com/57485
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-05-31 00:53:21 +00:00
Vyacheslav Egorov 3b86f823d0 [vm/corelib] Remove GrowableArrayMarker hack.
GrowableArrayMarker was a class that implemented int and was used to
enable implementation of default List factory constructor in pure Dart:

  factory List([int length = GROWABLE_ARRAY_MARKER]) {
    return identical(length, GROWABLE_ARRAY_MARKER) ? new _GrowableList<E>(0)
                                                    : new _List<E>(length);
  }

Its existence complicated all kinds of things in the VM and it is finally
time to remove it.

Instead we build List factory body directly in IL.

This CL also provides inlining rule for `new List(n)` case.

Change-Id: I870751658a4ac17fce649c9ac70395ff88a5436c
Reviewed-on: https://dart-review.googlesource.com/57262
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-05-30 13:44:43 +00:00
Alexander Markov 68b19b4ff4 [vm/kernel/bytecode] Add invocation kind to StaticICData constant
VM will use the invocation kind to distinguish between getters,
setters and calls via field/getter.

Change-Id: I97cf36bc8778533e53f8251c25b373fddec3c2e8
Reviewed-on: https://dart-review.googlesource.com/55581
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-21 23:03:01 +00:00
Alexander Markov 6202749429 [vm/kernel/bytecode] Support try-catch-finally in bytecode generator
Change-Id: I2882546741b1dd8f6e03a21d85b5487fb754b742
Reviewed-on: https://dart-review.googlesource.com/55324
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-20 19:52:07 +00:00
Alexander Markov 6b65dcbcf6 [vm/kernel/bytecode] Support closures in bytecode generator
Change-Id: I038ba92c7bc210568d817ebaa109ca0ad02550e1
Reviewed-on: https://dart-review.googlesource.com/52988
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-05-15 16:51:06 +00:00
Samir Jindel 1a23ff68a5 Fix incorrect handling of NSM forwarders and pull all logic into CFE. (Take 2)
The behavioral difference is that named and optional arguments are filled in
with their default values in the `Invocation` object passed to `noSuchMethod`.

On the implementation side we make NSM forwarders concrete and fill in their
bodies in the CFE. The custom (and somewhat hacky) VM support is no longer
needed, and Dart2JS can benefit from this implementation as well.

According to discussion on #33031 we will be able to re-land this soon without
breaking Mockito.

Prior failures on precompiler bots are fixed in Patchset 2.

Change-Id: If1b7fe4cf6da5ef38f330e1ad226121bcfc958a1
Reviewed-on: https://dart-review.googlesource.com/54401
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-15 11:23:32 +00:00
Alexander Markov 7e4cec8a49 [vm/kernel/aot] Fix handling of type parameters and annotations on typedefs in TFA tree shaker
Closes https://github.com/dart-lang/sdk/issues/33109

Change-Id: I84204373010ebfdd7d774c8bb29c743d056dc24e
Reviewed-on: https://dart-review.googlesource.com/54981
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-14 23:04:48 +00:00
Alexander Markov 0f9cbf5885 [vm/kernel/bytecode] Fix bytecode generation for StaticSet
Change-Id: I42fd72ba0b7226fb5e33958af8b242e26f26e811
Reviewed-on: https://dart-review.googlesource.com/54661
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-11 17:16:06 +00:00
Kevin Millikin 8dbe716085 Remove the unused GenericCovariantInterface bit
None of the back ends are using it and it imposes a cost to have to
compute it and try to preserve it.

Change-Id: I217e1191b535829021fa11f2698cadd8d4baf1c8
Reviewed-on: https://dart-review.googlesource.com/54383
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-09 15:04:43 +00:00
Dmitry Stefantsov 4f586e265e [fasta] Update expectation files after CL 50941
Change-Id: I85aba2501a7b8a911e122f0a802dfc21b7e87e1e
Reviewed-on: https://dart-review.googlesource.com/51620
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-05-08 10:53:47 +00:00
Alexander Markov 04e9f7da27 [vm/kernel/aot] Fix infinite looping in TFA (ensure convergence of analysis)
Change-Id: If4fe0d6522271880b4bf8d0957ca07ef1f038a90
Reviewed-on: https://dart-review.googlesource.com/53525
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-04 17:28:46 +00:00
Alexander Aprelev 2765fcf2ae Revert "Revert "Revert "Fix incorrect handling of NSM forwarders and pull all logic into CFE."""
This reverts commit 9a7e1f64a2 as it
breaks mockito tests and commit 0bc6e7217a as being done for
9a7e1f64a2.

Bug: https://github.com/dart-lang/sdk/issues/33031
Change-Id: Id20a83c8a7a62ec73446180ecb37e9200f3a92b6
Reviewed-on: https://dart-review.googlesource.com/53540
Reviewed-by: Alexander Aprelev <aam@google.com>
2018-05-03 06:01:08 +00:00
Alexander Aprelev 9a7e1f64a2 Revert "Revert "Fix incorrect handling of NSM forwarders and pull all logic into CFE.""
This reverts commit 24dd9b4176 as it broke
the presubmit buildbots.

Change-Id: If225ad7c5728413860ce7b5493e8a7fcd92f54e8
Reviewed-on: https://dart-review.googlesource.com/53461
Reviewed-by: Emily Fortuna <efortuna@google.com>
2018-05-02 19:48:25 +00:00
Samir Jindel 24dd9b4176 Revert "Fix incorrect handling of NSM forwarders and pull all logic into CFE."
This reverts commit 7d5025e814.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Fix incorrect handling of NSM forwarders and pull all logic into CFE.
> 
> The original implementation was designed around a shared misunderstanding
> of optional parameter handling in the spec. (which was also ambiguous about type parameters).
> 
> The correct behavior for optional/type parameters is to fill them in with their default values/bounds.
> This behavior can be implemented without any backend support, as is done in this CL.
> 
> Change-Id: Ib81f17ead2d2920e755703e244db5afc328d0315
> Reviewed-on: https://dart-review.googlesource.com/52802
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>

TBR=dmitryas@google.com,sjindel@google.com

Change-Id: Ice6cd36cc62772e013bded83e0f589fe4b5e9d53
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/53400
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-05-02 16:05:26 +00:00
Samir Jindel 7d5025e814 Fix incorrect handling of NSM forwarders and pull all logic into CFE.
The original implementation was designed around a shared misunderstanding
of optional parameter handling in the spec. (which was also ambiguous about type parameters).

The correct behavior for optional/type parameters is to fill them in with their default values/bounds.
This behavior can be implemented without any backend support, as is done in this CL.

Change-Id: Ib81f17ead2d2920e755703e244db5afc328d0315
Reviewed-on: https://dart-review.googlesource.com/52802
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-02 12:18:30 +00:00
Alexander Markov e7848a8cda [vm/kernel] Avoid dangling references to DartTypes from constant pool
While generating bytecode, avoid flattening of type arguments used for
instance allocations (and thus avoid creating new types when substituting
type parameters). This is a workaround to limitation of kernel metadata
which is unable to serialize references to nodes (such as DartType)
not reachable from root Component.

Change-Id: I52c5e21873d0159d389895dc570a9e7283f2a6ff
Reviewed-on: https://dart-review.googlesource.com/52643
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-04-25 21:36:31 +00:00
Alexander Markov 5484b94695 [vm/kernel] Support more operations in bytecode generator
Change-Id: Ie459289196d75fbd69490a0cd4d3d0445e025748
Reviewed-on: https://dart-review.googlesource.com/51800
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-04-23 22:50:21 +00:00
Alexander Markov ac7ca17652 [vm/kernel] Experimental: generate DBC-like bytecode in kernel binaries
To enable bytecode generation, toggle kEnableKernelBytecode flag at
the beginning of pkg/vm/lib/bytecode/gen_bytecode.dart.
This will also enable generation of bytecode in platform dill files.

Also, bytecode generation can be enabled using --gen-bytecode option of
pkg/vm/tool/gen_kernel.

In kernel binaries, the generated bytecode and constant pool are
placed into 'vm.bytecode' metadata attached to members.
pkg/vm/tool/dump_kernel tool can be used to disassemble
bytecode and print constant pool.

Differences between generated bytecode and original DBC are
described in pkg/vm/lib/bytecode/dbc.dart.

Format of constant pool is described in
pkg/vm/lib/bytecode/constant_pool.dart.

Currently, only a small subset of Dart language is supported.
Bytecode generator will not emit vm.bytecode metadata for a
member if its body has an unsupported operation.


Change-Id: I27d9a361dc779ea115e5676508ee757c1754e05d
Reviewed-on: https://dart-review.googlesource.com/49600
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-04-23 03:42:52 +00:00
Alexander Markov 17fc446579 [vm/kernel/aot] Fix handling of calls via fields/getters in TFA
Bug: https://github.com/flutter/flutter/issues/16182
Change-Id: Ib2021212fd2dde8b549ca5db9b23287276dc33c9
Reviewed-on: https://dart-review.googlesource.com/50840
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-12 16:48:39 +00:00
Alexander Markov 83f5b1f740 [vm/kernel/aot] Infer types of bool expressions in TFA
This CL enables type inference for bool expressions used in 'if',
'while', 'for', 'assert', '?:', '&&', '||' and '!' in TFA in order to
eliminate more bool checks.

AOT snapshot size of flutter_gallery (in release mode):

Before:
Instructions(CodeSize): 7297024
Total(CodeSize): 11833828

After:
Instructions(CodeSize): 7159120
Total(CodeSize): 11648470

Issue: https://github.com/dart-lang/sdk/issues/32718
Change-Id: If4212ec493ff9f4443be6da02bdd75f74c8c8c42
Reviewed-on: https://dart-review.googlesource.com/49823
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-04-05 23:19:03 +00:00
Alexander Markov 7b51acd37f [vm/kernel/aot] Treat 'return;' as 'return null;' in TFA
Change-Id: I8ccc72494fda00bbcc72b538035e9f6ff8cd2d82
Reviewed-on: https://dart-review.googlesource.com/49060
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-04-02 22:00:05 +00:00
Alexander Markov c60199cf86 [vm/kernel/aot] Tree shaking based on results of TFA, take 2.
This is a re-landing of

https://github.com/dart-lang/sdk/commit/06ebf884db61b97a60b1578560678329cd51bf61

after the fix was submitted separately at

https://github.com/dart-lang/sdk/commit/e3b9c2860e46f9d673ffc3129ede2a11c6125d06

Original review: https://dart-review.googlesource.com/c/sdk/+/46942

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I2d3a10acb9b5af0184b3d1504acb2f4ebebfff8a
Reviewed-on: https://dart-review.googlesource.com/48440
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-03-27 23:39:24 +00:00
Alexander Markov e3b9c2860e [vm/kernel/aot] Fix representation of SuperPropertySet in TFA summaries
This CL fixes TFA summary collector to use right-hand side value as the
result of SuperPropertySet expression instead of result of setter invocation.

Change-Id: Ie2388387645eeec95096ab797e2718b7e031131b
Reviewed-on: https://dart-review.googlesource.com/48300
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-03-26 16:41:25 +00:00
Alexander Markov 7386d7b5ec Revert "[vm/kernel/aot] Tree shaking based on results of TFA"
This reverts commit 06ebf884db.

Reason for revert: buildbot failures.

Change-Id: Ie6b33061cad80ae3b20b773cc435d64a755620fc
Reviewed-on: https://dart-review.googlesource.com/48263
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-23 22:57:19 +00:00
Alexander Markov 06ebf884db [vm/kernel/aot] Tree shaking based on results of TFA
This CL adds tree shaking transformation into TFA transformer, replacing
simple DropMethodBodiesVisitor. In addition to removing bodies of
unreachable members, tree shaker is able to remove unused classes, typedefs
and member declarations, and replace unreachable calls with 'throw'.

Total(CodeSize) of flutter_gallery in --release mode
before: 11,671,369
after:  11,499,694

https://github.com/dart-lang/sdk/issues/30480

Change-Id: I966cf222eb9725b7a75dd193ac479436b9b9b4c3
Reviewed-on: https://dart-review.googlesource.com/46942
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-03-23 22:21:39 +00:00
Dmitry Stefantsov 4989976a81 Add CFE support for noSuchMethod forwarders
Bug: https://github.com/dart-lang/sdk/issues/31424
Change-Id: Iaf3a8d6b090bda667a9a01c2d8413f8d5dd6d5a8
Reviewed-on: https://dart-review.googlesource.com/47780
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-03-22 16:52:57 +00:00
Alexander Markov 9a20a001a6 [vm/kernel/aot] Make static non-const fields nullable in TFA
In Dart, if initializer throws an exception, a static non-const field
will have a null value, even if result of initializer is non-nullable.
This CL fixes TFA to make static non-const fields with initializer
nullable in order to correctly handle this case.

Change-Id: Ib451927b3da508c18ea43fcd0533066fb129a45e
Reviewed-on: https://dart-review.googlesource.com/46577
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-03-16 17:15:47 +00:00
Alexander Markov 1c8841e52a [vm/kernel/aot] Fully support named parameters in type flow analysis
This CL adds all necessary support for analyzing types of named
parameters.

Also, optional positional parameters are analyzed more precisely:
default value is taken into account only if there is a call which omits
parameter.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I33ee68cfc736afb65ce561361975d67153af04a3
Reviewed-on: https://dart-review.googlesource.com/44883
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-03-07 21:33:42 +00:00
Peter von der Ahé 9f56e28372 Mixin Applications with a Vengeance
Change-Id: I213f99234f29abd7e2ec03dc8451ed6dd16f3d03
Reviewed-on: https://dart-review.googlesource.com/45021
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-03-06 15:15:57 +00:00
Lasse R.H. Nielsen 9ee735b659 Add missing methods to List and Map implementations.
Optimize FollowedBy when the operands have efficient length.

Change-Id: I0af59240d70b929358c06b8d57a85df2deee6aaf
Reviewed-on: https://dart-review.googlesource.com/43665
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-02-28 12:26:53 +00:00
Alexander Markov 3b005afc1c [kernel/vm/aot/tfa] Treat incoming arguments as dynamic in opaque calls
This CL changes incoming argument types of raw (opaque, untracked) calls
in type flow analysis (TFA) from static parameter types to 'dynamic'.
Currently, raw calls are used to approximate calls from native code to
entry points and calls through tear-offs. Using static parameter types
is not correct for raw calls as incoming argument types should not include
the effect of strong mode argument type checks inside the body of a
method. This change has almost no impact on the results of analysis
because intersection with static parameter types is already performed when
applying a summary.

To fill out the remaining gap, static types of fields are now taken
into account in TFA: type of an incoming value is intersected with a static
field type in _FieldValue.setValue().

Also, this CL includes a fix for handling cyclic type parameters in TFA
(this problem appears on language_2/cyclic_type_variable_test test as
soon as TFA starts looking at static types of fields).

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ib79f1399e6c086445a61acc22a24a5e37bf481e6
Reviewed-on: https://dart-review.googlesource.com/42820
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-23 01:23:42 +00:00
Alexander Markov 2dedc4f9bd [vm/kernel/aot] Add unreachable metadata to members and call sites
This CL adds metadata to mark unreachable (unused) members (both
functions and fields) and unreachable calls into kernel binaries
using the information inferred by global type flow analysis.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I86c75cd4c7798a23f1de52141d0e9d605b62bf19
Reviewed-on: https://dart-review.googlesource.com/42462
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-02-22 22:44:31 +00:00