From d615495807d324a5fb9a7352653f1f7d92737edd Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Fri, 7 May 2021 09:07:40 -0700 Subject: [PATCH 1/8] [dns] Try enabling lightweight isolates in jit --- runtime/dart_vm.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 0beb81259c28e..033593af9d793 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -62,6 +62,8 @@ static const char* kDartLanguageArgs[] = { "--background_compilation", "--no-causal_async_stacks", "--lazy_async_stacks", + "--enable-isolate-groups", + "--experimental-enable-isolate-groups-jit", // clang-format on }; From bb976c54b74b0c48c7d204cadb42c658c91eefc3 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 10 May 2021 11:32:28 -0700 Subject: [PATCH 2/8] Roll up dart to pick few changes that might affect ltw isolates --- DEPS | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DEPS b/DEPS index 759b4c8e4adfa..5fad4b735f413 100644 --- a/DEPS +++ b/DEPS @@ -35,7 +35,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS. # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': 'b8f4018535fa792891e2add3a475f35e3ec156ab', + 'dart_revision': 'ac7c44e4a985a6fd916b2b130ccc5ca2cb7b1c49', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py @@ -51,7 +51,7 @@ vars = { 'dart_resource_rev': '6b79867d0becf5395e5819a75720963b8298e9a7', 'dart_root_certificates_rev': '7e5ec82c99677a2e5b95ce296c4d68b0d3378ed8', 'dart_shelf_proxy_tag': 'v1.0.0', - 'dart_shelf_static_rev': 'fa30419055279a00c9e428439b1abe362d18f25d', + 'dart_shelf_static_rev': 'b8e51372332a27a4939466d94a22f15be53ac3e4', 'dart_sse_tag': '5da8fedcdc56f306933d202e2d204753eecefd36', 'dart_stack_trace_tag': '6788afc61875079b71b3d1c3e65aeaa6a25cbc2f', 'dart_stream_channel_tag': 'd7251e61253ec389ee6e045ee1042311bced8f1d', @@ -154,7 +154,7 @@ deps = { Var('dart_git') + '/args.git@d8fea36c10ef96797be02e3d132d572445cd86f4', 'src/third_party/dart/third_party/pkg/async': - Var('dart_git') + '/async.git@cde00b89bd3c19e877b21de2c02282d4d311d0a5', + Var('dart_git') + '/async.git@49464c342fe64c8632223ce3475364d163fb0623', 'src/third_party/dart/third_party/pkg/bazel_worker': Var('dart_git') + '/bazel_worker.git@0885637b037979afbf5bcd05fd748b309fd669c0', @@ -166,7 +166,7 @@ deps = { Var('dart_git') + '/charcode.git@bcd8a12c315b7a83390e4865ad847ecd9344cba2', 'src/third_party/dart/third_party/pkg/cli_util': - Var('dart_git') + '/cli_util.git@fd1b716e8a350a454e01ae56df540293d31ff6c8', + Var('dart_git') + '/cli_util.git@8a73cd7eca373ff71d290ccf47d4829e5ca44209', 'src/third_party/dart/third_party/pkg/clock': Var('dart_git') + '/clock.git' + '@' + Var('dart_clock_rev'), @@ -223,7 +223,7 @@ deps = { Var('dart_git') + '/intl.git' + '@' + Var('dart_intl_tag'), 'src/third_party/dart/third_party/pkg/json_rpc_2': - Var('dart_git') + '/json_rpc_2.git@5ec32a2e0e99dedcef5b3237f93167cd22c2da50', + Var('dart_git') + '/json_rpc_2.git@7e00f893440a72de0637970325e4ea44bd1e8c8e', 'src/third_party/dart/third_party/pkg/linter': Var('dart_git') + '/linter.git' + '@' + Var('dart_linter_tag'), @@ -268,7 +268,7 @@ deps = { Var('dart_git') + '/resource.git' + '@' + Var('dart_resource_rev'), 'src/third_party/dart/third_party/pkg/shelf': - Var('dart_git') + '/shelf.git@4b9294e29eb308709444a5c0b890fa8ccd69fae4', + Var('dart_git') + '/shelf.git@c511f06e6d2d28ffe905a45eea1da761b95ea0ca', 'src/third_party/dart/third_party/pkg/shelf_packages_handler': Var('dart_git') + '/shelf_packages_handler.git@78302e67c035047e6348e692b0c1182131f0fe35', @@ -334,7 +334,7 @@ deps = { Var('dart_git') + '/package_config.git@a84c0d45401f215fbe9384df923a38f4022a3c45', 'src/third_party/dart/tools/sdks': - {'packages': [{'version': 'version:2.12.0', 'package': 'dart/dart-sdk/${{platform}}'}], 'dep_type': 'cipd'}, + {'packages': [{'version': 'version:2.13.0-211.14.beta', 'package': 'dart/dart-sdk/${{platform}}'}], 'dep_type': 'cipd'}, # WARNING: end of dart dependencies list that is cleaned up automatically - see create_updated_flutter_deps.py. From 61f5257d1e3ca287f0c3c8d3f419c7eff9cd628d Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 10 May 2021 17:01:04 -0700 Subject: [PATCH 3/8] Ensure child isolate doesn't load kernel --- runtime/dart_isolate.cc | 17 +++++++++++------ runtime/dart_isolate.h | 3 ++- runtime/isolate_configuration.cc | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index ddec2276191e7..0c15cd1dbfcb5 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -603,6 +603,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, [[nodiscard]] bool DartIsolate::PrepareForRunningFromKernel( std::shared_ptr mapping, + bool child_isolate, bool last_piece) { TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromKernel"); if (phase_ != Phase::LibrariesSetup) { @@ -619,11 +620,13 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, tonic::DartState::Scope scope(this); - // Use root library provided by kernel in favor of one provided by snapshot. - Dart_SetRootLibrary(Dart_Null()); + if (!child_isolate) { + // Use root library provided by kernel in favor of one provided by snapshot. + Dart_SetRootLibrary(Dart_Null()); - if (!LoadKernel(mapping, last_piece)) { - return false; + if (!LoadKernel(mapping, last_piece)) { + return false; + } } if (!last_piece) { @@ -648,7 +651,8 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, for (uint64_t i = 0; i < buffers.size(); i++) { bool last_piece = i + 1 == buffers.size(); const std::shared_ptr& buffer = buffers.at(i); - if (!isolate->PrepareForRunningFromKernel(buffer, last_piece)) { + if (!isolate->PrepareForRunningFromKernel(buffer, + /*child_isolate=*/true, last_piece)) { return false; } } @@ -676,7 +680,8 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, for (size_t i = 0; i < count; ++i) { bool last = (i == (count - 1)); - if (!PrepareForRunningFromKernel(kernels[i], last)) { + if (!PrepareForRunningFromKernel(kernels[i], /*child_isolate=*/false, + last)) { return false; } } diff --git a/runtime/dart_isolate.h b/runtime/dart_isolate.h index d7d00bd707d42..eb2094e548d7e 100644 --- a/runtime/dart_isolate.h +++ b/runtime/dart_isolate.h @@ -328,7 +328,8 @@ class DartIsolate : public UIDartState { /// [[nodiscard]] bool PrepareForRunningFromKernel( std::shared_ptr kernel, - bool last_piece = true); + bool child_isolate, + bool last_piece); //---------------------------------------------------------------------------- /// @brief Prepare the isolate for running for a a list of kernel files. diff --git a/runtime/isolate_configuration.cc b/runtime/isolate_configuration.cc index a7f4aa19da5c9..03a4beacbe1dd 100644 --- a/runtime/isolate_configuration.cc +++ b/runtime/isolate_configuration.cc @@ -51,7 +51,8 @@ class KernelIsolateConfiguration : public IsolateConfiguration { if (DartVM::IsRunningPrecompiledCode()) { return false; } - return isolate.PrepareForRunningFromKernel(std::move(kernel_)); + return isolate.PrepareForRunningFromKernel(std::move(kernel_), + /*child_isolate=*/false, /*last_piece=*/true); } // |IsolateConfiguration| @@ -98,7 +99,7 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration { } const bool last_piece = i + 1 == resolved_kernel_pieces_.size(); if (!isolate.PrepareForRunningFromKernel( - std::move(resolved_kernel_pieces_[i]), last_piece)) { + std::move(resolved_kernel_pieces_[i]), /*child_isolate=*/false, last_piece)) { return false; } } From 4437e56d8fe308ecf7979e7756dabee98b78d3aa Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 10 May 2021 17:07:22 -0700 Subject: [PATCH 4/8] Format --- runtime/dart_isolate.cc | 3 ++- runtime/isolate_configuration.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 0c15cd1dbfcb5..f31ca2f12a011 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -652,7 +652,8 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, bool last_piece = i + 1 == buffers.size(); const std::shared_ptr& buffer = buffers.at(i); if (!isolate->PrepareForRunningFromKernel(buffer, - /*child_isolate=*/true, last_piece)) { + /*child_isolate=*/true, + last_piece)) { return false; } } diff --git a/runtime/isolate_configuration.cc b/runtime/isolate_configuration.cc index 03a4beacbe1dd..dee5c781691bb 100644 --- a/runtime/isolate_configuration.cc +++ b/runtime/isolate_configuration.cc @@ -52,7 +52,8 @@ class KernelIsolateConfiguration : public IsolateConfiguration { return false; } return isolate.PrepareForRunningFromKernel(std::move(kernel_), - /*child_isolate=*/false, /*last_piece=*/true); + /*child_isolate=*/false, + /*last_piece=*/true); } // |IsolateConfiguration| @@ -99,7 +100,8 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration { } const bool last_piece = i + 1 == resolved_kernel_pieces_.size(); if (!isolate.PrepareForRunningFromKernel( - std::move(resolved_kernel_pieces_[i]), /*child_isolate=*/false, last_piece)) { + std::move(resolved_kernel_pieces_[i]), /*child_isolate=*/false, + last_piece)) { return false; } } From abb07dd5436a64440659dee7241807b47536c9e2 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 10 May 2021 17:29:23 -0700 Subject: [PATCH 5/8] Update license hash --- ci/licenses_golden/licenses_third_party | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index eed239085c311..09db2144f8f58 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 0cd97bc3f34ac40583de63d2f282fdba +Signature: 1809be756f4c77a31ad9114e093f2b62 UNUSED LICENSES: From 22070d7b1752fd444ee0265963b3e128d37d6645 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 28 Jul 2021 10:40:39 -0700 Subject: [PATCH 6/8] Guard changes to isolate initialiation by enable-isolate-groups flag check --- runtime/dart_isolate.cc | 2 +- runtime/dart_vm.cc | 1 - sky/packages/sky_engine/lib/_embedder.yaml | 40 +++++++++++----------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index fc497bf4aab20..729cbf88bf8a0 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -594,7 +594,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr mapping, tonic::DartState::Scope scope(this); - if (!child_isolate) { + if (!child_isolate || !Dart_IsVMFlagSet("--enable-isolate-groups")) { // Use root library provided by kernel in favor of one provided by snapshot. Dart_SetRootLibrary(Dart_Null()); diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 79c1d39e335ac..2ab6a4d51a3fb 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -62,7 +62,6 @@ static const char* kDartLanguageArgs[] = { "--background_compilation", "--lazy_async_stacks", "--enable-isolate-groups", - "--experimental-enable-isolate-groups-jit", // clang-format on }; diff --git a/sky/packages/sky_engine/lib/_embedder.yaml b/sky/packages/sky_engine/lib/_embedder.yaml index c59d3623cd678..3c520c1966c5d 100644 --- a/sky/packages/sky_engine/lib/_embedder.yaml +++ b/sky/packages/sky_engine/lib/_embedder.yaml @@ -1,26 +1,26 @@ -# This file is suitable for use within the tree. A different _embedder.yaml -# is generated by the BUILD.gn in this directory. Changes here must be -# mirrored there. +# This file is generated by //flutter/sky/packages/sky_engine:_embedder_yaml +# Do not modify this file directly. Instead, update the build file. + embedded_libs: - "dart:async": "../../../../../third_party/dart/sdk/lib/async/async.dart" - "dart:collection": "../../../../../third_party/dart/sdk/lib/collection/collection.dart" - "dart:convert": "../../../../../third_party/dart/sdk/lib/convert/convert.dart" - "dart:core": "../../../../../third_party/dart/sdk/lib/core/core.dart" - "dart:developer": "../../../../../third_party/dart/sdk/lib/developer/developer.dart" - "dart:ffi": "../../../../../third_party/dart/sdk/lib/ffi/ffi.dart" - "dart:html": "../../../../../third_party/dart/sdk/lib/html/html_dart2js.dart" - "dart:io": "../../../../../third_party/dart/sdk/lib/io/io.dart" - "dart:isolate": "../../../../../third_party/dart/sdk/lib/isolate/isolate.dart" - "dart:js": "../../../../../third_party/dart/sdk/lib/js/js.dart" - "dart:js_util": "../../../../../third_party/dart/sdk/lib/js_util/js_util.dart" - "dart:math": "../../../../../third_party/dart/sdk/lib/math/math.dart" - "dart:typed_data": "../../../../../third_party/dart/sdk/lib/typed_data/typed_data.dart" - "dart:ui": "../../../../lib/ui/ui.dart" + "dart:async": "async/async.dart" + "dart:collection": "collection/collection.dart" + "dart:convert": "convert/convert.dart" + "dart:core": "core/core.dart" + "dart:developer": "developer/developer.dart" + "dart:ffi": "ffi/ffi.dart" + "dart:html": "html/html_dart2js.dart" + "dart:io": "io/io.dart" + "dart:isolate": "isolate/isolate.dart" + "dart:js": "js/js.dart" + "dart:js_util": "js_util/js_util.dart" + "dart:math": "math/math.dart" + "dart:typed_data": "typed_data/typed_data.dart" + "dart:ui": "ui/ui.dart" - "dart:_http": "../../../../../third_party/dart/sdk/lib/_http/http.dart" - "dart:_interceptors": "../../../../../third_party/dart/sdk/lib/_interceptors/interceptors.dart" + "dart:_http": "_http/http.dart" + "dart:_interceptors": "_interceptors/interceptors.dart" # The _internal library is needed as some implementations bleed into the # public API, e.g. List being Iterable by virtue of implementing # EfficientLengthIterable. Not including this library yields analysis errors. - "dart:_internal": "../../../../../third_party/dart/sdk/lib/internal/internal.dart" + "dart:_internal": "internal/internal.dart" "dart:nativewrappers": "_empty.dart" From 1632cbc604355078cc12d1fa38e0dd7d1eef6187 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 28 Jul 2021 10:43:16 -0700 Subject: [PATCH 7/8] Revert _embedder.yaml changes --- sky/packages/sky_engine/lib/_embedder.yaml | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sky/packages/sky_engine/lib/_embedder.yaml b/sky/packages/sky_engine/lib/_embedder.yaml index 3c520c1966c5d..c59d3623cd678 100644 --- a/sky/packages/sky_engine/lib/_embedder.yaml +++ b/sky/packages/sky_engine/lib/_embedder.yaml @@ -1,26 +1,26 @@ -# This file is generated by //flutter/sky/packages/sky_engine:_embedder_yaml -# Do not modify this file directly. Instead, update the build file. - +# This file is suitable for use within the tree. A different _embedder.yaml +# is generated by the BUILD.gn in this directory. Changes here must be +# mirrored there. embedded_libs: - "dart:async": "async/async.dart" - "dart:collection": "collection/collection.dart" - "dart:convert": "convert/convert.dart" - "dart:core": "core/core.dart" - "dart:developer": "developer/developer.dart" - "dart:ffi": "ffi/ffi.dart" - "dart:html": "html/html_dart2js.dart" - "dart:io": "io/io.dart" - "dart:isolate": "isolate/isolate.dart" - "dart:js": "js/js.dart" - "dart:js_util": "js_util/js_util.dart" - "dart:math": "math/math.dart" - "dart:typed_data": "typed_data/typed_data.dart" - "dart:ui": "ui/ui.dart" + "dart:async": "../../../../../third_party/dart/sdk/lib/async/async.dart" + "dart:collection": "../../../../../third_party/dart/sdk/lib/collection/collection.dart" + "dart:convert": "../../../../../third_party/dart/sdk/lib/convert/convert.dart" + "dart:core": "../../../../../third_party/dart/sdk/lib/core/core.dart" + "dart:developer": "../../../../../third_party/dart/sdk/lib/developer/developer.dart" + "dart:ffi": "../../../../../third_party/dart/sdk/lib/ffi/ffi.dart" + "dart:html": "../../../../../third_party/dart/sdk/lib/html/html_dart2js.dart" + "dart:io": "../../../../../third_party/dart/sdk/lib/io/io.dart" + "dart:isolate": "../../../../../third_party/dart/sdk/lib/isolate/isolate.dart" + "dart:js": "../../../../../third_party/dart/sdk/lib/js/js.dart" + "dart:js_util": "../../../../../third_party/dart/sdk/lib/js_util/js_util.dart" + "dart:math": "../../../../../third_party/dart/sdk/lib/math/math.dart" + "dart:typed_data": "../../../../../third_party/dart/sdk/lib/typed_data/typed_data.dart" + "dart:ui": "../../../../lib/ui/ui.dart" - "dart:_http": "_http/http.dart" - "dart:_interceptors": "_interceptors/interceptors.dart" + "dart:_http": "../../../../../third_party/dart/sdk/lib/_http/http.dart" + "dart:_interceptors": "../../../../../third_party/dart/sdk/lib/_interceptors/interceptors.dart" # The _internal library is needed as some implementations bleed into the # public API, e.g. List being Iterable by virtue of implementing # EfficientLengthIterable. Not including this library yields analysis errors. - "dart:_internal": "internal/internal.dart" + "dart:_internal": "../../../../../third_party/dart/sdk/lib/internal/internal.dart" "dart:nativewrappers": "_empty.dart" From 738971b890950080b2d69f5203d825e937f182dd Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Thu, 29 Jul 2021 13:07:42 -0700 Subject: [PATCH 8/8] Revert change to dart_vm.cc that enabled the flag --- runtime/dart_vm.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 2ab6a4d51a3fb..574b0eae652ae 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -61,7 +61,6 @@ static const char* kDartLanguageArgs[] = { "--enable_mirrors=false", "--background_compilation", "--lazy_async_stacks", - "--enable-isolate-groups", // clang-format on };