Commit Graph

143 Commits

Author SHA1 Message Date
Peter von der Ahé e14726a3f4 Use absolute URIs instead of relative paths
We change the type of FileUriNode.fileUri from String to Uri, which in principle
doesn't change the binary format. However, we did notice that LibraryParts
weren't serialized as specified in binary.md, so we also fixed that.

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

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

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

The original revision is in patchset 2.

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

This reverts commit 67adfe741b.

Bug:
Change-Id: Idd1aa15d47df68f2938285468dfa3d5043d8dae2
Reviewed-on: https://dart-review.googlesource.com/25520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-12-01 17:46:05 +00:00
Samir Jindel 67adfe741b [kernel] Introduce assert initializers.
Assert initializers in Dart may be compiled directly to this form of initializer,
rather than through local initializers as is done now.

Bug:
Change-Id: Ia149ea3d1df5d1dc18be5636801604ffaf7ca7d8
Reviewed-on: https://dart-review.googlesource.com/14760
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-01 14:04:06 +00:00
Jens Johansen b65d63e8b8 [kernel] Add position to catch
Bug:
Change-Id: Ie4a931ab55e923a3ed2bbf247535bc151c766272
Reviewed-on: https://dart-review.googlesource.com/23671
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-30 09:50:01 +00:00
Dmitry Stefantsov ccbeebe2a6 [kernel] Add new member kind for redirecting factory constructors
New type of AST nodes RedirectingFactoryConstructor is added to Kernel.
The goal is to keep the information about redirecting factory
constructors in the class for the linking phase.

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

This reverts commit 26735519cb.

Bug:
Change-Id: Ifa599b7bff752dec4c505e10fd6db206e1abd977
Reviewed-on: https://dart-review.googlesource.com/23820
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-11-27 18:25:31 +00:00
Vyacheslav Egorov 26735519cb Revert "[kernel] Implementation of fine-grained strong mode argument type-checks, phase 2"
This reverts commit f13f772bb2.

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

Reverting to restore green-ness of DEBUG builds.

TBR=sjindel@google.com

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

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

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

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

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

Bug:
Change-Id: I643b8dd778972621046fe76b536fd95e9bb66d1c
Reviewed-on: https://dart-review.googlesource.com/18820
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-22 09:29:57 +00:00
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
Jens Johansen c72b19a012 [kernel] Optimize BinaryPrinter slightly more
This CL basically:
 - Manually inlines writeAnnotationList.
 - Writes 2 and 4 byte uint30s and uint32 more effeciently in the general
   case (idea stolen from Slava).

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



Bug:
Change-Id: I79354b260e37cbbced0557069ae63817fac0f333
Reviewed-on: https://dart-review.googlesource.com/19188
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-11-09 10:28:20 +00:00
Vyacheslav Egorov d755f87781 [kernel] Improve performance of the BinaryPrinter.
In order of importance:

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

Before this change:

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

After this change:

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

Bug:
Change-Id: Ida2365088a51a5095c2ce8aef5f1582bc0b5b99e
Reviewed-on: https://dart-review.googlesource.com/19005
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-11-07 15:04:09 +00:00
Jens Johansen dfef2338eb [kernel] Reduce context creations in BinaryBuilder
The VM creates context objects even though it's only applicable in a
non-taken branch. This CL moves such a branch into its own function
and thus avoids the context object creation when loading a dill file
eagerly.

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

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

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

Bug:
Change-Id: I9634e0a81f43efeb4e2524edb765d36072074f1e
Reviewed-on: https://dart-review.googlesource.com/18220
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-03 08:25:11 +00:00
Samir Jindel 091f12b148 [kernel] Serialize fileOffset with SuperProperty{Get,Set}
Bug:
Change-Id: I35d568b8ce98413df36bd83837fd46cb95e98ec7
Reviewed-on: https://dart-review.googlesource.com/18184
Reviewed-by: Jens Johansen <jensj@google.com>
2017-11-02 14:11:33 +00:00
Jens Johansen 57c3f0579c [kernel] Replace for in loop in BinaryBuilder
Loading vm_platform.dill 100 times after 2 seconds warmup:
		Statistics on 5 runs:
			It varies to much to tell on the runs I did.

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

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

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

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

Bug:
Change-Id: I16474e32715df57922376d88baddd17a1cf73663
Reviewed-on: https://dart-review.googlesource.com/17788
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2017-11-02 09:07:08 +00:00
Jens Johansen c8e51ef922 [kernel] Add offset to this[i] and super[i]
Bug:
Change-Id: Ic65b69c4977be834c7b69638d6c030727c7210e5
Reviewed-on: https://dart-review.googlesource.com/17441
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2017-11-01 09:57:00 +00:00
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
Jens Johansen f94ffbf624 [kernel] Move procedure lazy loading to function node body
Previously lazy loading was done in Procedure by lazy loading functionNode,
now lazy loading is done (only through Procedure) in the functionNode by
lazy loading the body.

Bug:
Change-Id: I25cc86d038123ed4992162b65aa95781ea2c56e8
Reviewed-on: https://dart-review.googlesource.com/15560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2017-10-25 08:45:59 +00:00
Peter von der Ahé ae0ac23e80 Prototype BulkCompiler API for fuzz testing.
Change-Id: Icf9134dccfa02ff36167287cd63abe9886e0f2e4
Reviewed-on: https://dart-review.googlesource.com/13985
Reviewed-by: Luke Church <lukechurch@google.com>
2017-10-20 12:44:15 +00:00
Konstantin Shcheglov c3a76ed636 Move all documentation comments into metadata.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com

Bug:
Change-Id: I05382fe275e7a3a0f18128508d30fe1438adffc4
Reviewed-on: https://dart-review.googlesource.com/14623
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2017-10-18 14:48:56 +00:00
Paul Berry dca8a9acf5 Make it possible to distinguish "as" checks that come from generic covariance.
Change-Id: Ie230e6ca3ae28a0f4a6faaf5cb559426de0d8a0e
Reviewed-on: https://dart-review.googlesource.com/14361
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-18 09:16:05 +00:00
Paul Berry 9a0e962e67 Add a kernel flag to represent generic contravariance.
This flag indicates when a procedure's return type makes contravariant
use of a class type parameter.  The front end will have to insert "as"
checks at any call sites that refer to such a procedure as their
interface target.  Placing the flag on the procedure will allow the
front end to determine whether the check is needed once, at the same
time as it's determining the need for covariant parameter checks,
rather than when compiling individual call sites.

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

Change-Id: I989fc702bc233384eb5ea8cd630c8efd384ab248
Reviewed-on: https://dart-review.googlesource.com/14365
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-17 05:24:21 +00:00
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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
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
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
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
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