Commit Graph

96 Commits

Author SHA1 Message Date
Peter von der Ahé 5b32ab3be6 Remove the word "strongMode" from some package:kernel libraries.
Temporarily using "legacyMode" instead, but I plan to rid these soon.

Change-Id: Iff8bcde03b6ebe4ad95f963f456c855e73e58926
Reviewed-on: https://dart-review.googlesource.com/c/79042
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-10-11 08:50:43 +00:00
Peter von der Ahé f942af451b Remove kernel interpreter
The test isn't normally run, and all 12 testcases caused a crash.

Change-Id: Ie1576e32b70f01aa775c3305bff2bc992eebf86f
Reviewed-on: https://dart-review.googlesource.com/c/78940
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-10-10 08:42:21 +00:00
Kevin Millikin 796d628ab6 Improve error reporting from Kernel scripts
* Ensure that we have a .dill file and it has the correct version before
  we start decoding it in dump.dart.

* Throw errors, not strings.  Ensure that they have a useful
  toString().

* Do not print usage except when the command is invoked
  incorrectly (wrong number of arguments).  Once we get into the
  command it's less likely that it's been invoked incorrectly and more
  likely that something else has gone wrong.

  Because these utilities are invoked from other scripts (like the
  fasta command), printing their usage for problems other than
  invoking them correctly doesn't match the way that they were invoked
  and it's confusing.

Change-Id: I7832383594d2b3719a0a7a7392ba4685717a79d2
Reviewed-on: https://dart-review.googlesource.com/c/78206
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-10-05 12:19:01 +00:00
Vyacheslav Egorov f8a3d802d0 Revert "[vm/kernel] Preserve strong mode types in async transformation"
This reverts commit eec96f9076.

Revert "[vm/kernel] In async transformation check if strongMode is on."

This reverts commit 348ed30efd.

Reason for revert: getStaticType is unreliable in Kernel

R=alexmarkov@google.com

Change-Id: I08b914f947a00923491bb610ed74d6348882554f
Reviewed-on: https://dart-review.googlesource.com/75220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-09-17 22:58:55 +00:00
Vyacheslav Egorov 348ed30efd [vm/kernel] In async transformation check if strongMode is on.
It seems we are still using non-strong mode targets in few
places (e.g. when training front-end server we by accident
train it in legacy mode).

A separate bug is filed to clean that up https://github.com/dart-lang/sdk/issues/34468

For now to unbreak the build we simply check if we are in the
legacy mode and then avoid using getStaticType in async
transformation.

This is followup to eec96f9076.

Bug: https://github.com/dart-lang/sdk/issues/34463
Change-Id: Ib693fddfb9abbf89599ae646cb408d4a9c93f1b6
Reviewed-on: https://dart-review.googlesource.com/75061
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 22:11:30 +00:00
Vyacheslav Egorov eec96f9076 [vm/kernel] Preserve strong mode types in async transformation
Async transformation uses dynamic variables in few places (e.g.
for temporaries and for incomming arguments) - which creates
not strongly typed AST with method invocations having dynamic
receivers and non-null interface targets at the same time.

To maintain strong typedness of the AST we insert unsafeCast
when accessing the temporaries.

Bug: https://github.com/dart-lang/sdk/issues/34463
Change-Id: I11e38c128645ebc8acb0c982a80fe4c5c4036673
Reviewed-on: https://dart-review.googlesource.com/75000
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 17:19:29 +00:00
Alexander Aprelev c339846594 [kernel] Move util.dart from bin to lib.
bin/util.dart doesn't have main() entry point and that breaks snapshot generation that is
automatically invoked by pub for all dart sources in bin/ folder.

See https://github.com/flutter/flutter/pull/19044\#issuecomment-402241782

Change-Id: Ie91549173536740992ce61d830efdfdc603c5564
Reviewed-on: https://dart-review.googlesource.com/63683
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-04 00:50:16 +00:00
Peter von der Ahé 02cd63eefd Remove unused closure conversion
Change-Id: I0edbbd29a4cc603e7479023bc0e8869c78ca7bcc
Reviewed-on: https://dart-review.googlesource.com/54225
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-14 14:58:17 +00:00
Peter von der Ahé 4f2bdff90b Rename Program to Component
Change-Id: I1a3cc03fba9783807fa637a9d42fdbad68ee7686
Reviewed-on: https://dart-review.googlesource.com/31040
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-03-15 12:22:23 +00:00
Kevin Millikin 1abf929476 Fix some uses of deprecated API
Fix all deprecation warnings in the kernel and vm packages.

Change-Id: I44e5b128cc8fbc1360ad4c49ecdf2aa7cfd269d8
Reviewed-on: https://dart-review.googlesource.com/46720
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-03-15 10:09:23 +00:00
Jens Johansen 89cec72771 [kernel] Add two new kernel tools; add error handling in existing tools.
This CL adds two new kernel tools which can answer questions about
a dill file:

* count_breakdown.dart
  Enumerates the different node types in the provided dill file and
  counts them.
  This has proved useful in the past to e.g. see how many doubles are
  included in Flutter.

* size_breakdown.dart
  Gives an overview of which parts of the dill file contributes how many
  bytes.
  This has proved useful in the past to see that the string table gets
  huge when we have many doubles (because we currently save doubles in
  kernel as strings).

It also adds error handling and usage information to existing tools.

Change-Id: Ie2ce9e4b8806d5975dba8f57445705a840be3474
Reviewed-on: https://dart-review.googlesource.com/42660
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-21 14:35:16 +00:00
Florian Loitsch 3b8e4d41a7 Reapply "Run async functions immediately."
Which was reverted in commit 032be73dbe.
Originally commited in commit 67bac0bce6.
Original review URL: https://dart-review.googlesource.com/5263

Change-Id: Ic7333c29e502a3924dc6aade8ffa46fc8aa5b04a
Reviewed-on: https://dart-review.googlesource.com/38120
Commit-Queue: Florian Loitsch <floitsch@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2018-02-02 15:50:16 +00:00
Florian Loitsch 032be73dbe Revert "Run async functions immediately."
This reverts commit 67bac0bce6.

Reason for revert: broke the bot.

Original change's description:
> Run async functions immediately.
> 
> Migrated from https://codereview.chromium.org/2478703003/
> 
> Change-Id: I1d678c01ba5876490b12c676c500171328361d31
> Reviewed-on: https://dart-review.googlesource.com/5263
> Commit-Queue: Florian Loitsch <floitsch@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Vijay Menon <vsm@google.com>
> Reviewed-by: William Hesse <whesse@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>

TBR=whesse@google.com,rnystrom@google.com,vegorov@google.com,kustermann@google.com,zra@google.com,floitsch@google.com,jmesserly@google.com,vsm@google.com,regis@google.com,sigmund@google.com

Change-Id: I20c948057423c3fa5aa8c72843f8f2a17e086ad5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/37981
Reviewed-by: Florian Loitsch <floitsch@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2018-02-01 15:01:21 +00:00
Florian Loitsch 67bac0bce6 Run async functions immediately.
Migrated from https://codereview.chromium.org/2478703003/

Change-Id: I1d678c01ba5876490b12c676c500171328361d31
Reviewed-on: https://dart-review.googlesource.com/5263
Commit-Queue: Florian Loitsch <floitsch@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-02-01 14:08:57 +00:00
Peter von der Ahé 4d1adf42d3 Deprecate IncrementalClassHierarchy
See https://github.com/dart-lang/sdk/issues/31842

Change-Id: I019909831a91a4e06138dc3a6bf32f766bca1ae6
Reviewed-on: https://dart-review.googlesource.com/34880
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-01-17 13:30:17 +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
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
Paul Berry cd1898be16 Move ErrorFormatter and HighlightingPrinter into pkg/kernel/lib.
This will allow it to be used by front_end unit tests.

Change-Id: I7eef0f2ca361a75fd98fdd7a25abd1739f1aa1f8
Reviewed-on: https://dart-review.googlesource.com/16981
Reviewed-by: Karl Klose <karlklose@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-30 11:12:52 +00:00
Jens Johansen 07b6ec3425 [kernel] Allow VM to load concatenated dill file
The kernel format has been designed so that one can concatenate several
dill files into one file and then load it. For instance the dart
function BinaryBuilder.readProgram supports this.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: I233a033aa3042b202dd4708908a5be3089474588
Reviewed-on: https://dart-review.googlesource.com/16820
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-10-27 12:01:48 +00:00
Karl Klose b46375ef7b Fix reporting of source lines
R=vegorov@google.com

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

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

Change-Id: I9ae50f48e24a5c45e93f4218e6b61f193f549e7a
Reviewed-on: https://dart-review.googlesource.com/16601
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-25 18:55:37 +00:00
Vyacheslav Egorov 81f2664908 [kernel] In bin/type_check.dart allow arbitrary calls on values of type Function
This change silences errors that were reported for Function.call callsites because
there is no valid interface target for them:

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

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

Bug: https://github.com/dart-lang/sdk/issues/31052
Change-Id: I13b5dc3ff69e7adede3040334556ff6653b50515
Reviewed-on: https://dart-review.googlesource.com/14524
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2017-10-17 18:46:20 +00:00
Vyacheslav Egorov 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
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
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 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 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
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
Peter von der Ahé 39ec420753 Option to enable showOffsets in dump.dart.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2931073002 .
2017-06-09 14:21:28 +02:00
Konstantin Shcheglov 5bdfd1e69b Pass ClassHierarchy instead of creating it.
MixinFullResolution is also updated to create new ClassHierarchy
instance only if there are transformed classes. This improves
incremental kernel generator initial time from 22 to 16 seconds.

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

Review-Url: https://codereview.chromium.org/2918593003 .
2017-06-01 07:20:13 -07:00
Konstantin Shcheglov 3803374d32 Don't recreate CoreTypes in transformers. Pass it in.
The same will be done later for ClassHierarchy. So, it would be up to
the client to decide which flavour to create, and whether the same
instance can be reused.

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

Review-Url: https://codereview.chromium.org/2904203003 .
2017-05-31 09:54:27 -07:00
Konstantin Shcheglov 0dd81884bf Perform MixinFullResolution only for source libraries.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2912503003 .
2017-05-30 09:33:26 -07:00
Sigmund Cherem 26c2f3e17f Move dartk to the tool folder
"bin" is part of the public API of a package, private tools can go under the
`tool` folder. This allows us to use a dev_dependency on analyzer without
exposing a broken import publicly.

I've only moved `dartk` so far (which I expect will be removed once we have a
better API for front_end.

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

Review-Url: https://codereview.chromium.org/2842643002 .
2017-04-28 15:39:17 -07:00
Asger Feldthaus a3402df15c [Kernel] Remove code from the old type propagation.
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2780513004 .
2017-03-28 12:43:22 +02:00
Paul Berry 685045d619 Start unraveling circularities between analyzer and front_end/kernel.
This CL moves many of the files from
pkg/front_end/lib/src/fasta/analyzer/ to pkg/analyzer/lib/src/fasta/.
It also moves two files from pkg/kernel/lib/analyzer/ to
pkg/analyzer/lib/src/kernel/.

This reduces the amount of circularity between analyzer and
front_end/kernel so that there are no files in front_end or kernel
which are both dependend upon by analyzer and depend upon analyzer.  I
will clean up the remaining circularities in future CLs.

There should be no functional change.

R=ahe@google.com, asgerf@google.com, kmillikin@google.com, scheglov@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2756593004 .
2017-03-17 05:56:06 -07:00
Dmitry Stefantsov b87a479c2b Pass type arguments as a list in generic methods invocations
All generic methods are equipped with one extra named parameter for
passing type arguments as a list of type values.

Additinally, this change forces strong mode usage for 'dartk' in
'reified_dart'. Strong mode is required for loader to not strip away
type arguments from generic methods. In future, a command line argument
may be implemented for that (e.g. --generic-methods), if generic method
support will land before the strong mode.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2713163002 .
2017-03-16 10:47:11 +01:00
Zhivka Gucevska bd3cfd6979 Implements support for variables and evaluation of logic expressions
BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2740433006 .
2017-03-15 12:50:16 +01:00
Zhivka Gucevska 1b82e0c3a0 Initial implementation of interpreter for Kernel
Basic framework, evaluation of BasicLiterals and dummy evaluation
of print.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2722283003 .
2017-03-02 13:19:27 +01:00
Asger Feldthaus 8bfc4b47c0 Implement canonical name scheme in kernel.
This adds a class CanonicalName that can represent a library, class,
or member.  All references now go through a Reference object, which is
linked to both the AST node and its CanonicalName, so either can be
created first.

dartk now accepts multiple input files:
- If multiple dart files are given, they are all compiled.
- If multiple binaries are given, they are linked together.
Mixed dart and binary input is not supported by dartk.

dartk now has a flag --include-sdk which includes the entire SDK in
the output.  This is so the SDK can be compiled alone and then linked.

Example of compiling separately and then linking:
  dartk foo.dart -o foo.dill
  dartk main.dart -o main.dill
  dartk --include-sdk -o sdk.dill
  dartk main.dill foo.dill sdk.dill --target=vm --link -o program.dill

dartk still has incredibly slow cold start due to the analyzer loading
the dart sdk, so this does not actually speed things up at the moment.

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

Review-Url: https://codereview.chromium.org/2665723002 .
2017-02-23 14:12:10 +01:00
Dmitry Stefantsov d5e2fcb430 Merge the work on Generic Types Reification from 'dart-lang/reify' repo
This CL adds the work done at https://github.com/dart-lang/reify to SDK.
The commit that is used for the merge is
a2066a68374d49de92ff75f5e1ffc36335fd9451 (Nov 23, 2016). The code is
adjusted to respect the changes of the kernel package in SDK since that
commit.

The reify transformation is run by specifying 'vmreify' target to
'dartk'. The transformation requires its runtime library to present in
the program being transformed. The library is found in its default
location in SDK checkout if 'dartk' is run from its default location in
SDK checkout. To preserve the library in the output, TreeShaker is
disabled in 'vmreify' target.

The "golden" set of tests is also copied from 'dart-lang/reify'
repository, and the appropriate test suite is defined for it.

The bash script 'bin/reified_dart' from 'dart-lang/reify' is rewritten
as Dart script 'pkg/kernel/bin/reified_dart.dart'. It requires path to
'dartk' and path to SDK. Those are taken from their default locations in
SDK if 'reified_dart.dart' is run from its default location in SDK.

The added files were formatted using 'dartfmt' with default settings.
Additionally, the files were checked with 'dartanalyzer --strong'. The
necessary changes were made to fix the error messages. There are some
'hint' and 'error' messages left for some .dart files from the added
test cases, but they reflect intentional errors or conventions in those
files.

R=asgerf@google.com, karlklose@google.com

Review-Url: https://codereview.chromium.org/2697873007 .
2017-02-17 14:19:29 +01:00
Jens Johansen 0f711a9c54 [kernel] Rewrite method calls transformation
Bring in old CL (https://chromereviews.googleplex.com/485307013/)

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2688513004 .
2017-02-15 14:18:33 +01:00
Asger Feldthaus ac3e8cb7b3 Support for modular mixin resolution.
When a class from a different build unit is mixed in, the instance
members of the mixed-in class are retained in the external library
definition, so the mixin resolution pass can clone them.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2669303002 .
2017-02-13 14:20:04 +01:00
Paul Berry 9e5cba8838 Clean up imports in kernel.
dartk.dart was missing a necessary import, and util.dart had an unused one.

TBR=asgerf@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2674733003 .
2017-02-03 08:58:23 -08:00
Martin Kustermann 2e4849856a VM: [Kernel] Add --embedder-entry-points-manifest to dartk/transform and pass it to the treeshaker
The VM's gen_snapshot already accepts an --embedder-entry-points-manifest option.

This CL makes dartk/transform.dart accept the same option and pass the
roots on to the treeshaker.

In addition to what gen_snapshot accepts, we also accept
"*external-instantiation*" instead of a specific constructor/factory name)

BUG=https://github.com/dart-lang/sdk/issues/28559
R=asgerf@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2668893004 .
2017-02-03 12:14:32 +01:00
Asger Feldthaus 14c6b27533 Put tree-shaking behind a flag in dartk.
BUG=
R=jensj@google.com

Review-Url: https://codereview.chromium.org/2669783002 .
2017-02-02 15:10:10 +01:00
Kevin Millikin 3057283f0c Split the Kernel transformations into modular and global ones
Target-specific modular transformations have to be able to cope with
external libraries.  Target-specific global transformations should be
optimizations, and not required for correctness, since a simple linker
may choose not to perform them.

Make mixin resolution modular by making it fail when a mixed-in class
comes from an external library.  (We cannot mix in such a class because
we do not necessarily have all class members.)

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2671653003 .
2017-02-02 13:08:27 +01:00
Jens Johansen 3f55b8e2b7 Non-format-changing kernel offset changes
Updates to kernel that sets more offsets (and introduces end offests
and 'debuggability') - but doesn't necessarily persist them,
i.e. the format doesn't change and no C++ changes are neccessary yet.

This is step #1 in introducing these things, next step(s) will be
persisting the new stuff and using it on the C++ side.

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

Committed: https://github.com/dart-lang/sdk/commit/5edca8c4d3733f319ab2d328aa28ceb286a30904

Reopening as I reverted the change as it broke package:compiler.

Review-Url: https://codereview.chromium.org/2610133002 .
2017-01-10 09:16:19 +01:00