Commit Graph

1010 Commits

Author SHA1 Message Date
Sam Rawlins 78121c713e dev_compiler: Remove unused imports
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I3fe1093fbd0a01e1dc5e99750c4c7e9441c3d056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192610
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-03-23 20:13:13 +00:00
Anna Gringauze 9b901bc21f Communicate start failures from ExpressionCompilerWorker to the consumer
In some cases, such as file system exceptions,  ExpressionCompilerWorker
fails to start but does not close its receiver port, which causes the
consumer to wait indefinitely for responses.

Make ExpressionCompilerWorker communicate the failure to the consumer,
close the receiver port, and exit.

Added tests to verify graceful exit.

Issue that uncovered the bug: https://b.corp.google.com/issues/183218372

Change-Id: I54a9c3620cfc5f77c101b26b4e98b6eeb03ad7e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192260
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-03-23 02:27:55 +00:00
Mark Zhou 5eceb354e2 [dartdevc] Porting expression compiler tests.
This is part of a series of changes to add support for SDK expression eval tests.

Change-Id: Ia96931fdf81324fa131014b49ec2067507c451f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191022
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-03-22 23:17:55 +00:00
Brian Wilkerson ec04c1f335 Remove some unnecessary ignore comments
Change-Id: Iafa4b9c8aa5dc696c5746248a8701b4f6e875979
TEST=Existing tests.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191980
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-03-18 19:58:43 +00:00
Mark Zhou ce473df469 [dartdevc] Adapting expression evaluation test suite for end-to-end evaluation.
The full workflow for an end-to-end test:
  1) Perform test/compiler options pre-initialization.
  2) Start an instance of Chrome (with 1 tab) and save a persisted debug connection for use in all tests.
  3) For each separate Dart program to be tested:
    1) Create inside a temp directory the HTML bootstrapper, DDC-compiled JS sources, and auxiliary JS files (dart_library.js or require.js).
    2) Initialize a DDC ProgramCompiler/IncrementalCompiler and perform a full compile of the program, saving the compiler's state for subsequent incremental compiles.
    3) Enable the debugger and set a URL breakpoint at the program's main JS entrypoint.
    4) For each test for this Dart program:
      1) Navigate to the HTML bootstrapper, pausing when the target module is loaded (at the breakpoint set above).
      2) Set a breakpoint at a JS location translated from a Dart breakpoint ID via source maps.
      3) Resume the debugger, pausing at that breakpoint. Remove the breakpoint.
      4) Reconstruct the local JS scope, then evaluate the Dart expression.
      5) Evaluate the JS expression inline, then compare results with expectations.
    5) Disable the debugger to clear its state.
  4) Shut down Chrome and clean up any temporary directories.

Other notes:
  * Supports bootstrapping/compilation on AMD and DDC module systems only (though expression eval is only supported on AMD)
  * Requires that Dart breakpoint IDs be set declaratively (no support for columns)

The test structure/flow is subject to change. While I port existing tests, Dart programs will consist of inline source file strings with simple breakpoints. In the future, we want to allow more complicated Dart programs to be specified (like in the modular test framework) and more complicated expression evaluation test patterns (rather than allowing only a single evaluation per test).

Change-Id: I5de7cfa66991fd14b24fa16edd1615f55c041ae3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190962
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-03-18 17:41:23 +00:00
Anna Gringauze e2baf16ebd Support ddc module format in expression compilation in ddc.
Closes: https://github.com/dart-lang/sdk/issues/45303
Change-Id: I2b1eb9d149c03c138150d126c108ad86af8584c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191023
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2021-03-15 23:58:44 +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
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
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
Konstantin Shcheglov d48fb41e68 Remove dev_compiler/test/testing.dart
Change-Id: If100f15d9798a90c7389f15cdf99d0b1cf60e6dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-08 18:58:21 +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
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
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
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
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 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
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
Johnni Winther 5dbb6e245b [kernel,cfe,ddc] Add new method invocation node to package:kernel
This adds
* InstanceInvocation, DynamicInvocation, FunctionInvocation, and
   LocalFunctionInvocation, EqualsCall, and EqualsNull as a future
   replacement for MethodInvocation.
* InstanceGet, DynamicGet, InstanceTearOff, and FunctionTearOff as a
   future replacement for PropertyGet
* InstanceSet and DynamicSet as a future replacement of PropertySet
* StaticTearOff as an addition to StaticGet

TEST=pkg/front_end/test/binary_md_vm_tags_and_version_test.dart

This CL combines
* https://dart-review.googlesource.com/c/sdk/+/171729
* https://dart-review.googlesource.com/c/sdk/+/172649
* https://dart-review.googlesource.com/c/sdk/+/172650
* https://dart-review.googlesource.com/c/sdk/+/172651

using the initial encoding fo EqualsCall and EqualsNull

Change-Id: I98e020b5f2b405a812663bdcd2c05aba8efa74c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175480
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-14 10:55:48 +00:00
Mark Zhou 2e97d91dcd [dartdevc] Fixing expression eval breaks from stepping update.
Followup on https://dart-review.googlesource.com/c/sdk/+/173800

This change forces certain top-level containers to be emitted (even if empty) per module. These modules also carry a self-referential element so that V8 does not optimize them away.

Change-Id: Ic02adb9c4e322c29ba092951fd912019931b3871
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175445
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-12-11 00:18:28 +00:00
Nicholas Shahan d0ee5dbe40 [ddc] Verify null safety modes of modules agree
Checks that the null safety mode of every module loaded matches the mode
of the SDK.

This relands https://dart-review.googlesource.com/c/sdk/+/173120 with
additional fix to correctly set the mode of a new component created
in the frontend_server.

Change-Id: I855b226f724ce0b6c83dbdc11ff6113853892dbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174881
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-12-09 21:12:20 +00:00
Nicholas Shahan a9f3c66bd8 Revert "[ddc] Verify null safety modes of modules agree"
This reverts commit fda897a423.

Reason for revert: Breaks all the flutter web tests here:
https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/flutter-engine-linux-web_tests/1089/overview

This indicates we still have a misconfiguration in flutter web dev 
builds where artifacts with different null safety modes are being 
mixed.

Original change's description:
> [ddc] Verify null safety modes of modules agree
>
> Checks that the null safety mode of every module loaded matches the mode
> of the SDK.
>
> Change-Id: I50543d10fbea22a61bd7f12d51d6e9c8f8286890
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173120
> Commit-Queue: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>

TBR=sigmund@google.com,nshahan@google.com,markzipan@google.com

Change-Id: I0d09efde53f268b353cb842286b11bb3f375e754
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173440
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-21 17:42:25 +00:00
Nicholas Shahan fda897a423 [ddc] Verify null safety modes of modules agree
Checks that the null safety mode of every module loaded matches the mode
of the SDK.

Change-Id: I50543d10fbea22a61bd7f12d51d6e9c8f8286890
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173120
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-11-21 00:51:14 +00:00
Anna Gringauze c6c4661567 Enable fixed expression compilation tests, add more loop tests.
Tests are no longer failing since
https://github.com/dart-lang/sdk/issues/44235 is now fixed.

Change-Id: I2654233e4c62426e363eab518fdb5b041bc22724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173160
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-11-20 21:47:23 +00:00
Anna Gringauze 57cbfa73ed Add tests for expression compilation with sound null safety
Change-Id: I895b769ce203c2aed0cfcce9f1fca70f42dbb97c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172689
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-11-19 01:24:41 +00:00
Johnni Winther 887ab360e5 Revert "[kernel] Ensure that visitors don't implicitly returns null"
This reverts commit 4a3f121341.

The changes broke flutter/engine

TEST=It's a revert!

Change-Id: I1e65e6cfab03795a21a64a96fe3ed72e6ba8ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-18 14:51:30 +00:00
Johnni Winther 4a3f121341 [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: I9f9b318982148d844be9826a5f8c88374a9fc402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-18 11:54:30 +00:00
Anna Gringauze 9c54996510 Fix issues in expression evaluation in google3
- Define private symbols load without reloading the module
  and knowing module format
- Remove libraryName->moduleName map from ExpressionCompiler's
  compileExpressionToJs API as a result of above
- Make ddc tolerate null locations on kernel loaded from dill
  during assert insertions for nullability
- Disable asserts in expression compilation worker
  due to ddc reading source for assert statement compilation
- Remove unused test configuration for expression compiler worker
- Add and update expression compiler tests

Part of: https://github.com/dart-lang/webdev/issues/1174

Change-Id: Idf8f508308915a5487fa0e9810b5674140393fed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170028
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-11-14 01:34:16 +00:00
Dmitry Stefantsov d54e2bb568 [cfe,ddc,dart2js,vm] Add NullType
This CL is the sum of the following 5 CLs:
* https://dart-review.googlesource.com/c/sdk/+/170342/
* https://dart-review.googlesource.com/c/sdk/+/170344/
* https://dart-review.googlesource.com/c/sdk/+/170345/
* https://dart-review.googlesource.com/c/sdk/+/170346/
* https://dart-review.googlesource.com/c/sdk/+/170347/

The reason for landing the 5 CLs as one CL is to prevent potential
troubles with bisecting over the branch because the change is fully
functional only with all 5 CLs.

Closes #40122.

TEST=Verified by changes in .expect files in pkg/vm/.
Bug: https://github.com/dart-lang/sdk/issues/40122
Change-Id: Ib8197802fdc69694387ae47ac990c58b3aaab7a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170689
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-06 12:43:52 +00:00
Anna Gringauze 42dc617ee8 Emit constants during expression compilation to js
Closes: https://github.com/dart-lang/sdk/issues/43963
Change-Id: Ic8af046b2cf1506984b84ea66b2676b3cc0f1771
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169580
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-11-02 20:03:14 +00:00
Nicholas Shahan 2615e865e2 [ddc] Opt code in expression compiler test
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Change-Id: I052853c42b772af9180d109f231215c00a5a8202
Fixes: https://github.com/dart-lang/sdk/issues/43843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168742
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-23 17:49:22 +00:00
Johnni Winther b42f954364 [cfe] Use experiment release version when non-nullable is enabled explicitly
Even when non-nullable is enabled by default, enabling the experiment
explicitly should result in the experiment release version (and not
the experiment enabled version) to be used for opting in.

For this change, the semantics of parseExperimentalFlags was change
to _not_ normalize the flags to a full mapping including default values.
For this reason all uses of such maps are renamed to
'explicitExperimentalFlags'.

Closes #43879

Change-Id: I0d0262e68ec1403549abcfd305ae3a4404fe93e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168654
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-22 06:17:39 +00:00
Nicholas Shahan f990e70930 [ddc] Opt code in nullable inference test
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Change-Id: Idaf69b40c27336c8601cb143741f79604d2647e7
Fixes: https://github.com/dart-lang/sdk/issues/43843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168583
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-20 21:38:51 +00:00
Anna Gringauze f04bc85e4f Refined scope calculation in expression compiler
- make sure nested blocks scopes are visited
- make sure variable definitions do not leak beyond block scopes
- properly collect scopes for loops, if statements, constructors
- add calculation of fileEndOffsets for blocks
- save block file offsets to dill
  - update binary format version
  - change kernel readers and writers to read and write block offsets
  - change vm readers to read and block offsets for new version
- add missing fileOffsets and fileEndOffsets on functions for
  late fields
- add missing fileOffsets and fileEndOffsets on functions for
  extensions
- add errors on failures to find scope
- find libraries for private fields correctly
- add more expression compilation tests
- add test to verify fileOffsets and fileEndOffsets are set for
  SDK summary (will add full dill tests later)

Closes: https://github.com/dart-lang/sdk/issues/40278
Related: https://github.com/dart-lang/sdk/issues/34942

Change-Id: I5bc1bb645543045b689d8d61069ee77dc4ee9025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167541
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-20 01:44:52 +00:00
Nicholas Shahan f3962367a5 [ddc] Add language version to test files
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Some of these synthetic files are created as packages but the
expression compiler wasn't designed to handle that information.
In the future we should support language versioning better in the
expression compiler or setup similar tests for opted in code since
in reality the language versioning might be handled by the dev
build system.

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

Change-Id: Icfac40d1c9b47e75fb92d7672700e066ac372267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168441
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-20 00:48:08 +00:00
Anna Gringauze a8c727a61a Use types of parameters for expression compilation
- use parameter types passed to IncrementalCompiler.compileExpression
  for compilation of the synthetic function containing the expression
- updated expression compiler tests

Note: some expressions that previously compiled wouldn't now
Example:

** package:test/library.dart **

class TestLibraryClass {
  final int field;
  final int _field;
  TestLibraryClass(this.field, this._field);
}

** main.dart **

import 'package:test/library.dart';

void main() {
  var instance = TestLibraryClass(1, 2);
  print('$instance'); // Breakpoint here
}

Expression:

`instance._field`

Previously, the incremental compiler would compile the expression
to kernel due to the type of instance being Dynamic. That compilation
result made it impossible for dartdevc to generate correct code due
 to missing type information.

Now, the compilation will fail with "Getter isn't defined"
error. To properly evaluate private fields now, we would need
the CFE to support a special mode for expression compilation
where private fields from other libraries are allowed.

Closes: https://github.com/dart-lang/sdk/issues/43469
Change-Id: Id8015c5e334115a82049fb2d1725db54dd3ea3dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166925
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-10-13 01:44:02 +00:00
Leaf Petersen e85bf740ef Opt pkg/dev_compiler out of null safety.
Change-Id: I62207a436605480b6981b8b00bf7b88d8589db0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166980
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-10-12 23:25:42 +00:00
Anna Gringauze 1c8020cfc7 Emit module and add logging with timer to expression compilation
- Emit module before expression compilation to JavaScript so the
  ProgramCompiler has all types available.

- Add logging with ticker to expression compilation in expression
  compilation worker in DDC and in frontend server.

- Remove excessively verbose logging

Related:
https://github.com/dart-lang/webdev/issues/1006
https://github.com/dart-lang/webdev/issues/1106
Change-Id: Ia3a985f2d12d27f0bcc2c5d3923db137070e9cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162624
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-09-22 02:17:12 +00:00
Anna Gringauze 0567798ea5 fix expression_compiler_worker_test failure on windows
Closes: https://github.com/dart-lang/sdk/issues/43324
Change-Id: I73c861e8b665d023ac5c820fc88eb75d62edb179
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162106
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-09-09 16:22:29 +00:00
Anna Gringauze 34052bf2bb Add expression evaluation to ddc for google3
- Move expression evaluation to ddc in preparation for google3
- Added server to ddc to handle update and compileExpression requests
- Added tests
- Added 'experimental-output-compiled-kernel' option to ddc to generate
  full kernel files only for compiled libraries, and store with
  '.full.dill' extension
- Added AssetFileSystem to communicate to the asset server in the
  debugger
- Made expression_compiler_worker work with full kernel files,
  so removed invalidation of current file to improve performance
- Made expression_compiler_worker reuse already loaded imports
  to avoid reading them from source in the incremental compiler
- Updated tests to work with DDC (for simulating webdev)
- Disabled tests that work with bazel kernel worker for now
  as it does not generate full dill files yet
- Addressed code review comments from the prototype version:
  https://dart-review.googlesource.com/c/sdk/+/157005

Details:

Currently, in flutter tools, expression evaluation is supported via
expression compilation, which is done by the incremental compiler in
the frontend server. The same incremental compiler is used for initial
application compilation, incremental code compilation for hot reload,
and any number of expression compilation requests.

In google3, the apps are typically too large to be compiled as a whole
in memory by the frontend server. Build in google3 is currently done by
blaze, as a distributed build using a task dependency graph. Build tasks
output kernel outline files as an interface between components produced
by individual tasks.

We are proposing an implementation of the expression compilation in
google3 that is taking advantage of full kernel files produced by the
build (supporting build changes to follow). This change introduces a
small server based on dev_compiler, which can handle following requests:

- update: load full kernel for given modules (done on app start)
- compileExpression: compile expression in a given library and module
  (done when paused on a breakpoint)

Expression compilation uses previously loaded kernel files for the
application component and its dependencies to compile an expression.


Change-Id: Icf73868069faf3a2eb6d43ba78e459f8457e9e35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160944
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-09-03 03:05:13 +00:00
Nicholas Shahan 7478143e5f [ddc] Inline the sound null safety flag
Now that the sound null safety mode is a compile time flag
instead of a runtime flag there is no need to set the value in
the bootstrapping code before running main(). The sound and weak
versions of the sdk now have it already set.

Add compileTimeFlag() method that will inline the constant value
directly into the generated output.

Change-Id: I5b9243c47cffc421067ac820ef49342b9d0efff9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154100
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-07-13 22:45:19 +00:00
Jacob MacDonald d9d4e5ccb3 copy package config changes to the modular_suite_nnbd.dart
Change-Id: Ib2c645c0d94adb60693be85b266d23b811982e70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153364
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-07-06 20:53:11 +00:00
Jacob MacDonald f42889fbb8 create package_config.json files in ddc modular test suite
Copies the same changes as were added for dart2js here https://dart-review.googlesource.com/c/sdk/+/152361/9/pkg/compiler/tool/modular_test_suite.dart

Change-Id: I785b275c62c3d3afb9f37c0b0c8c4e4369b4ccf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153362
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-07-06 19:33:11 +00:00
Anna Gringauze c909e16ee2 Added module information to metadata and use by frontend_sever
- created class representing module metadata, added metadata to JsCode
  class
- added module information to metadata, such as module name, load
  function name
- added import and file uris for libraries
- added experimental-emit-debug-metadata flag to frontend_server
- added frontend server tests to check for saved metadata

Related: https://github.com/dart-lang/sdk/issues/41852
Closes: https://github.com/dart-lang/sdk/issues/40774
Change-Id: Iecbbf1e4eea1919e01f002f45363d30707cb1590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150181
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-06-20 00:40:35 +00:00