Commit graph

788 commits

Author SHA1 Message Date
Samir Jindel a2ff93da67 [kernel] Partial support for conditional imports in CFE.
In order to un-block Flutter integration, we introduce partial support for
conditional imports into the CFE. There are two incomplete parts:

- The condition strings are evaluated by the Target.
  They should be looked up in the environment, but this introduces
  complications with modular compilation.

- Type inference and other static checks are performed with reference to
  the implementation (conditionally-imported) library rather than the
  interface library.

See issue #30143 for more details.

Bug:
Change-Id: I740b45e9d32796644837de4caefd8d6e8015f229
Reviewed-on: https://dart-review.googlesource.com/34721
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-01-16 17:27:19 +00:00
Peter von der Ahé 1bca76d012 Convert Platform.resolvedExecutable to URI correctly
Change-Id: I583b98277b1c62328885c775fcb712823c9ff405
Reviewed-on: https://dart-review.googlesource.com/34860
Reviewed-by: Alexander Thomas <athom@google.com>
2018-01-16 14:24:52 +00:00
Vyacheslav Egorov ff008ca37a [vm/kernel/async] Use proper type argument when createing async* controller.
Change-Id: I40e5d2d933b83a24c9d8177437fb6df1f21b5cc1
Reviewed-on: https://dart-review.googlesource.com/34741
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-01-15 22:06:30 +00:00
Paul Berry 45b02f8216 Use the new spec for Future flattening for type inference
Change Fasta type inference and Kernel type checking to use the new
definition for Future flattening, which is really unwrapping (peeling
off one layer of Future or FutureOr).  Use this for inferring types of
`await` expressions and return types from `async` functions.

Ensure that we are using the same notion of flattening for inference
and checking.  (Maybe it was a red flag that we weren't.)

This fixes await_test so that it produces a runtime error rather than
a compile time error - see #31541.

A similar change will need to be made to the analyzer - see #31887.

Change-Id: I7d936e9788969a48fdc216628eaa793389fb5e30
Reviewed-on: https://dart-review.googlesource.com/34504
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-01-15 07:09:36 +00:00
Samir Jindel 96381b76bc [kernel] Introduce 'forwardingStubInterfaceTarget' field for Procedures.
First step in fixing issue #31519.

Change-Id: I8df86954993ae5edd59ad2edc57179725880c1d9
Reviewed-on: https://dart-review.googlesource.com/34143
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-01-11 15:31:48 +00:00
Samir Jindel 28a0706e91 [kernel] Implement correct semantics of forwarding stubs in VM
This revision has been factored out of Revision 29300.

Change-Id: Idf579f0e5ffeea5764e2a9654c6812d69f6977c7
Reviewed-on: https://dart-review.googlesource.com/31921
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-01-10 07:39:31 +00:00
Peter von der Ahé bb9af782a7 Correct type arguments for NSM
Change-Id: I28623bed9d5d203e82d50c4b057803a89e76757d
Reviewed-on: https://dart-review.googlesource.com/33380
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-01-10 07:13:30 +00:00
Leaf Petersen 5aea404159 Hide new core lib MapEntry class where it conflicts in kernel, and
suppress a hint on undefined imported name to make it backwards
compatible.

Bug:
Change-Id: I9c92adcf685248fb8aae9da39c008968768ad29b
Reviewed-on: https://dart-review.googlesource.com/33662
Reviewed-by: Paul Berry <paulberry@google.com>
2018-01-10 01:59:48 +00:00
Martin Kustermann 0fb2d0bfed Finish the kernel2kernel "constants" transformation by fixing a whole bunch of issues
Change-Id: I24e2ff06db1a7555f5091d0c27060ed79d6787ee
Reviewed-on: https://dart-review.googlesource.com/31980
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-01-08 19:56:24 +00:00
Dmitry Stefantsov 1f3b493dcc Add simple instantiate-to-bounds algorithm to the common front-end
Bug:
Change-Id: I65097b037f4b02f0a161c9c183844a3dc3339c77
Reviewed-on: https://dart-review.googlesource.com/29880
Reviewed-by: Paul Berry <paulberry@google.com>
2018-01-04 11:31:08 +00:00
Kevin Millikin 6fa813d818 Change handling of Kernel static errors
Before: Kernel static errors were represented by throwing a distinguished
error or else by calling a distinguished library const constructor.

Now: Kernel static errors are represented by InvalidExpression.  To support
error reporting, InvalidExpression has an optional message and a file
offset.  A back end can choose to signal these errors at any time; for
example, when deserializing the binary, or when compiling the procedure
containing the static error, or when the erroneous expression is evaluated
at run time.

InvalidStatement is removed because it can be encoded as ExpressionStatement
of InvalidExpression.

Future work:

* supporting static errors where an expression cannot appear in the AST
* allowing InvalidExpression to contain an Expression for error recovery
* adding a top-level list of static errors and warnings to the binary

Bug: https://github.com/dart-lang/sdk/issues/29840
Change-Id: Ifdfe9a76cee6cefed28061bf245be70531d2f413
Reviewed-on: https://dart-review.googlesource.com/31320
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-01-04 11:00:25 +00:00
Jens Johansen dab5ac348b [kernel] Remove unused file
Bug:
Change-Id: I6a14d9f70d90bb59c26370b3aa62c8b30722cb58
Reviewed-on: https://dart-review.googlesource.com/32041
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-01-04 10:20:56 +00:00
Sigmund Cherem e3b70f4af1 Add mechanism to transform outlines and ensure metadata is preserved in summaries.
Change-Id: I3796612936a13c262efa54011c66c6f5ad881e07
Reviewed-on: https://dart-review.googlesource.com/32001
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-01-03 18:45:34 +00:00
Alexander Markov c812f6ab33 [vm, kernel] Tool for dumping kernel files with VM-specific metadata
Change-Id: I7f7b3cd797e30283821741583983dbe939e5132e
Reviewed-on: https://dart-review.googlesource.com/30960
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-01-03 17:40:04 +00:00
Aske Simon Christensen de2ce48e17 Finish type variables earlier so their bounds are available when building the program.
Check bounds in verifier.
Fixed an inconsistency in the printing of parent nodes in the verifier.

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

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

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

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

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

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

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

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

Closes issue #31550

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

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

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

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

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

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

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

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

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

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

    int x;
    String y;
    x = y;

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

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

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

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

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

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

Gets compiled to:

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

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

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

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

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

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

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

The original revision is in patchset 2.

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

This reverts commit 67adfe741b.

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

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

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

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

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

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

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

This reverts commit 26735519cb.

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

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

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

Reverting to restore green-ness of DEBUG builds.

TBR=sjindel@google.com

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: Iace1771f1adcf029049ee8e7f8903017f512ed46
Reviewed-on: https://dart-review.googlesource.com/20022
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2017-11-10 13:15:08 +00:00