Commit graph

774 commits

Author SHA1 Message Date
Aske Simon Christensen de2ce48e17 Finish type variables earlier so their bounds are available when building the program.
Check bounds in verifier.
Fixed an inconsistency in the printing of parent nodes in the verifier.

Closes https://github.com/dart-lang/sdk/issues/30838
Closes https://github.com/dart-lang/sdk/issues/31213
Closes https://github.com/dart-lang/sdk/issues/31700

Change-Id: I328ca2c5bfa01a6753a806abd2510c98fa2b7cfe
Reviewed-on: https://dart-review.googlesource.com/22500
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-12-22 11:06:52 +00:00
Samir Jindel 7a9ec34310 [kernel] Fix Procedure constructor.
Change-Id: I640fb932f16d45f3ec97d2c498a32ac16b466df7
Reviewed-on: https://dart-review.googlesource.com/31060
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-12-21 14:19:17 +00:00
Samir Jindel 075720c352 [kernel] Add flag on Procedures for forwarding semi stubs.
Change-Id: I6e39557e9ed2e636a8f43e8835ae797e3fd8b0c2
Reviewed-on: https://dart-review.googlesource.com/29721
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-12-17 04:12:15 +00:00
Paul Berry ae9b0c42d7 Add type inference code to generate Instantiation nodes.
Fixes #31586.

Note that none of the back-ends handle Instantiation nodes yet, so the
language_2 tests added in this CL
(instantiate_tearoff_after_contravariance_check_test,
instantiate_tearoff_of_call_test, and instantiate_tearoff_test) fail
pretty much across the board right now.

Includes two fixes to Instantiation.getStaticType and the kernel type checker:

- Previously, they attempted to perform substitution on the full
  function type, which had no effect because the type parameters were
  bound.

- The type checker was not checking that type parameter bounds were
  satisfied.

Note that the front end doesn't yet check that type parameter bounds
are satisfied by the inferred type parameters.  I will address that in
a follow-up CL.

Change-Id: Ib0ad7a5fc5f4a2fdc8c99abe1f2d3d15b21a4974
Reviewed-on: https://dart-review.googlesource.com/29744
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-12-15 20:41:43 +00:00
Kevin Millikin bc2560069a Add a representation for an instantiated generic function
Kernel allows instantiating a tearoff to type arguments.  This
construct is not yet produced by the front end or supported in any
back end.

Closes issue #31550

Bug: https://github.com/dart-lang/sdk/issues/31550
Change-Id: I5e50d26cdc77a84ba92fa0ea5eea49b42ca83551
Reviewed-on: https://dart-review.googlesource.com/29587
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2017-12-14 14:51:45 +00:00
Sigmund Cherem f34af36ef9 [pkg:kernel] Add fileUri to Constructors
We have a fileUri for fields and procedures and it was missing in constructors.

This is needed to be able to correctly store the patch URI in patched
constructors and to be able to workaround
https://github.com/dart-lang/sdk/issues/31579.
Change-Id: Ic80d3dc87450ada8b39b555e9b16e162d0e40b45
Reviewed-on: https://dart-review.googlesource.com/29003
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-13 19:35:34 +00:00
Bob Nystrom 650c9dcc8e Support extractTypeArguments() in 1.0 mode on the VM and dart2js.
Without strong mode, a "good enough" implementation is to simply call
the generic method with "dynamic" for the type arguments, which is what
this does. That should be enough to unblock our internal users.

We also need to not report a compile error when
dart_internal/extract_type_arguments.dart imports the hidden
"dart:_internal" library.

This patch does both of those for the VM and dart2js (using its old
front end).

Note that the test still fails because the test is more particular than
most actual user code would be -- it validates that the instantiated
type arguments are *exactly* correct, and not that the returned object
is merely subtype compatible.

Bug:
Change-Id: I0343beace4991861b29712b3fd7067ec8dc8f8ba
Reviewed-on: https://dart-review.googlesource.com/28020
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-12-12 19:04:18 +00:00
Jens Johansen aaa125cd25 [kernel] Fix for incorrect transformerFlags with lazy loading
When the body of a function node in a Procedure is lazy loaded the value
of the Procedures transformerFlags is not properly set before the body
has been read. That means that one can get the wrong result.
This CL makes sure to read the body (thereby setting the correct result)
before answering. The same thing is neccessary when setting the value to
avoid it being overwritten later.

Bug:
Change-Id: Id5e631e69885af0872b9644d02eb7b27dfb13391
Reviewed-on: https://dart-review.googlesource.com/21349
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-11 08:30:17 +00:00
Vyacheslav Egorov 3fc72c50d9 [kernel] Fix strong mode typing in async transformer.
Fill in interfaceTarget for :for-iterator._subscription.

Bug:
Change-Id: I29bd44ca4649f3530c0b74f8372349704c99d443
Reviewed-on: https://dart-review.googlesource.com/26700
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-12-06 23:19:13 +00:00
Alexander Markov da61c326ed [VM/Kernel] Move devirtualization to pkg/vm, cleanup target-options
* The package:kernel/transformations/precompiler.dart is moved to
  package:vm and split into 2 libraries: metadata/direct_call and
  transformations/cha_devrtualization.

* Fasta 'target-options' command line argument and
  package:kernel/target/implementation_option.dart are cleaned up
  as they are no longer used.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I21a7b6bc62a036a9694e62a5dae890f6120d79ab
Reviewed-on: https://dart-review.googlesource.com/26360
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-06 18:49:33 +00:00
Sigmund Cherem a10da3ae66 Copy typedef reference when doing operations on function types (like substitutions)
Closes #31521
Bug: https://github.com/dart-lang/sdk/issues/31521
Change-Id: I045974823257cc4e43e3ba348757781a409b92ff
Reviewed-on: https://dart-review.googlesource.com/25722
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2017-12-05 19:12:38 +00:00
Paul Berry c800a1cc29 Fix error recovery for invalid assignment.
Previously, the front end recovered from an invalid assignment by
producing an "as" expression, e.g.:

    int x;
    String y;
    x = y;

Would produce an "invalid assignment" error, as well as this kernel
code:

    int x;
    String y;
    x = y as{TypeError} int;

The rationale was that the "as" check was guaranteed to fail, so this
code would produce a runtime error at the correct location.  However,
there were two problems:

1. (Minor problem) the "as" doesn't actually fail if the RHS is null.

2. (Major problem) for type inference, the type of an assignment
expression is defined to be the type of the RHS.  This means that if
the invalid assignment gets used for type inference, we generate
mal-typed kernel code, e.g.:

    int x;
    String y;
    var z = (x = y);

Gets compiled to:

    int x;
    String y;
    String z = (x = y as{TypeError} int);

This CL addresses both problems by changing the kernel representation
so that it evaluates the RHS and then throws an exception.  Since a
"throw" expression has type Bottom, the kernel representation is
guaranteed to be properly typed.  This also ensures that an exception
gets thrown if the RHS is null.  Finally, as a side bonus, it makes
the error-recovered kernel code more similar to the kernel code we
generate in other error recovery scenarios.

Change-Id: Iac74e0c726ce029ac0560d271413e85c15bfec5c
Reviewed-on: https://dart-review.googlesource.com/24140
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-12-04 14:38:04 +00:00
Dmitry Stefantsov 7340057cf8 [kernel] Clean up RedirectingFactoryConstructor class
Also, use more descriptive "redirecting_factory" instead of "factory"
in the textual representation of RedirectingFactoryConstructors.

Bug:
Change-Id: Ib01e21107b86e55a10721dde551e802ef3230c80
Reviewed-on: https://dart-review.googlesource.com/24400
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2017-12-04 13:07:34 +00:00
Peter von der Ahé e14726a3f4 Use absolute URIs instead of relative paths
We change the type of FileUriNode.fileUri from String to Uri, which in principle
doesn't change the binary format. However, we did notice that LibraryParts
weren't serialized as specified in binary.md, so we also fixed that.

Since fileUris are stored as strings in a separate table, Uri.parse is only called
once per unique URI.

Fasta only uses relativizeUri when printing diagnostics, and URIs stored in
expectation files (golden files) are relativized using String.replaceAll.

Change-Id: Ib2dc1b80c03a0cdaf84e48b8b3ba73b16bdf8a40
Reviewed-on: https://dart-review.googlesource.com/25421
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-12-04 11:34:24 +00:00
Samir Jindel bf797e6507 [kernel] Re-land assert initializers.
This change updates Dart2js and DDC.
Thanks to johnniwinther@ for the Dart2js updates.

The original revision is in patchset 2.

Change-Id: I26db33312f003f88ccccb67b27998ef21a1f667f
Reviewed-on: https://dart-review.googlesource.com/25820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-12-04 11:22:34 +00:00
Samir Jindel 48a927acb2 Revert "[kernel] Introduce assert initializers."
Reverting due to several test failures.

This reverts commit 67adfe741b.

Bug:
Change-Id: Idd1aa15d47df68f2938285468dfa3d5043d8dae2
Reviewed-on: https://dart-review.googlesource.com/25520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-12-01 17:46:05 +00:00
Samir Jindel e50326af39 [kernel] Update cloner.dart
Several revisions have updated ast.dart without updating cloner.dart to
clone the newly added fields. This revision fixes #31438.

Bug: https://github.com/dart-lang/sdk/issues/31438
Change-Id: I2347de69e6a424f25c04d2a773d3f8d8b8387619
Reviewed-on: https://dart-review.googlesource.com/23180
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-01 14:06:26 +00:00
Samir Jindel 67adfe741b [kernel] Introduce assert initializers.
Assert initializers in Dart may be compiled directly to this form of initializer,
rather than through local initializers as is done now.

Bug:
Change-Id: Ia149ea3d1df5d1dc18be5636801604ffaf7ca7d8
Reviewed-on: https://dart-review.googlesource.com/14760
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-01 14:04:06 +00:00
Alexander Markov 39f049d643 [Kernel/VM] Introduce VM-specific translation of Dart sources to kernel
This CL introduces compileToKernel() function in package:vm/kernel_front_end
as the replacement for kernelForProgram() from package:front_end/kernel_generator.

The new function will be used to customize kernel Programs for VM need.
For example, it will perform additional AOT-specific global transformations.
In future, compileToKernel() will be used from Flutter and precompiler2.

Also, this CL cleans up Target.strongModeSdk as it is no longer used.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ib9c2b5d0af955475292df8e456073a5f0e6a64be
Reviewed-on: https://dart-review.googlesource.com/25080
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-30 20:44:45 +00:00
Jens Johansen b65d63e8b8 [kernel] Add position to catch
Bug:
Change-Id: Ie4a931ab55e923a3ed2bbf247535bc151c766272
Reviewed-on: https://dart-review.googlesource.com/23671
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-30 09:50:01 +00:00
Brian Wilkerson 725c3fad49 Update front_end and kernel before publishing
Change-Id: Ifea9db1f41e232136afe0c0eacdcc7c1a430e69d
Reviewed-on: https://dart-review.googlesource.com/24200
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2017-11-28 19:28:24 +00:00
Dmitry Stefantsov ccbeebe2a6 [kernel] Add new member kind for redirecting factory constructors
New type of AST nodes RedirectingFactoryConstructor is added to Kernel.
The goal is to keep the information about redirecting factory
constructors in the class for the linking phase.

Change-Id: I7477c617fa7fd4935ceb23098ec7c056d1f286ca
Reviewed-on: https://dart-review.googlesource.com/14740
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-11-28 17:36:44 +00:00
Samir Jindel be07555207 Revert "Revert "[kernel] Implementation of fine-grained strong mode argument type-checks, phase 2""
This fixes some incorrect asserts that were breaking the debug bots.
The original revision is available in Patchset 1.

This reverts commit 26735519cb.

Bug:
Change-Id: Ifa599b7bff752dec4c505e10fd6db206e1abd977
Reviewed-on: https://dart-review.googlesource.com/23820
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-11-27 18:25:31 +00:00
Alexander Markov f6334d583f [Kernel/AOT] Check if call is legal before doing devirtualization
This change makes devirtualization more robust until front-end fully
implements override checks.

Change-Id: I96f666cca034984a10bd1a90078c4a5e53ddd27d
Reviewed-on: https://dart-review.googlesource.com/21786
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-27 17:59:12 +00:00
Vyacheslav Egorov 26735519cb Revert "[kernel] Implementation of fine-grained strong mode argument type-checks, phase 2"
This reverts commit f13f772bb2.

Reason for revert: dartk(p)-strong debug mode is completely broken
because we convert int values non-representable as Smi to Smi, which
triggers that assert. The code that does tagging checks that
Untag(Tag(x)) == x, however for our purposes this identity does not
need to hold because we only care about lower bits and ignore the sign.

Reverting to restore green-ness of DEBUG builds.

TBR=sjindel@google.com

Bug:
Change-Id: Id436cbe000d6dec8db3469070ed531327cc82d89
Reviewed-on: https://dart-review.googlesource.com/23661
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-26 10:21:01 +00:00
Samir Jindel f13f772bb2 [kernel] Implementation of fine-grained strong mode argument type-checks, phase 2
This revision continues the implementation of:
https://docs.google.com/document/d/1KK8b6kzr0pQev5YNftSZhN3M6I8HcvOJwJ6U-cW4nfw/edit?ts=5a05b3e9#heading=h.7j21arix8p2

* Add argument checking bits for named arguments in the arguments descriptor.
* Add argument checking bits for type arguments.
* Calculate argument checking bits for setters.
* Add dispatch category to PropertySet and DirectPropertySet.

Bug:
Change-Id: Ieb0a4a99c401f53a72de473fda7bab61581f9996
Reviewed-on: https://dart-review.googlesource.com/22700
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2017-11-24 18:23:57 +00:00
Jens Johansen ca877c964f [kernel] Wrap debugPath in assert in BinaryBuilder
The code for reading dill files via dart has a "debugPath" list that is
continously added and removed to in order to be able to debug what went
wrong if something goes wrong (e.g. if the dill file is invalid or the
reading code is wrong etc).

This CL wraps the updates of this list in assert so that we don't pay
for what we don't use in the general case. In a debug setting we can get
the functionality back via --checked.

On a benchmark of 10 runs, the time it takes to read vm_outline.dill 100
times after a 2 second warmup changes by -2.77% +/- 1.21%.

Bug:
Change-Id: I643b8dd778972621046fe76b536fd95e9bb66d1c
Reviewed-on: https://dart-review.googlesource.com/18820
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-22 09:29:57 +00:00
Jens Johansen df1d05a7a1 [DDC-kernel] Initial source maps; testing framework for sourcemaps
This CL adds the bare minimum of source map generation for the kernel
pipeline in DDC.

It additionally introduces a testing framework that compiles dart files
with DDC (with or without kernel), steps through it via D8 and compares
the positions stopped at to the expected stop positions.

Bug:
Change-Id: Ie9e06164d8e51c973b83c46a8472e044876e4317
Reviewed-on: https://dart-review.googlesource.com/20662
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-21 10:23:08 +00:00
Martin Kustermann c7bbaaf9f5 [Kernel] Add treeshaker support for constants
Change-Id: I9546147dbcb76a3112785fd99dbd0cca4463bd70
Reviewed-on: https://dart-review.googlesource.com/21641
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-11-20 14:33:47 +00:00
Martin Kustermann abaaee069a [kernel] Fix various issues in the kernel treeshaker
The changes in this CL include:

   * handle interface targets also on this dispatch (which happens due
     to mixins)
   * preserve class members if interface targets refer to them
   * remove references to shaken elements in `Library.additionalExports`
   * support handling of typedefs

Change-Id: Id8df6fbf5c3428ae9c9f8b11ee9bf80c35a7a091
Reviewed-on: https://dart-review.googlesource.com/21640
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2017-11-20 13:23:27 +00:00
Jens Johansen 3692c0285a [kernel] Allow ast_to_text to print 'partial' dills
Currently we produce 'partial dills' for the VM when compiling through
kernel, i.e. we only include the user-code and whatever canonical names
the user refers to. That's perfectly fine for the VM as it always loads
the platform.dill file too.

We cannot currently print it though.
(Technically we should be able to concatenate it with platform.dill and
print that).

This CL allows us to print these partial dills without concatenating
anything first.

Bug:
Change-Id: I7d5f12332e16623d02531ad46e2dc103222f59e9
Reviewed-on: https://dart-review.googlesource.com/19002
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-11-17 11:02:33 +00:00
Martin Kustermann d354a28cb2 [kernel] Add kernel2kernel constant evaluation, binary format as well as vm support
The introduced "constants" transformation can evaluate constant expressions.  The
original use-sites of constant expressions are replaced by a new [ConstantExpression]
node, which points to a subclass of a new [Constant] class hierarchy.  Constant
[Field]s and [VariableDeclarations]s will be removed, since all use-sites are
re-written.

The [Constant] class hierarchy is, similarly to the [DartType] class hierarchy, not
part of the AST tree (also has no parent pointer).  The constants form a
DAG (directed acyclic graph).

There is no canonicalization requirement of the [Constant] objects referenced by the
AST (via [ConstantExpression]).  Although it is beneficial to canonicalize them during
construction, since it reduces time spent in operator==/hashCode.

This CL furthermore adds support for a constant table in the binary format.  Similarly
to [String]s, we canonicalize the constants before writing the table to the binary.
The constant table entries in the binary are written in a post-order way, to ensure
easy construction on the backend side.

The text format will be augmented with a "constants { ... }" section at the end,
which lists the constants in the same order as in the binary format.

The transformation can be used by those backends who choose to do so.  It is not
enabled by default atm.  It should therefore not affect analyzer, fasta or other
components.

Change-Id: I57cd9624fedcf537ab6870db76246149647bed21
Reviewed-on: https://dart-review.googlesource.com/14382
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-11-16 11:08:02 +00:00
Kevin Millikin 02511ceeb4 Fix the precedence of FunctionExpression
FunctionExpression should have a low precedence to ensure that it is
properly parenthesized.

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

Bug:
Change-Id: I2ca2bb728973c5b374411dc07fdadc4dda8c707b
Reviewed-on: https://dart-review.googlesource.com/21343
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2017-11-16 10:38:12 +00:00
Vyacheslav Egorov c847cbd5e4 [VM, Kernel] Use T as a Completer type argument in async transformation.
Previously we used FutureOr<T> by mistake.

This causes the code construct a much more meaningful type Future<T> not

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

Bug:
Change-Id: I38d4e4101b81bb33d53a87385ebcf60302f6764f
Reviewed-on: https://dart-review.googlesource.com/21081
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-11-15 14:05:32 +00:00
Zachary Anderson 1113d6adb1 Fix missed vmservice_sky -> vmservice_io rename
Change-Id: I9a8fb047ea361a99949e80394733e30a70851de7
Reviewed-on: https://dart-review.googlesource.com/20904
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-11-14 22:13:06 +00:00
Aske Simon Christensen 4b3bb06c4f Put no bound on substituted type when substitution has no bound.
Closes https://github.com/dart-lang/sdk/issues/31181

Change-Id: Iace1771f1adcf029049ee8e7f8903017f512ed46
Reviewed-on: https://dart-review.googlesource.com/20022
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2017-11-10 13:15:08 +00:00
Siva Annamalai c29b19fb34 - Do not generate a separate vmservice kernel file, include it in vm_platform file
- Load vmservice_io library only in the service isolate or when an AOT snapshot is being generated

This should account for the following issues:
- https://github.com/dart-lang/sdk/issues/31203 - there should be a vmservice_io_strong.dill file
- https://github.com/dart-lang/sdk/issues/30158 - Consider extracting flutter vmservice_sky into
                                                  separate .dill from platform.dill
- https://github.com/dart-lang/sdk/issues/30111 - support compiling vmservice with an external
                                                  outline of the sdk

Bug:
Change-Id: If945ec05afe8127e288e8d3b55172c0f7c3d6e7a
Reviewed-on: https://dart-review.googlesource.com/18147
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Chandra <sivachandra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2017-11-09 19:05:15 +00:00
Jens Johansen c72b19a012 [kernel] Optimize BinaryPrinter slightly more
This CL basically:
 - Manually inlines writeAnnotationList.
 - Writes 2 and 4 byte uint30s and uint32 more effeciently in the general
   case (idea stolen from Slava).

Benchmarking 10 times with binary_bench gives the following:
 - vm_platform.dill: -10.02% +/- 0.93%
 - vm_outline.dill: -12.45% +/- 1.66%



Bug:
Change-Id: I79354b260e37cbbced0557069ae63817fac0f333
Reviewed-on: https://dart-review.googlesource.com/19188
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-11-09 10:28:20 +00:00
Alexander Aprelev 1a45ad96ca Move super resolution from kernel transformation to VM flow graph construction.
Super resolution kernel transformation updates kernel graph with
resolved static calls in place, which breaks incremental modular nature
of transformations.

Bug: dartbug.com/31043
Change-Id: I7ec52d29ea03652cae1403dd89552b30686a5749
Reviewed-on: https://dart-review.googlesource.com/18320
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-11-08 20:17:51 +00:00
Konstantin Shcheglov 6541c720e5 Update mock SDK and shaker to include required declarations.
Bug:
Change-Id: I585daea4bb4315d01333a6515c809e3a862b44e5
Reviewed-on: https://dart-review.googlesource.com/19064
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-11-08 01:19:50 +00:00
Konstantin Shcheglov f9c1b896f4 Add test that shows that we don't include additional exports for external libraries into shaken outlines.
As promised in https://dart-review.googlesource.com/c/sdk/+/18960

Bug:
Change-Id: I33970364e04a28a174aa036456ccdc1ce3fa965b
Reviewed-on: https://dart-review.googlesource.com/19060
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-11-07 19:23:31 +00:00
Vyacheslav Egorov d755f87781 [kernel] Improve performance of the BinaryPrinter.
In order of importance:

* manually inline putIfAbsent invocation in StringIndexer.put;
* manually inline writeList into writeNodeList;
* don't create Switch/Label indexers eagerly. Most functions don't need them.

Before this change:

  AstToBinary(RunTimeRaw): 83019.54 us.
  AstToBinaryP50(RunTimeRaw): 80010 us.
  AstToBinaryP90(RunTimeRaw): 96234 us.

After this change:

  AstToBinary(RunTimeRaw): 57031.02 us.
  AstToBinaryP50(RunTimeRaw): 56251 us.
  AstToBinaryP90(RunTimeRaw): 60861 us.

Bug:
Change-Id: Ida2365088a51a5095c2ce8aef5f1582bc0b5b99e
Reviewed-on: https://dart-review.googlesource.com/19005
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-11-07 15:04:09 +00:00
Vyacheslav Egorov 9ccc2877eb [kernel] Update binary_bench to use a single name for each benchmark.
Previously we used one name for command line argument and one name for
output.

Bug:
Change-Id: Idc422f077e77cd932a27380d49e2c0b061a6b716
Reviewed-on: https://dart-review.googlesource.com/19001
Reviewed-by: Martin Kustermann <kustermann@google.com>
2017-11-07 09:21:49 +00:00
Samir Jindel bc9645509e Revert "Revert "[kernel] Fix NoSuchMethod errors for generic functions.""
This un-revert fixes the issues revealed in https://logs.chromium.org/v/?s=chromium%2Fbb%2Fclient.dart%2Fvm-kernel-mac-release-x64-be%2F2217%2F%2B%2Frecipes%2Fsteps%2Fvm_tests%2F0%2Fstdout.

Patchset 1 contains the original revision unmodified.

This reverts commit 9029ee09c5.

Bug:
Change-Id: I109c011c2688144b00293ce50b3aad53e018a2f2
Reviewed-on: https://dart-review.googlesource.com/18340
Reviewed-by: Régis Crelier <regis@google.com>
2017-11-06 17:07:38 +00:00
Konstantin Shcheglov cd2f4a1e44 Update references to Class and TypeParameter, updates for tests.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: I8a922df8c21fe2ff54c60da989f87524b0cff56c
Reviewed-on: https://dart-review.googlesource.com/17340
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-11-03 18:55:11 +00:00
Samir Jindel 7b6b716071 [kernel] Don't cancel completed streams in the Async transformation.
Bug:
Change-Id: I40742b13f1b47f2817c480bfc257deaf6f1028ca
Reviewed-on: https://dart-review.googlesource.com/17820
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-03 17:03:01 +00:00
Jens Johansen dfef2338eb [kernel] Reduce context creations in BinaryBuilder
The VM creates context objects even though it's only applicable in a
non-taken branch. This CL moves such a branch into its own function
and thus avoids the context object creation when loading a dill file
eagerly.

This CL further more reduces the number of context creations by not
lazy loading basically non-existing function node bodies (e.g. the body
of a FunctionNode in the outline).

The change has the following effect when loading platform/outline
100 times after 2 seconds warmup (statistics on 5 runs):

Outline, lazy loading disabled: -12.8133% +/- 2.26214%
Outline, lazy loading enabled: -40.9197% +/- 1.50042%
Platform, lazy loading disabled: No difference proven at 95.0% confidence
Platform, lazy loading enabled: -44.3347% +/- 0.613235%

Bug:
Change-Id: I9634e0a81f43efeb4e2524edb765d36072074f1e
Reviewed-on: https://dart-review.googlesource.com/18220
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-03 08:25:11 +00:00
Samir Jindel 9029ee09c5 Revert "[kernel] Fix NoSuchMethod errors for generic functions."
This reverts commit 52e1466588.

Bug:
Change-Id: Ic1b37a5df2f50ede4f6873b6d2a701663673bcbb
Reviewed-on: https://dart-review.googlesource.com/18261
Reviewed-by: Zach Anderson <zra@google.com>
2017-11-02 16:52:32 +00:00
Samir Jindel 52e1466588 [kernel] Fix NoSuchMethod errors for generic functions.
Bug:
Change-Id: I8ad90e34a7b1f77b29f1d711f158bcb69f5928f4
Reviewed-on: https://dart-review.googlesource.com/17941
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2017-11-02 15:16:08 +00:00
Vyacheslav Egorov 8306f07fb6 [kernel] Add pkg/kernel/test/binary_bench.dart.
This file implements a simple benchmark for kernel serialization and
deserialization routines.

Change-Id: Ib67745a4176c2bcf5717395af86d724ffbb164fd
Reviewed-on: https://dart-review.googlesource.com/18185
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-11-02 15:09:48 +00:00