Commit Graph

52 Commits

Author SHA1 Message Date
Anna Gringauze 0e8ee2b668 Do not crash on invalid offsets in ExpressionCompiler
ExpressionCompiler crashes while detecting current scope
if there are any scopes in the library with valid fileOffset
and invalid fileEndOffset.

Make ExpressionCompiler more tolerant to incomplete offset
information by just skipping scopes where fileEndScope is not set.

Fixes: https://github.com/dart-lang/sdk/issues/41241
Change-Id: I357017be1cb641053f23144edd5b74f30a9240ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142080
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-04-01 23:16:58 +00:00
Alexander Markov 7a2c8b3f90 [vm/nnbd/aot/tfa] Support NNBD strong mode in type flow analysis
This change adds support for types with different nullabilities to TFA,
and adjusts subtyping checks in TFA to take nullability into account.
This change assumes that NNBD strong mode is sound and there are no
opted-out libraries.

Fixes: https://github.com/dart-lang/sdk/issues/40717
Change-Id: I739b6ae317f218ced07636c09cfdbb277e1f81a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140375
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-27 18:56:47 +00:00
Vijay Menon d29e79a595 [dartdevc] record metrics
This reverts commit 056bd5e72f.

Change-Id: I12479342060b276c54a981ce17d96c179c0e4554
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140620
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2020-03-23 15:38:37 +00:00
David Morgan 056bd5e72f Reland "Revert "[dartdevc] record metrics""
This reverts commit a0e4f0575a.

Reason for revert: Issues with hot restart in google3, see b/152181536.

Original change's description:
> Revert "Revert "[dartdevc] record metrics""
> 
> Reland with fixes for internal build (patch set 2+)
> 
> Change-Id: I5b130d020c9437a2c52dd074ad007e1fef7a8fa5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139241
> Commit-Queue: Vijay Menon <vsm@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>

TBR=vsm@google.com,sigmund@google.com,grouma@google.com

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

Change-Id: I012e1adaa405e85fd1a3d7d280b889b7df44e5b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140580
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-03-23 12:16:13 +00:00
Vijay Menon a0e4f0575a Revert "Revert "[dartdevc] record metrics""
Reland with fixes for internal build (patch set 2+)

Change-Id: I5b130d020c9437a2c52dd074ad007e1fef7a8fa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139241
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-03-19 13:09:59 +00:00
jonahwilliams af46f7b103 [frontend_server] output dill during initial compilation to JavaScript
This will allow the tool to use initialize from dill to speedup subsequent runs. In local testing, adding this and initialize from dill sped up the initial compile of the flutter_gallery from 14 seconds to 7 seconds.

https://github.com/flutter/flutter/issues/50616

Change-Id: Ie6bf08ec547c903da75177d892fdbb36a8924d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139313
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2020-03-16 20:34:46 +00:00
Jens Johansen 6b4c4faf28 [CFE] Combine 'inputSummaries' and 'linkedDependencies'
The two fields are already treated the same, so having two is just
confusing.

Change-Id: I649db2a77bced62429dfd94ab300673cf886e367
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138291
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-03-05 12:38:34 +00:00
Anna Gringauze 7466c1f9da [frontend_server] Make module names debugger-friendly
Module names and import module names generated by the frontend server
are currently breaking debugger's assumptions on module names. This
change fixes it to make debugger works with various compiler
configurations, such as build_runner, frontend server with dwds tests,
and unblocks flutter tools to continue debugger and frontend server
integration.

JavaScriptBundle
  - Change module import names to module names instead of file paths,
    omit leading '/' as it cannot be in a module name in requireJS
  - Module name changes are hidden under "debugger-module-names" flag
    to prevent breaking flutter tools.

FrontendServer
  - Always call exit after listening to commands is finished,
    otherwise process running frontend server does not exit on 'quit'
    command.
  - Call computeCanonicalNames after initial compilation to support
    subsequent module importing in compileExpressioToJs calls
  - Add error handling to usage of kernelToJs compilers

ExpressionCompiler
  - Separate library variables from library fields for loading modules,
    as they can be different, for example
    ```main = require('web/main.dart').web__main```

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

Change-Id: Ic103c22932c7181ee325f239193d32361d057ed0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138010
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2020-03-05 07:39:33 +00:00
Jacob MacDonald 6746579d1b Use package_config instead of package_resolver in frontend_server
We want to deprecate package_resolver and it isn't migrating to the latest package_config format.

Bug: https://github.com/dart-lang/package_resolver/issues/30
Change-Id: I657ff16dfbf9fa75493d0975b5efcc7f4162431c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138322
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-03-04 19:02:06 +00:00
Jens Johansen 70b4ffae4b [kernel] Delete limited_ast_to_binary.dart
Change-Id: I11277942cd8bb9f3f3b875233934ec0281c0369b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138085
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-03-04 11:45:55 +00:00
jonahwilliams 5a1ff9f870 [frontend_server] add libraries spec option
Expose an option to configure the libraries specification path for the frontend_server

Change-Id: Icc50fd79fd1b8a5fd03d616bc2e58679bb0c8032
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137649
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2020-02-27 23:15:34 +00:00
Alexander Markov aa2c1a4950 [vm/nnbd] Add --null-safety option to VM's kernel compilers
This change adds --null-safety option to the front-end server and
gen_kernel tools. This option is forwarded to CFE via
CompilerOptions.nnbdMode.

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

Change-Id: I410b1d5466d93d9514cb7571bf37b32c848f136c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137106
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-02-25 19:04:43 +00:00
Alexander Aprelev 612728f970 [frontend-server] Only set VM environment defines for VM compilation target.
Fixes https://github.com/dart-lang/sdk/issues/40669.

Change-Id: I9e58deed5d2c67c953de7dae10ccbf9c46ab6fd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136411
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-02-20 03:05:25 +00:00
Anna Gringauze 25559399ed Reland "Implementation of evaluation to JS in frontend server"
This is a reland of 344c584ec4

First attempt failed due to lack of implementation of the new
API from SDK in Flutter/engine that this change introduces.
Fixed by creating dummy implementation in flutter/engine:

https://github.com/flutter/engine/pull/16309

Original change's description:
> Implementation of evaluation to JS in frontend server
>
>     - made ProgramCompiler somewhat incremental by letting the user
>       set the current library and class
>     - fixed a bug in procedure_builder where extension method wrappers
>       did not have correct fileEndOffset set, which prevented finding
>       dart scope at a line when extension methods are used
>     - added new compileExpressionToJs API to frontend server and
>       frontend compiler interface
>     - added ExpressionCompier class that combines IncrementalCompiler
>       and ProgramCompiler to compile expression at given dart location
>       to JavaScript
>     - in JavascriptBundle, set the module name for library tracking in
>       JavaScript and saved program compilers to a table for incremental
>       reuse in expression compiler
>     - Exposed generator from IncrementalCompiler for use in
>       ExpressionCompiler
>     - added tests for expression compiler
>     - added test for compileExpressionToJs API in frontend server tests
>
>
> Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>
> Reviewed-by: Jake Macdonald <jakemac@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I56426d2b6d831b2f8d8c57d468d0b54833a0062e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134561
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-11 18:31:44 +00:00
Siva Annamalai 0987024f51 Revert "Implementation of evaluation to JS in frontend server"
This reverts commit 344c584ec4.

Reason for revert: It is breaking the flutter builds and is blocking the roll of Dart into Flutter (see https://github.com/flutter/engine/runs/416355895 and
https://ci.chromium.org/p/flutter/builders/try/Linux%20Host%20Engine/3451)

Original change's description:
> Implementation of evaluation to JS in frontend server
> 
>     - made ProgramCompiler somewhat incremental by letting the user set
>       the current library and class
>     - fixed a bug in procedure_builder where extension method wrappers
>       did not have correct fileEndOffset set, which prevented finding
>       dart scope at a line when extension methods are used
>     - added new compileExpressionToJs API to frontend server and
>       frontend compiler interface
>     - added ExpressionCompier class that combines IncrementalCompiler
>       and ProgramCompiler to compile expression at given dart location
>       to JavaScript
>     - in JavascriptBundle, set the module name for library tracking in
>       JavaScript and saved program compilers to a table for incremental
>       reuse in expression compiler
>     - Exposed generator from IncrementalCompiler for use in
>       ExpressionCompiler
>     - added tests for expression compiler
>     - added test for compileExpressionToJs API in frontend server tests
> 
> 
> Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>
> Reviewed-by: Jake Macdonald <jakemac@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

TBR=aam@google.com,jensj@google.com,johnniwinther@google.com,jakemac@google.com,sigmund@google.com,grouma@google.com,nshahan@google.com,jonahwilliams@google.com,markzipan@google.com,annagrin@google.com

Change-Id: I3dc1ab0117df7b3141b8056ae684fc1c3492b2a3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133867
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-01-30 02:22:40 +00:00
Anna Gringauze 344c584ec4 Implementation of evaluation to JS in frontend server
- made ProgramCompiler somewhat incremental by letting the user set
      the current library and class
    - fixed a bug in procedure_builder where extension method wrappers
      did not have correct fileEndOffset set, which prevented finding
      dart scope at a line when extension methods are used
    - added new compileExpressionToJs API to frontend server and
      frontend compiler interface
    - added ExpressionCompier class that combines IncrementalCompiler
      and ProgramCompiler to compile expression at given dart location
      to JavaScript
    - in JavascriptBundle, set the module name for library tracking in
      JavaScript and saved program compilers to a table for incremental
      reuse in expression compiler
    - Exposed generator from IncrementalCompiler for use in
      ExpressionCompiler
    - added tests for expression compiler
    - added test for compileExpressionToJs API in frontend server tests


Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-30 00:54:51 +00:00
Jacob MacDonald d3070f4bbc - simplify convertFileOrArgumentToUri to just use resolveInputUri
- Allow non-file uris as a multi-root root

resolveInputUri already does what we need, and also supports other types of uris such as http.

This enables us to set a multi-root uri which is actually pointing to a dev server, thus hiding the server uri from generated kernel files.

Bug:https://github.com/dart-lang/webdev/issues/865
Change-Id: I0994df0594d57f5d2f020ecfe3bfc0657771cb74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133083
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-24 22:52:13 +00:00
Jacob MacDonald 2b221f9b49 Require pre-initialized importToSummary and summaryToModule maps in the ProgramCompiler constructor, and remove the corresponding arguments from emitModule.
This allows these maps to be re-used across multiple instances.

Change-Id: I433538d88dbe0348e2cfa592dae2e17af3dc17b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133150
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-01-24 17:23:09 +00:00
Jacob MacDonald 14544a3e2d Allow http uris in frontend_server, front_end, and ddc.
Also updates StrongComponents to prefer the main component as the root if it is in a cycle. This makes bootstrapping more predictable.

This enables a clean integration of build_runner or ddr (internal) and the frontend_server by allowing it to work with any dev server.

All that is needed is a custom .packages file with `http` uris pointing at a dev server which does all code generation, etc.

Bug: https://github.com/dart-lang/webdev/issues/865
Change-Id: I14533d71e5f7ddac58d98073cf016c2589165e9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132962
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-23 23:47:22 +00:00
Jacob MacDonald 52fd18ac42 Remove multiRootOutputPath special case for package: uris
This was added for the case where the package root is the file system root, but it causes problems for other cases.

Removing this for now, there are no uses yet.

Change-Id: I99cee2d0b9cc8aac63ce4b4ff7f2e25ffc9c21b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133085
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2020-01-23 20:57:54 +00:00
Jacob MacDonald 4460f95782 Updates frontend_server javascript bundler to be based on import uri instead of file uri.
Converts `package:` import uris into `/packages/` modules.

Also renames the output modules to append `.lib.js` instead of just `.js`. This allows us to distinguish between modules and applications based on extension.

Updates DDC source map code to be able to convert absolute file uris in sources so that they are relative to the source map.

Bug: https://github.com/dart-lang/webdev/issues/865
Change-Id: I55d70aa3761f10cc8bd7e92f5b567478040660de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132300
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-01-21 17:41:02 +00:00
Jens Johansen 2e32972929 [pkg/vm] Remove usage of Library.isExternal
Change-Id: I014184e2324ab0379653cb8c23cb7eed52677aeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124985
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-21 08:36:54 +00:00
Alexander Aprelev efbfda2e6d [gardening] Fix frontend-server-test uri vs file path use.
Also fix bracketing for "reject" compiler output (flutter/issues/35924).

Change-Id: I0a0d14665520cf5eb4594cc4e5e552c0b35a136e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124914
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-11-14 04:14:26 +00:00
Clement Skau a196d68145 Revert "[vm, front-end server] Cache generated bytecode using separate file"
This reverts commit 86641d07ae.

Reason for revert: Appears to break Flutter 3H:

- https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8897037674557388176/+/steps/flutter_test_framework_coverage/0/stdout

- https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8897037674557388176/+/steps/flutter_test_framework_tests/0/stdout

- https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8897037674557388176/+/steps/flutter_test_hostonly_devicelab_tests/0/stdout

Original change's description:
> [vm, front-end server] Cache generated bytecode using separate file
> 
> Previously, generated bytecode was cached using metadata in kernel AST.
> When serializaing kernel AST (for subsequent compilations) incremental
> serialization was not used, so AST serialization was considerably
> slower in bytecode mode compared to non-bytecode mode.
> 
> Apparently, metadata is not compatible with incremental serialization
> (https://github.com/dart-lang/sdk/issues/39302).
> 
> This change reimplements caching of generated bytecode using a separate
> 'foo.dill.cache' file near the generated 'foo.dill' and 'foo.dill.ast'.
> AST is now written using incremental serialization both in bytecode
> and non-bytecode modes.
> 
> flutter_test_performance benchmark:
> 
> AST mode:
> 
>   "without_change_elapsed_time_ms": 2615-2652,
>   "implementation_change_elapsed_time_ms": 6292-6394,
>   "interface_change_elapsed_time_ms": 6183-6484,
>   "with_coverage_time_ms": 2723-2834
> 
> Bytecode mode, before this change:
> 
>   "without_change_elapsed_time_ms": 3246-3295,
>   "implementation_change_elapsed_time_ms": 7998-8068,
>   "interface_change_elapsed_time_ms": 7899-8029,
>   "with_coverage_time_ms": 3316-3378
> 
> Bytecode mode, after this change:
> 
>   "without_change_elapsed_time_ms": 2689-2737,
>   "implementation_change_elapsed_time_ms": 7630-7677,
>   "interface_change_elapsed_time_ms": 7724-7917,
>   "with_coverage_time_ms": 2841-2949
> 
> Change-Id: I603d33f49949146cf6620226d810f2f3cb9853a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124592
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com

Change-Id: Ib433b68b7de3b08179c9c080a10f62703cd2546d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124983
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-11-12 11:11:10 +00:00
Alexander Markov 86641d07ae [vm, front-end server] Cache generated bytecode using separate file
Previously, generated bytecode was cached using metadata in kernel AST.
When serializaing kernel AST (for subsequent compilations) incremental
serialization was not used, so AST serialization was considerably
slower in bytecode mode compared to non-bytecode mode.

Apparently, metadata is not compatible with incremental serialization
(https://github.com/dart-lang/sdk/issues/39302).

This change reimplements caching of generated bytecode using a separate
'foo.dill.cache' file near the generated 'foo.dill' and 'foo.dill.ast'.
AST is now written using incremental serialization both in bytecode
and non-bytecode modes.

flutter_test_performance benchmark:

AST mode:

  "without_change_elapsed_time_ms": 2615-2652,
  "implementation_change_elapsed_time_ms": 6292-6394,
  "interface_change_elapsed_time_ms": 6183-6484,
  "with_coverage_time_ms": 2723-2834

Bytecode mode, before this change:

  "without_change_elapsed_time_ms": 3246-3295,
  "implementation_change_elapsed_time_ms": 7998-8068,
  "interface_change_elapsed_time_ms": 7899-8029,
  "with_coverage_time_ms": 3316-3378

Bytecode mode, after this change:

  "without_change_elapsed_time_ms": 2689-2737,
  "implementation_change_elapsed_time_ms": 7630-7677,
  "interface_change_elapsed_time_ms": 7724-7917,
  "with_coverage_time_ms": 2841-2949

Change-Id: I603d33f49949146cf6620226d810f2f3cb9853a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124592
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-11 19:32:53 +00:00
Alexander Markov 830b3d5f36 [front-end server] Remove obsolete --strong option
Corresponding cleanup in flutter tools:
https://github.com/flutter/flutter/commit/cf6a8d6a4727919436daed8444a273ea7ffe8d73

Cleanup in the flutter engine:
https://github.com/flutter/engine/commit/ddceed5f7af13531ec38d522916736c0e42e4619

Change-Id: Idbc2d42aeb53e461e48522cb961feca30de8f1cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124209
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-11-11 17:33:03 +00:00
Alexander Markov ec519c3d16 [vm/aot] Disable bytecode in AOT compilation pipeline
This is needed for the next D27 release.

Change-Id: I199ac701cb140dc84bb723d232c1b408088b1fe2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124469
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-11-08 03:18:36 +00:00
Alexander Markov b0cb4125e2 [vm,frontend-server] Add checks for invalid combination of options to kernel compilers
Add checks that --aot cannot be used with the following options:
--no-link-platform (front-end server, gen_kernel and Fuchsia kernel compiler).
--split-output-by-packages (front-end server, gen_kernel and Fuchsia kernel compiler).
--incremental (front-end server).
--import-dill (front-end server).

Change-Id: I0a38ab8b3a31ec497d1dc05ace0c254455879504
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123820
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-11-07 00:45:33 +00:00
Jens Johansen f91ef3afd7 [kernel] Deprecate Library.isExternal
We're deprecating kernels Library.isExternal as it wasn't used for
what it was originally intended. It will hopefully go away entirely
soon.

Change-Id: If363c50af5607febae68865875af452c106fff85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123721
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-04 09:24:02 +00:00
jonahwilliams f7722a2ecd [frontend_server] write JavaScript source maps
Write JavaScript source map contents as part of the incremental compile. places them in a single file adjacent to the source and offset manifests.

This file contains a map where the module name corresponds to the key and the value is the source map object.

Change-Id: Ice8ac910a5d7119a51d567b8f14cef560cfe8e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123360
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2019-10-31 17:50:34 +00:00
Ryan Macnak 7e76414eab [frontend_server] Support Fuchsia-style package splitting and FAR manifest generation.
Bug: https://github.com/dart-lang/sdk/issues/39126
Change-Id: I79a44316bea4350433a320794569c70ed3baa649
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123464
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-30 16:47:04 +00:00
jonahwilliams fe3aa126a2 [frontend_server] fix package-scheme crash in dartdevc target
If the entrypoint is not a file URI, we'll crash as the strong components implementation is unable to find it. Fallback to the first library in the component

Change-Id: Ibd1650978ebc904463ca2a97bd219a4069524b60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122560
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2019-10-28 23:54:53 +00:00
Ryan Macnak 700765a4d7 [vm, bytecode] The AST cache file's directory might not exist.
Change-Id: I7f097497548d84b2944220fbe3630a52c963453a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122683
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-23 21:18:17 +00:00
Alexander Aprelev be3348253d [gardening] Fix sink use in frontend-server dartdevc.
This is follow-up to  https://dart-review.googlesource.com/c/sdk/+/122461.

Change-Id: Id0c11daa1f37bf7254e5a75f28d64cac37ea9175
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-10-22 20:53:06 +00:00
Alexander Aprelev db8370e361 [gardening] Fix frontend-server dartdevc windows test.
This is follow-up to https://dart-review.googlesource.com/c/sdk/+/121400.

Change-Id: I45afdc8094f8b8d4be3e774bf475dc7b20a71498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122461
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-10-22 17:49:06 +00:00
Alexander Markov 230f48d685 [vm,aot] Simple unreachable code elimination before type-flow analysis, take 3
This is a reland of 56991ad94b

Original change's description:
> [vm,aot] Simple unreachable code elimination before type-flow analysis, take 2
>
> This is the relanding of https://dart-review.googlesource.com/c/sdk/+/121500
> with fixes.
>
> Original CL description:
>
> This change adds transformation for very early cleanup of unreachable
> code such as code guarded by if statements with constant conditions or
> code used in assert statements when assertions are disabled.
>
> The advantage of cleaning such code early is that type-flow analysis
> won't be looking at it and TFA-based tree shaker is able to remove
> more code.
>
> flutter_gallery_total_size -0.5663% (arm), -0.5409% (arm64)
> build_bench_total_size -2.533% (arm), -2.449% (arm64)
> gesture_detector_total_size -4.183% (arm), -4.072% (arm64)
>
> Change-Id: Ief8ebd0cd828c0e7a847a824f44d2d97a3595b87
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121901
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

Change-Id: I82ea0f70845851f85ec159c366f408aa7f9e5788
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122166
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-21 21:41:39 +00:00
jonahwilliams c26d5969f7 [flutter] JavaScript support to frontend_server
Adds support to the frontend server for producing javascript when
compiling with a target model of dartdevc. This uses the ProgramCompiler
and associated types from the dev_compiler package to output the kernel
AST into a "bundle" format.

dev_compiler:
* Exposes additional types needed for JavaScript compilation.
* Allows  overriding CoreTypes instead of forcing it to be created from
Component. This is require to support compilation of the
partial Components created by the incremental compiler.
* provides extraIndexedLibraries in Target class so the CoreTypes produced by the incremental compiler have indexed them.

frontend_server:
* When the target model is dartdev, JavaScript is output instead of
kernel. For each Component we compile, we first compute the strongly
connected components and produce a List of new Components to interop
with the dev compiler. The file uri is used as module name.

Change-Id: I4cc117b20671ffd48dd43f9786961c016a02d056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121400
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2019-10-21 15:41:29 +00:00
Alexander Markov eb9480daa5 Revert "[vm,aot] Simple unreachable code elimination before type-flow analysis, take 2"
This reverts commit 56991ad94b.

Reason for revert: broke building Flutter apps in release mode

Original change's description:
> [vm,aot] Simple unreachable code elimination before type-flow analysis, take 2
> 
> This is the relanding of https://dart-review.googlesource.com/c/sdk/+/121500
> with fixes.
> 
> Original CL description:
> 
> This change adds transformation for very early cleanup of unreachable
> code such as code guarded by if statements with constant conditions or
> code used in assert statements when assertions are disabled.
> 
> The advantage of cleaning such code early is that type-flow analysis
> won't be looking at it and TFA-based tree shaker is able to remove
> more code.
> 
> flutter_gallery_total_size -0.5663% (arm), -0.5409% (arm64)
> build_bench_total_size -2.533% (arm), -2.449% (arm64)
> gesture_detector_total_size -4.183% (arm), -4.072% (arm64)
> 
> Change-Id: Ief8ebd0cd828c0e7a847a824f44d2d97a3595b87
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121901
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com

Change-Id: I25fe5d4457bfcc5ee25506810aa7eee01ca1b28a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122023
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-17 21:23:38 +00:00
Alexander Markov 56991ad94b [vm,aot] Simple unreachable code elimination before type-flow analysis, take 2
This is the relanding of https://dart-review.googlesource.com/c/sdk/+/121500
with fixes.

Original CL description:

This change adds transformation for very early cleanup of unreachable
code such as code guarded by if statements with constant conditions or
code used in assert statements when assertions are disabled.

The advantage of cleaning such code early is that type-flow analysis
won't be looking at it and TFA-based tree shaker is able to remove
more code.

flutter_gallery_total_size -0.5663% (arm), -0.5409% (arm64)
build_bench_total_size -2.533% (arm), -2.449% (arm64)
gesture_detector_total_size -4.183% (arm), -4.072% (arm64)

Change-Id: Ief8ebd0cd828c0e7a847a824f44d2d97a3595b87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121901
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-17 20:34:46 +00:00
Alexander Markov 882a6b57d2 Enable bytecode in AOT compilation pipeline
Change-Id: I3f1bb7d56522cf5dfedf68c022fbed59c3d04717
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118103
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-10-17 17:22:12 +00:00
Ryan Macnak f26aa6fff4 [vm, bytecode] Put the 'main' sub-component last when generating a single file.
Fixes 'hot_mode_dev_cycle_linux__benchmark' when bytecode is enabled.

Change-Id: I73d42b3d8fa0fb43fe028f877813b27891dae3aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121650
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-16 16:40:08 +00:00
Alexander Markov fbc406aec3 Revert "[vm,aot] Simple unreachable code elimination before type-flow analysis"
This reverts commit 41b65b27c2.

Reason for revert: broke protobuf-aot benchmarks.

Original change's description:
> [vm,aot] Simple unreachable code elimination before type-flow analysis
> 
> This change adds transformation for very early cleanup of unreachable
> code such as code guarded by if statements with constant conditions or
> code used in assert statements when assertions are disabled.
> 
> The advantage of cleaning such code early is that type-flow analysis
> won't be looking at it and TFA-based tree shaker is able to remove
> more code.
> 
> flutter_gallery_total_size -0.5663% (arm), -0.5409% (arm64)
> build_bench_total_size -2.533% (arm), -2.449% (arm64)
> gesture_detector_total_size -4.183% (arm), -4.072% (arm64)
> 
> Change-Id: Ic764c056b6594164dc32eed4fd5679a7077ea2f9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121500
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com

Change-Id: I3e5668176a7a90d2891126bf79139ac5859bc630
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121824
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-10-16 00:05:54 +00:00
Alexander Markov 41b65b27c2 [vm,aot] Simple unreachable code elimination before type-flow analysis
This change adds transformation for very early cleanup of unreachable
code such as code guarded by if statements with constant conditions or
code used in assert statements when assertions are disabled.

The advantage of cleaning such code early is that type-flow analysis
won't be looking at it and TFA-based tree shaker is able to remove
more code.

flutter_gallery_total_size -0.5663% (arm), -0.5409% (arm64)
build_bench_total_size -2.533% (arm), -2.449% (arm64)
gesture_detector_total_size -4.183% (arm), -4.072% (arm64)

Change-Id: Ic764c056b6594164dc32eed4fd5679a7077ea2f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121500
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-15 22:58:58 +00:00
jonahwilliams a9e1e7e4fd Remove 'new' from frontend_server
Change-Id: I23afa1ab5d9e722f355eabaaa0491b3f08f261eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121404
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2019-10-11 19:47:40 +00:00
Jens Johansen 8796723b82 [frontend_server] Enable incremental serializer by default
Trying it out in flutter (for flutter test runs):

Running "flutter test" in flutter/packages/flutter:

BEFORE ENABLING
===============
$ flutter test --local-engine=host_debug
[...]
03:38 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug
[...]
03:11 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug
[...]
03:10 +5149 ~27: All tests passed!


With coverage:

$ flutter test --local-engine=host_debug --coverage
[...]
08:37 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug --coverage
[...]
08:21 +5149 ~27: All tests passed!


WITH THIS ENABLED
=================
$ flutter test --local-engine=host_debug
[...]
01:39 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug
[...]
01:32 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug
[...]
01:31 +5149 ~27: All tests passed!


With coverage:

$ flutter test --local-engine=host_debug --coverage
[...]
08:33 +5149 ~27: All tests passed!

$ flutter test --local-engine=host_debug --coverage
[...]
08:34 +5149 ~27: All tests passed!


So, without coverage more than twice as fast!
With coverage ~no change (which makes sense considering it's the VM thats spending extra time collecting coverage, so the compilation is not the bottleneck).


Running "flutter test" in a new project created with "flutter create" (i.e. with a single test):


BEFORE ENABLING
===============
$ time flutter test --local-engine=host_debug
00:05 +1: All tests passed!

real    0m6.360s
user    0m8.783s
sys     0m0.987s

$ time flutter test --local-engine=host_debug
00:02 +1: All tests passed!

real    0m2.790s
user    0m3.089s
sys     0m0.962s

$ time flutter test --local-engine=host_debug
00:02 +1: All tests passed!

real    0m2.693s
user    0m2.872s
sys     0m0.933s

WITH THIS ENABLED
=================
$ time flutter test --local-engine=host_debug
00:05 +1: All tests passed!

real    0m6.356s
user    0m8.253s
sys     0m1.161s

$ time flutter test --local-engine=host_debug
00:02 +1: All tests passed!

real    0m3.035s
user    0m3.449s
sys     0m0.880s

$ time flutter test --local-engine=host_debug
00:02 +1: All tests passed!

real    0m3.055s
user    0m3.534s
sys     0m0.885s

So maybe ~10% improvement on non-first runs (where it reuses the serialization from the dill it initialized from).
~no change on a clean run.

Change-Id: I2817fba9ca60190966194aa0b1ae8e16701137a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121121
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-11 07:02:43 +00:00
Jens Johansen 18aed26e83 [frontend_server] Wire up incremental serializer into frontend server / package VM
Change-Id: I4d8dbc2d9b0915c654eccae9e35357d7ec9fa13d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120787
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-10 11:39:06 +00:00
jonahwilliams cc3e22f724 [flutter] expose dartdevc target to incremental compiler
Doesn't do anything with the new target, but establishes a public API for dev_compiler (at least within the SDK)

Change-Id: I4c86b890d3993f96cf32ed0f749608a72a173da6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119526
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-10-09 20:02:42 +00:00
Ryan Macnak 4f752e6598 Reapply "[vm, bytecode] Use CoreTypes and ClassHierarchy from non-incremental front end results when generating bytecode."
Account for null result from kernelForProgram.

Change-Id: Ia4349c68ce023a5714752bf3294ab1e293b1d409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120749
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-09 18:09:58 +00:00
Ryan Macnak 5092b8ef82 Revert "[vm, bytecode] Use CoreTypes and ClassHierarchy from non-incremental front end results when generating bytecode."
This reverts commit f2c882bd87.

Reason for revert: batch mode failures

Original change's description:
> [vm, bytecode] Use CoreTypes and ClassHierarchy from non-incremental front end results when generating bytecode.
> 
> Change-Id: I9a8b2530009ff6cc6880ee177a6bee4bb9101e82
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120626
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com

Change-Id: I8ea8e155af0d2a4c4382107d723f7bf8a50dc3d7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120748
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-09 00:21:14 +00:00
Ryan Macnak f2c882bd87 [vm, bytecode] Use CoreTypes and ClassHierarchy from non-incremental front end results when generating bytecode.
Change-Id: I9a8b2530009ff6cc6880ee177a6bee4bb9101e82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120626
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-08 21:58:30 +00:00