Commit Graph

1571 Commits

Author SHA1 Message Date
Johnni Winther 1aa6f00107 [kernel] Refactor CanonicalName/Reference integration
The CL is a step towards have a more restricted and wellstructured
handled of references and canonical names.

The CL moves Reference to canonical_name.dart and makes
CanonicalName.reference private, and replaces CanonicalName.getReference
with a 'reference' getter.

It also removes NamedNode.canonicalName, Field.getterCanonicalName and
Field.setterCanonicalName so that these can only be accessed through the
corresponding reference. This is to reduce the reliance on the
canonical names which, ideally, should only be part of serialization and
deserialization.

TEST=existing

Change-Id: I955fb7d52d4e112d8741f7c12dcf38b74ae0c91a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190442
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-10 15:39:28 +00:00
Anna Gringauze 14eeb7507f First version of incremental DDC mode for expression compilation
- Support evaluate() calls from VM service in expression compiler
  - emit all accessed symbols, types, constants, extension symbols,
    and imports as part of synthetic evaluation function
    - Note: this fixes missing symbol issues in evaluateInFrame()
      as well
  - update expression evaluation tests
  - fix expression compilation broken after hot reload

See widget inspector layout explorer, a result of evaluate() call:
https://drive.google.com/file/d/16UdSE5_V1ZRXAf2KeBxNwYNHMfo1RbnT/view?usp=sharing&resourcekey=0-HZcPm68VbsVzrZ672CApvA

Closes: https://github.com/dart-lang/sdk/issues/41480
Closes: https://github.com/dart-lang/sdk/issues/44979
Closes: https://github.com/dart-lang/sdk/issues/44713
Closes: https://github.com/dart-lang/sdk/issues/44933
Closes: https://github.com/dart-lang/sdk/issues/44813
Closes: https://github.com/dart-lang/sdk/issues/44686
Change-Id: I96c74578c51503adbc4bfe6d6e6112319addc959
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188400
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-03-09 17:23:05 +00:00
Johnni Winther 01b0947a6d [kernel] Update kernel encodings
* Add InstanceGetterInvocation for getter/field invocation in web
  backends
* Add localFunction getter to LocalFunctionInvocation
* Remove isNot from EqualsCall and EqualsNull - the encoding didn't
  carry its weight.
* Remove uses of Name.name
* Remove BottomType code from VM

TEST=existing

Change-Id: I99d05d35b9ef193d092cc151c99ad472dbd60834
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188725
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-08 11:29:51 +00:00
Riley Porter bfaf674479 Optimize js_util getProperty calls to lowered call to native JS.
No change in the generated JavaScript for dart2js based on both a small
foo.dart sample file and tests/lib/js/js_util/properties_test.dart

All changes in generated JavaScript for DDC are smaller and clearer:
  - foo.dart: https://paste.googleplex.com/4738045023617024
  - properties_test.dart: https://paste.googleplex.com/5107699705446400

Bug: #44533
Change-Id: I670f0226fbef90d05a95c51d918831bea58d6aa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187840
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-03-06 01:16:24 +00:00
Jens Johansen 93f4ac0a83 [cfe] Actually have both ansi and plain text formatted messages (2nd try)
The CFEs FormattedMessage always had two getters to get the text inside
one that would supposedly give an ansi formated version of the message
and one that would supposedly give a plaintext formated version of the
message. They both returned the same string, though, which would either
be with ansi escape codes or plain text depending on the environment at
compile time.

This CL fixes that by having both messages, and letting the reporting
(i.e. whenever the message is read) decide which to use. That way we
can - for instance - report errors with color if the terminal supports
it correctly when reusing a dill (and reissuing problems, but where the
terminal support changes) and if printing the problem to an html <pre>
field (like observatory does).

It also cleans up two different implementations of whether we think
the terminal supports colors or not, by deleting one of them.

This is the second try. Patchset #1 is the original.
Patchset #2(and possibly beyond) is the changes.

TEST=Existing test suites.

Change-Id: I8e483049ce81ce1bd8e5396b588a31e0ad3a8630
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187402
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-26 13:06:17 +00:00
Nicholas Shahan ab789de75b [ddc] Add full .dill uri to metadata
Change-Id: I0333b41298c5556d6ce72e339c9eec061b620866
Fixes: https://github.com/dart-lang/sdk/issues/43684
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181861
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-25 19:35:41 +00:00
Dmitry Stefantsov c191551fac [cfe] Remove BottomType
TEST=Covered by existing tests.

Change-Id: Ied8be1874164e68e0a3a48e1b2f9a33310071381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183009
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-24 13:21:55 +00:00
Jens Johansen 3a4a4f53d0 Revert "[cfe] Actually have both ansi and plain text formatted messages"
This reverts commit f63f7736c5.

Reason for revert: This somehow breaks the Windows bots. `python tools/test.py -n dartk-win-release-x64 standalone_2/io/process_shell_test`.

Original change's description:
> [cfe] Actually have both ansi and plain text formatted messages
>
> The CFEs FormattedMessage always had two getters to get the text inside
> one that would supposedly give an ansi formated version of the message
> and one that would supposedly give a plaintext formated version of the
> message. They both returned the same string, though, which would either
> be with ansi escape codes or plain text depending on the environment at
> compile time.
>
> This CL fixes that by having both messages, and letting the reporting
> (i.e. whenever the message is read) decide which to use. That way we
> can - for instance - report errors with color if the terminal supports
> it correctly when reusing a dill (and reissuing problems, but where the
> terminal support changes) and if printing the problem to an html <pre>
> field (like observatory does (1)).
>
> It also cleans up two different implementations of whether we think
> the terminal supports colors or not, by deleting one of them.
>
> (1) At least sometimes. It works - I think - only for 'evaluateInFrame',
>     but that's another story (and will be fixed in a follow-up CL).
>
> TEST=Existing test suites.
>
> Change-Id: Iedaedd9a5c41458d40c23ed4b706324c004ae943
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186291
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: I0b53f943a61f76705badfead30d9e1ee35baff57
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186941
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-02-24 12:30:18 +00:00
Jens Johansen f63f7736c5 [cfe] Actually have both ansi and plain text formatted messages
The CFEs FormattedMessage always had two getters to get the text inside
one that would supposedly give an ansi formated version of the message
and one that would supposedly give a plaintext formated version of the
message. They both returned the same string, though, which would either
be with ansi escape codes or plain text depending on the environment at
compile time.

This CL fixes that by having both messages, and letting the reporting
(i.e. whenever the message is read) decide which to use. That way we
can - for instance - report errors with color if the terminal supports
it correctly when reusing a dill (and reissuing problems, but where the
terminal support changes) and if printing the problem to an html <pre>
field (like observatory does (1)).

It also cleans up two different implementations of whether we think
the terminal supports colors or not, by deleting one of them.

(1) At least sometimes. It works - I think - only for 'evaluateInFrame',
    but that's another story (and will be fixed in a follow-up CL).

TEST=Existing test suites.

Change-Id: Iedaedd9a5c41458d40c23ed4b706324c004ae943
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186291
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-24 10:33:45 +00:00
Alexander Markov 9d4ad8a14b [core lib] Add unimplemented int.operator >>>
This change adds a placeholder for int.operator >>>.
No implementation is added yet.

This change unblocks implementation of this operator in
the backends (VM, dart2js, DDC).

Issue: https://github.com/dart-lang/sdk/issues/44912
Issue: https://github.com/dart-lang/sdk/issues/30892
Change-Id: I9912ca9f44d594e9c5fa91f5fc65e807fe48cc7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-02-22 00:02:47 +00:00
Johnni Winther 07ddd00e1b [cfe] Remove unneeded hide combinators
The front end previously enforced a stricter-than-spec requirement on
conflicting imports on its own code. The check was included of the
kernel snapshot and therefore always enforced, even in published sdks.

The extra check was removed a month ago and now tools/sdks/ have been
updated to use a later version of the sdk, so the unneeded hide
combinators can now be removed from the source code.

Closes #44667

TEST=existing

Change-Id: I1d1053b1ef9a40b6a918eef515a02d7b404906c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185084
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-18 14:23:10 +00:00
Gary Roumanis dfd52f60a1 Use async reads if possible
Change-Id: Ib7ae51e5f79e10797376cc3e4ca1a5bf6708fa30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185307
Auto-Submit: Gary Roumanis <grouma@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-02-17 19:30:30 +00:00
Sam Rawlins 82c87aefbf dev_compiler: Remove unnecessary import
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I903be88485200af4929fde78a575ff40c039da39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185303
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-02-17 17:42:27 +00:00
Nicholas Shahan f0ec362a1c [ddc] Use .futureValueType from CFE
The CFE FunctionNode has a new getter for the Future value type that
can be used in null safe libraries.

Legacy libraries will still rely on flatten to get the type of the
Future.

Change-Id: I54ad3bc096fdb981f7f499f2ba3ddfcb01fd97d6
Issue: https://github.com/dart-lang/sdk/issues/44745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-17 17:07:18 +00:00
Nicholas Shahan 16ca849c65 [ddc] Don't let null sources invalidate the dart size
Null sources appear to come from files that contain only external
declarations. These sources can simply be ignored in the summation
of the sizes of dart files that make up a module.

Change-Id: I38864c7f4a3e208b19e26d5a887445fdf4622479
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184901
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-16 18:57:09 +00:00
Nicholas Shahan 8eda75fc1a [ddc] Allow dynamic, Null, and void in assert
This assertion fails when compiling the SDK because the types
dynamic, Null, and void all have `Nullability.nullable`.

They are safe to allow through unchanged because each has their own
visitor that avoids the nullability wrapper at runtime.

Change-Id: I0ce345ce11dddb345eab3708804cbde6a540fdd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184880
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-12 22:32:29 +00:00
Gary Roumanis 0bdd0b4fad Load in parallel
Improve the performance by loading resources in parallel if possible.

Change-Id: Ibf93b7aa7510a110740399eef825f3c140c6dfd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184203
Auto-Submit: Gary Roumanis <grouma@google.com>
Commit-Queue: Gary Roumanis <grouma@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2021-02-10 20:12:45 +00:00
Johnni Winther ee0c0bcd57 Reland "[kernel] Ensure that visitors don't implicitly returns null"
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.

TEST=Refactoring

Change-Id: Ie8fa5d41b99850d9e4abb59634c72920c64128d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183691
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-10 07:51:52 +00:00
Nicholas Shahan 9c2d9b6831 [ddc] Enforce unnecessary_this lint
- Fix violations
- Ignore lint in js_ast directory. Still holding onto hope that we will
  merge this with dart2js version and move out of the ddc package.
- Import all lints from pedantic 1.9.0

Change-Id: I834b4b197dcf0b6924417cdd337cda9a1b6249d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183043
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-09 20:19:15 +00:00
Johnni Winther b60e0aa5a1 Revert "[kernel] Ensure that visitors don't implicitly returns null"
This reverts commit ce81216885.

Reason for revert: Flutter dependency

Original change's description:
> [kernel] Ensure that visitors don't implicitly returns `null`
>
> This is in preparation to migrate package:kernel to null safety.
> For the visitor interfaces to support non-nullable return types, the
> implementations must avoid using `null` as return value in its base case.
>
> TEST=Refactoring
>
> Change-Id: Ie5e4153f8d3779d94957bb13b3d2d2a942040ff2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179760
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>

TBR=jensj@google.com,johnniwinther@google.com

Change-Id: I61b838d3371e6b1de2427716d056324c120be499
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183689
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-09 12:41:12 +00:00
Johnni Winther ce81216885 [kernel] Ensure that visitors don't implicitly returns null
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.

TEST=Refactoring

Change-Id: Ie5e4153f8d3779d94957bb13b3d2d2a942040ff2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-09 09:46:46 +00:00
Ben Konyi 848121e6d4 Reland "[ CLI ] Improved consistency of -D and --define across tools and commands"
- Added support for --define to the VM and dart2js
- Added support for -D and --define for `dart run` and `dart compile js`

Remaining improvements:
- Add support for providing multiple comma separated values for `dart
  run`, `dart`, and `dart2js`

Related issue: https://github.com/dart-lang/sdk/issues/44562

TEST=Updated CLI tests and added new dart2js tests.

This reverts commit e49937769f.

Change-Id: I5f9275b829665eb5e8695403d67f230e752ab0e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183180
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-02-05 23:53:28 +00:00
Sigmund Cherem 912005267d [web] rename suite dart2js -> web.
Change-Id: I46be49b2effec3e38a3dc44cd45cfe736f77fa78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182680
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-02-04 23:11:32 +00:00
Anna Gringauze d6cf6b6bc9 Pass type parameters to expression evaluation function
- Pass type parameters to the synthetic expression evaluation
  function
- Add tests

Closes: https://github.com/dart-lang/sdk/issues/44755
Change-Id: Ifbc859b72c616d8f47a76ad9de2cc2aeef67e636
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181660
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2021-01-29 01:24:05 +00:00
Mark Zhou f09a5d4243 [dartdevc] Avoid caching constants during eval.
Avoids masking the issue underlying #44713.

Change-Id: I107c1ea3aab18a97ac08e868741fa0929e2292b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181304
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-01-27 20:25:45 +00:00
Nicholas Shahan f5743e6c66 [ddc] Fix async methods with Object return type
The sound null safety spec includes a change in the calculation of
static types of return values in async methods. The "Future value
type" should be `Object?` when the declared return type of the
async method is `Object`.

See https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md#the-future-value-type-of-an-asynchronous-non-generator-function

With this change,
co19/LanguageFeatures/nnbd/future_value_type_A05_t01 is now passing
in sound mode.

Change-Id: Ia7d4cb2fd57c1d2e50dbf8e59658a70124b0c8b3
Fixes: https://github.com/dart-lang/sdk/issues/44745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181303
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-01-27 18:17:40 +00:00
Sigmund Cherem 6854871069 [ddc] omit type constant literals without nullability in all contexts.
In non foreign-js calls this is immediatelly passed to wrapType which will
normalize it to the same value. So this is only added as a small optimization.

Change-Id: I145d58ad0244a2e7068a928b231f69a9491c465e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180444
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2021-01-22 02:24:17 +00:00
Sigmund Cherem 04d9240939 [ddc] recognize constant type literals in the compiler.
This change prepares for an upcoming CFE normalization.
Today kernel AST shows type literals as TypeLiteral nodes. Soon the CFE
will change the representation and canonicalize type literals and
represent them using constnats.

With this change, the compiler will recognize both the old and new
patterns.

Change-Id: I5aa3d99743c95c2dda04d299e586e77540fb7f7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180266
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-01-22 02:24:17 +00:00
Nicholas Shahan c3e56519fc [ddc] Add getGenericClassStatic runtime helper
Used in the SDK runtime library like the getGenericClass helper but this
is intended to be used when we statically know the type of the class to
be retrieved. Helps avoid breaks caused by an upcoming CFE change that
turns type literals into constants.

Change-Id: I262dd2dae347170050d2fe5cd2722ab132951036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180265
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-01-22 02:24:17 +00:00
Mark Zhou 0d275a6b7c [dartdevc] Clearing labeled statement caches before entering inline JS while statements.
Change-Id: I249913cebba553b8fad8a7646688807a968c2e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180443
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-01-21 23:55:57 +00:00
Anna Gringauze 599a265fdb Use full dill for main module and summaries for dependencies
- load summaries on updateDependencies and replace them by full
   kernel files for current module on expression evaluation

 - add tests for compiling expressions in various modules

 - add tests for compiling expressions after updating dependencies

 - test expression compilation in sound null safety mode

Change-Id: I243e8d1535e9510bc51f094545743d82bdbf23ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179404
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-20 23:26:33 +00:00
Sigmund Cherem 0845ebaad8 [ddc] Do not require a @JS annotation at the library level.
Dart2js allows to declare JS-interp members, even if the enclosing library
doesn't have a JS annotation. This relaxes DDC to do the same.

Change-Id: I733d1cbb308692d89b8cd443cbde0ed30637e48e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177780
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2021-01-20 22:11:23 +00:00
Mark Zhou dce8fcda1b [dartdevc] Unwrapping container objects.
These are causing aggregated containers to miss some fields.

Fixes #44685

Change-Id: I9d996bddbd10e7eb573f74fddf720a02fb1f4765
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180042
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-01-19 23:02:54 +00:00
Johnni Winther cad04f8604 [cfe,dart2js,dartdev] Show null safety mode for dart compile
This adds a new messages kind 'info' to the CFE for showing general
information during compilation. A 'configuration' options is added
to `CompilerOptions` for telling the CFE how it is run.

The configuration 'compile' is added for when the CFE is invoked to
produces an "executable" as when running `dart compile`. When
configuration is set, the CFE emits an info message about the
null safety compilation mode.

Support for `dart compile exe` and `dart compile js` is added in this
CL. Support for `dart compile kernel|app-jit|aot` is not included.

In response to https://github.com/dart-lang/sdk/issues/44234

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: I08f51e2a3f5ad4841c4d703bcd266b7afb63c7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178982
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-15 11:28:13 +00:00
Sigmund Cherem 8d971e1bef [ddc] do not enforce assertInterop on native methods from native tests
Change-Id: I3819da5708bc8a7f21d14d5531d9178c05839f45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178140
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-01-15 02:16:42 +00:00
Sigmund Cherem 90e6fd4734 [web] Support for running native tests in dartdevc.
This consists of a few combined changes:
* support `@Native` on tests: This entails calling registerExtensions
  on user code, but only when running on native tests (which are explicitly
  added to an allow list).

* support for invoking external top-level methods also on native tests.

* support for running `applyExtension` later in tests. This is because
  tests introduce the JavaScript definitions after the calls to
  registerExtensions happen. Note: this wouldn't be necessary if we one
  day change how tests are loaded (e.g. if we can load the JavaScript
  portion of the test before the module compiled by dartdevc is loaded).
  That would entail more infrastructure work and given that this is only
  used for ~200 tests, it doesn't seem worthwhile at this time.

* ensure extension symbols are also stored in `dartx.*` from a native
  test. This is to ensure dynamic calls are fully supported.

* changes to the dart2js runtime to ensure the test code can run in both
  dartdevc and dart2js with the same API.

* one updated test: all native tests need to be updated and I'll follow
  up with those, but the changes on this test are included in this CL to
  illustrate how this all fits together.

After this change (and parent changes), you can now run:

  ./tools/test.py -m release -c dartdevk -r d8 dart2js/native/native_checked_arguments1_frog_test

Change-Id: I4c2615a80b0e7611aa6f57abaa55b4e03b42bfe4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177180
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-01-15 02:16:42 +00:00
Srujan Gaddam 787ec114e1 [pkg:js] Revert revert of @Native/@JS conflicts and cache native
Bug: https://github.com/flutter/flutter/issues/73176

This reverts commit 825f56c6aa.

Both ddc and dart2js keep a set of native class names to make sure
@JS() classes don't conflict. Instead of processing native classes
for every component, this CL caches the set of native classes. This
should address the recompile time issues related to the original
revert.

Change-Id: If8028f0842440e8b9354bec9d7f72d0d42fcd8bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178926
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-01-15 01:18:02 +00:00
Ben Konyi e49937769f Revert "[ CLI ] Improved consistency of -D and --define across tools and"
This reverts commit e83e78431f.

Reason for revert: Failing on SIMARM and AOT bots

Original change's description:
> [ CLI ] Improved consistency of -D and --define across tools and
> commands
>
> - Added support for --define to the VM and dart2js
> - Added support for -D and --define for `dart run` and `dart compile js`
>
> Remaining improvements:
> - Add support for providing multiple comma separated values for `dart
>   run`, `dart`, and `dart2js`
>
> Related issue: https://github.com/dart-lang/sdk/issues/44562
>
> TEST=Updated CLI tests and added new dart2js tests.
>
> Change-Id: I9379c7aee1eab377adb3438393d9ad79c4938cc4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178262
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,asiva@google.com,sigmund@google.com

Change-Id: I1c594ae7db551619cc3191ff7f832c4fc61a4171
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179081
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-01-14 01:05:29 +00:00
Ben Konyi e83e78431f [ CLI ] Improved consistency of -D and --define across tools and
commands

- Added support for --define to the VM and dart2js
- Added support for -D and --define for `dart run` and `dart compile js`

Remaining improvements:
- Add support for providing multiple comma separated values for `dart
  run`, `dart`, and `dart2js`

Related issue: https://github.com/dart-lang/sdk/issues/44562

TEST=Updated CLI tests and added new dart2js tests.

Change-Id: I9379c7aee1eab377adb3438393d9ad79c4938cc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178262
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-01-13 23:33:17 +00:00
Nicholas Shahan 07fa8a6589 [ddc] Add null safety mode to metadata output
Change-Id: Ic9c932aa1161885a9b4073ada1c17f475716950e
Fixes: https://github.com/dart-lang/sdk/issues/44601
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178161
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-01-13 01:32:54 +00:00
Stephen Adams a4956e8f99 [dart2js/js_ast] cleanup: Simplify LiteralExpression
LiteralExpression used to be the mechanism for 'interpolating' the
`JS` pseudo-function, but that long ago was reimplemented via the
js_ast template feature.

There are a few vestigial uses of LiteralExpression, but as none of
them use the `inputs`, this field is removed.

Change-Id: I4cd7c64766a7d6d9dd2c196c134bbfcb536fd2f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178400
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-01-12 01:28:10 +00:00
Srujan Gaddam 825f56c6aa Revert "[pkg:js] Add errors for JS interop using @Native classes"
This reverts commit bc43d06479.

Reason for revert: Breakage in https://github.com/flutter/flutter/issues/73176

Original change's description:
> [pkg:js] Add errors for JS interop using @Native classes
>
> Closes https://github.com/dart-lang/sdk/issues/44211
>
> - Preprocesses and hashes Native classes defined in the sdk.
> - Adds an error if you use a JS class with the same underlying name
> as a Native class.
> - Adds tests with different namespaces to test for the error.
>
> Change-Id: I649e8b2346de8cc6d11205941a37152ce42104b9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175423
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sigmund@google.com,srujzs@google.com,rileyporter@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I4b492015468d41335fc5c9d4952560d303841695
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178260
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-01-08 18:55:02 +00:00
Anna Gringauze b1b0a6ce14 Do not add variables to scope that appear after the breakpoint
During expression evaluation, we are collecting  all variables in
all scopes that contain the current breakpoint line, and adding them
as available in current scope, which makes variables declared below
the current breakpoint line declared but undefined in JavaScript.

There is one exception to this seen so far - a variable
declared on the current breakpoint line might appear as not declared
in JavaScript and cause expression evaluation not to work due to
JS compilation errors.

This change fixes the issue by not collecting variables that are
declared on or after the current breakpoint line, making them undeclared
in dart (which also is correct according to dart scoping rules).

Closes: https://github.com/flutter/flutter/issues/72094
Change-Id: I113b69531171e0348d44edb8db6dd08a599c9db3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177760
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-01-07 23:55:59 +00:00
Mark Zhou 5ee1ee3c04 [dartdevc] Adding support for deferred library checks in DDC.
Fixes #42491

Change-Id: I6afc084bb7b1ccf6c667cb241ab2ac20aa881af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177620
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-01-07 21:43:08 +00:00
Mark Zhou bd30532d82 [dartdevc] Creating container entrypoints for expression eval.
The expression evaluator should now index/read object containers (types and symbols right now) via accessors like 'A$Eval'.

Fixes #44494

Change-Id: I31d203cfe59a6e2c03eeb22e8c86270c28b5e2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176923
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-01-06 00:20:29 +00:00
Nicholas Shahan daba9f3626 [ddc] Fix equals operator on native types
Emit `===` instead of `[$equals]` when the LHS is represented as a
primitive type.

The calculation of the left type was resulting in Object instead of a
more precise type. This caused the check for primitives types to always
fail.

Provides 20%+ performance improvements on the Wordsolver and
CollectionSieves-removeWhere benchmarks.
https://golem.corp.goog/Comparison?repository=dart&team=dartdevc#targetA%3Ddartdevc%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D89773%3BpatchA%3Dnshahan-fix-primative-equals%3BtargetB%3Ddartdevc%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D89771%3BpatchB%3DNone

Change-Id: Ica980f28bf8df627571b9aa53e77478e2b1de17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176069
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-01-05 23:47:34 +00:00
Sam Rawlins 5ece7f3a6e dev_compiler: Remove unnecessary imports
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Icad2908772eb42593c0149a99b8256d470490670
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177241
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-05 19:57:57 +00:00
Johnni Winther b4d4316de0 [cfe] Rename stub kinds
ForwardingStub -> AbstractForwardingStub
ForwardingSuperStub -> ConcreteForwardingStub
MixinStub -> AbstractMixinStub
MixinSuperStub -> ConcreteMixinStub

TEST=refactoring

Change-Id: Ice76a41ce8e1071f553ed8fd3ecbb29c97377161
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177129
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-29 16:54:55 +00:00
Johnni Winther 52db62dd65 [cfe] Use MixinSuperStub
This CL adds stub for each concrete mixed in member into mixin
applications. The body of the stub calls the original member via
a super call.

This addition means that resolution of super access now use the
stub and not the original declaration as the target, which means
that it will be correct even when mixed in members are cloned. For
this reason, dart2js no longer needs to perform its own super
member resolution.

When a super call targets a mixin super stub (after cloning) it
can be optimized away by redirecting the call to the `stubTarget`
of the call. This optimization is performed in dart2js.

Since dart2js now uses the correct super target, its runtime
mixin application needs to avoid overriding members already
declared in the mixin application. These members are the
forwarding super stubs which ensure that correct runtime types
when members with covariant parameters are implemented.


Change-Id: Iab71ffcc400aa6a683987bc20b9553a263ebc8e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176526
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-25 23:32:17 +00:00
Srujan Gaddam bc43d06479 [pkg:js] Add errors for JS interop using @Native classes
Closes https://github.com/dart-lang/sdk/issues/44211

- Preprocesses and hashes Native classes defined in the sdk.
- Adds an error if you use a JS class with the same underlying name
as a Native class.
- Adds tests with different namespaces to test for the error.

Change-Id: I649e8b2346de8cc6d11205941a37152ce42104b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175423
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-12-24 00:00:46 +00:00