Commit Graph

915 Commits

Author SHA1 Message Date
Kevin Millikin 2d46ebd6a5 Fix Dart 2 runtime errors in the front end
Fix all the Dart 2 runtime errors revealed by compiling dart2js, the
front end itself, the front end tests.

Change-Id: Ic6e6dd9f85db845b6a351ebbcfea9a6045843fc2
Reviewed-on: https://dart-review.googlesource.com/56322
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-05-24 10:14:20 +00:00
Dmitry Stefantsov 08d466bfad [kernel] Treat TypeParameter.defaultType as a child in visit methods
Change-Id: Id2bc2ec8f4d08ca3ef0c428efa2dbf369039b59c
Reviewed-on: https://dart-review.googlesource.com/55883
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-05-22 13:14:16 +00:00
Dmitry Stefantsov 2c9d8924e3 [fasta] Make explicit Object in bound a constraint during type inference
Change-Id: I1da9c822e83663dd285880a074e5a36ff295003c
Reviewed-on: https://dart-review.googlesource.com/55897
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-05-22 13:06:11 +00:00
Alexander Aprelev e71bd048e5 [vm, kernel] Fix async stack code traversal in dart2.
With this change debugger requests yield(await) positions from kernel builder so it can confirm which frame handles what exceptions.
This also renames ':completer' to ':async_completer' in constructed kernel, so it is compliant with what VM expects to see(and updates test expectations accordingly).
Further it fixes async stack navigation for sync-async that became default in dart vm since first version went for the review((uses `future` getter, rather than property).
It also makes `future` getter non-debuggable to allow stepping-out of async methods.

Make Handle zone-scoped. Clean up frame counter var name.

Bug: https://github.com/dart-lang/sdk/issues/29056

Change-Id: Ia71f3c851a6b313655b57dad28c296f5dd081eda
Reviewed-on: https://dart-review.googlesource.com/54640
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-05-22 00:27:01 +00:00
Samir Jindel c31b9a461d [vm/kernel] Reference constants in Dill by offset into constants table.
Summary:

The constants table contains a concatenation of the variable-length encodings of
each constant used in the serialized component. Previously, we referenced the
constants in the code by index into the constants table, which requires reading
potentially the entire constants table to dereference. Now, we refer to the
constant by the binary offset into the constants table, which allows us to peek
into it in constant time.

Test Plan:

The constants table is used by all the precompiler modes, so the new encoding
will inherit the coverage of the existing encoding.

Results from debug and release precompiler bots are available under the
"cl-linux-try" button.

Change-Id: I4782bc0035d0b0cbd5bd6b9d086561ea601286c8
Reviewed-on: https://dart-review.googlesource.com/55470
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-05-21 15:54:08 +00:00
Jens Johansen e491bc5d86 Allow to specify what dill file to initialize from
This CL updates the frontend_server to allow specifying what dill
file to initialize from.

Normally, it tries to initialize from the same dill file as is the
output. This is fine in many cases (e.g. flutter run always says it
should output to build/app.dill): The first time it compiles
everything, subsequent times (across restarts) it only recompiles
what's needed.

When running tests, however, the output is in a temporary directory,
so it doesn't work across restarts. The startup time for tests is
always rather high, because it always has to recompile everything.

This CL updates the frontend_server to allow specifying what dill
file to initialize from. Flutter can thus save the compiled test
file in a centralized location (e.g. build/test.dill) and load from
that across restarts.

Plumbing this into flutter yields the following result, when running
a single test (the one automatically created when creating a new
flutter project):

Before: ~5.5 seconds
Now, first run: ~5.5 second (unchanged)
Now, subsequent runs: ~3.4 seconds

Approximate breakdown:

Startup cost (e.g. if there's no test directory):        ~ 800 ms
Starting up the actual frontend server: ~150 ms
Reading source from old dill, loading all relevant files
and invalidating source:                                 ~ 300 ms
Compiling everything (or, rather, nothing as it's all
from the dill at this point):                            ~ 650 ms
Serializing:                                             ~ 250 ms
Copying files:                                           ~  50 ms
Running the actual test:                                 ~1100 ms

Total:                                                   ~3300 ms

`time flutter test --local-engine=host_debug --preview-dart-2`
says ~3.4 seconds...

To compare, --no-preview-dart-2 takes ~2.2 seconds,
so dart2 still has a (significantly) higher startup cost.

Moves the needle on https://github.com/flutter/flutter/issues/15767.

Change-Id: I36a2d05bc76e0193d369df42eb3b9f08416dd78f
Reviewed-on: https://dart-review.googlesource.com/51820
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-17 06:49:41 +00:00
Jens Johansen 8101ee0479 [kernel] Remove unused GlobalIndexer from ast_to_binary.dart
Change-Id: Ide2b8997d831f811fa278164a25139ea1fde0c5f
Reviewed-on: https://dart-review.googlesource.com/55460
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-17 06:03:02 +00:00
Martin Kustermann aafc2a6d43 Reland "[vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)"
The CL was originally committed in 039e8a175 (and reverted in
46ab040e5). The fix for the issue has landed in 9d9ce8d69 .

This time the CL will land in "disabled" form and will be enabled in a separate CL.

Change-Id: I3d5eb952230aee99875e3c58a6595691c5145e25
Reviewed-on: https://dart-review.googlesource.com/55361
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-16 12:48:38 +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
Martin Kustermann 9d9ce8d69a [VM] Ensure constant table is written in depth-first post-order
The addition of recently added [PartialInstantiationConstant] caused an
issue during constant table writing, becaused we the table writing code
wasn't updated.

This change uses visitChildren to guard against such changes in the
future.

Closes https://github.com/dart-lang/sdk/issues/33095

Change-Id: I3c6b19e1383c6825f11120b2d6255b8b747d0063
Reviewed-on: https://dart-review.googlesource.com/55161
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-15 15:17:36 +00:00
Martin Kustermann f2b37ab643 [VM] Add support for conditions in switch-case expressions to "constants" transformation
This seems to be the last remaining case which causes constant
evaluation in the VM in AOT mode.

Change-Id: I37dba2c634afa3bebd918ebe6dd93ff52a7708e7
Reviewed-on: https://dart-review.googlesource.com/55163
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-05-15 12:52:22 +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
Jens Johansen 9d05ada522 Renamings and updated comments in class hierarchy #2
Follow-up to https://dart-review.googlesource.com/c/sdk/+/53804.

Change-Id: I8359985f60207ef92c365c9a6e3833be181b49be
Reviewed-on: https://dart-review.googlesource.com/55162
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-15 10:12:32 +00:00
Jens Johansen 68f2db2f66 Renamings and updated comments in class hierarchy
Follow-up to https://dart-review.googlesource.com/c/sdk/+/53662.

Change-Id: I47923ee7e83800ac9d1f77c5f0e39d4b64bcfc7a
Reviewed-on: https://dart-review.googlesource.com/55120
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-05-15 09:15:53 +00:00
Jens Johansen f08f61e84d Incremental ClassHierarchy
This CL turns the ClassHierarchy incremental and use that in two places:

* When compiling incrementally
* When performing the second ClassHierarchy computation after adding
  forwarding stubs.

Change-Id: I7046d6be9d7673dc0783a98789b5a25183b44799
Reviewed-on: https://dart-review.googlesource.com/53804
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-05-15 07:37:09 +00:00
Alexander Markov 344c68e54c [kernel, vm] Revise how metadata is written in kernel binaries
Metadata is no longer written ahead of all nodes. Instead, metadata for
each node is written in the same context as the node itself (into a separate
buffer). This allows metadata to contain (serialize) arbitrary nodes
(for example, arbitrary DartTypes) and use serialization context of parent
nodes (such as declared type parameters).

However, with this change metadata looses the ability to reference
arbitrary AST nodes. This ability was overly restricted and had no
practical uses. (It was not possible to reference nodes which are not
reachable from root Component. As a consequence, it was not possible to
write references to arbitrary DartTypes.)

This change aligns the serialization capabilities of metadata with
how kernel AST nodes are serialized.

Change-Id: I027299a33b599b62572eccd4aa7083ad1dd2b3b3
Reviewed-on: https://dart-review.googlesource.com/54481
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-15 00:41:08 +00:00
Janice Collins e6d9ed5688 Restrict analyzer/front_end/kernel SDK versions to dev.48+.
Change-Id: If341e8aa3503881bb44e445c39e5f821fd213bfd
Reviewed-on: https://dart-review.googlesource.com/55000
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2018-05-14 19:32:45 +00:00
Janice Collins 90618bdcf3 Prepare for analyzer 0.32.0.
Change-Id: Ica117a443f922c9bb5377c99ff87ce4a7a0bce16
Reviewed-on: https://dart-review.googlesource.com/54741
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2018-05-14 18:07:02 +00:00
Peter von der Ahé 02cd63eefd Remove unused closure conversion
Change-Id: I0edbbd29a4cc603e7479023bc0e8869c78ca7bcc
Reviewed-on: https://dart-review.googlesource.com/54225
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-14 14:58:17 +00:00
Peter von der Ahé bc86dc1dd6 Remove unused reify transformation
Change-Id: I4d29e3372b9aaf6bc7f1849e9fc0fb27f63e5c5f
Reviewed-on: https://dart-review.googlesource.com/54223
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
2018-05-14 14:48:57 +00:00
Peter von der Ahé abb861d812 Remove pkg/kernel/lib/frontend directory
Removing this directory as it is mostly unused.
Closure conversion still relies on VariableAccessor, so I moved it
there.

We should consider removing closure conversion. I don't believe we
actually use it.

Change-Id: I885620b310c4d1bf3a9b9b805188921bc242a993
Reviewed-on: https://dart-review.googlesource.com/54221
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-14 14:25:38 +00:00
Jens Johansen 7b3ba3f41f ClassHierarchy refactorings
This CL:
* Removes unused functions in the ClassHierarchy
* Turns the data structures used in the ClassHierarchy upside down
  (nodes have a lists of supers instead of lists of subs)
* Factors some things that needs the original list-of-subs into another
  class that the user can ask the ClassHierarchy to compute if needed.
  It appears that it isn't generally.

This is step #1 in turning the ClassHierarchy into an incremental
ClassHierarchy.

Change-Id: I48c5731c01c1b0e8bf1fcd4ddba7f2bf7ce3b9c9
Reviewed-on: https://dart-review.googlesource.com/53662
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-05-14 11:33:20 +00:00
Jens Johansen 94a6a48edd Don't encode strings up front; don't toString uris
Second try. First try was reverted because a previously empty URL (the
default 'always there' one) is now a null url instead, which wasn't
handled properly in the frontend_server.

See 47e9039512 for original details.

This reverts commit 4c9b712052.

Change-Id: I717eb927cbe29b6388e72f7e270428d234d44e4d
Reviewed-on: https://dart-review.googlesource.com/53580
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-05-14 11:31:58 +00:00
Kevin Millikin 896cf38eca Stop using some deprecated APIs
Change-Id: Id75c317c6728fb2bd5f374e00c8a8f2e8556ded2
Reviewed-on: https://dart-review.googlesource.com/54840
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-05-14 08:42:07 +00:00
Zach Anderson 46ab040e58 Revert "[vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)"
This reverts commit 039e8a1755.

Reason for revert:
Blocks the roll into Flutter.
See https://github.com/dart-lang/sdk/issues/33095

Original change's description:
> [vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)
> 
> This CL also uses the newer `onProblem` error reporting mechanism, which supports contexts.
> 
> The errors by the constant evaluator are formatted e.g. like this:
> 
>     .../language_2/compile_time_constant_o_test_01.dart:14:8: Error: Duplicate keys are not allowed in constant maps (found duplicate key "StringConstant(foo)").
>       "foo": 499
>        ^
>     .../language_2/compile_time_constant_o_test_01.dart:32:24: Context: While analyzing:
>       Expect.identical(m1, m3);
> 
> Change-Id: I463416e14686e218b0f08903bd6aa0bca7392260
> Reviewed-on: https://dart-review.googlesource.com/53021
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,alexmarkov@google.com,askesc@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I1af0200dcb0aef03c7bd9ba3b5aead1565f05708
Reviewed-on: https://dart-review.googlesource.com/54720
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Todd Volkert <tvolkert@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-05-11 17:50:46 +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 fe3f87f192 [fasta] Reland "Handle annotations on formals and variables"
The original CL: https://dart-review.googlesource.com/c/sdk/+/51840

Bug: http://dartbug.com/28434
Change-Id: I0812ef4223337f5bf72218dfac0f26f76a6b9df1
Reviewed-on: https://dart-review.googlesource.com/52449
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
2018-05-09 09:53:42 +00:00
Martin Kustermann 039e8a1755 [vm/kernel] Enable kernel2kernel "constants" transformation in AOT mode (after running TFA)
This CL also uses the newer `onProblem` error reporting mechanism, which supports contexts.

The errors by the constant evaluator are formatted e.g. like this:

    .../language_2/compile_time_constant_o_test_01.dart:14:8: Error: Duplicate keys are not allowed in constant maps (found duplicate key "StringConstant(foo)").
      "foo": 499
       ^
    .../language_2/compile_time_constant_o_test_01.dart:32:24: Context: While analyzing:
      Expect.identical(m1, m3);

Change-Id: I463416e14686e218b0f08903bd6aa0bca7392260
Reviewed-on: https://dart-review.googlesource.com/53021
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-09 09:00:02 +00:00
Samir Jindel 2296f9d637 Run transformations on expression compilation.
Change-Id: Ie0107d908f9e83050e83fbcf1384818100f334b9
Reviewed-on: https://dart-review.googlesource.com/44427
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-05-08 13:35:52 +00:00
Jens Johansen 2ccafe7a54 [kernel] Change dill representation of doubles
This is the second try. First commit failed because another reading of
the binary was added after the change was originally made and before
actually landing it (and wasn't noticed when rebasing).
This reverts commit b298fc6d8f.

See 6e2536f585 for more information.

Change-Id: Ia0e7f8921de2cec8088654fa24950df13d846237
Reviewed-on: https://dart-review.googlesource.com/53560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2018-05-08 13:15:13 +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 384a59595c Recognize synthetic catch-clause and unhandled exceptions.
Bug: https://github.com/flutter/flutter/issues/16741
Change-Id: I619c2eb0662cfdd16cc865ae5eae9c7d19bc55c4
Reviewed-on: https://dart-review.googlesource.com/52984
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-02 22:39:56 +00:00
Alexander Aprelev 4c9b712052 Revert "Don't encode strings up front; don't toString uris"
This reverts commit 47e9039512 as it
breaks flutter build aot.

Bug: https://github.com/flutter/flutter/issues/17214
Change-Id: I5e727db976822a6a001e5fa7a0bb0ffc7460fea8
Reviewed-on: https://dart-review.googlesource.com/53500
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-02 22:16:29 +00:00
Alexander Aprelev b298fc6d8f Revert "[kernel] Change dill representation of doubles"
This reverts commit 6e2536f585 as it
breaks flutter hot_reload test.

Bug: https://github.com/flutter/flutter/issues/17202
Change-Id: I36261a1aec5ec2196c3a02cc0da0dc0833337004
Reviewed-on: https://dart-review.googlesource.com/53460
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2018-05-02 20:25:58 +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
Jens Johansen 47e9039512 Don't encode strings up front; don't toString uris
Change kernel serialization so that
a) We don't UTF8 encode strings up front, but only as needed
   (if nothing else it makes it more obvious where the cost of stuff is)
b) Don't call toString on URIs to save them in a StringIndexer, only to
   parse the string later to get a URI back again.

This shaves a bit of the serialization time.
Timings from running `flutter test` in flutter/packages/flutter:

Without change:
```
02:14 +2438 ~18: All tests passed!
02:12 +2438 ~18: All tests passed!
02:14 +2438 ~18: All tests passed!
```

with change:
```
02:10 +2438 ~18: All tests passed!
02:11 +2438 ~18: All tests passed!
02:09 +2438 ~18: All tests passed!
```

 => -2.5% +/- 1.83615%

Change-Id: I03e651bbef23445fb1901452a4efcc732789a168
Reviewed-on: https://dart-review.googlesource.com/51302
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-05-02 07:42:40 +00:00
Kevin Millikin 9371ca061c Remove all the contravariance bits
Change-Id: Ib43b32d12749ddac0a93795cb5e8543eb5131dd9
Reviewed-on: https://dart-review.googlesource.com/52867
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-01 10:56:11 +00:00
Martin Kustermann c544a9fcd1 [vm/kernel] Implement Constant.getStaticType
Change-Id: I314f423257b970016dcaec9967fc624c7c39c4a8
Reviewed-on: https://dart-review.googlesource.com/53040
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-05-01 09:49:01 +00:00
Jens Johansen 6e2536f585 [kernel] Change dill representation of doubles
Previously doubles was saved as strings in the string table,
with a DoubleLiteral holding a StringReference.

This can cause overhead in both computation time
(converting the double to and from string) as well as size
(e.g. a single usage of the previously unused double 1000000.42
would use (at least)
* 10 bytes for the characters
* 1 byte for the size
* 1 byte for the reference to the string

whereas saving it as a double would simply save the 8 bytes.

On the other hand the string table doesn't contain duplicates so
many usages of the same double will use more space.

The SDK dill file size decreases slightly (< 1 KB).

On a Dart file with 1M different doubles (0.42, 1.42, ..., 999999.42)
added to a list:

Before:

compile and write via fasta (non-strong-mode): 0:12.18
Reading (via dart, eager): 2500-2600 ms
Writing (to null sink) (after reading): 1600-1800 ms
Output dill file (via fasta compile): ~62 MB

After:

compile and write via fasta (non-strong-mode): 0:11.76
Reading (via dart, eager): 2050-2350 ms
Writing (to null sink) (after reading): 400-550 ms
Output dill file (via fasta compile): ~54 MB

Running the dill file is ~the same time, but "Maximum resident set size
(kbytes)" (from /usr/bin/time -v) decreases with ~4%.

On the other side, if it's 1M of the same doubles (0.42), while
compiling is ~the same speed, the output dill goes from 43MB to 50MB.
Surprisingly the "Maximum resident set size (kbytes)" still decreases
though (~3%).

Running flutter test in flutter/packages/flutter:

Before:
```
02:33 +2425 ~18: All tests passed!
02:28 +2425 ~18: All tests passed!
02:28 +2425 ~18: All tests passed!
```

After:
```
02:12 +2425 ~18: All tests passed!
02:11 +2425 ~18: All tests passed!
02:12 +2425 ~18: All tests passed!
```

So that's -12.0267% +/- 3.15253%

File size of a dill file of an arbitrary test using flutter is reduced by ~44 KB (~0.3%).

Change-Id: I64151376cde1dae6f0d02b3d96991bc432a994ae
Reviewed-on: https://dart-review.googlesource.com/41660
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-01 09:35:21 +00:00
Janice Collins 6d9371aec3 Prepare for analyzer-0.31.2-alpha.2
Change-Id: Ib428b7316633bb77978428a17956bc05e736d57d
Reviewed-on: https://dart-review.googlesource.com/52981
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
2018-04-30 17:56:31 +00:00
Martin Kustermann a31d24dbd8 [vm/kernel] Add a knob to constant evaluate annotations only conditionally
This "knob" to turn off constant evaluation for annotations is required
because the TFA transformation leaves annotations in a state where they
cannot be evaluated anymore.

Change-Id: I7720a07ef42ff69834e24a856613ea2e846b4f2d
Reviewed-on: https://dart-review.googlesource.com/52803
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-30 13:34:35 +00:00
Martin Kustermann 4697e3c8f6 [vm/kernel] Change "constants" kernel2kernel transformation to be able to recover from errors
Instead of simply throwing an exception when a compile-time error was
discovered during constant evaluation, we report the error and continue
transforming.

This also collects a context, which can be used by error reporters to
show users in which context an error occured.

The reason for using an interface for reporting errors is to be able to
report reasonable nice error messages, keep the transformation inside
package:kernel and allow users of the transformation to possibly report
nicer error message, e.g. by adding quotes of source positions (which
will come in another CL). This makes it slightly verbose.

Change-Id: I965cafc690dddb525b20368d03bb978e18a6ee58
Reviewed-on: https://dart-review.googlesource.com/52447
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-04-30 11:27:55 +00:00
Alexander Markov 45e390003f [kernel] Report error for dangling node reference in metadata
Currently, kernel metadata does not support references to nodes which
are not reachable from root Component. This CL adds an error if such
reference exists, instead of silently writing zero offset.

Change-Id: I6de886296bea66bd732f379cc99e0e3693ea79af
Reviewed-on: https://dart-review.googlesource.com/52527
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-04-26 16:33:00 +00:00
Vyacheslav Egorov 328163bba9 [kernel] CloneVisitor should preserve isDefault on switch cases.
Fixes https://github.com/dart-lang/sdk/issues/32971

Change-Id: I16bf688080ee60853f5de449ead3e7feaec37fc2
Reviewed-on: https://dart-review.googlesource.com/52602
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-04-25 23:53:22 +00:00
Martin Kustermann 859a216e89 Add missing annotations in Library.visitChildren/transformChildren
Change-Id: I0e06b19a2d47383a2cbcbdda123e4d6e41acf537
Reviewed-on: https://dart-review.googlesource.com/52444
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-04-25 10:20:18 +00:00
Martin Kustermann e9ffc02663 Add partial instantiation support for constant evaluator [PartialInstantiationConstant]
Change-Id: Iaa93da60331737aaa6bceb4d2fe1d791dc7e95e9
Reviewed-on: https://dart-review.googlesource.com/52445
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-04-25 09:25:28 +00:00
Ben Konyi b641826ccf [ VM / CFE ] Removed changes introduced in c7e4a7d333 which allowed for dart:_internal to be imported for tests and updated DartAPI_InvokeNoSuchMethod to not depend on dart:_internal.
Change-Id: Ia861f7ef9eb6de0ee79743592d3517011c66327e
Reviewed-on: https://dart-review.googlesource.com/52266
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2018-04-24 22:14:48 +00:00
Samir Jindel db2f3de25d [kernel] Fix handling of function type type parameters in closure conversion.
Change-Id: Ic805d13bff3e1bc09f8483d918a14fe2f1d7f2d9
Reviewed-on: https://dart-review.googlesource.com/51920
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-04-22 23:01:45 +00:00