Commit Graph

1059 Commits

Author SHA1 Message Date
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
Aske Simon Christensen 5121a2e831 [cfe] Read product mode directly from environment in async transform.
When we perform constant evaluation in the CFE, the async transform
runs after constant evaluation. Thus, it can no longer use const
bool.fromEnvironment("dart.vm.product") to query whether the VM is
in product mode.

Instead, it can read the product mode define directly from the
environment defines given to the CFE and generate different code
depending on the value.

Change-Id: I2aabc4a84b50a940d35d5664ff4ebdf0680ed5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111645
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-08-07 08:28:25 +00:00
Jens Johansen 69ae29076a Default language version if nothing is specified
A kernel library will say it has the newest language version if no
language version is set.
This basically preserves the current semantics of always being on the
newest version (if nothing is explicitly done), e.g. if creating a kernel
library by hand and not setting it.
The front_end also utilize this and just doesn't set it, if it isn't set.

Change-Id: I033fef13626ee034030ba8fc9d141b182ba1a5ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111739
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-08-06 09:13:29 +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
Jens Johansen 6d1c9975d7 [CFE] Initial language versioning "support"
This CL sets up the bare minimum support for saving the language version
specified in a file on the kernel library, and adds simple support for
testing it.

The data is not serialized out, error checked or similar in this change.

Change-Id: I4b061ce617acae7964b85be105e0ad0e3e031aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111640
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-08-05 07:03:04 +00:00
Dmitry Stefantsov 2875b1bcce [kernel][nnbd] Keep declared nullability on type parameter types
Programmers can use nullability modifiers on type parameters when using
them as types.  However, the actual nullability of such types is
calculated from that and also from the bound of the type parameter, and
from the promoted bound if it has it.  Previously, the final result of
the nullability calculation was stored on the type.  This CL also stores
the nullability declared by the programmer.

Change-Id: Iabbddc1e8a477678975190fa00bf702c914f7777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111424
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2019-07-31 11:38:23 +00:00
Johnni Winther fe2f82650b [cfe] Remove generics from Loader and UnresolvedType
+ cleanup raw types to remove severity rewrite for codeMissingExplicitTypeArguments

Change-Id: I30af950db640cb15ddeeb86e17d9e9cb960a76d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110902
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-07-31 11:19:52 +00:00
Dmitry Stefantsov 20e4c74f7f [fasta][nnbd] Print NNBD type modifiers in Kernel's text representation
Change-Id: I48c43858094e2b7264a15be05238bfc3dadd5ecb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108264
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-07-31 08:26:14 +00:00
Stephen Adams 87626888a4 [cfe, dart2js] Constant hashcode improvements.
CFE and dart2js hashCodes for class instance constants behaved poorly
for certain patterns.

The new tests in https://dart-review.googlesource.com/c/sdk/+/110640
take too long with dart2js (many minutes).

These changes bring dart2js compilation into the normal expected time
(a few seconds) for this size of input.

Change-Id: I67f9be826c2ce7e395379f1ddfff422523631bb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110660
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-07-28 16:53:50 +00:00
Johnni Winther bcfe26cba0 [cfe] Fail early on unsupported evaluated constants
The many different entrypoints to the CFE have repeatedly shown problems
with targets that do not support unevaluated constants being used
without providing an environment.

Making the targets opt-in to supporting unevaluated constants will
give the users of CFE early notice that CFE is used inconsistently
(as opposed to the backends failing when they happen to see an
UnevaluatedConstant node that they don't support).

Change-Id: I98c80df3a551823598e413e2895f5649f22f7c22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110561
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-07-26 16:57:51 +00:00
Johnni Winther a66a3e321e [cfe+dart2js] Handle duplicated references in constant nodes.
Change-Id: If21810ea938cd697039e9549c7dbd6ac869eabc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109260
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2019-07-17 06:26:34 +00:00
Vyacheslav Egorov cbaf890f88 [kernel] Few more tweaks to ast_to_text for Constant nodes.
- Change formatting of Set/Map/List constants to match Dart literals
- Add formatting methods for TearOff and PartialInstantiation constants

Change-Id: Ie7deac3ee6b5a60e0bcc8088bab2c819a1d3788a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108808
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-07-12 11:41:33 +00:00
Jens Johansen 28f95fcd24 [cfe] Track dependencies in the incremental compiler
The objective of this CL is to allow the incremental compiler to track
which dill input libraries it actually used (in order to - in a modular
context - be able to ignore changes to dependencies we didn't really
use).

This is done by:
* Making the dill library builder lazy (and mark if it has been used).
* Making kernels class hierarchy record which classes it has been
  asked questions about.
* Add special handling to redirecting factory constructors as they
  bypass the fasta-builders and directly use the kernel ast.

Please note that:
* This has to be enabled, but kernels class hierarchy always records
  which classes it was asked about (even if disabled,
  or not running though the incremental compiler).
  There might potentially be some overhead to this (though setting
  a bool to true is probably comparably cheap - we did just do a
  map lookup).
* This was designed to be used together with modules
  (e.g. setModulesToLoadOnNextComputeDelta) - as used via for instance
  api_unstable/bazel_worker.dart. It might not function the way you'd
  expect in other circumstances.
* The incremental compiler (potentially) gives you the full kernel tree
  despite not having marked all of those libraries as 'used'. If a
  client use such libraries it is the clients responsibility to take
  that into account when answering any questions about this
  libraries/dill files was used.
* This feature works on the library level. In practice it is most likely
  needed at the dill-filename level. A translation from library to
  dill-filename is up to the client.
* This is a new feature, and we cannot promise that 100% of actually
  used libraries are marked. If you find used but un-marked libraries
  please report a bug.

Change-Id: I01d7ff95b9baac9550b77d8e09ea772d43173641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-07-12 10:40:55 +00:00
Vyacheslav Egorov afac6b1d50 [kernel] Fix text serialization for Constant nodes
Make sure to use Printer methods when formatting class references
instead of going through TreeNode.toString which uses globalNames
instead of Printer's own syntheticNames.

Change-Id: I3107a1b4d5d6d2b26a9f0001f846bd74b85853df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108803
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
2019-07-12 10:20:25 +00:00
Johnni Winther d16c0a127e [cfe] Change supportSetLiterals default value to true
This aligns the NoneTarget with the raw output of the CFE.

Change-Id: Ic3a0a3de46dac389d0ade581192e392fdaba9553
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108721
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-07-11 08:54:19 +00:00
Alexander Markov 1eb113ba27 [vm/bytecode] Support native extensions
Change-Id: I224f740db674e20d643191605d0a7463bf85d39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107451
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-27 20:24:25 +00:00
Dmitry Stefantsov bce89db6a5 Reland "Combine override checks and override-based inference in one phase"
Original CL description:

> Combine override checks and override-based inference in one phase
>
> Change-Id: I2760f72f4eaa44bd192747179e843f017db30874
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97301
> Commit-Queue: Peter von der Ahé <ahe@google.com>
> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>

Change-Id: I8408b35819a89336d10bb11e36c7b1bee707994d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100580
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-06-25 08:02:46 +00:00
Dmitry Stefantsov 0a4d47de3c [fasta][nnbd] Add nullability modifiers to DartType
Change-Id: Ica2e5e250831573453c1d469571d9d001e7702a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106642
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-06-21 11:43:26 +00:00
Alexander Markov 0ae10fa68d [vm/bytecode] Support --causal_async_stacks in bytecode generator
Also, standalone_2/causal_async_stack_test is updated to actually
test --causal_async_stacks after Dart 2 sync-async.

Change-Id: I28a7a281963828707461652f19494ff54bdd21c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106760
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-20 20:23:37 +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
Johnni Winther cbe48553c0 [CFE] Add LocalFunction as super-interface for FunctionExpression and FunctionDeclaration
+ use it in dart2js to simplify and clarify handle of local function nodes

Change-Id: I35da2dd8bd3baba6eff6ad631ebe63d572bae4d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105423
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-06-12 07:20:39 +00:00
Dmitry Stefantsov 40ef0c6d9f Specify type of _location field in Widget Inspector Transformer
The change in the CL prevents the widget transformer from introducing
compile-time errors.

Change-Id: Ib4a73eb13fb33397daeb5d17c613c42a1d1a6025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105245
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-06-07 08:02:54 +00:00
Jens Johansen 5eff2a0374 Split CanonicalNameError, no warning if CanonicalNameSdkError
Prior to this CL, we would issue a warning whenever a CanonicalNameError
was encountered.
This is in principal a good thing, but because we currently have no way
to detect if the sdk we get is the one we expect
(by any other measure than when it issues a CanonicalNameError) we often
issue these warnings for no "real reason" whenever, for instance,
the flutter sdk changes.

This CL splits the CanonicalNameError in two such that errors with
references to the sdk ("dart:" libraries) issue CanonicalNameSdkError
instead, an we then handle that differently. Namely we silently ignore
the error (i.e. don't issue a warning) and just don't initialize from
dill.

This should remedy the situation and be strictly better than to always
swallow CanonicalNameErrors.

Bug: 36032
Change-Id: Idbae0b5ee5b9843a5dbeb49b3c65ae25f5962e36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105240
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-06-06 10:10:46 +00:00
Kevin Millikin 907f31e6de Reland "[cfe] Build some annotations during outlining"
Reland the change to build some annotations during outlining, with a
bug fix.  Annotations from patch classes and procedures were not
applied to the actual class or procedure, which is fixed.

The original commit was reviewed at
https://dart-review.googlesource.com/c/sdk/+/103806

The revert was reviewed at
https://dart-review.googlesource.com/c/sdk/+/104220

The original commit message was:

    During the outline phase, after top-level type inference, compile
    annotations for libraries, classes, fields, procedures, and
    constructors.

Change-Id: I836160ddad4114ded72701e8a3938f703228931c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104560
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-06-03 10:20:15 +00:00
Vyacheslav Egorov 39ec9fc4f3 Revert "[cfe] Build some annotations during outlining"
This reverts commit 1df5fb3d57.

Reason for revert: large regressions on Flutter microbenchmarks. Reverting to prevent this reaching Flutter.

Original change's description:
> [cfe] Build some annotations during outlining
> 
> During the outline phase, after top-level type inference, compile
> annotations for libraries, classes, fields, procedures, and
> constructors.
> 
> Change-Id: I95ca65fd58ad88d9452a28d5a0652bee44aeda3a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103806
> Commit-Queue: Kevin Millikin <kmillikin@google.com>
> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>

TBR=alexmarkov@google.com,dmitryas@google.com,askesc@google.com,kmillikin@google.com

Change-Id: I67c0719f9175c1bd75b609d7d5c0cea5c294bd6d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104220
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-05-30 08:46:55 +00:00
Kevin Millikin 1df5fb3d57 [cfe] Build some annotations during outlining
During the outline phase, after top-level type inference, compile
annotations for libraries, classes, fields, procedures, and
constructors.

Change-Id: I95ca65fd58ad88d9452a28d5a0652bee44aeda3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103806
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-05-30 07:29:12 +00:00
Aske Simon Christensen 25033cee32 [CFE] Control inlining of const variables from backend.
Needed for https://github.com/dart-lang/sdk/issues/36535

Also preserve StaticGet of unavailable constants not in const context,
rather than wrapping it in an unevaluated constant.

Change-Id: Ifac6f251ea9a90a17d06014be12c0d387a32d757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99020
Reviewed-by: Vijay Menon <vsm@google.com>
2019-05-27 11:45:08 +00:00
Aske Simon Christensen f051cd5b4d [CFE] Transform spread and if in const collections early.
This makes sure that the AST before constant evaluation only contains
official kernel nodes.

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

Change-Id: Ic4e8e15adeaea8ad4700d6feb67e31f5f0a54f7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103123
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-05-21 11:07:26 +00:00
Jens Johansen 7f67e83e36 Add sanity check assert int class hierarchy
Change-Id: Iddcf2b64f745bb9385fb5b1621afa68056da89a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103127
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-05-21 08:23:08 +00:00
Jens Johansen 099af47a69 [kernel] add ability to disable offsets for bazel worker to use
This is a lightly modified version of Jennys CL @
https://dart-review.googlesource.com/100275

Change-Id: I46a1665d84d04602af1f338cf963bc25b4e6b25c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-05-21 07:55:10 +00:00
Jacob Richman e2976acd22 Add --track-widget-creation flag to frontend_server.
This is needed to activate the kernel transformer embedded with the kernel package from the flutter engine.

Change-Id: I3253e01723b662eb48b4b3743ac5bcc1b44c7d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102920
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jacob Richman <jacobr@google.com>
2019-05-20 22:47:28 +00:00
Aske Simon Christensen 8754351283 [CFE] Run widget transformer before constant evaluation.
Change-Id: I51ded35ecb95cb5cfbac5ecf8967e0918a48269a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101987
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
2019-05-10 11:02:49 +00:00
Aske Simon Christensen 1179467a5e Move widget transformer to kernel package
Change-Id: I7f9ece029e181d380f37028ed04f97d4fdfb12b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101985
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-05-10 11:02:49 +00:00
Jens Johansen 407378879b Error reporting and ~no location data
We shouldn't crash and reporting something as being on line 1 of a file
because we don't know where in the file it is, doesn't seem right.

Change-Id: Ia8d6145e21a136903771d876633036b292ea12ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100842
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-05-01 10:24:46 +00:00
Jens Johansen ed8e4255a4 Proposed fix to #36644
TL;DR: Unbind canonical names doesn't do what you think it does and
probably shouldn't (ever) be used. This CL stops using it in a few places.

Longer version:

When loading a dill file it:
- First loads the table of canonical names. These have no references yet.
- When a canonical name is asked for its reference it creates one if it
  doesn't yet have one.
- When loading, for instance, a library, it asks for the reference.

When unbinding a canonical name:
- It removes itself (the canonical name) from the reference
- It removes the reference in itself
- Note: Whatever has a pointer to the reference keeps it, and the
  reference points to whatever node it already pointed to.

This also means, that if we have a dill file that's split in two and:
- Load #1
- Load #2
that works fine, but if we
- Load #1
- Unbind canonical names
- Binds canonical names
- Load #2
stuff is not bound correctly (and an error is thrown).

And - the cause of this bug:
- Load #1
- Load #2
everything is fine
- Unbind canonical names
- Binds canonical names
- Load #2'
stuff is not bound correctly --- references points to stuff loaded as #2,
not as #2'. On top of being weird, wrong and confusing it also caused wrong
things to be but into the class hierarchy which ultimatly caused the crash.

This CL fixes it by not calling unbind and force loading of dill files
(at specific call sites) to create new libraries
(and in the process overwriting references ".node").

Revert "[dartdevc] Retry ddc incremental compile on crash"

This reverts commit ecdbdf00b8.

Revert "[kernel_worker] retry on failure"

This reverts commit 43eebea5a3.

Fixes #36644

Bug: #36644
Change-Id: Id8f548179e6a409b01f2ebfa3219f94cb64b1c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100380
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-04-26 07:18:28 +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
Jens Johansen 88068ebfe3 Add missing _getLocationInEnclosingFile on Typedef
Change-Id: I81fbef620fd1742fe9a6e6428596718b038b0925
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98462
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-11 12:34:04 +00:00
Jens Johansen 460d00616c Better printing of imports
Before a import of, say "hello.dart" was printed as
"import './hello.dart'".
Now instead it is printed as "import 'hello.dart'".

At the same time we get rid of a dependency.

Change-Id: I352f0f507168fde75358704ec9bf0e248bb8179d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98480
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-04-11 11:43:23 +00:00
Jens Johansen fe535ac27c Add missing offset to yield produced by await for
Fixes #36069.
Fixes #28916.

Change-Id: I1acc6b9f0aaba100827749a1f3653f5cc9e4fd2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98665
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-04-11 11:16:13 +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
Johnni Winther 4fc0e1f13d Use .nullType as type of null and fix null type handling in getStaticTypeAsInstanceOf
The .getStaticType results for NullLiteral and NullConstant are inconsistent. The former returns `const BottomType()` and the latter return `TypeEnvironment.nullType`.

To avoid this inconsistency and since `const BottomType()` is really the "unreachable" type, used for instance of for the type of a throw expression, the implementation is changed to consistently use the .nullType.

For this to work, getStaticTypeAsInstanceOf (and the equivalent dart2js implementation), and the `Type.fromStaticType` constructor in the VM type flow analysis have to special case the .nullType.

Change-Id: If6b806d4a39ef7b906275c43fa2089b9d140523b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98563
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-09 06:49:17 +00:00
Kevin Millikin b700223542 [cfe] Do not reset the VM async name generator
In the VM-specific async transformation, an index is used to generate
fresh temporary names for values that are live across an await.
Before it was always 0 when translating a statement because there are
no live values on entry or exit to a statement.

When translating statements nested inside block expressions there can
be live values, so the index should not be reset.

Closes https://github.com/dart-lang/sdk/issues/36466

Change-Id: I6103d75c25f312ab1538a7c0f8fee0fea9f01b27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98664
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-04-05 09:00:24 +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 8ce2d7a4e1 [CFE] Better error messages on errors with user definable operators
Fixes #36383

Change-Id: I24fd51bdb3ead75973009fe515819f9c8354e1b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98332
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-02 10:46:18 +00:00
Kevin Millikin c71888d537 [cfe] Async translation of block expressions
Translate block expressions in the VM's async translation.  Closes
https://github.com/dart-lang/sdk/issues/36277

Change-Id: I606b155bfe1364e948d18043c167a272007411e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98339
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-04-02 10:00:53 +00:00
Johnni Winther 1a3e8dda3b Handle nested unevaluated constants in constant evaluator
The constant evaluator assumed that any ConstantExpression met during evaluation of a sub expression was not an unevaluated constant. This do occur, for instance when a field is initialized to an unevaluated constant. With the change, unevaluated constants met during evaluation are themselves evaluated.

This change also fixed handling of assert initializers in unevaluated constants.

Change-Id: Id9e676f40bc829c4d234f34a74ef0ca5c4c6ec48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98348
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-04-01 14:29:32 +00:00
Alexander Markov 61f0f5bc43 [vm/bytecode] Declare members in bytecode
This change replaces kernel AST declarations of fields and functions
with bytecode declarations.

Size of dilp files is reduced by 11-12%.

Startup latency:
Time to the first full frame: 1.945s -> 1.687s
FinalizeClass: 554ms -> 277ms
FinishClassLoading: 296ms -> 156ms

There are following regressions in bytecode mode, which will be fixed
in future:

* dart:mirrors are not supported yet (implementation of mirrors relies
  on reading kernel AST in certain cases).

  As the result, lib_2/mirrors/* tests fail.

* native extensions are not supported yet (annotations on libraries
  and classes in AST are cleaned up as they could reference members
  which are now removed from AST).

  As the result, standalone_2/entrypoints_verification_test test fails.

* language_2/spread_collections/const_error_test/* tests fail
  due to https://github.com/dart-lang/sdk/issues/36286.

Change-Id: I5130f401fd7b84038b136136e7ccc1a6e51b6cea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97561
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-26 21:40:10 +00:00
Vyacheslav Egorov c9ecdabe5d Revert "Combine override checks and override-based inference in one phase"
This reverts commit 9db4119b67.

Revert "Change default of 'keepFields' in constant transformation to true"

This reverts commit b1e14cbe5f.

Revert "[fasta] Don't create forwarding stub if there's already a member"

This reverts commit 51da94da76.

These commits are reverted to unblock rolls into Flutter.

b1e14cbe5f is reverted because it contained
changes that prevented clean revert of the other CLs.

Change-Id: I8d3c00f0c1b146f4debe7f1a1a7de75be154e265
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97802
Commit-Queue: Alexander Aprelev <aam@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-03-25 19:40:26 +00:00
Peter von der Ahé 9db4119b67 Combine override checks and override-based inference in one phase
Change-Id: I2760f72f4eaa44bd192747179e843f017db30874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97301
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-03-22 08:59:48 +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