Commit Graph

149 Commits

Author SHA1 Message Date
Johnni Winther eae781c73e [cfe] Add Field.isLate, VariableDeclaration.isLate and VariableDeclaration.isRequired
Add support for the `late` modifier on fields and local variables in
CFE, and `required` on named parameters When using the option
--enable-experiment=non-nullable the `isLate` and `isRequired` flags will be set
accordingly on Field and VariableDeclaration nodes.

Closes #37686
Closes #37684

Change-Id: If37fc93defdabc5cc974f3f068f57752a665f4cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113036
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-08-16 19:39:05 +00:00
Jens Johansen f29f41f1a5 Update binary.md forgotten when adding language version fields to binary
Change-Id: I243881923c55229f1e03901f2f655cba99633e3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112086
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-08-07 12:03:10 +00:00
Dmitry Stefantsov f3139f57b4 [cfe][nnbd] (De)Serialize nullability modifiers in .dill files
Closes #37688.

Bug: http://dartbug.com/37688
Change-Id: Ie3aa8fe09d859cd65bbb58da3f56297483b7b725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112085
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2019-08-07 10:06:40 +00:00
Jens Johansen fd7baa4fd9 [CFE] Serialize language version
Change-Id: I6ea448df722a7e1e51c31f06d42bfbe743855a45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111725
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-08-05 09:14:09 +00:00
Aske Simon Christensen 50efd7f187 [Kernel] Add list of unused arguments to InstanceCreation nodes.
During constant evaluation, unused arguments to a const constructor are
thrown away after evaluation, since their values do not affect the
resulting instance constant. If such an unused argument ends up
unevaluated, any errors that would arise in the final evaluation are
not reported.

This CL adds space in the Kernel AST for saving these unevaluated
expressions so they can be checked during final constant evaluation.

Even though this is an incompatible change, no update is needed to the
VM code (except for the version bump), since the VM does not support
InstanceCreation nodes in the first place.

Change-Id: I4752562c1164efbba79eb018c15b07ed8354ce5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105761
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2019-06-13 09:42:26 +00:00
Aske Simon Christensen af3ec66106 [Kernel] Fix specification of constant reference.
Change-Id: Ic17294da65e3f27d52692975a48b8aa3132c2739
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100841
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-30 10:24:38 +00:00
Jens Johansen 1555594ddb Include a per-library index of owned sources in kernel
This for instance allows the VM to include all patches
(e.g. the previously missing `runtime/lib/date_patch.dart`)
in what's returned from `LoadedScripts()`.

Over time this also allows for `LoadedScripts()` to be simplified and
become faster (it's currently something like O(m + m*n) where m is the
number of results in DictionaryIterator(*this) and n is the number of
returned scripts).

Change-Id: I4b5a6a0fe666b774fc0987d099ed02e81ac97b43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98660
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-04-11 12:40:49 +00:00
Dmitry Stefantsov 4ab4545ff7 [cfe] Add type and file offset to constant expressions
Closes #36471.

Bug: http://dartbug.com/36471
Change-Id: I5ac294057f2f69f1a8edfdf1106f65908fc257ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98677
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-04-10 09:55:36 +00:00
Aske Simon Christensen f63eaab3af [kernel] Add instance creation kernel node.
This is used in constant evaluation to represent const constructor
invocations with unevaluated field values or asserts.

Change-Id: I1d2d60a18f967a4dd195b3b5895db9a126c47803
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98561
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-04 12:22:50 +00:00
Jens Johansen e9e0daee5c Add importUri and fileUri to Source.
This will enable the VM to map URIs to package-URIs to solve problems
such as https://github.com/dart-lang/sdk/issues/35859

Change-Id: I15520325a5b81a99a7e3f56c2e35fd775d9da946
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96905
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2019-03-20 08:44:33 +00:00
Aske Simon Christensen ff55d429f6 [kernel] Collection concatenation nodes.
These arise when the constant evaluator partially evaluates collections
containing spreads or control-flow constructs with unevaluated
subexpressions. They are removed by the final constant evaluation.

Change-Id: Icdd155c4805cbcefe6aa4b45c2f85ec258e7bd36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95760
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-08 13:08:55 +00:00
Aske Simon Christensen 2b2e71770c [kernel] Add SetConstant node to Kernel.
Change-Id: I83da1afc9f15009c650a871a51ca8171b482d4df
Reviewed-on: https://dart-review.googlesource.com/c/94863
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-04 10:20:56 +00:00
Kevin Millikin c9b8bae4e6 [Kernel] Add BlockExpression to the Kernel language
This is not yet used or tested.

Change-Id: Id050802926ad6452df3c39ace12ea5dd56d4faaa
Reviewed-on: https://dart-review.googlesource.com/c/87970
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2019-02-22 12:38:26 +00:00
Jens Johansen eb956a2516 Add synthetic bit to Library flags
Fasta can generate synthetic libraries.
Previously we didn't include them when serializing, but that leaves
references in the binary to libraries that doesn't exist which isn't
ideal.

This change includes them, and adds a flag to kernel Libraries such that
we know they are synthetic.

Change-Id: Ied25a21cd1f384d318347021bc7ec18dae3a4e05
Reviewed-on: https://dart-review.googlesource.com/c/91722
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2019-02-01 11:00:26 +00:00
Kevin Millikin c9a55b437a [Kernel] Remove the dedicated fromEnvironment constants
These can be represented as an unevaluated static invocation.

Change-Id: Ib827345f1f65a09f1a856eae33366722a2e613d2
Reviewed-on: https://dart-review.googlesource.com/c/90008
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-01-18 10:10:42 +00:00
Jens Johansen 1c82f6757c Save problems in ast - kernel format changes
Change-Id: I978c90762ee85a6d7936d6a55e11d5d95d509b4f
Reviewed-on: https://dart-review.googlesource.com/c/89507
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-01-17 10:41:53 +00:00
Kevin Millikin 944984f015 [Kernel] Add syntax for unevaluated constants
Add Kernel syntactic support for constants constructed by
bool.fromEnvironment, int.fromEnvironment, and String.fromEnvironment.
These values are not necessarily available at compile time.  Because
constants can depend on these values, there is also an unevaluated constant
that represents an expression depending on environment values.

This syntax is not yet produced by the Fasta compiler.

Change-Id: Ie96ea7f60a7efcd35ac802b320a00f398d41232e
Reviewed-on: https://dart-review.googlesource.com/c/88827
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-01-11 08:35:20 +00:00
Jens Johansen d53f02aa8a Remove writeOptionalReference
References can be null --- it's written as the byte [0].
Thus in the null case it would before be [0] and now be [0].
In the non-null case it would before be [1, xyz] (1 for Tag.Something
and xyz for the actual, now positive, uint30). Now it would be [xyz].

Change-Id: Ibc08d3afb7275b0429a4d6c5e667fbd381121489
Reviewed-on: https://dart-review.googlesource.com/c/85394
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-01-04 13:31:03 +00:00
Aske Simon Christensen 05fb37a808 Add SetLiteral node to kernel.
Change-Id: I2f12662efc8ae3f064674bba03c333e0c23ffa0d
Reviewed-on: https://dart-review.googlesource.com/c/85681
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-12-06 14:46:58 +00:00
Peter von der Ahé 45e7ff28e1 Kernel Binary Format: Reify originating TypedefType on FunctionType
Previously, we only stored a reference to the originating Typedef declaration
and is thus loosing the originating type arguments. We need these type arguments
in various places, including diagnostics and bounds checks.

Note: this CL maintains backwards compatibility wrt to the Dart API of
FunctionType. I'll update the API in a follow-up CL.
Change-Id: I896ce3c3b4522d542a82c5036f8a17ee098143dc
Reviewed-on: https://dart-review.googlesource.com/c/81367
Commit-Queue: Peter von der Ahé <ahe@google.com>
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-10-25 11:40:37 +00:00
Kevin Millikin 2e43557274 Mark Kernel classes that were Dart mixin declarations
Add a flag to Kernel classes that indicates that they were Dart mixin
declarations.  Also, add an API to Kernel Class that allows a list of
superclass constraints to be gotten from it.

Change-Id: Ie78e7e56b5421dfb9d340e4330135b8d6f4e94f1
Reviewed-on: https://dart-review.googlesource.com/75261
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-09-20 15:10:12 +00:00
Martin Kustermann 609d2770be Reland "[VM] Add new SymbolConstant to package:kernel/ast.dart"
The canonicalization of symbols needs to take library privacy into
account. Since the Symbol class itself only has a [_name] field but does
not reference in which library the symbol came from, the [_name] must be
mangled.

Mangling is done by backends and so we make a new [SymbolConstant] which
the backends can desugar by doing appropriate mangling and construction
of a [Symbol] instance.

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

Change-Id: I2e13288483c35f875d39eefdb73677b2cc03527a
Reviewed-on: https://dart-review.googlesource.com/74360
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-09-11 09:29:01 +00:00
Alexander Aprelev d97823b704 Revert "[VM] Add new SymbolConstant to package:kernel/ast.dart"
This reverts commit ef72098353 as it broke
buildbot on CQ.

Change-Id: If9d19a9393157078d0e0890b92a418ba5ced42c6
Reviewed-on: https://dart-review.googlesource.com/74281
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-10 20:40:43 +00:00
Martin Kustermann ef72098353 [VM] Add new SymbolConstant to package:kernel/ast.dart
The canonicalization of symbols needs to take library privacy into
account. Since the Symbol class itself only has a [_name] field but does
not reference in which library the symbol came from, the [_name] must be
mangled.

Mangling is done by backends and so we make a new [SymbolConstant] which
the backends can desugar by doing appropriate mangling and construction
of a [Symbol] instance.

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

Change-Id: I5ddb5331ce79a0b942807929d4b8f1050a9899e7
Reviewed-on: https://dart-review.googlesource.com/73883
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-09-10 15:31:09 +00:00
Dmitry Stefantsov 53321309da [kernel] Remove Vector-related Kernel nodes
They were supposed to be used as a part of the closure conversion pass,
which is now obsoleted.

Change-Id: Ie063f6c44487df7cd5d21895e8edc03251525d5f
Reviewed-on: https://dart-review.googlesource.com/68662
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-08-07 11:49:49 +00:00
Dmitry Stefantsov 637e55d4be [kernel] Add VariableDeclarations to represent formals of Typedefs
Change-Id: Ic1575dadb4fcf644dfdeb436612e2bed72d41a03
Reviewed-on: https://dart-review.googlesource.com/68083
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-08-03 12:28:11 +00:00
Jens Johansen d26dba1619 More positions in dart2 constant evaluator
Use positions already available in for instance AsExpressions,
also adds new offsets in the kernel format to
SuperInitializer and RedirectingInitializer.

Bug: #33216
Change-Id: I542967ddc6ec782e6513d62fce038a49239e1622
Reviewed-on: https://dart-review.googlesource.com/63883
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-07-09 07:31:44 +00:00
Jens Johansen 8747da838f Bump kernel version after e2ce88d
e2ce88dfcc changed the kernel format
but forgot to bump the kernel version.
This CL is a folow-up that bumps the kernel version.

Change-Id: Ic3f150af4b022acd971e91aed3c602cd5b1782af
Reviewed-on: https://dart-review.googlesource.com/61880
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-06-25 08:19:33 +00:00
Jens Johansen e2ce88dfcc Add startFileOffset on procedures et al, enable VMs GetSource
Prior to this change we only had fileOffset which points to the name.
This CL adds a field - startFileOffset - that points to the start
(e.g. 'static', 'factory', the return type or any presiding annotation
(including '@')), as well as fixing `Function::GetSource` in the VM to
fix a crash when using mirrors to ask for the source of a function or
constructor.

The field is added to procedures, constructors and classes.
The latter changes the location of classes with annotations to be
the position of the annotation. This is on-par with --no-preview-dart-2.
The change in regards to procedures and constructors mean, that both
the location and the source (from .location and .source on a
MethodMirror) will change to include any annotations. This is a
different behavior than --no-preview-dart-2.

Closes #33271.

Change-Id: I90f1232c5ec2d01e60e0bab070d44c37232b2730
Reviewed-on: https://dart-review.googlesource.com/60560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-06-21 13:10:04 +00:00
Samir Jindel 3d2b66074c Reland "[vm] Support definition of entry-points via @pragma('vm.extern') annotations.""
When the constant transformation is enabled on annotations, we need to fix handling
of @ExternalName annotations in the kernel_loader to ensure that we are setting
is_external = false on native methods.

The original revision is in patchset 1.

# Test Plan

The only regression was on benchmarks, Golem results are pending.

Change-Id: Ib80bb9f532299056e770a3b378cc5ad9ee451f57
Reviewed-on: https://dart-review.googlesource.com/56960
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-30 20:06:40 +00:00
Alexander Markov 1ca17b6d03 [vm/kernel] Recognize desugared mixin applications in dart:mirrors
Kernel mixin transformation desugars mixin applications into normal
classes. Mixed-in type is pulled into interfaces list.
However, dart:mirrors needs to know the original mixed-in type of
a mixin application.

This change solves this problem by propagating a 'isTransformedMixinApplication'
attribute of a class through kernel AST, kernel binary and VM objects
into dart:mirrors implementation.

Fixes: https://github.com/dart-lang/sdk/issues/33240
Change-Id: I98ca69294e1ad445402a5ca91d90c30447aabcb2
Reviewed-on: https://dart-review.googlesource.com/56721
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-05-29 18:12:26 +00:00
Samir Jindel 58dc4e476d Revert "[vm] Support definition of entry-points via @pragma('vm.extern') annotations."
This reverts commit 3e50ea32b5.

Reason for revert: Severe performance regressions on many aot-v2 benchmarks.

Original change's description:
> [vm] Support definition of entry-points via @pragma('vm.extern') annotations.
> 
> The `@pragma` annotations are evaluated by the constants transformation and
> visible to TFA and the precompiler, which match on the "options" field of the
> annotation to determine whether to mark the class/procedure as a root.
> 
> This required enabling the transformation of annotation constants by default.
> 
> # Test Plan
> 
> The "vmservice_io.main" entry-point is removed from `main.cc` and annotated with
> `@pragma`. All precompiler tests will crash if "vmservice_io.main" is not
> available at runtime.
> 
> Debug/release precompiler bots are visible in "cl-linux" button.
> 
> Change-Id: I03c5d6ba7918672ed9905fcaee8dabe675a93a5d
> Reviewed-on: https://dart-review.googlesource.com/56660
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,sjindel@google.com

Change-Id: I779c17d003659129a4b3fcf284423104948f60e2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/56820
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-05-28 19:23:16 +00:00
Samir Jindel 3e50ea32b5 [vm] Support definition of entry-points via @pragma('vm.extern') annotations.
The `@pragma` annotations are evaluated by the constants transformation and
visible to TFA and the precompiler, which match on the "options" field of the
annotation to determine whether to mark the class/procedure as a root.

This required enabling the transformation of annotation constants by default.

# Test Plan

The "vmservice_io.main" entry-point is removed from `main.cc` and annotated with
`@pragma`. All precompiler tests will crash if "vmservice_io.main" is not
available at runtime.

Debug/release precompiler bots are visible in "cl-linux" button.

Change-Id: I03c5d6ba7918672ed9905fcaee8dabe675a93a5d
Reviewed-on: https://dart-review.googlesource.com/56660
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-28 15:13:55 +00:00
Kevin Millikin e2597dfba7 Revert "Mark normal classes that were originally mixin applications"
This reverts commit 53cd0b4af1.

The commit causes failures in the VM's precompiler because its mixin
deduplication transformation apparently needs to distinguish between
anonymous and named mixins.

Change-Id: I3861a3bf90b10f627d5fc8f0e94f117c102422d7
Reviewed-on: https://dart-review.googlesource.com/56780
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-05-28 12:05:46 +00:00
Kevin Millikin 53cd0b4af1 Mark normal classes that were originally mixin applications
To implement dart:mirrors correctly, a backend like the VM needs to
know that a class was originally a mixin application.  Use the
`isSyntheticMixinImplementation` flag which was already there and
ignored by the VM.

Now the property is:

- if `isSyntheticMixinImplementation` is set on a class with a
  mixed-in type, then it was originally an anonymous mixin application

- if `isSyntheticMixinImplementation` is set on a normal class then it
  was originally a mixin application of some kind and the mixed-in
  type can be found as the last impelemented type

Bug: https://github.com/dart-lang/sdk/issues/33240
Change-Id: I004adc6bfe08e583efba8e511076a6c603c0c687
Reviewed-on: https://dart-review.googlesource.com/56760
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-05-28 09:17:34 +00:00
Alexander Markov 344c68e54c [kernel, vm] Revise how metadata is written in kernel binaries
Metadata is no longer written ahead of all nodes. Instead, metadata for
each node is written in the same context as the node itself (into a separate
buffer). This allows metadata to contain (serialize) arbitrary nodes
(for example, arbitrary DartTypes) and use serialization context of parent
nodes (such as declared type parameters).

However, with this change metadata looses the ability to reference
arbitrary AST nodes. This ability was overly restricted and had no
practical uses. (It was not possible to reference nodes which are not
reachable from root Component. As a consequence, it was not possible to
write references to arbitrary DartTypes.)

This change aligns the serialization capabilities of metadata with
how kernel AST nodes are serialized.

Change-Id: I027299a33b599b62572eccd4aa7083ad1dd2b3b3
Reviewed-on: https://dart-review.googlesource.com/54481
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-15 00:41:08 +00:00
Kevin Millikin 8dbe716085 Remove the unused GenericCovariantInterface bit
None of the back ends are using it and it imposes a cost to have to
compute it and try to preserve it.

Change-Id: I217e1191b535829021fa11f2698cadd8d4baf1c8
Reviewed-on: https://dart-review.googlesource.com/54383
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-09 15:04:43 +00:00
Jens Johansen 2ccafe7a54 [kernel] Change dill representation of doubles
This is the second try. First commit failed because another reading of
the binary was added after the change was originally made and before
actually landing it (and wasn't noticed when rebasing).
This reverts commit b298fc6d8f.

See 6e2536f585 for more information.

Change-Id: Ia0e7f8921de2cec8088654fa24950df13d846237
Reviewed-on: https://dart-review.googlesource.com/53560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2018-05-08 13:15:13 +00:00
Alexander Aprelev 384a59595c Recognize synthetic catch-clause and unhandled exceptions.
Bug: https://github.com/flutter/flutter/issues/16741
Change-Id: I619c2eb0662cfdd16cc865ae5eae9c7d19bc55c4
Reviewed-on: https://dart-review.googlesource.com/52984
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-05-02 22:39:56 +00:00
Alexander Aprelev b298fc6d8f Revert "[kernel] Change dill representation of doubles"
This reverts commit 6e2536f585 as it
breaks flutter hot_reload test.

Bug: https://github.com/flutter/flutter/issues/17202
Change-Id: I36261a1aec5ec2196c3a02cc0da0dc0833337004
Reviewed-on: https://dart-review.googlesource.com/53460
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2018-05-02 20:25:58 +00:00
Kevin Millikin 9371ca061c Remove all the contravariance bits
Change-Id: Ib43b32d12749ddac0a93795cb5e8543eb5131dd9
Reviewed-on: https://dart-review.googlesource.com/52867
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-01 10:56:11 +00:00
Jens Johansen 6e2536f585 [kernel] Change dill representation of doubles
Previously doubles was saved as strings in the string table,
with a DoubleLiteral holding a StringReference.

This can cause overhead in both computation time
(converting the double to and from string) as well as size
(e.g. a single usage of the previously unused double 1000000.42
would use (at least)
* 10 bytes for the characters
* 1 byte for the size
* 1 byte for the reference to the string

whereas saving it as a double would simply save the 8 bytes.

On the other hand the string table doesn't contain duplicates so
many usages of the same double will use more space.

The SDK dill file size decreases slightly (< 1 KB).

On a Dart file with 1M different doubles (0.42, 1.42, ..., 999999.42)
added to a list:

Before:

compile and write via fasta (non-strong-mode): 0:12.18
Reading (via dart, eager): 2500-2600 ms
Writing (to null sink) (after reading): 1600-1800 ms
Output dill file (via fasta compile): ~62 MB

After:

compile and write via fasta (non-strong-mode): 0:11.76
Reading (via dart, eager): 2050-2350 ms
Writing (to null sink) (after reading): 400-550 ms
Output dill file (via fasta compile): ~54 MB

Running the dill file is ~the same time, but "Maximum resident set size
(kbytes)" (from /usr/bin/time -v) decreases with ~4%.

On the other side, if it's 1M of the same doubles (0.42), while
compiling is ~the same speed, the output dill goes from 43MB to 50MB.
Surprisingly the "Maximum resident set size (kbytes)" still decreases
though (~3%).

Running flutter test in flutter/packages/flutter:

Before:
```
02:33 +2425 ~18: All tests passed!
02:28 +2425 ~18: All tests passed!
02:28 +2425 ~18: All tests passed!
```

After:
```
02:12 +2425 ~18: All tests passed!
02:11 +2425 ~18: All tests passed!
02:12 +2425 ~18: All tests passed!
```

So that's -12.0267% +/- 3.15253%

File size of a dill file of an arbitrary test using flutter is reduced by ~44 KB (~0.3%).

Change-Id: I64151376cde1dae6f0d02b3d96991bc432a994ae
Reviewed-on: https://dart-review.googlesource.com/41660
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-01 09:35:21 +00:00
Martin Kustermann e9ffc02663 Add partial instantiation support for constant evaluator [PartialInstantiationConstant]
Change-Id: Iaa93da60331737aaa6bceb4d2fe1d791dc7e95e9
Reviewed-on: https://dart-review.googlesource.com/52445
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-04-25 09:25:28 +00:00
Kevin Millikin 74cf86cbbb Remove Kernel's DispatchCategory
It complicates the intermediate language, none of the back ends are
using it, and it's not something that we want transformation writers
and code generators to deal with.

Change-Id: Ic79f7935dd8619bd233346bb25947e864f38a104
Reviewed-on: https://dart-review.googlesource.com/50440
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-04-11 07:43:41 +00:00
Peter von der Ahé 47f09a619e Redesign LibraryPart
Before, the part-URI was serialized as a file-URI and conflated with
source location information. The part-URI is the URI in the following
declaration in a Dart source file:

   part "URI";

This is different from what we normally call a file-URI. A file URI
is used to point to the source location of the part declaration, not
the URI in the part declaration.

Furthermore, the field was serialized using writeUriReference which
only works for URIs that are in the uriToSource map on a Component.
Although this might seem like a safe optimization, it doesn't work
if the uriToSource map is omitted or if a part declaration refers to
a missing file.

Finally, due to the confusing use of fileUri, LibraryPart was
mistakenly implementing FileUriNode and annotations were stripped
of source locations if the source for the part were omitted from
uriToSource.

The partUri field is now an unresolved string that can be resolved
against either the parent library's import- or file-URI to obtain
either version as needed.

Change-Id: I255cb4eeaf89928292ab32a2f6be9ead6cc8cee1
Reviewed-on: https://dart-review.googlesource.com/49500
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-04-04 16:08:57 +00:00
Samir Jindel 70f455351d [kernel] Add field for instantiate-to-bounds algorithm in TypeParameter.
Change-Id: Idd1859b378080f01dc5d5078ee0960021c1689b6
Reviewed-on: https://dart-review.googlesource.com/48424
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-03-27 22:26:07 +00:00
Samir Jindel 95e9e890a9 [kernel/vm] Implement NSM-forwarding in the VM.
Change-Id: I43ce98235a7fdb43f99f433ef8dd10a6ed08fbbb
Reviewed-on: https://dart-review.googlesource.com/47621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-03-22 19:14:04 +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 65b19ffa3c Translate asserts in the VM-specific async translation
Translate assert statements in async functions.  The translation of
the condition subexpression can produce a sequence of statements that
have been hoisted out of it.  These need to be guarded so they are
executed only when asserts are enabled.

For this purpose, we introduce an AssertBlock.  The semantics of the
assert block:

assert { s0; ...; sn; }

is the same as:

if (assertsEnabled) { s0; ...; sn; }

where assertsEnabled is a more primitive nullary expression that is
true iff. assertions are enabled.  We chose not to encode this using a
construct like assertsEnabled because (1) we would have to support it
appearing as an arbitrary expression which we don't currently need
and (2) it requires deeper pattern matching to detect and skip the
guarded code when desired.

The translation is more complicated because if there is a message
subexpression in an assert, it is conditionally evaluated only if the
assert's condition is false.

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

Change-Id: I0912a57104ede3160533e49f65b6fb79b76f1500
Reviewed-on: https://dart-review.googlesource.com/46442
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-03-14 19:41:09 +00:00
Martin Kustermann aeee91ac5d [VM] Remaining fixes for flutter coverage issue
This CL changes:

   * package:kernel/clone.dart: To not clone file offsets if the
     file-uri we copy from is unknown.

   * package:kernel/binary/ast_to_binary.dart: To not write out file
     offsets if the file-uri is not written/indexed (which happens if
     the file uri is not in the `Program.uriToSource` map).

   * It reverts the file renaming part of 60a2cfa219 which
     fixed the name collision problem only partially (it missed to
     rename `runtime/lib/double.dart`, which is not possible because
     there's already a `double_patch.dart` file).

     Instead of renaming, we solve the problem by mangling the names as follows:

         .../sdk/lib/core/double.dart       ->  dart:core/double.dart
         .../runtime/lib/double.dart        ->  dart:core/runtime/lib/double.dart
         .../runtime/lib/double_patch.dart  ->  dart:core/runtime/lib/double_patch.dart

   * It changes the test to ignore any negative token positions.  The vm
     service does not just expose `-1` token positions for places where
     there is no source, but also e.g. `-9` (which means TokenPosition::kMethodExtractor),
     this was one reason why the appjit test failed.

   * It changes the test to try to force-compile everything (unsure if that works).

Issue https://github.com/dart-lang/sdk/issues/32489

Change-Id: Ia9f42ca9d56d987e3041175add549bb7a133f269
Reviewed-on: https://dart-review.googlesource.com/46341
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-03-14 17:08:17 +00:00