Commit graph

788 commits

Author SHA1 Message Date
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