Commit graph

968 commits

Author SHA1 Message Date
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
Samir Jindel 091f12b148 [kernel] Serialize fileOffset with SuperProperty{Get,Set}
Bug:
Change-Id: I35d568b8ce98413df36bd83837fd46cb95e98ec7
Reviewed-on: https://dart-review.googlesource.com/18184
Reviewed-by: Jens Johansen <jensj@google.com>
2017-11-02 14:11:33 +00:00
Jens Johansen 57c3f0579c [kernel] Replace for in loop in BinaryBuilder
Loading vm_platform.dill 100 times after 2 seconds warmup:
		Statistics on 5 runs:
			It varies to much to tell on the runs I did.

	Loading vm_outline.dill 100 times after 2 seconds warmup:
		Statistics on 5 runs:
			-7.84428% +/- 1.21335% at 95.0% confidence

Bug:
Change-Id: I34bbdca555ec50e1d16a5994c5cb46f845b4a4a3
Reviewed-on: https://dart-review.googlesource.com/18183
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-02 11:55:58 +00:00
Jens Johansen 4ea37a8702 [Kernel] Replace List.generate in BinaryBuilder
Changes in runtime:
	Running python tools/test.py -m release -cdartk language -j6
		Statistics on 3 runs:
			real -1.21% +/- 1% at 95.0% confidence
			user -2.01% +/- 0.29% at 95.0% confidence
			sys No difference at 95%

	Loading vm_platform.dill 100 times after 2 seconds warmup:
		Statistics on 5 runs:
			-15.3209% +/- 1.26028% at 95.0% confidence

	Loading vm_outlin.dill 100 times after 2 seconds warmup:
		Statistics on 5 runs:
			-21.9672% +/- 0.48754% at 95.0% confidence

Bug:
Change-Id: I16474e32715df57922376d88baddd17a1cf73663
Reviewed-on: https://dart-review.googlesource.com/17788
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-02 09:07:08 +00:00
Jens Johansen c8e51ef922 [kernel] Add offset to this[i] and super[i]
Bug:
Change-Id: Ic65b69c4977be834c7b69638d6c030727c7210e5
Reviewed-on: https://dart-review.googlesource.com/17441
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2017-11-01 09:57:00 +00:00
Paul Berry cd1898be16 Move ErrorFormatter and HighlightingPrinter into pkg/kernel/lib.
This will allow it to be used by front_end unit tests.

Change-Id: I7eef0f2ca361a75fd98fdd7a25abd1739f1aa1f8
Reviewed-on: https://dart-review.googlesource.com/16981
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-30 11:12:52 +00:00
Samir Jindel 031a7ffe41 [kernel] Improve Enum representation.
Dart2JS and the VM prefer for Enum names to be stored inline in the Enum
object to avoid having the static array of all Enum values. A base class
for Enums is provided to avoid repeating the common fields and accessors
between Enum definitions.

Bug:
Change-Id: I783f863015b45f13317fda06e627d14844fe2ddf
Reviewed-on: https://dart-review.googlesource.com/16526
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-27 12:10:53 +00:00
Jens Johansen 07b6ec3425 [kernel] Allow VM to load concatenated dill file
The kernel format has been designed so that one can concatenate several
dill files into one file and then load it. For instance the dart
function BinaryBuilder.readProgram supports this.

Currently a dill file contains one or more programs.
In the VM each of these programs are called either program or subprogram.
Technically a dill "program" isn't necessarily a program at all (e.g. it
could be missing a library).
This naming snafu should probably be cleaned up at some point, but that's
for another CL.

When loading a dill file via BinaryBuilder.readProgram what happens is
this:
- Each program in the dill file ends in 4 bytes that indicates the size
  of the program.
- Reading the input from the end one can then read the size, skip back
  that amount of bytes, if we have more data (i.e. there's another
  program), read another size and so on, and continue until we have
  accounted for all bytes in the input.
- We then read each program from the start, and basically overwrite any
  library, class, procedure etc. we find.
  The first main reference found is the one used though.
  (Saying that we overwrite is not completely true, but when the library
  is a non-external library that's basically what happens).

This CL introduces (some) support on the C++ side for the same thing.
So far the C++ side could only handle single-program-dills, and trying
to load anything else would probably crash the VM.
The support added is this:
- Assume the SDK (i.e. vm_platform.dill) is not a concatenated file
  (error out if it is).
- For user provided input, loop over each contained program one-by-one,
  for each individual one behave as normal.
- The way LibraryLoad is implemented (i.e. it skips if the library is
  already loaded) this means that it currently would behave differently
  than the dart version (i.e. the first one is used, not the last one).
  For now it is assumed that that's not a problem.
- There is a possibly snafu if the same script is included several times.
  This could probably mostly be remedied by not creating scripts up front,
  but only as needed. By the "keep only one" (and fixing the above point,
  probably by simply loading in the opposite order, i.e. last program
  in the binary first) the (theoretical) problem would probably do away.

Note that we will have separate string tables, canonical name tables etc
per "sub program" and that there might be some duplication.

The implementation was tested as indicated below, but introduces no tests.

$ cat test_lib1.dart
import "test_lib2.dart" as lib2;

String lib1field = "lib #1 field!!";

main() {
  foo();
  lib2.foo();
  print("From lib2: ${lib2.lib2field}");
}

foo() {
  print("Hello, Foo, from test_lib1!");
  var x = 42;
  print(x);
}
$ cat test_lib2.dart
String lib2field = "Lib #2 field!!!!";

foo() {
  print("Hello, Foo, from test_lib2!");
  var y = 34;
  print(y);
}

$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart --packages=.packages --platform=out/ReleaseX64/vm_platform.dill test_lib1.dart

$ ls -lha test_lib1.dart.dill
[...] 4.2M Oct 26 14:42 test_lib1.dart.dill

$ dart pkg/kernel/bin/split.dart test_lib1.dart.dill
Wrote test_lib1.dart.dill.part1.dill
Wrote test_lib1.dart.dill.part2.dill

$ ls -lha test_lib1.dart.dill.part{1,2}.dill
[...] 811 Oct 26 14:42 test_lib1.dart.dill.part1.dill
[...] 582 Oct 26 14:42 test_lib1.dart.dill.part2.dill

$ cat test_lib1.dart.dill.part1.dill test_lib1.dart.dill.part2.dill > test_lib1.dart.dill.concat.dill

$ ls -lha test_lib1.dart.dill.concat.dill
[...] 1.4K Oct 26 14:44 test_lib1.dart.dill.concat.dill

$ out/ReleaseX64/dart --kernel-binaries=out/ReleaseX64 --packages=.packages test_lib1.dart.dill.concat.dill
Hello, Foo, from test_lib1!
42
Hello, Foo, from test_lib2!
34
From lib2: Lib #2 field!!!!

Change-Id: I233a033aa3042b202dd4708908a5be3089474588
Reviewed-on: https://dart-review.googlesource.com/16820
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-10-27 12:01:48 +00:00
Jason Simmons 81c8e2bfc4 Remove Flutter diagnostic server
Bug:
Change-Id: I729f60ad310c3d864273687fe46b9b93d4696772
Reviewed-on: https://dart-review.googlesource.com/16882
Reviewed-by: Alexander Aprelev <aam@google.com>
2017-10-27 03:50:59 +00:00
Peter von der Ahé a18358482e Don't crash if there's no enclosing program.
Change-Id: If526d29a0fcbf9cc787127b73725088c05565efe
Reviewed-on: https://dart-review.googlesource.com/16544
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-10-26 15:38:11 +00:00
Paul Berry cc3f95b41d Check procedure kind when matching up forwarding stubs during mixin resolution.
Otherwise we might match up a getter to a setter and crash.

The test cases indirectly verify that mixin resolution does the right
thing by checking the semantics of the generated code.  These tests do
not pass yet, because covariance checks are not yet implemented in the
VM.

Change-Id: Ibe6d8b7479f86151c515c45c20ed7c880bf2ad43
Reviewed-on: https://dart-review.googlesource.com/16686
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-26 12:54:08 +00:00
Karl Klose b46375ef7b Fix reporting of source lines
R=vegorov@google.com

Change-Id: I3efa2d8be318a6dc58dce6924bcca7ac0d97609f
Reviewed-on: https://dart-review.googlesource.com/16484
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Karl Klose <karlklose@google.com>
2017-10-26 12:08:21 +00:00
Karl Klose 6a0ef10862 Move error formatting out of the type checker
Change-Id: Ib4860e15950912f8a0108886c21741bdb11b4bd3
Reviewed-on: https://dart-review.googlesource.com/16528
Commit-Queue: Karl Klose <karlklose@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-10-26 07:38:40 +00:00
Karl Klose 51089b53cd Remove strong mode type check insertion transformations
Change-Id: I7f4bb08b32b0ecf5af4d60af0a5b5b3a2e41c49a
Reviewed-on: https://dart-review.googlesource.com/16482
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Karl Klose <karlklose@google.com>
2017-10-26 07:32:00 +00:00
Paul Berry 7bb6369db6 Move naive type checker into pkg/kernel/lib.
This will allow it to be used by front_end unit tests.

Also plumb through the "ignoreSdk" boolean, since we will need to use
it when invoking the naive type checker from front_end unit tests.

Change-Id: I9ae50f48e24a5c45e93f4218e6b61f193f549e7a
Reviewed-on: https://dart-review.googlesource.com/16601
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-25 18:55:37 +00:00
Alexander Markov 1d629221d1 Wrap the description of an option to fit within 80 columns
This is the follow-up for review comment

https://dart-review.googlesource.com/c/sdk/+/15644/2/pkg/kernel/lib/target/implementation_option.dart#10

to the CL 34df7f3599.

Change-Id: If0c17e36bbfb42df0aa410b04e5830ebd979d3cd
Reviewed-on: https://dart-review.googlesource.com/16301
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-10-25 17:27:49 +00:00
Karl Klose ed390e7bad Change imports in reify transformation to not use 'package:'
R=dmitryas@google.com

Change-Id: If2e1f735de9f3879fcf321af5d5fa00e291e28a8
Reviewed-on: https://dart-review.googlesource.com/16460
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Karl Klose <karlklose@google.com>
2017-10-25 11:25:00 +00:00
Jens Johansen f94ffbf624 [kernel] Move procedure lazy loading to function node body
Previously lazy loading was done in Procedure by lazy loading functionNode,
now lazy loading is done (only through Procedure) in the functionNode by
lazy loading the body.

Bug:
Change-Id: I25cc86d038123ed4992162b65aa95781ea2c56e8
Reviewed-on: https://dart-review.googlesource.com/15560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-25 08:45:59 +00:00
Kevin Millikin 034501e805 Handle forwarding stubs in mixin application classes
Before: mixin application classes could not have methods of their
own.

After: type inference will sometimes insert forwarding stubs in mixin
application classes.  In the mixin elimination transformation, these
forwarding stubs are replaced with the methods of the mixin class if
they have the same name, but the parameter flags from the forwarding
stub are retained.  The other forwarding stubs are left as methods of
the class.
Change-Id: I5ee89d6b1fc83194df82009c2800b54ce856e8c5
Reviewed-on: https://dart-review.googlesource.com/15887
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2017-10-24 08:04:18 +00:00
Alexander Aprelev b6d7ad59dc Include dart:diagnostic_server into flutter patched sdk.
Bug: https://github.com/dart-lang/sdk/issues/31145
Change-Id: Id9cd5e484d108f62d1008cd07dc3d4e0eb05d598
Reviewed-on: https://dart-review.googlesource.com/15920
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2017-10-23 21:29:09 +00:00
Alexander Markov 34df7f3599 Wire up strong-aot implementation option
This CL adds handling of previously introduced 'strong-aot'
implementation (target-specific) option into VM target.

After this change, it will be possible to enable strong-mode
whole-program optimizations in Flutter (in addition to standalone VM).

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I054b75ce4ba1b9bcf150e0b7f25fa7ca1bdd187e
Reviewed-on: https://dart-review.googlesource.com/15644
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-10-23 16:57:17 +00:00
Vyacheslav Egorov a7809d6f2e [kernel] SyncYielding functions created from SyncStar are expected to return bool
Change TypeCheckingVisitor._getInternalReturnType to reflect this assumption.

Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: Ib0b06b41acc6b0b7eabe9eaa9b0fe80a8b85f7ad
Reviewed-on: https://dart-review.googlesource.com/15124
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-10-23 14:40:57 +00:00
Sigmund Cherem bc1dd524ba Use custom URIs on most of front_end unit tests
This required a couple small fixes where we had made assumptions in our system
about not having anything other than dart, package, and file URIs.

Change-Id: Ie0943f609ceeaacf3fb284ceba0df5c55c315b0b
Reviewed-on: https://dart-review.googlesource.com/11650
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-21 00:26:58 +00:00
Vyacheslav Egorov 9cd7bc724d [VM, Kernel] Fix sync* implementation in checked mode
Change abefb7b432 introduced a typing issue
instead of fixing it: _SyncIterator<T>._current was actually used to return
either a value of type T (for yield) or value of type Iterable<T> (for yield*)
from the move callback.

This change refactors implementation of _SyncIterator in such a way that
_current is only used to return value for yield and a separate field
_yieldEachIterable is used to return Iterable<T> for yield*.

Change-Id: I3e3c832bbc8986d6976ddbb0856a1b5a127d845b
Reviewed-on: https://dart-review.googlesource.com/15542
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2017-10-20 18:15:28 +00:00
kmillikin 809a549494 Do not clone forwarding stubs in mixin applications
Forwarding stubs are added to a class for when calls target that
class's interface.  When a class is used as a mixin, these forwarding
stubs should not be copied into the mixin application class.

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

Change-Id: If516210391fed83ddeb150faca42b6df4049da12
Reviewed-on: https://dart-review.googlesource.com/15600
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2017-10-20 16:49:38 +00:00
Peter von der Ahé ae0ac23e80 Prototype BulkCompiler API for fuzz testing.
Change-Id: Icf9134dccfa02ff36167287cd63abe9886e0f2e4
Reviewed-on: https://dart-review.googlesource.com/13985
Reviewed-by: Luke Church <lukechurch@google.com>
2017-10-20 12:44:15 +00:00
P.Y. Laligand ce79a77331 Remove Fuchsia-specific build files.
Also fix Fuchsia tools to account for new project location (//third_party/dart).

Change-Id: If89a934729c4fa44229eaca83219dbdf8bb700a8
Bug:
Reviewed-on: https://dart-review.googlesource.com/14800
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-19 17:52:37 +00:00
Vyacheslav Egorov 587a7cfae5 [kernel] TypeCheckingVisitor.getReceiverType should respect promoted bounds
Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: I6e1238e4622c5af089cbc6962b07a7eaf9aa6c32
Reviewed-on: https://dart-review.googlesource.com/15125
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-10-19 14:24:27 +00:00
Konstantin Shcheglov c3a76ed636 Move all documentation comments into metadata.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: I05382fe275e7a3a0f18128508d30fe1438adffc4
Reviewed-on: https://dart-review.googlesource.com/14623
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-10-18 14:48:56 +00:00
Paul Berry dca8a9acf5 Make it possible to distinguish "as" checks that come from generic covariance.
Change-Id: Ie230e6ca3ae28a0f4a6faaf5cb559426de0d8a0e
Reviewed-on: https://dart-review.googlesource.com/14361
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-18 09:16:05 +00:00
Samir Jindel d794eb3330 [kernel] No metadata for types.
Since 'DartType's overload equality with a structural comparison, we cannot
store metadata for them in a 'Map', as is done for 'TreeNode's. Since there is
no use-case yet for storing metadata on types, we remove this ability and the
restrict the metadata test.

Bug:
Change-Id: I825f55a5fd48da2c615b3154f909dd666baf5a33
Reviewed-on: https://dart-review.googlesource.com/14640
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-10-17 23:44:35 +00:00
Vyacheslav Egorov 81f2664908 [kernel] In bin/type_check.dart allow arbitrary calls on values of type Function
This change silences errors that were reported for Function.call callsites because
there is no valid interface target for them:

  Function f;
  f();
  f(null);
  f(null, null, 10);
  f<bool, int>(11, true);

All of these call sites are valid, so we have to simply treat them as dynamic 
invocations.

Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: I13b5dc3ff69e7adede3040334556ff6653b50515
Reviewed-on: https://dart-review.googlesource.com/14524
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-17 18:46:20 +00:00
Vyacheslav Egorov abefb7b432 [kernel] Assign proper types and interface targets to nodes created by async transformer.
Bug: https://github.com/dart-lang/sdk/issues/31070
Change-Id: Iaedbd425fcb6d243c0bfa93495335658553a9301
Reviewed-on: https://dart-review.googlesource.com/14481
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-10-17 17:44:00 +00:00
Peter von der Ahé b96ac4520a Update most clients to use computePlatformBinariesLocation.
Change-Id: I6e6960c471b2fab3f0cd8a672da05d7699217410
Reviewed-on: https://dart-review.googlesource.com/12291
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-10-17 10:48:40 +00:00
Paul Berry 9a0e962e67 Add a kernel flag to represent generic contravariance.
This flag indicates when a procedure's return type makes contravariant
use of a class type parameter.  The front end will have to insert "as"
checks at any call sites that refer to such a procedure as their
interface target.  Placing the flag on the procedure will allow the
front end to determine whether the check is needed once, at the same
time as it's determining the need for covariant parameter checks,
rather than when compiling individual call sites.

Once this lands I will follow up with CLs that cause the front end to
set the flag appropriately, and to generate the necessary "as" checks.

Change-Id: I989fc702bc233384eb5ea8cd630c8efd384ab248
Reviewed-on: https://dart-review.googlesource.com/14365
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-17 05:24:21 +00:00
Samir Jindel ab5afac660 [kernel] Add const constructors to visitors.
Bug: 30809
Change-Id: I46da961a2320bdb7cf8eb315777f4f8ffc641d13
Reviewed-on: https://dart-review.googlesource.com/12580
Reviewed-by: Stephen Adams <sra@google.com>
2017-10-17 00:09:20 +00:00
Samir Jindel dd0d299dcb [kernel] Un-revert support for generic function types and removing type erasure.
Change-Id: I8032e4622a0756199528a61fdb59f3d0ec132d1f
Reviewed-on: https://dart-review.googlesource.com/14202
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2017-10-16 23:17:09 +00:00
Samir Jindel dcf48efa23 [kernel] Un-revert support for generic closures in VM's kernel frontend.
Change-Id: I09dbcfdb13600fe694863db628b379bcf1f56684
Reviewed-on: https://dart-review.googlesource.com/14200
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2017-10-16 22:27:03 +00:00
Konstantin Shcheglov 26d0486de2 Fix serializing metadata when using LimitedBinaryPrinter.
TBR

This also fixes a race condition on Windows, where we sometimes
consume not serialized/deserialized Kernel.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: Ie40534d2562e75c05618e9ccb4fb86fc499184ff
Reviewed-on: https://dart-review.googlesource.com/14260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-10-16 21:57:39 +00:00
Konstantin Shcheglov 6b5ba5351b Implement combining outlines for top-level declarations.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: Id849e68d3026457bdddb98604b92c7424961bbd9
Reviewed-on: https://dart-review.googlesource.com/11649
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-10-13 20:32:24 +00:00
Paul Berry 27f5e7f9ee Remove ClassHierarchy.forEachCrossOverridePair.
This method is no longer needed, since the front end iterates through
members directly to find cross overrides.

Change-Id: Ibc5180962a097c4d6194dbf4cbd1a0dea15050c2
Reviewed-on: https://dart-review.googlesource.com/13582
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-13 20:28:55 +00:00
Régis Crelier ae94cbf3d6 Revert "[kernel] Support generic closures in VM's kernel frontend."
This reverts commit a273ff8314.

Revert "[kernel] Support generic function types in the VM's kernel frontend."

This reverts commit 2cac57da09.

Revert "[kernel] Completely remove type erasure."

This reverts commit 3ffacb3814.

Change-Id: I8fdd40a6a8f34911028353f48249fdd4bf7dba76
Reviewed-on: https://dart-review.googlesource.com/13622
Reviewed-by: Alan Knight <alanknight@google.com>
Commit-Queue: Alan Knight <alanknight@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-10-12 20:01:11 +00:00
Alexander Markov 8e5c172b43 [Kernel, VM] Add internal kernel binary format version
This CL adds internal binary format version to kernel binaries.
Kernel readers in the front-end and VM verify that the reader's format
version matches the format version in the binary file.
This improves detection and diagnostics of stale kernel binary files.

Change-Id: Ic69b16057397a84627040bdd6420ffa1852a4b3f
Reviewed-on: https://dart-review.googlesource.com/13280
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-10-12 16:50:21 +00:00
Samir Jindel 3ffacb3814 [kernel] Completely remove type erasure.
Bug:
Change-Id: I146db24f3f745d9f87560b051f3e57b784de1cb4
Reviewed-on: https://dart-review.googlesource.com/12294
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-12 15:34:21 +00:00
Samir Jindel 2cac57da09 [kernel] Support generic function types in the VM's kernel frontend.
Bug:
Change-Id: I3554562b409b35478437601f34e6263615409b38
Reviewed-on: https://dart-review.googlesource.com/12292
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2017-10-12 14:45:21 +00:00
Dmitry Stefantsov 41f1407ca8 [kernel-f11n] Prove that valid configuration is well-formed
Bug:
Change-Id: Ib7272cbe377f9e8c71ca4d289d170a0cc173ba6b
Reviewed-on: https://dart-review.googlesource.com/12640
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-10-12 14:13:58 +00:00
Dmitry Stefantsov 6a5b0c7b60 [kernel-f11n] Add missing cases of configuration_wf and step
Bug:
Change-Id: I2c521a54a3d45b3908ebe0b6147a5cef1221e040
Reviewed-on: https://dart-review.googlesource.com/12441
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-10-12 14:07:44 +00:00
Dmitry Stefantsov fcd2abfe7b [kernel-f11n] Define the properties of configuration validity
Change-Id: I8f312cb914042a8713eae9171c724708d986e09f
Reviewed-on: https://dart-review.googlesource.com/10540
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-10-12 14:05:13 +00:00
Samir Jindel a273ff8314 [kernel] Support generic closures in VM's kernel frontend.
Change-Id: I0866971dc633c27df55811cba734d7cca0e849d4
Reviewed-on: https://dart-review.googlesource.com/12290
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2017-10-12 13:53:21 +00:00
Paul Berry b474f5e754 Process getters and setters together when creating forwarding nodes.
This will be necessary when we try to integrate type inference with
the creation of forwarding nodes, because getter types can be inferred
from inherited setters and vice versa.

We accomplish this by producing two separate lists (getters and
setters), then merging them together.  This results in a list where
correspondingly-named getters and setters are grouped together, with
getters appearing before setters.

Change-Id: I549f0b4354370753a6aa7a15285d778980fb4841
Reviewed-on: https://dart-review.googlesource.com/12900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-11 14:35:41 +00:00
Vyacheslav Egorov bbc1933705 [Kernel] Report unresolved invocations in kernel/bin/type_check.dart
Bug:
Change-Id: Id95694c687ce0251a887f1a035769b2b796fb2a3
Reviewed-on: https://dart-review.googlesource.com/12661
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-11 06:35:35 +00:00
Alexander Aprelev 87538ffd7e Add vmservice_sdk to target as it is needed in platform.dill to be included into app dill file for Flutter release gen_snapshot
Bug:
Change-Id: I699768ef6f3a315d497bc65c7d713d0c538313ca
Reviewed-on: https://dart-review.googlesource.com/12783
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2017-10-10 21:18:06 +00:00
Vyacheslav Egorov f460586505 [kernel] Implement naive type checker based on pkg/kernel/lib/type_checker.dart
This type checker can be used to find strong mode violations in the
Kernel files.

This will be used to work on cleaning strong mode violations in VM's patch files
in the absence of any other way to type-check them.

Bug:
Change-Id: Id7005f6312dafe04eb0e7b33d008934b62a1b726
Reviewed-on: https://dart-review.googlesource.com/11883
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-10 06:42:02 +00:00
Alexander Markov 0be57ec442 Fix analyzer warning (unused import)
Change-Id: Ief1b570a311bf3a7e0c78744b845f7fff9c5fe20
Reviewed-on: https://dart-review.googlesource.com/12480
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-10-10 01:50:20 +00:00
Alexander Markov 14f6276945 [Kernel, VM] Add null checking to devirtualization
Devirtualization optimization now adds metadata to kernel AST instead
of transforming nodes to Direct* ones. The direct call metadata
provides information about checking receiver for null, while
Direct* kernel nodes do not support null checking.

VM's kernel binary loader is extended to extract arbitrary metadata
from kernel binaries and keep it for flow graph builder.
Kernel flow graph builder is extended to take direct call metadata
into account and generate CheckNull/StaticCall instructions
for devirtualized PropertyGet, PropertySet and MethodInvocation nodes.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I57f56fbf4a8981d33b1571c0d93105cf8ca71d76
Reviewed-on: https://dart-review.googlesource.com/12260
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-10-10 00:50:31 +00:00
Peter von der Ahé 16aa720d27 Remove compiling platform.dill from patch_sdk.dart
This separates compiling platform.dill files from the patch_sdk.dart
script. The motivation for that is that I'm working on reading patch
files directly from Fasta, so we can completely remove the build step
for generating patched_sdk and dart2js_patched_sdk.

Short-term this should allow Paul to add a strong-mode version of
platform.dill without causing to many conflicts with my work on
patches.

Change-Id: I1150845b2986348d4fffe27092701d8a9b57ea54
Reviewed-on: https://dart-review.googlesource.com/11506
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2017-10-06 15:34:37 +00:00
Vyacheslav Egorov 8ee26d8a19 [kernel] Make TypeEnvironment.strongMode into a field instead of getter.
This allows creating strong mode TypeEnvironments without actually subclassing
it.

Make SubtypeTester.isBottom treat Null as Bottom in strong mode.

Bug:
Change-Id: Icdd1a4b736ce0fe839a6ef30cf24487111f32d25
Reviewed-on: https://dart-review.googlesource.com/11882
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-06 15:14:36 +00:00
Paul Berry 039f82f7ed Include generic covariance annotations for type parameters in kernel output.
This was inadvertently left out of f94d3950ad.

Change-Id: Ifc3bbd8358322e112bf6b57fc751570d6101c9b6
Reviewed-on: https://dart-review.googlesource.com/11561
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-05 21:40:53 +00:00
Samir Jindel 3b347f94bc [kernel] Don't erase captured type parameters.
- We no longer erase type parameters of generic non-closures in the body of closures.
- We implement support for captured type parameters in the VM.

Bug:
Change-Id: I4f2f19301df1b44108ab2073332934d5d083e219
Reviewed-on: https://dart-review.googlesource.com/10942
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-10-05 12:45:36 +00:00
Dmitry Stefantsov e3efa299b7 [kernel] Fix addAnnotation method for variables and type parameters
Change-Id: Icd34608da45b9a3ddbf7df1d8aae1868fd01bb87
Reviewed-on: https://dart-review.googlesource.com/11321
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2017-10-05 09:14:20 +00:00
Paul Berry f94d3950ad Include generic covariance annotations in kernel text output.
Change-Id: I81a7b3ea692e94d7e9bbd8562f1771a7626e0715
Reviewed-on: https://dart-review.googlesource.com/10803
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-10-05 05:23:43 +00:00
Alexander Markov 9ee73fe322 [Kernel] Remove outdated and duplicated front-end Targets
This CL replaces outdated VmTarget and FlutterTarget with VmFastaTarget
and FlutterFastaTarget. 'Fasta' suffix is droped from target names.

The new FlutterTarget extends VmTarget, so they share more code.

Change-Id: Id79956698a889c9a49b8a67914f1f96a731407ab
Reviewed-on: https://dart-review.googlesource.com/9423
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-10-04 18:02:49 +00:00
Vyacheslav Egorov a52d4b0f75 [kernel] Extend Kernel with backend specific metadata section
This section contains a linear mapping between offsets of serialized nodes
and associated opaque binary metadata.

Note: this CL does not yet update C++ reader and only implements metadata in Kernel package. 

C++ implementation will be updated if we agree that format seems flexible enough.

Bug:
Change-Id: Id433458afc6c2ea76c72f6a1901b9dc55b8f1696
Reviewed-on: https://dart-review.googlesource.com/9340
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-10-04 15:14:02 +00:00
Dmitry Stefantsov e7a29d8dfb [kernel] Add annotations for type parameters and variable declarations
Bug: http://dartbug.com/30035
Change-Id: Id122c2d6596bfa3505418ac2f65369a16965bce5
Reviewed-on: https://dart-review.googlesource.com/10300
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-04 10:29:23 +00:00
Peter von der Ahé 086f389959 Implementation options with expiration date.
Change-Id: Ie71ca21fb37a036f32fe8ee3348e95ee02089ac7
Reviewed-on: https://dart-review.googlesource.com/9542
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-10-04 07:47:52 +00:00
Paul Berry eb7fc7d158 Tag forwarding stubs with a boolean flag in the kernel representation.
Change-Id: I5cdd05acd79f149b3702f982b1289930078d4e1b
Reviewed-on: https://dart-review.googlesource.com/10620
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-03 17:17:09 +00:00
Samir Jindel 6aa6f43815 [kernel] Pass type arguments to method calls.
Bug:
Change-Id: Ic9a29d7c0fc361a3ce9bff6a6ba648fc5a54c86c
Reviewed-on: https://dart-review.googlesource.com/10140
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-10-03 15:20:30 +00:00
Samir Jindel 195c62ff0c [kernel] Begin reducing type erasure.
1. We no longer remove type parameters on functions.
2. We no longer remove type arguments at call sites.
3. We allow non-captured function type parameters to be used outside closures. 

Bug:
Change-Id: I116ec54c90b04be90e1157042c22797e57a7c51c
Reviewed-on: https://dart-review.googlesource.com/9342
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-03 14:33:30 +00:00
Dmitry Stefantsov 005f998de0 [kernel-f11n] Add skeleton for soundness properties and theorems
Change-Id: I7230398d576f922ef150ec6678fcfda6b9cbfc40
Reviewed-on: https://dart-review.googlesource.com/8620
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-10-03 11:21:57 +00:00
Alexander Markov 1969314cde Avoid devirtualization of invocations of Object members
This CL fixes incorrect devirtualization of invocations of methods and
getters from Object, as null also implements Object members.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I39b2e1dd6147482b1331527d61b76841ae401343
Reviewed-on: https://dart-review.googlesource.com/9742
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-10-02 16:35:56 +00:00
Dmitry Stefantsov 172aecaac8 [kernel-f11n] Move another helper theorem about maps to Common.v
Change-Id: Ice6d0c2c6fec6a9ae525d300799892ca4bb563bc
Reviewed-on: https://dart-review.googlesource.com/9480
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-10-02 15:15:40 +00:00
Dmitry Stefantsov fbf3c4f8f1 [kernel-f11n] Fix operational semantics w.r.t. changes in object model
Recently `member_env` was simplified in the object model, and the
corresponding changes should be done in the operational semantics.
Additionally, the existence theorem now can be fully proven.

Change-Id: I30f86bd5d7e9b89eefc02fd51d928a9af139eee1
Reviewed-on: https://dart-review.googlesource.com/9341
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-29 08:15:03 +00:00
Kevin Moore b7a9f2ae7c Fix SDK constraints on analyzer, front_end, kernel, meta
Prepare to publish meta

Change-Id: I1bc564c68315fb2f27469deda76e75495e42c23b
Reviewed-on: https://dart-review.googlesource.com/9364
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2017-09-28 19:33:27 +00:00
Kevin Moore 6b91739cec Making license files consistent across all packages
Helps with internal license concatenation

Change-Id: I3042ba2ec0ef5fcd35937254827560f8a97c2f8a
Reviewed-on: https://dart-review.googlesource.com/9363
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2017-09-28 19:33:08 +00:00
Samir Jindel ed0590b532 [kernel-f11n] Cleanup to object model.
- Fix force_options so it doesn't take so long to run
- Fix property get typechecking so it forces getters to be synchronized with
  methods.
- Simplify member_env.

Bug:
Change-Id: I3e2a0710c7fde950e7573ba6216820907b9ae374
Reviewed-on: https://dart-review.googlesource.com/9040
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-28 14:20:01 +00:00
Dmitry Stefantsov 1c882d8958 [kernel-f11n] Use getters in operational semantics and update hypotheses
The changes in the object model that introduce getters are reflected in
`value_of_type`, `step`, and `configuration_wf` relationships.  Additionally,
the program well-formedness hypothesis is updated, so that it uses `lib_to_env`
function defined in the object model.  A few other well-formedness hypotheses
are added.  The existence proof for the next configuration is adjusted.

Change-Id: I14ca8aac5830a6ea0fc96f3f37818fdda3fa2c07
Reviewed-on: https://dart-review.googlesource.com/8880
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-28 13:44:10 +00:00
Samir Jindel 77736e83f2 [kernel-f11n] Fix statement typing and complete proof of statement typing consistency.
Previously, we inferred the return type of statements in a way that made it
impossible to prove the statement typing consistency. Now, we use just the
stated return type for checking statements.

The proofs of statement typing are complete, except for one result generalizing
the expression typing consistency result to multiple variables changing; this
result is obvious to see directly from the provided lemmas but very tedious to
prove in Coq.

Bug:
Change-Id: I0bbcfb613df7510015f278fa85021ba0b3e57503
Reviewed-on: https://dart-review.googlesource.com/9020
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-28 13:20:00 +00:00
Dmitry Stefantsov 49996eeb88 [kernel-f11n] Add the opertional semantics spec for Kernel
Change-Id: Ic5780eaf5743e525b8ae646867bc0a60f5bfbbbb
Reviewed-on: https://dart-review.googlesource.com/9260
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-09-28 12:04:25 +00:00
Régis Crelier db8b20107b Revert "Revert "Dart Core Lib change to support generic functions in class NoSuchMethodError.""
This reverts commit 8cf9ef22c4.

The expectations in Dart2js and Kernel tests have now been updated.

Change-Id: I9d65ff207490cfc783849b1b726db81cf56ecfc2
Reviewed-on: https://dart-review.googlesource.com/9124
Reviewed-by: Régis Crelier <regis@google.com>
2017-09-28 00:27:24 +00:00
Régis Crelier 8cf9ef22c4 Revert "Dart Core Lib change to support generic functions in class NoSuchMethodError."
This reverts commit db15f5d73b.

Dart2js and Kernel tests are comparing text that has changed because of
the core lib change.

Change-Id: I1d33716a3d6e6a077aa1f1a9ad7cc37825d31fa6
Reviewed-on: https://dart-review.googlesource.com/9082
Reviewed-by: Siva Chandra <sivachandra@google.com>
2017-09-27 21:08:20 +00:00
Régis Crelier db15f5d73b Dart Core Lib change to support generic functions in class NoSuchMethodError.
Change-Id: If7d1a8c07e4bee7ec68fede80a9d17cae0044d31
Reviewed-on: https://dart-review.googlesource.com/5329
Reviewed-by: Florian Loitsch <floitsch@google.com>
2017-09-27 17:57:41 +00:00
Paul Berry 240fd56709 Change main function in erasure_test to take optional args.
This will allow the test to be run inside google3, where the test
framework calls main with no arguments.

Change-Id: Ia3135b634b4752be816b53209c39d24d72edb6b3
Reviewed-on: https://dart-review.googlesource.com/8960
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-27 16:24:44 +00:00
Samir Jindel cf0d17df57 [kernel-coq] Correct statement of subtyping consistency, extend to statements.
Bug:
Change-Id: I48f073fa592ccdac56fb63b33b7d9961be5fc3fe
Reviewed-on: https://dart-review.googlesource.com/8220
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-27 13:39:05 +00:00
Jens Johansen dc5df933e4 Use kernel indexes to jump past procedure bodies.
Before this CL we skipped procedure bodies in kernel_loader.cc by
parsing the body (but not storing anything).
With this CL we now skip them directly (i.e. don't read them at all)
in kernel_loader.cc by using the newly available extra indexes in kernel.

Change-Id: I48cf0599b2a85102c9008ff7c455785151ef3c9c
Reviewed-on: https://dart-review.googlesource.com/5764
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-27 06:19:35 +00:00
Samir Jindel 1cac4c7924 [kernel-coq] Extend interfaces to contain getters.
Bug:
Change-Id: If8411f356496017cf371349b3edfae3972725662
Reviewed-on: https://dart-review.googlesource.com/8121
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-26 17:39:15 +00:00
Jens Johansen 6982d1d517 [kernel] Make binary.md up to date
0a76d327e3 updated the binary without
updating binary.md.

Bug:
Change-Id: Ia7ba1cec4b45ebf3dca2a1c1db0a1709a881483e
Reviewed-on: https://dart-review.googlesource.com/8521
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-09-26 13:27:52 +00:00
Jens Johansen 308a1af6ab [kernel] Add more random access; don't read procedure bodies up front
This adds more indexes to the kernel format so we know where classes
and procedures starts and stops. This allows for more random access.
E.g. one could now read the program index and jump directly to
library $i_1$, then read the library index and jump directly to class $i_2$,
read the class index and jump directly to procedure $i_3$.

The utilization (in this CL) is to not (always) read the procedure body
up front when loading kernel code on the dart side (ast_from_binary).
The observation is that - when running through the VM - almost none
of the bodies from the platform file are actually used.

This lowers the start-up cost which is noticeable for small programs
(e.g. hello world, or tests).
In this CL this is only done on the dart side and not on the C++ side,
that's for another CL.

Startup time:
dart2js: -1.84253% +/- 1.22157%
hello world: -11.1188% +/- 5.57892%

Running "time python tools/test.py -m release -cdartk language -j6":
real: -11.72% +/- 0.35%
user: -14.59% +/- 0.24%
sys: -12.71% +/- 0.61%

File size change (compiling with fasta to dill file incl. platform):
hello world: 0.88% (35,934 bytes).
dart2js: 0.97% (200,967 bytes).

Change-Id: I1f0ec121bc75bb17f11d3fade03da9815037d0bb
Reviewed-on: https://dart-review.googlesource.com/5262
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-09-26 08:14:17 +00:00
Paul Berry d9ca760992 Start writing the infrastructure for creating forwarding stubs.
This CL adds the ability to create a list of "forwarding nodes" for a
source class.  A forwarding node is a data structure that will later
be resolved to either an explicitly declared member in the class or a
superclass, or to a forwarding stub.  The idea is that we will create
the forwarding nodes at the time of outline building, and later,
during type inference, we will resolve each forwarding node as it is
encountered.

The reason we need to defer resolution of the forwarding nodes until
inference is because we may need to use the results of type inference
to determine which member a given forwarding node resolves to.  For
example:

num f() => 1;
class A {
  final x = 1; // Inferred type: int
}
class B {
  final x = f(); // Inferred type: num
}
abstract class C implements A, B {}

We cannot determine at the time of building the outline for C whether
it inherits its x from A or B, because we need the results of type
inference to determine which of the two x's has a more specific type.

Note that some refactoring of ClassHierarchy was necessary in order to
allow the front end to maintain member lists in the same order used
internally by ClassHierarchy.  This will let us avoid unnecessary
redundant sorting of methods.

Change-Id: Iee754957e0ad3b16c4b60608e17a4a7b0006dfb4
Reviewed-on: https://dart-review.googlesource.com/7851
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-09-25 20:59:49 +00:00
Konstantin Shcheglov 04ba26d638 Write/read fileOffset for LibraryDependency.
This should take care of some or all flaky tests like:
TypePropagationTest_Kernel | test_forEach_async_inheritedStream

What was happening is that every tests adds /test.dart to AnalysisDriver,
which means that this file is scheduled for analysis at some point,
and then it also calls getResult() to get the resolved unit. When we
resolve the file for the first time, the ByteStore is empty, so we
build the corresponding Kernel file from scratch, and it has the offset.
But the second time we read the Kernel file from ByteStore. So, if we
manage to process the file as added first, and then as getResult(),
we fail because we cannot resolve the import directive. But if we
were not able to process the file as added, and just do getResult()
first (which also marks the file as added as ready), we succeed.

So, it was flaky.


R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug: https://github.com/dart-lang/sdk/issues/30863
Change-Id: I96151e3ebefcd212f2a7a1b2b22abb7d87ed4781
Reviewed-on: https://dart-review.googlesource.com/7782
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-09-22 19:47:07 +00:00
Paul Berry f1665714a5 Move batch_util.dart into pkg/kernel/lib/.
This will allow tests that use batch_util.dart to be run inside
google3, where package layout conventions are more strictly enforced
(files in test/ cannot import files in bin/ or vice versa).

Change-Id: I046b864bc3b1c4e78b984b0047b7567873146c52
Reviewed-on: https://dart-review.googlesource.com/7340
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-22 16:52:07 +00:00
Paul Berry 5dd63f9fdc Implement proper subtype check for promoted bounds in kernel.
Note that the parser used for unit tests in kernel didn't have a
notation for promoted bounds.  I chose `T & A` to mean "type parameter
T with promoted bound A", following Leaf's convention (the rationale
is that semantically, a promoted bound functions like an intersection
type).

It was also necessary to change the test infrastructure so that we
could specify the (non-promoted) bounds of type parameters when
running a subtype test.

Fixes #30833.

Change-Id: Ic62722df63c5ed5288b23560745a1cd0869b63fb
Reviewed-on: https://dart-review.googlesource.com/7628
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-22 15:37:19 +00:00
Samir Jindel b75f1baaf2 [kernel-coq] Cleaning up and exposing program well-formedness proof.
Bug:
Change-Id: If55a527f439a7bec39f2d286a582cb606efdabfb
Reviewed-on: https://dart-review.googlesource.com/7554
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-22 11:55:53 +00:00
Dmitry Stefantsov 5daf3c6d9d [kernel] Add the theorem about existence of next configuration
* The definition of the well-formedness property for
  configurations is added.
* The theorem that states that the abstract CESK-machine can
  make one transition step from any well-formed configuration
  is defined and proven.
* Execution of a variable declaration statement is added to
  the operational semantics formalization with all necessary
  changes (one new eval configuration, three new transition
  rules).
* Some auxiliary theorems are added. One of them states that
  any runtime value has its method bodies in the function
  environment.

Change-Id: I95f233a4db498ce0df76983d9e605c3c263100bb
Reviewed-on: https://dart-review.googlesource.com/7266
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-22 08:55:43 +00:00
Kevin Millikin 785ae4a9e0 [Kernel] when transferring libraries, keep their canonical names
Before: ownership of some or all of the libraries from one Kernel
program (P1) would be transferred to another program (P2).  All the
canonical names in P1 would be unbound from their references and the
canonical names would eventually be recreated for the libraries that
were transferred.

After: when ownership of a library is transferred, the ownership of
the canonical name subtree rooted at the library's name is also
transferred.  This allows the 1:1 relationship between Canonicalname
and Reference to be maintained which will enable lazy deserialization
of procedure bodies (because the mapping from CanonicalNames to
References in the corresponding link table will be persistent).
Change-Id: I98f975d6ba5804f975c30528a484756b39f09d2a
Reviewed-on: https://dart-review.googlesource.com/7549
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-09-22 08:19:27 +00:00
Samir Jindel 4087297d4a [kernel-coq] Proof for program well-formedness.
Bug:
Change-Id: I614d967fc0386c2c4cb0c56586f7f7c2e50b033a
Reviewed-on: https://dart-review.googlesource.com/7362
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-21 14:00:43 +00:00
Peter von der Ahé 9baee97ea2 Revert "Add NamedNode.nameOffset, fill it for constructors, and use in Analyzer."
This reverts commit 9a8621b60a.

Revert "Rework getElement() in resynthesizer."

This reverts commit e4fa080f69.

Revert "Create (empty) initializers for parameters resynthesized from Kernel."

This reverts commit 8df6c79b9d.

Revert "Run NonErrorResolverTest in strong mode. Extract not strong tests."

This reverts commit 9bdda4b1d3.

Revert "Move TypeProvider creation into KernelResynthesizer and create loadLibrary functions."

This reverts commit c59eaf1788.

Revert "Return SimpleIdentifier or PrefixedIdentifier from _buildIdentifier()."

This reverts commit 6d0515f9ca.

Change-Id: I1099ca715ce6287ab56808b7cc3abe0589e939c1
Reviewed-on: https://dart-review.googlesource.com/7550
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-09-21 12:19:47 +00:00
Konstantin Shcheglov 9a8621b60a Add NamedNode.nameOffset, fill it for constructors, and use in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: If0f815e86049381e9db3386f243789e9b4f9f5ce
Reviewed-on: https://dart-review.googlesource.com/6780
Reviewed-by: Paul Berry <paulberry@google.com>
2017-09-20 17:54:30 +00:00
Paul Berry a8afd3ab16 Remove reified_dart.dart, batch_consistency.dart, and dartk.dart.
These files all have to do with the old "dartk" front end, which is no
longer used.

Change-Id: I67041bf0a3a8a9213153123d9f79ac1632cc4d24
Reviewed-on: https://dart-review.googlesource.com/7101
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-20 15:33:16 +00:00
Samir Jindel 8ebdd7662f [kernel-coq] Build class and function table, allow mutually recursive functions and classes.
Bug:
Change-Id: I0d1fb82bccdf8174e4ab5ffdd38301600ecf4dd2
Reviewed-on: https://dart-review.googlesource.com/6620
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-20 12:51:34 +00:00
Paul Berry 2d74043f3a Implement type promotion of type parameter bounds.
Fixes #30804.

Change-Id: I16094e54514b2109fda4b388083d2467a0b11bc7
Reviewed-on: https://dart-review.googlesource.com/7105
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-19 23:19:46 +00:00
Paul Berry a811daca97 Add serialization/deserialization for parameter type check annotations.
Change-Id: I8a156de8f0b73606172f8a4ab48c595b92116aeb
Reviewed-on: https://dart-review.googlesource.com/4604
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2017-09-19 02:07:29 +00:00
Dmitry Stefantsov 2aef206f3f [kernel] Add the first draft of Kernel operational semantics in Coq
The semantics is defined for a small subset of Kernel.

Change-Id: I39b72c5671e9ca0dee86a5a6068fe745ad1728f1
Reviewed-on: https://dart-review.googlesource.com/5860
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-18 15:16:23 +00:00
Samir Jindel 09f891b89b [kernel] Generalization of type equivalence to subtyping.
This revision includes changes from:
- [kernel] Completion of consistency proofs for type system of first subset of kernel.
due to the suckiness of gerrit.

We generalize type equivalence to subtyping. The contravariant property of
function parameter types causes properties for the totality checker. To
cicumvent this, we define a well-ordered relation on pairs of dart types and
prove subtyping respects it. We develop new lemmas and tactics for managing
proofs involving subtyping, includinging factoring out the messy business of
dealing with its convoluted recursion scheme.

Bug:
Change-Id: I18936168006617874a82eefc983f1b2d4d8af5af
Reviewed-on: https://dart-review.googlesource.com/5861
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-18 11:47:31 +00:00
Samir Jindel 12c4b62be8 [kernel] Completion of consistency proofs for type system of first subset of kernel.
Bug:
Change-Id: I5ae6fa1ddbb79b6f9dfecb53762b7ee5660c9117
Reviewed-on: https://dart-review.googlesource.com/5746
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-18 11:37:03 +00:00
Jens Johansen 4d55a6779e [kernel] Offset on IfStatement
Bug:
Change-Id: I40acad4d9f66da0324dcf7da95aab05c0784faac
Reviewed-on: https://dart-review.googlesource.com/5661
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2017-09-18 09:31:09 +00:00
Alexander Markov 8a368a1a4c [Kernel, VM/AOT] Avoid DirectMethodInvocations to getters or fields
This CL changes devirtualization to detect corner case of a method
invocation which is resolved to a getter or a field. This kind of
invocation should call getter first, and then call 'call()' method on
the result of the getter, passing the rest of the arguments.

For simplicity, devirtualization of such method invocations is avoided.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ibe6321931cbb5527a26b139c5f1ee9773a253629
Reviewed-on: https://dart-review.googlesource.com/5902
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-09-15 16:15:12 +00:00
Paul Berry 034a8f37a4 Rework terminology and representation of covariant checks.
Instead of using enums, we use booleans, and we change the terminology
as follows:

FormalSafety.semiSafe     -> isGenericCovariantImpl
InterfaceSafety.semiTyped -> isGenericCovariantInterface

(The enum value FormalSafety.unsafe turned out to be redundant with
isCovariant, so it is no longer needed).

Similarly, the annotations in the front end tests are updated as follows:

@checkFormal=unsafe       -> @covariance=explicit
@checkFormal=semiSafe     -> @covariance=genericImpl
@checkInterface=semiTyped -> @covariance=genericInterface

Change-Id: Iafc0c5d3fc4e7608a2b8c52d8c29f293d9219995
Reviewed-on: https://dart-review.googlesource.com/5540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-15 15:43:50 +00:00
Kevin Millikin 3df5cfa614 Add a reference interpreter in Standard ML
It's sometimes easier to read SML than text.  This is the higher-order
interpreter, we have plans for a first-order version.

Bug:
Change-Id: Ic6bcc989e6a544889d0ff3eefac266bd54f9489b
Reviewed-on: https://dart-review.googlesource.com/5420
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-15 10:42:44 +00:00
Konstantin Shcheglov 0a76d327e3 Resynthesize LibraryElement documentation from Kernel.
R=brianwilkerson@google.com, paulberry@google.com

Bug:
Change-Id: I24fe6be8c27b0182eb859073cd9cba498065d23b
Reviewed-on: https://dart-review.googlesource.com/6081
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-09-15 03:47:57 +00:00
Samir Jindel 79386c100e [kernel] type_equiv proof for property_get case.
Bug:
Change-Id: Ibbaabc8ca7652eef1077fc743a9d0927a1c7911a
Reviewed-on: https://dart-review.googlesource.com/5461
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-14 12:56:40 +00:00
Jens Johansen f0665e33f3 [kernel] Fix mistake in binary.md
A Block contains Statements, not Expressions.

Bug:
Change-Id: I02dfc9725e15e39c8e1b5ae3056cfa321778ecde
Reviewed-on: https://dart-review.googlesource.com/5660
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-14 10:18:20 +00:00
Jens Johansen 493876a2b3 [kernel] Writing ints as such, reading bytes as such.
While writeByte(0) can be read with readUint() (and writeUInt30(0) can be
read correctly with readByte()) it's probably better to use
writeUInt30/readUInt as a pair and writeByte/readByte as a pair.

Change-Id: I3e638c1de0bd66b112cfa1370a54412e876dca5a
Reviewed-on: https://dart-review.googlesource.com/4720
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-09-14 09:52:37 +00:00
Samir Jindel 184d1959c5 [kernel] Proofs about type equality, beginnings of the type checking homomorphism proof.
I also added mutual induction schemes for types and expressions.
Some changes from the "Cleanup" revision are in here as well because Gerrit is terrible.

Bug:
Change-Id: I0859a6c1cba8179e0a64cc0455ab2a83fad8f26b
Reviewed-on: https://dart-review.googlesource.com/5300
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-13 12:00:19 +00:00
Samir Jindel a71d91ea62 [kernel] Cleanup of object model and coq.dart.
Bug:
Change-Id: I4a93d2ab0a052b61d3819d04316c05f534057f02
Reviewed-on: https://dart-review.googlesource.com/5266
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-13 11:43:30 +00:00
Konstantin Shcheglov cb2fba6dbc Serialize and print typedef annotations.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: Icb3a4452603753de645b3fb4280152799f26bb61
Reviewed-on: https://dart-review.googlesource.com/5323
Reviewed-by: Paul Berry <paulberry@google.com>
2017-09-13 03:56:49 +00:00
Samir Jindel 5e32e1a6d4 [kernel] Fix analyze_test on coq.dart.
Bug:
Change-Id: I1538ce55d1fc89e342ed7e1d25bf38e9354dfed8
Reviewed-on: https://dart-review.googlesource.com/5267
Reviewed-by: Emily Fortuna <efortuna@google.com>
2017-09-12 17:39:27 +00:00
Konstantin Shcheglov e1d47bd889 Serialize trimmed outlines without damaging Program.
R=ahe@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: I19b6debeb629b83af071e6a0d4f97b46096d83f5
Reviewed-on: https://dart-review.googlesource.com/5141
Reviewed-by: Paul Berry <paulberry@google.com>
2017-09-12 17:23:20 +00:00
Samir Jindel 474c075794 [kernel] Simplified Coq AST and first draft of it's type system.
Details to come in discussions.

Bug:
Change-Id: Ia50d85dd27cde83e25086f64dc6746cc52036128
Reviewed-on: https://dart-review.googlesource.com/4941
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-12 16:23:16 +00:00
Samir Jindel 95c5b043fb [kernel] Infrastructure for the Coq formalization.
Summary:

Common datastructures used by both the Kernel AST definition and the object
model are factored into a shared module. A monad for partial computation is
defined to allow us to factor out termination proofs and syntactic validity
checks from the type checking and subtyping relations.

Test Plan:

Ran through coqc.

Bug:
Change-Id: I884666d7cc5b757d62541a46b868f8579a06f011
Reviewed-on: https://dart-review.googlesource.com/4700
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-11 17:22:14 +00:00
Konstantin Shcheglov f9f33c7578 Fix for reading VariableDeclaration flags.
As requested in https://dart-review.googlesource.com/c/sdk/+/4080/1/pkg/kernel/lib/binary/ast_from_binary.dart#1379

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: I7bd5158fcafc40d82a8c0a1a54a281e51414208c
Reviewed-on: https://dart-review.googlesource.com/4520
Reviewed-by: Paul Berry <paulberry@google.com>
2017-09-08 17:45:37 +00:00
Alexander Markov 0d77b0b61d [kernel] Clean up warnings to fix fasta/analyze_test
This is the follow-up to 1989edb06e.

Change-Id: I1e3118475f2cef68b5d7e1ddd624b5b8163d7633
Reviewed-on: https://dart-review.googlesource.com/4100
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-09-07 18:22:44 +00:00
Alexander Markov 1989edb06e [kernel] Add VM precompiler target and devirtualization optimization
This CL adds a new target for kernel front-end, vm_precompiler. This is
an experimental target for new Dart VM precompiler pipeline which
will fully exploit strong mode type system and perform whole-program
optimizations.

As an example of such whole-program optimization, this CL adds
draft implementation of devirtualization of method invocations, which
uses single target computed by closed-world class hierarchy analysis.
Corresponding null checks (required for correctness) are not generated
yet.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I704cd16843a08f036a188b1188c80ee4dfbeab3b
Reviewed-on: https://dart-review.googlesource.com/3402
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-09-07 16:54:33 +00:00
Dmitry Stefantsov 1132579731 Add the first draft of the object model formalization in Coq
Change-Id: I6c1a79f23d7a8327766cc450d4c0d6e1b1a5902a
Reviewed-on: https://dart-review.googlesource.com/3921
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-07 14:08:00 +00:00
Samir Jindel e42b4e6456 Remove unused import.
Fixes fasta analyzer test.

Bug:
Change-Id: I1ecc739be3eb5b72fdeba835d2d7fc05ef21c06c
Reviewed-on: https://dart-review.googlesource.com/3621
Reviewed-by: Karl Klose <karlklose@google.com>
2017-09-06 14:58:32 +00:00
Samir Jindel 4cefd6476b Don't run verifier after transforms as it's currently broken.
Bug:
Change-Id: I761c65c409553deb33fd398403491b86a3752dda
Reviewed-on: https://dart-review.googlesource.com/3541
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-06 13:20:27 +00:00
Jens Johansen bb33a42e72 [kernel] Give random access to included source
Before this CL to read the source (and line endings etc) for a specific
file index, one had to read at least part of the data for all previous
file indexes (e.g. read all the line endings).

This CL introduces an index to the included sources meaning that we have
random access based on file id, i.e. can go to the data concerning a
specific file id in constant time.

Benchmarks run with "time python tools/test.py -m release -cdartk language -j6"
shows that - of 5 runs - the runtime has changed as follows:

real: -3.93% +/- 1.03%
user: -3.41% +/- 0.54%
sys: No difference at 95%

(statistics by math stolen from ministat)

So it is ~4% faster to run the language tests (with above command),
shaving approximately 9 seconds off the real runtime.

Change-Id: I9e60a16958356b16b3da0bf6c01ffc5619deb976
Reviewed-on: https://dart-review.googlesource.com/3180
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-06 11:59:17 +00:00
Jens Johansen d854c77e58 [kernel] Only serialize non-external libaries and sources from those.
Previously the VM couldn't handle external libraries, but that was
fixed in 2f49198520.

Part of the CL was reverted though because the compilatin was changed
to using an outline instead of the platform which doesn't work.
What does work though, is not including the external libraries in the
output.

This CL makes the following changes:

* Don't include external libraries in the output (by not setting all
  libraries to be non-external).

* Only writes the sources actually used to the binary (i.e. whatever
  libraries left out because they were external will not contribute
  source code either).

* Cleanup of now unused code.


Timings (only run once though):


Without this CL (but with the CL it's based on):

$ time python tools/test.py -m release -cdartk language -j6
Test configuration: dartk_vm_release_x64
[05:43 | 100% | + 3504 | -    0]

real    5m43.597s
user    33m48.152s
sys     9m34.140s


Only the "utils/kernel-service/kernel-service.dart" part of this CL:

$ time python tools/test.py -m release -cdartk language -j6
Test configuration: dartk_vm_release_x64
[04:55 | 100% | + 3504 | -    0]

real    4m55.684s
user    29m54.360s
sys     8m7.408s


Entire CL:

$ time python tools/test.py -m release -cdartk language -j6
Test configuration: dartk_vm_release_x64
[04:20 | 100% | + 3504 | -    0]

real    4m20.416s
user    27m17.320s
sys     6m53.472s

Change-Id: Ie9c5bfa958e558a5007784e821a0b58d417bae55
Reviewed-on: https://dart-review.googlesource.com/3161
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-06 11:56:24 +00:00
Jens Johansen 3e599229b9 [kernel] Don't scan strings up front when serializing.
Currently serializing the ast for kernel is done in two passe:

1) Scan the program to find and index all strings. These are then
   sorted based on frequency and assigned an id. All string-
   references are refering to that id. As small numbers use less
   space in the binary than big numbers, sorting the numbers by
   frequency saves a certain amount of space.
   In addition the string indexing is "hijacked" for the
   "LimitedBinaryPrinter" to also perform some CanonicalName
   re-indexing.

2) We then serialize the entire thing.

This CL gets rid of a pass by not indexing the strings up-front.
Whenever it is asked to serialize a string it adds it to the index
(if not already there). The serialization is otherwise the same.
This means that:

1) Strings are not sorted by frequency, i.e. the binary output size
   can by bigger (numbers below).

2) The stringindex and canonical names are moved to the end of the
   binary instead of the front. As we still need it up front for
   deserialization some additional data is added to the
   ProgramIndex.

3) The "hijacking" done in "LimitedBinaryPrinter" is replaced by
   an alternative.

4) We don't spend time on walking the tree twice.

The cost is the binary size. Compiling helloworld with fasta,
as well as looking at outline.dill, platform.dill and
vmservice_io.dill reveals these numbers:

* helloworld.dill is 0.657248732% bigger (26573 bytes)
* outline.dill is 1.686911399% bigger (9395 bytes)
* platform.dill is 0.657062238% bigger (26565 bytes)
* vmservice_io.dill is 0.44991899% bigger (19147 bytes)

The cost does thus not appear to be very big.

The gain is the serialization time.

From 20 runs of an instrumented VM/serialization, running numbers
through calculations stolens from ministat
(https://www.freebsd.org/cgi/man.cgi?query=ministat) reveals the
following:

* Serialization time: -21.69% +/- 1.44%

* Total time spend in relevant parts of bootstrap_nocore.cc,
dart_api_impl.cc (Dart_LoadKernel), bootstrap_nocore.cc,
dart_api_impl.cc (LoadKernelProgram) as well as serialization:
-14.01% +/- 1.58%

From 5 runs of
"time python tools/test.py -m release -cdartk language -j6"
(again run through ministat calculations):

* real: -4.18% +/- 0.5%
* user: -4.2% +/- 0.29%
* sys: No difference at 95%
* user+sys: -3.3% +/- 0.36%

Change-Id: I1c220eac083496994f0a9f1e2a2445b3707c9a93
Reviewed-on: https://dart-review.googlesource.com/2880
Reviewed-by: Samir Jindel <sjindel@google.com>
2017-09-06 11:55:16 +00:00
Konstantin Shcheglov 50e1444644 Fix fuzzy arrow warnings in kernel.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Change-Id: Iea7360e5c80342e303ff1bd261754676ac3a057a
Reviewed-on: https://dart-review.googlesource.com/3081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2017-09-05 17:07:46 +00:00
Samir Jindel ae8c6a9afe Dart Kernel AST in Coq
Summary:

We use a modest set of annotations in ast.dart to describe how the Kernel AST
should be converted into Coq definitions.

We define a Kernel transformation that converts the kernel tree of ast.dart into
a valid Coq file containing the corresponding definitions.

Currently generating the Coq file is not done in the build system because
compiling it requires having Coq installed, and I don't want to introduce a
depedency on Coq into the build system.

Some parts of the AST are not represented because they don't significantly
contribute to the typing semantics:

- asserts
- typedefs
- most literals/basic types (excl. bool, which is needed for "is" tests)
- switch
- for-in
- parts
- yield/await

Test Plan:

Ran the output KernelSyntax.v file through "coqc".

Change-Id: Ic573163a017eaaf3759b741b9eec5ce3ce19225c
Reviewed-on: https://dart-review.googlesource.com/2960
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2017-09-05 13:22:26 +00:00
Paul Berry d9de63eb81 Disable supermixin support in front end and kernel.
Supermixin support is not currently planned for the initial release of
Dart 2.0, so it seems unwise for front end and kernel to enable it.

Kernel didn't actually contain any usages of supermixin support; front
end contained one usage in a test.

Change-Id: I2b225f8d6c5f0ea32cb60d7636e043c89439548c
Reviewed-on: https://dart-review.googlesource.com/3020
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-04 18:50:17 +00:00
Peter von der Ahé b460a25459 Store actual Reference(s) for additional exports.
R=johnniwinther@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/3009953003 .
2017-09-01 16:30:43 +02:00
Samir Jindel f0941f7c7d Improve the performance of closure-converted code.
Summary:

Previously, we would create a wrapper function in the flowgraph around converted
closures, which would forward all the closure's arguments and unpack the context
argument before calling the real closure function.

Now, we perform the unpacking at the top of the real function to avoid having
any wrapper function.

Previously, captured parameters would still be appear live to the GC even if
they're updated, because after they are copied into the context, all updates to
them are done there.

Now, as in regular closures, we zero-out the parameter variable after copying
it's value into the context, avoiding potential memory leaks.

Test Plan:

Ran the closure conversion test suite.
Ran benchmarks on Golem -- all statistically significant regressions are gone.

BUG=
R=dmitryas@google.com, regis@google.com

Review-Url: https://codereview.chromium.org/3008923002 .
2017-09-01 14:59:40 +02:00
Peter von der Ahé f0277b32e8 Revert "Store actual Reference(s) for additional exports."
This reverts commit 234c4a7f49.

Revert "Fix for ScopeBuilder[] - look into setters too."

This reverts commit 7924f4c42f.

Revert "Don't include BuiltinTypeBuilder(s) into additional exports."

This reverts commit e28aac09c4.

The reason for reverting is that the two follow-up commits aren't correct.

R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/3004973002 .
2017-08-31 16:13:50 +02:00
Paul Berry 1c57563a31 Proposed kernel AST changes for annotating parameter type checks.
This proposal just describes the API to the AST classes; it does not
introduce any serialization/deserialization code, nor does it try to
represent the annotations in a compact way.

In the final implementation we will probably want to make use of
bitfields; e.g. the new fields VariableDeclaration.formalSafety and
VariableDeclaration.interfaceSafety should probably be replaced with
getters and setters that access bits in VariableDeclaration.flags.

R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/3008853002 .
2017-08-30 12:52:32 -07:00
Konstantin Shcheglov 234c4a7f49 Store actual Reference(s) for additional exports.
We need this to be able to tree shake outline.
https://github.com/dart-lang/sdk/issues/30448#issuecomment-325434406

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/3008763002 .
2017-08-30 09:56:21 -07:00
Konstantin Shcheglov 80b16d6a88 Fixes for AST <-> binary serialization.
I'm working on changes for KernelDriver to use Bazel-like model with
tree shaking, and noticed these problems, because in this new model
we serialize and deserialize kernels.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/3008843002 .
2017-08-29 16:57:29 -07:00
Paul Berry 017a1f4eff Revert "Fix forEachOverridePair in the case where the class in question is abstract."
This reverts commit e81deebfd8.

My reasoning in the above commit was wrong.  Consider the following code:

class A {
  void foo() {}
}
abstract class B extends A {
  void foo([x]);
}
class C extends B {}
main() {
  B b = new C();
  b.foo(42); // BAD: A.foo can't accept arguments.
}

To ensure soundness, this code needs to be disallowed, and the current
mechanism for doing that is to use forEachOverridePair.  Note that
forEachOverridePair is a bit of a misnomer; in addition to yielding
all pairs of methods (M1, M2) for which M1 overrides M2, it also
yields pairs of methods (M1, M2) for which the target class inherits
the concrete implementation M1, and M2 is part of the interface.
Technically this latter case is not an "override" but rather an
"implementation" (thanks to Lasse for pointing out this distinction).
However in both cases we need to do the same compile-time check to
ensure soundness: we need to check that the type of M1 is a subtype of
M2 (unless the check is suppressed by a "covariant" keyword).  Hence
it makes sense for forEachOverridePair to cover both cases.

To ensure that the above example is properly rejected, it is crucial
that some invocation of forEachOverridePair yield the pair (A.foo,
B.foo).  Prior to e81deebfd8,
forEachOverridePair(B) would not yield this pair, but
forEachOverridePair(C) would.  After
e81deebfd8, both calls yield this pair.

When I made e81deebfd8, I failed to
notice that forEachOverridePair(C) would yield the pair, so I thought
there was a problem.  So my "fix" was unnecessary.  And it created a
fresh problem: it meant that the following code would be disallowed:

class A {
  void foo() {}
}
abstract class B extends A {
  void foo([x]);
}
class C extends B {
  void foo([x]) {}
}
main() {
  B b = new C();
  b.foo(42); // OK: C.foo can accept an argument.
}

There is no a priori soundness reason for rejecting this code, and
according to Lasse, it has not yet been decided whether Dart 2.0 will
allow it.

This CL restores the old behavior.  Rather than remove the test case
in e81deebfd8, it modifies it to
demonstrate why the old behavior was correct.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3004023002 .
2017-08-29 14:46:15 -07:00
Peter von der Ahé 6eff945874 Mark top-level error field as static.
Closes https://github.com/dart-lang/sdk/issues/30431

R=sjindel@google.com

Review-Url: https://codereview.chromium.org/2999033002 .
2017-08-29 12:39:00 +02:00
Paul Berry e81deebfd8 Fix forEachOverridePair in the case where the class in question is abstract.
ClassHierarchy.forEachOverridePair contains special logic for unusual
cases like this one:

class A {
  void foo() {}
}
class B extends A {
  void foo();
}
main() {
  B b = new B();
  b.foo();
}

In this case, A.foo is considered to override B.foo (contrary to the
usual situation where the derived class method overrides the
superclass method).  The reasoning is that calling foo on a concrete
instance of B will cause A.foo to be executed (as illustrated in
main); therefore A.foo is callable via the interface of B.foo, thus in
a sense A.foo "overrides" B.foo.

The code contained a questionable optimization, however; it only
executed this special logic if the derived class was concrete.
Presuambly the reasoning was that if B were abstract, then a concrete
instance of B could never be created, so this situation could never
arise.

However, there is nothing to stop a concrete class from being derived
from B, e.g.:

class A {
  void foo() {}
}
abstract class B extends A {
  void foo();
}
class C extends B {}
main() {
  B b = new C();
  b.foo();
}

Now, calling foo on a concrete instance of C will cause A.foo to be
executed (as illustrated in main); therefore A.foo is callable via the
interface of B.foo, as before.  So we still need to report this as an
override pair even though B is abstract.

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2998383002 .
2017-08-28 11:48:59 -07:00
Samir Jindel 7bf835b9d5 Fix many bugs with closure conversion in checked mode.
Summary:

Previously, we use the "Vector" type in the kernel tree for the result of the
"VectorCreation" operation as as the parameter type for converted closure
functions. In the VM, we use the "Context" type instead, which the VM treats a
little differently than normal Dart-visible types, and it doesn't not handle
type checks against it correctly, breaking all closure converted code running in
checked mode.

Now, Since we are forced to use dynamic to represent the types of elements of
the context, we may as well just use dynamic for the context type itself.

Previously, we did not correct handle converted closure type checks for closures
that capture type parameters. The way we handled these type checks also had
several latent bugs that prevented type parameters being handled properly.

Now, we handle type parameters for converted closures similarly to normal
closures, and the places we treat them specially are fewer and more integrated
with the rest of the closure type checking code.

There is still a problem where assignments to captured variables are not
checked, because they are transformed to assignments into the context, whose
elements are necessarily untyped. This breaks many co19 tests, which expect type
errors on these assignments. The example below should error in checked mode, but
after closure conversion is runs with no errors.

int b;
bool c;
(() { b = c; })()

Test Plan:

- All test cases in "pkg/kernel/testcases/closures" now run in checked mode.

- Added a test "closures_types.dart" to check that captured type parameters are
  handled correctly in the converted closures' signature types.

R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/3007623002 .
2017-08-28 17:39:32 +02:00
Jens Johansen 1ad24e4b46 [kernel] Add offset to SwitchContinueStatement; add debugging test
BUG=
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/3004693002 .
2017-08-28 12:01:03 +02:00
Paul Berry 41dcc04a80 Expose getInterfaceMembers method through ClassHierarchy.
The front end will need to use this method to iterate through the
interface of a class in order to determine when to create forwarding
stubs.

The functionality already exists; this CL merely exposes it and adds
tests.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/3003913002 .
2017-08-25 13:57:01 -07:00
Brian Wilkerson f64000374d Update pubspecs prior to publishing
R=devoncarew@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/3006623002 .
2017-08-25 13:24:17 -07:00
Jens Johansen 2ba6cce387 [kernel] Position on switch expression
BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/3003863002 .
2017-08-25 13:54:40 +02:00
Zhivka Gucevska 984382b64e Add support for catch statements.
BUG=
R=ashlaura02@gmail.com, dmitryas@google.com

Review-Url: https://codereview.chromium.org/3002003002 .
2017-08-25 13:53:54 +02:00
Samir Jindel 7b53e209c5 Fix several bugs in closure conversion.
Summary:

1. Previously, in 'BuildGraphOfConvertedClosureFunction', the VM was unable to
   correctly forward parameters to converted closure functions when
   they were captured in the converted function's body. This could happen when, for
   example, a closure was introduced into it by async conversion.

   Now, this is fixed by an approach that mirrors the technique in
   'BuildGraphOfFunction'.

2. Previously, local variables declared inside loop bodies were being saved in
   the loop's enclosing context, so closures within the loop would see new
   values initialized to the variable in subsequent iterations.

   Now, this is fixed by creating nested contexts for all loops, regardless of
   whether the loop variables are captured.

3. Previously, arity checks were not being performed on converted closures, so
   they could be called with too few or too many arguments. In the former case, the
   missing arguments would be filled in with garbage on the stack.

   Now, the assembly generation in 'CompileGraph' inserts argument count checks
   for converted closures as well as regular closures.

Test Plan:

Introduced new tests in the closure conversion suite to test each bug:

1. syncstart.dart
2. loop2.dart, blocks.dart, updated for_in_closure.dart
3. arity.dart

With these changes, closure conversion passes all co19 tests in non-checked mode, except those that are not passed without it:

python tools/test.py -m release -c dartk --vm-options "--reify --reify_generic_functions" co19

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/3000333002 .
2017-08-24 20:21:28 +02:00
Konstantin Shcheglov 827075befb Store the covariant keyword flag for parameters and fields into Kernel and resynthesize in analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/3008463002 .
2017-08-24 07:17:36 -07:00
Zhivka Gucevska c237e6dbcd Fix initialization of instance fields.
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/3002013002 .
2017-08-21 18:54:33 +02:00
Zhivka Gucevska 3cac905c54 Implement support for property accessors
- Evaluation of PropertyGet expression by accessing a field,
 execution of a getter or creating a method tearoff.
 - Evaluation of PropertySet expression by setting a field or
 execution of a setter.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2999673002 .
2017-08-21 08:38:47 +02:00
Zhivka Gucevska e89bbf96a5 Implement support for static accessors
- Evaluation of StaticPropertyGet expression by reading a value stored in
the main environment, execution of static getter or creating a method tear off.
- Evaluation of StaticPropertySet expression by modifying the value
stored in main environment or execution of static setter.

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

Review-Url: https://codereview.chromium.org/2997563002 .
2017-08-21 08:24:18 +02:00
Zhivka Gucevska e09b3830cf Add support for function declarations and function expressions
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2997443002 .
2017-08-21 07:52:20 +02:00
Samir Jindel 402e6f492d [kernel] Fix bug with redirecting constructors in closure conversion.
Previously, the captured variable analysis did not provide sufficient
information for the conversion phase regarding variable uses in initalizers: in
particular, it did not differentiate the case when a variable is used in an
initializer and captured in the body vs. being captured in the body and not used
in an initializer. In addition, there were a few bugs stemming from the use
of lazy iterables and OR conjunctives with effectful operations.

Now, we separate the information about which variables are captured from flags
indicating whether variables are used in initializers. The other bugs are fixed
in obvious ways.

Finally, we reintroduce some code that ensures that redirecting factory
constructors listed in "_redirecting#" field (a hack used when writing DILL
files) remain with one-expression bodies after closure conversion.

Test Plan:

Added a test case for the initializers bug, ensured that the patched SDK builds
with closure conversion always-on.

Reviewers: dmitryas@google.com

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2995083002 .
2017-08-17 18:15:44 +02:00
Samir Jindel 6c5d1fba95 [kernel] Support for top-level generic functions.
Summary:

Previously, there was no support for generic methods in kernel. This prevented
us from being able to pass captured type arguments to the target top-level
function in converted closures, so these type arguments were always instantiated
to 'dynamic'.

Now, we save the type arguments to the closure creation operation in the
context, and read them out and forward them appropriately in closure wrapper
function. Since fasta doesn't currently support generic methods (their type
parameters are replaced by 'dynamic'), only top-level generic functions can
surface in kernel, as they are generated by closure conversion of closures that
capture type parameters of a class.

My focus here is enabling closure conversion to work in only these cases, and as
such, the code has some temporary "hacks" in the VM that may not work for
generic member functions or generic closures when they are enabled in fasta.

Test Plan:

I ran all the tests in closures/, and those which were previously expected to
crash due to missing VM support now pass and produce correct results.

Further testing is paused until we understand why the recent commit "[kernel]
Insert kernel bodies into VM heap" has broken all these tests.

Reviewers: regis@google.com, jensj@google.com, dmitryas@google.com

BUG=
R=dmitryas@google.com, jensj@google.com

Review-Url: https://codereview.chromium.org/2998803002 .
2017-08-16 15:24:26 +02:00
Jens Johansen 3f9d99be50 [kernel] Add fileOffset on FunctionExpression
BUG=
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/3000023002 .
2017-08-16 12:10:11 +02:00
Peter von der Ahé ec258a4ae9 Implement erasure of local function declarations.
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2993993002 .
2017-08-15 10:37:10 +02:00
Jens Johansen 821b13a5a3 [kernel] Update binary.md
binary.md was out-of-date. This should make it up-to-date.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2993393003 .
2017-08-14 08:32:07 +02:00
Jens Johansen 6c2232cb60 [kernel] Insert kernel bodies into VM heap
This CL copies the kernel bodies for all functions and
fields into the VM heap. The function bodies in the VM
heap are then used when compiling the flowgraphs.
This theoretically means that the malloc'd data can be
freed and that snapshotting from kernel could possibly
work, though it hasn't been tested.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2972343002 .
2017-08-10 09:38:17 +02:00
Jens Johansen fb745e6e1b [kernel] Change how TypeParameterType is calculated.
Prior to this CL we carried around information about the containing class
and member, both of which was fetched by reading out-of-line in the binary
(i.e. while reading the current member, start reading something from the
parent member etc).
It had also required the introduction of extra fields in the kernel
binary file (dill file).

This CL cleans that up, by
a) Setting type parameters on functions as needed (in kernel_reader.cc)
b) Using the VM Class and VM Function to get the required information
   (with a above the information is all available).
   (in kernel_binary_flowgraph.cc.) This means that
c) We don't have to read the binary out-of-line (for TypeParameterType
   to work at least), and that
d) We can remove the previously introduced extra fields from the
   kernel binary file (dill file).

R=dmitryas@google.com, kmillikin@google.com

Review-Url: https://codereview.chromium.org/2973633002 .
2017-08-09 11:44:59 +02:00
Jens Johansen f6d6898bce [kernel] Offsets on loops
BUG=
R=ahe@google.com, johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2999633002 .
2017-08-09 08:39:26 +02:00
Brian Wilkerson c6870aa51b Fix hints in kernel (TBR)
Review-Url: https://codereview.chromium.org/2998583003 .
2017-08-08 11:30:47 -07:00
Konstantin Shcheglov 4ef7fd14c1 Record Typedef reference into Kernel FunctionType and resynthesyze typedefs in Analyzer.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986393002 .
2017-08-04 12:02:26 -07:00
Konstantin Shcheglov 60a576108c Store parts in Kernel Library, resynthesize parts in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988373002 .
2017-08-03 10:36:29 -07:00
Samir Jindel e80b42a235 Fix parsing of ClosureCreation kernel nodes in VM.
Summary:

Previously, the VM would crash when it encountered a ClosureCreation node
because it was not aware of the new type arguments field.

Now, it skips the type arguemnts field, which allows many tests to pass again,
even though it doesn't correct forward the type arguments at runtime.

Test Plan:

Removed expected failure lines for all the tests added in my prior
CL (introducing the new field).

BUG=
R=dmitryas@google.com, jensj@google.com

Reviewers: dmitryas@google.com
Review-Url: https://codereview.chromium.org/2987143002 .
2017-08-03 16:42:57 +02:00
Zhivka Gucevska 115232ada2 Add support for finalizer of TryFinally in labeled statements
When a break is encountered in the body of a TryFinally statement to an
enclosing label, the finalizer statement of the TryFinally is executed.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2991113002 .
2017-08-03 16:17:17 +02:00
Zhivka Gucevska 72ba4f6c1c Add partial support for TryFinally and TryCatch statements
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2985383002 .
2017-08-03 12:51:39 +02:00
Zhivka Gucevska 5e241d86b2 Add support for 'throw' expression
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2987153002 .
2017-08-03 12:36:03 +02:00
Zhivka Gucevska dde7ce2ab0 Add components for handling of exceptions
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2988153002 .
2017-08-03 11:35:49 +02:00
Samir Jindel 454ab91576 Fix duplicate context creation when closures appear in initializers.
Summary:

Previously, when a function parameter was captured both in an initializer and in
the body of a constructor, we would create two contexts: one created in a local
initializer and used by other initializers, and another in the body of the
function. This is incorrect, as it means that changes to the parameter in the
initializer's closure won't be visible in the body.

Now, to work around this problem we re-use the context created for the
initializers in the body of the constructor by moving the body into a new
constructor, and redirecting the original constructor to that one, passing the
context as an additional argument. This dance is necessary because local
initializers aren't visible in the body of a constructor.

Test Plan:

A few of the existing closure conversion tests were changed or fixed by this
revision. We also modify the 'closure_in_initializer.dart' test to hit this case
directly.

R=dmitryas@google.com

Reviewers: dmitryas@google.com
Review-Url: https://codereview.chromium.org/2991853002 .
2017-08-03 11:33:40 +02:00
Zhivka Gucevska a04c14da7d Add support for redirecting constructors
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2984423002 .
2017-08-03 11:12:16 +02:00
Zhivka Gucevska 4aab6a4a49 Add support for super initializers in constructor initializer list
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2990943002 .
2017-08-03 09:00:16 +02:00
Zhivka Gucevska 66426a2b1c Add support for initializers in constructor invocation
This adds support for field and local initialziers
for constructor invocation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2986973002 .
2017-08-02 12:57:23 +02:00
Sigmund Cherem e1bccfc857 FE: let targets override whether imports to internal platform
libraries (dart:_foo) are allowed.

Override this in Dart2jsTarget to allow it in the dart2js_native test suite.

R=sra@google.com

Review-Url: https://codereview.chromium.org/2992073002 .
2017-07-31 15:23:12 -07:00
Konstantin Shcheglov 66663f7fd6 Add optional FunctionType.positionalParameterNames and use them to resynthesize function-type formal parameters in Analyzer.
This will be also used as an alternative approach to support of
typedefs in Analyzer. The previous one was reverted in
e431e93e87, because it caused problems
during storing parameters of generic Function(s).

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2985293002 .
2017-07-31 14:09:21 -07:00
Konstantin Shcheglov e64115f93f Add Class.isEnum to Kernel and use it to resynthesize enums in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988113002 .
2017-07-31 10:35:03 -07:00
Konstantin Shcheglov ea876bd780 Reapply 47ecf72 after it was reverted in e431e93e87.
There was a conflict with the problematic afc392b, so it was reverted
too. But 47ecf72 per se does not cause dartk failures. This runs
without failures.

python tools/test.py -m release -c dartk --builder-tag no_ipv6 language/

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991993002 .
2017-07-28 09:48:51 -07:00
Erik Corry e431e93e87 Revert two Kernel changes that were causing test failures.
Example failure:
python tools/test.py -m release -c dartk --builder-tag no_ipv6 \
    language/function_type/function_type63_test

Revert "Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel."
This reverts commit afc392b66d.
Reverts https://codereview.chromium.org/2990783002

Revert "Add Member.documentationComment and use it to resynthesize documentation from Kernel."
This reverts commit 47ecf72272.
Reverts https://codereview.chromium.org/2990873002

Also reverts some attempts to fix test files:
302b410364
https://codereview.chromium.org/2984343002
05ccf27015
https://codereview.chromium.org/2992683002
f71dcd7834
https://codereview.chromium.org/2984363003

Also had to revert some test changes that were committed on top of a red buildbot, in order to try to get back to a place where bots were green:

23952fdf56
https://codereview.chromium.org/2990773002
557cab2a3e
https://codereview.chromium.org/2985173002

R=johnniwinther@google.com, karlklose@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986093002 .
2017-07-28 14:08:23 +02:00
Konstantin Shcheglov 47ecf72272 Add Member.documentationComment and use it to resynthesize documentation from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990873002 .
2017-07-27 15:22:48 -07:00
Konstantin Shcheglov afc392b66d Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990783002 .
2017-07-27 11:53:15 -07:00
Konstantin Shcheglov f603889766 Store dependency libraries canonical names during limited store.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991873002 .
2017-07-27 11:22:05 -07:00
Zhivka Gucevska 2331199968 Add support for field initialization in objects
Fields declared as T f = E are now initialized to the value
expression E evaluates to.
Fields without initalizer expression are intialized with null.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2985883002 .
2017-07-27 13:47:12 +02:00
pq 6e45682ebb Analyzer 0.31.0-alpha.0
For analyzer, front_end and kernel packages:

* bump alpha versions
* update SDK constraints

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2985103002 .
2017-07-26 13:18:14 -07:00
Samir Jindel ff0c3936a1 Revert "Revert "Preserve type variables in closure conversion.""
This reverts commit fd4a0c658f.
2017-07-26 13:27:35 +02:00
Samir Jindel fd4a0c658f Revert "Preserve type variables in closure conversion."
This reverts commit 4d7490c609.
2017-07-26 12:44:15 +02:00
Samir Jindel 4d7490c609 Preserve type variables in closure conversion.
Summary:

Previously, we filled in all occurrences of captured type variables with either
"dynamic" or their bound, if they had one.

Now, we add extra type parameters to the top-level function corresponding to the
closure, and pass in the corresponding arguments as type arguments to the
"MakeClosure" operation.

Test Plan:

Updated [type_variables.dart] and added a new test case to it.

R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2989563002 .
2017-07-26 12:43:02 +02:00
Konstantin Shcheglov e0658b18a3 Resynthesize constructor initializers from Kernel.
We don't resynthesize assert initializers yet, because they are
compiled into an unholy mess.

R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983413002 .
2017-07-25 09:24:13 -07:00
Zhivka Gucevska 43cf49a717 Add support for running constructors with new
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2984903002 .
2017-07-25 17:24:15 +02:00
Dmitry Stefantsov 08e91e07b7 Enable Run step in closure-conversion test suite
R=sjindel@google.com

Review-Url: https://codereview.chromium.org/2984963002 .
2017-07-25 14:02:52 +02:00
Konstantin Shcheglov ebd3ed5ade Resynthesize mixins from Kernel.
This adds Class.isSyntheticMixinImplementation flag which is set
to 'true' for synthetic X&Y classes.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2982373002 .
2017-07-21 10:29:46 -07:00
Konstantin Shcheglov 2289ce12ae Add import dependencies to Kernel libraries and use them to resynthesize ImportElement(s) in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987553002 .
2017-07-21 09:21:57 -07:00
Zhivka Gucevska 3e563c6e9e Modify class definition in interpreter according to spec:
- Populate implicit getters and setters.
 - Populate instance methods, getters and setters.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2987573002 .
2017-07-21 12:37:11 +02:00
Dmitry Stefantsov 5475240725 Add support for converted closures with explicit contexts to VM
The closure-conversion transformation is not enabled yet.  This commit
only adds the support for it to FlowGraphBuilder and
StreamingFlowGraphBuilder.  More work should be done before enabling the
transformation; most mportantly, the 'platform.dill' file that is used
in the Kernel isolate and is loaded by VM for linking with executed
programs should be separated.  The former should receive a file not
touched by the transformation, and the latter should receive a
transformed one.

BUG=
R=jensj@google.com, karlklose@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2891053003 .
2017-07-21 11:45:15 +02:00
Konstantin Shcheglov 1170b117c9 Remember isFieldFormal informative flag in VariableDeclaration(s).
It is informative in the same way as documentation.

Yesterday I tried to make Analyzer and Analysis Server stop using
FieldFormalParameterElement(s) and found one important use case requested
by the Flutter team. We need to show documentation of a field when
user requests documentation on the corresponding field formal named
parameter. This happens outside of the file that declares the parameter
and the field, so we don't have AST available. Of course we could
resolve the unit, but it would cost us something. And if we decide
that it is OK, then maybe we don't need to have documenation comments
in elements at all.

This is of course more convenience, and we could store documentation
and parameter to field mappings outside, like we store index. Just a
compromise - convenience vs. purity.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2983173002 .
2017-07-20 09:53:04 -07:00
Samir Jindel 239e044874 Remove dead code for closure-converting tearoffs.
This review scraps the (currently disabled) code for converting tearoffs in the
closure conversion pass.

The closure conversion pass can only ever do a partial job with tearoffs, due to
the possibility of an unconverted library tearing off a method from any object
it likes. Partially converting [PropertyGet]s makes the closure conversion pass
slower and introduces a new method for any field or method anywhere with a name
used in any [PropertyGet], inflating code size and potentially regressing
performance. As it provides no concrete value in return we've decided to scrap
this aspect of the transformation. Anyway, creating closures for tearoffs is
much easier for a backend than converting anonymous or nested functions, since
there is only one object ("this") captured. Thus ignoring tear-offs does not
undermine the value of the transformation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2986553002 .
2017-07-20 16:47:09 +02:00
Zhivka Gucevska 0e07361eb5 Store field locations instead of values in objects
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2979293002 .
2017-07-20 10:35:26 +02:00
Zhivka Gucevska cbafc38513 Remove unused private methods in interpreter
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2978193002 .
2017-07-18 13:48:09 +02:00
Zhivka Gucevska d62ff42f0e Add support for binding 'this'
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2978893002 .
2017-07-18 13:18:54 +02:00
Zhivka Gucevska 1288ece5c8 Introduce statement continuations following the specification
The next statement to be executed is captured by a statement
continuation.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2975173002 .
2017-07-18 13:03:39 +02:00
Vyacheslav Egorov c6815e8522 Reapply 0489249d29 with a fix for front_end tests.
Proper sequencing of _asyncStackTraceHelper in Kernel

This helper function was being called before its argument was
initialized so it was passing null.  Instead, it should be called
after its argument is initialized.

Because the initialization happens in Kernel code, it is simplest to
insert the call explicitly in Kernel code as well as part of the async
transformation.  This has the consequence that we now call the helper
function even when the flag causal_async_stacks is false.

Fixes issue #29771.
Fixes issue #30178
Fixes issue #30058

BUG=
R=aam@google.com, asiva@google.com

Review-Url: https://codereview.chromium.org/2936793003 .
Review-Url: https://codereview.chromium.org/2982943002 .
2017-07-17 20:56:28 +02:00
Konstantin Shcheglov a9fbe224bc Add documentationComment for Class to Kernel. Parse it. Resynthesize in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977133002 .
2017-07-15 09:53:48 -07:00
Sigmund Cherem 98d057075a Add missing import: fix warning introduced in last CL
TBR=paulberry@google.com

Review-Url: https://codereview.chromium.org/2979093002 .
2017-07-14 15:42:11 -07:00
Sigmund Cherem 4ad4f985af Move reify to use fasta instead of dartk
Note the suite seemed to have a lot of tests crashing in verification.

With my change I'm noting other crashes, but I haven't investigated where they are from.

Also, to run the suite, before it used to be run as:

  dart pkg/kernel/test/reify/suite.dart

Now it needs to be run as:
  DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/dart pkg/kernel/test/reify/suite.dart

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2981813002 .
2017-07-14 15:04:43 -07:00
Samir Jindel a459f73fac Convert closures in all initializers, and share the context between them.
Summary:

Previously, we only handled `FieldInitializer` and `LocalInitializer`.

Now we handle all initializers.

Previously, we would create separate contexts for each initializers, which was
incorrect because it changes made to an argument from a closure within one
initializer would not be seen by a closure within another.

Now, we create the context in a `LocalInitializer` so all initializers will see
the same copy of the argument variables.

There is still an outstanding issue where variables introduced as local
initializers and later captured by closures in subsequent initializers are not
placed into the context. However, this will at least trigger an assert in the closure conversion pass.

Test Plan:

'closures_initializers/initializers.dart(.expect)' has been updated with very
simple test cases for super and redirecting initializers. The second bug
mentioned (captured local initializers) has not been reproduced yet.

BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2981603002 .
2017-07-14 10:59:17 +02:00
Konstantin Shcheglov 00d5012906 Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt.
...instead of mixing formatting with actual changes in many CLs.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2975253002 .
2017-07-13 16:28:18 -07:00
Zhivka Gucevska 77ae919a46 Rename continuations according to Kernel semantics specification
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2979843002 .
2017-07-13 10:48:08 +02:00
Zhivka Gucevska 76ff97880b Rename configurations according to specification
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2975893002 .
2017-07-13 10:09:35 +02:00
Zhivka Gucevska 8e52eea681 Modify environment binding to bind variable declarations to locations
BUG=
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2980483002 .
2017-07-13 09:54:43 +02:00