From 35bfa78fba4530bed0330a185d46493e47b592c4 Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 21 Feb 2025 10:54:56 -0800 Subject: [PATCH 1/5] Use 'compile js-dev' instead of directly invoking the dartdevc snapshot. --- dwds/CHANGELOG.md | 1 + dwds/test/expression_compiler_service_common.dart | 5 ++--- frontend_server_client/example/web_client.dart | 3 ++- test_common/lib/sdk_asset_generator.dart | 2 +- test_common/lib/test_sdk_layout.dart | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 0d00e8192..7ff81f47c 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,6 +1,7 @@ ## 24.3.6-dev - Bump minimum sdk version to 3.7.0 +- use 'compile js-dev' instead of directly invoking the ddc snapshot. ## 24.3.5 - Allow clients to specify the `packageConfigPath` in `LoadStrategy` class and associated providers. diff --git a/dwds/test/expression_compiler_service_common.dart b/dwds/test/expression_compiler_service_common.dart index de28b8577..2efe33a9b 100644 --- a/dwds/test/expression_compiler_service_common.dart +++ b/dwds/test/expression_compiler_service_common.dart @@ -52,8 +52,6 @@ void testAll({required CompilerOptions compilerOptions}) { // generated in the SDK, so we use the current SDK layout and // configuration. final executable = Platform.resolvedExecutable; - final dartdevc = - SdkConfiguration.defaultConfiguration.compilerWorkerPath!; // redirect logs for testing _output = StreamController.broadcast(); output.stream.listen(printOnFailure); @@ -110,7 +108,8 @@ void testAll({required CompilerOptions compilerOptions}) { '''); final args = [ - dartdevc, + 'compile', + 'js-dev', 'try.dart', '-o', 'try.js', diff --git a/frontend_server_client/example/web_client.dart b/frontend_server_client/example/web_client.dart index cbbe257d2..94e2b8142 100644 --- a/frontend_server_client/example/web_client.dart +++ b/frontend_server_client/example/web_client.dart @@ -22,7 +22,8 @@ void main(List args) async { _print('compiling the dart sdk'); final sdkCompileResult = await Process.run(Platform.resolvedExecutable, [ - p.join(sdkDir, 'bin', 'snapshots', 'dartdevc.dart.snapshot'), + 'compile', + 'js-dev', '--multi-root-scheme=org-dartlang-sdk', '--modules=amd', '--module-name=dart_sdk', diff --git a/test_common/lib/sdk_asset_generator.dart b/test_common/lib/sdk_asset_generator.dart index e86f0317e..0752885d9 100644 --- a/test_common/lib/sdk_asset_generator.dart +++ b/test_common/lib/sdk_asset_generator.dart @@ -131,7 +131,7 @@ class SdkAssetGenerator { final output = []; _logger.fine('Executing dart ${args.join(' ')}'); - final process = await Process.start(sdkLayout.dartPath, args, + final process = await Process.start(sdkLayout.dartAotRuntimePath, args, workingDirectory: sdkLayout.sdkDirectory); process.stdout diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index dca372e80..7218a60e2 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -108,7 +108,7 @@ class TestSdkLayout { sdkLayout.sdkDirectory, 'bin', 'snapshots', - 'kernel_worker.dart.snapshot', + 'kernel_worker_aot.dart.snapshot', ), devToolsDirectory: p.join( sdkLayout.sdkDirectory, From 6fdf399ff76aed54e66c41ab506de3310ce8729a Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 21 Feb 2025 11:25:04 -0800 Subject: [PATCH 2/5] Fix snapshot paths. --- dwds/lib/src/utilities/sdk_configuration.dart | 15 +++++++++++++-- dwds/test/sdk_configuration_test.dart | 2 +- test_common/lib/test_sdk_layout.dart | 5 ++++- test_common/test/sdk_asset_generator_test.dart | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dwds/lib/src/utilities/sdk_configuration.dart b/dwds/lib/src/utilities/sdk_configuration.dart index 9f3657b1f..260fff6d6 100644 --- a/dwds/lib/src/utilities/sdk_configuration.dart +++ b/dwds/lib/src/utilities/sdk_configuration.dart @@ -45,6 +45,7 @@ class SdkLayout { final String sdkDirectory; final String summaryPath; + final String dartdevcJitSnapshotPath; final String dartdevcSnapshotPath; @Deprecated('Only sound null safety is supported as of Dart 3.0') @@ -62,12 +63,18 @@ class SdkLayout { '_internal', 'ddc_outline.dill', ), - dartdevcSnapshotPath: p.join( + dartdevcJitSnapshotPath: p.join( sdkDirectory, 'bin', 'snapshots', 'dartdevc.dart.snapshot', ), + dartdevcSnapshotPath: p.join( + sdkDirectory, + 'bin', + 'snapshots', + 'dartdevc.aot.dart.snapshot', + ), ); const SdkLayout({ @@ -75,6 +82,7 @@ class SdkLayout { required this.summaryPath, this.soundSummaryPath = '', this.weakSummaryPath = '', + required this.dartdevcJitSnapshotPath, required this.dartdevcSnapshotPath, }); } @@ -113,7 +121,10 @@ class SdkConfiguration { : this( sdkDirectory: sdkLayout.sdkDirectory, sdkSummaryPath: sdkLayout.summaryPath, - compilerWorkerPath: sdkLayout.dartdevcSnapshotPath, + // This compiler path is used to spawn the expression compiler + // in a new isolate and hence it needs to be a JIT snapshot + // until dwds itself can run in AOT mode. + compilerWorkerPath: sdkLayout.dartdevcJitSnapshotPath, ); static Uri? _toUri(String? path) => path == null ? null : p.toUri(path); diff --git a/dwds/test/sdk_configuration_test.dart b/dwds/test/sdk_configuration_test.dart index e8e77dd08..15a303291 100644 --- a/dwds/test/sdk_configuration_test.dart +++ b/dwds/test/sdk_configuration_test.dart @@ -100,7 +100,7 @@ void main() { final sdkLayout = SdkLayout.createDefault(sdkDirectory); final sdkConfiguration = SdkConfiguration.fromSdkLayout(sdkLayout); final sdkSummaryPath = sdkLayout.summaryPath; - final compilerWorkerPath = sdkLayout.dartdevcSnapshotPath; + final compilerWorkerPath = sdkLayout.dartdevcJitSnapshotPath; setUp(() async { fs = MemoryFileSystem(); diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index 7218a60e2..8c07ad9f8 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -103,6 +103,7 @@ class TestSdkLayout { 'snapshots', 'frontend_server_aot.dart.snapshot', ), + dartdevcSnapshotPath: sdkLayout.dartdevcJitSnapshotPath, dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath, kernelWorkerSnapshotPath: p.join( sdkLayout.sdkDirectory, @@ -141,6 +142,7 @@ class TestSdkLayout { final String dartPath; final String dartAotRuntimePath; final String frontendServerSnapshotPath; + final String dartdevcJitSnapshotPath; final String dartdevcSnapshotPath; final String kernelWorkerSnapshotPath; final String devToolsDirectory; @@ -159,6 +161,7 @@ class TestSdkLayout { required this.dartPath, required this.dartAotRuntimePath, required this.frontendServerSnapshotPath, + required this.dartdevcJitSnapshotPath, required this.dartdevcSnapshotPath, required this.kernelWorkerSnapshotPath, required this.devToolsDirectory, @@ -169,7 +172,7 @@ class TestSdkLayout { SdkConfiguration( sdkDirectory: sdkLayout.sdkDirectory, sdkSummaryPath: sdkLayout.summaryPath, - compilerWorkerPath: sdkLayout.dartdevcSnapshotPath, + compilerWorkerPath: sdkLayout.dartdevcJitSnapshotPath, ); } diff --git a/test_common/test/sdk_asset_generator_test.dart b/test_common/test/sdk_asset_generator_test.dart index da109dd29..403c708d2 100644 --- a/test_common/test/sdk_asset_generator_test.dart +++ b/test_common/test/sdk_asset_generator_test.dart @@ -38,7 +38,7 @@ void main() { final copySdkLayout = TestSdkLayout.createDefault(sdkDirectory); sdkSummaryPath = copySdkLayout.summaryPath; - compilerWorkerPath = copySdkLayout.dartdevcSnapshotPath; + compilerWorkerPath = copySdkLayout.dartdevcJitSnapshotPath; // Copy the SDK directory into a temp directory. await copyDirectory(TestSdkLayout.defaultSdkDirectory, sdkDirectory); From 9609d09e89d4468f83df225f5e7a9e43309232b8 Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 21 Feb 2025 11:28:12 -0800 Subject: [PATCH 3/5] Fix parameter. --- test_common/lib/test_sdk_layout.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index 8c07ad9f8..64ea55b8b 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -103,7 +103,7 @@ class TestSdkLayout { 'snapshots', 'frontend_server_aot.dart.snapshot', ), - dartdevcSnapshotPath: sdkLayout.dartdevcJitSnapshotPath, + dartdevcJitSnapshotPath: sdkLayout.dartdevcJitSnapshotPath, dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath, kernelWorkerSnapshotPath: p.join( sdkLayout.sdkDirectory, From d2e65fae35e3375bec4975f1a1dc604817056734 Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 21 Feb 2025 12:34:35 -0800 Subject: [PATCH 4/5] Use 'compile js-dev' --- test_common/lib/sdk_asset_generator.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test_common/lib/sdk_asset_generator.dart b/test_common/lib/sdk_asset_generator.dart index 0752885d9..65f4c0ffa 100644 --- a/test_common/lib/sdk_asset_generator.dart +++ b/test_common/lib/sdk_asset_generator.dart @@ -112,7 +112,8 @@ class SdkAssetGenerator { final sdkDirectoryUri = fileSystem.directory(sdkLayout.sdkDirectory).uri; final args = [ - sdkLayout.dartdevcSnapshotPath, + 'compile', + 'js-dev', '--compile-sdk', '--multi-root', '$sdkDirectoryUri', @@ -131,7 +132,7 @@ class SdkAssetGenerator { final output = []; _logger.fine('Executing dart ${args.join(' ')}'); - final process = await Process.start(sdkLayout.dartAotRuntimePath, args, + final process = await Process.start(sdkLayout.dartPath, args, workingDirectory: sdkLayout.sdkDirectory); process.stdout From 9130d89c38f2734e77c01a841f59ec4386cc2e3a Mon Sep 17 00:00:00 2001 From: asiva Date: Fri, 21 Feb 2025 13:16:57 -0800 Subject: [PATCH 5/5] Adjust sdk layout. --- dwds/lib/src/utilities/sdk_configuration.dart | 15 ++------------- dwds/test/sdk_configuration_test.dart | 2 +- test_common/lib/test_sdk_layout.dart | 5 +---- test_common/test/sdk_asset_generator_test.dart | 2 +- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/dwds/lib/src/utilities/sdk_configuration.dart b/dwds/lib/src/utilities/sdk_configuration.dart index 260fff6d6..9f3657b1f 100644 --- a/dwds/lib/src/utilities/sdk_configuration.dart +++ b/dwds/lib/src/utilities/sdk_configuration.dart @@ -45,7 +45,6 @@ class SdkLayout { final String sdkDirectory; final String summaryPath; - final String dartdevcJitSnapshotPath; final String dartdevcSnapshotPath; @Deprecated('Only sound null safety is supported as of Dart 3.0') @@ -63,17 +62,11 @@ class SdkLayout { '_internal', 'ddc_outline.dill', ), - dartdevcJitSnapshotPath: p.join( - sdkDirectory, - 'bin', - 'snapshots', - 'dartdevc.dart.snapshot', - ), dartdevcSnapshotPath: p.join( sdkDirectory, 'bin', 'snapshots', - 'dartdevc.aot.dart.snapshot', + 'dartdevc.dart.snapshot', ), ); @@ -82,7 +75,6 @@ class SdkLayout { required this.summaryPath, this.soundSummaryPath = '', this.weakSummaryPath = '', - required this.dartdevcJitSnapshotPath, required this.dartdevcSnapshotPath, }); } @@ -121,10 +113,7 @@ class SdkConfiguration { : this( sdkDirectory: sdkLayout.sdkDirectory, sdkSummaryPath: sdkLayout.summaryPath, - // This compiler path is used to spawn the expression compiler - // in a new isolate and hence it needs to be a JIT snapshot - // until dwds itself can run in AOT mode. - compilerWorkerPath: sdkLayout.dartdevcJitSnapshotPath, + compilerWorkerPath: sdkLayout.dartdevcSnapshotPath, ); static Uri? _toUri(String? path) => path == null ? null : p.toUri(path); diff --git a/dwds/test/sdk_configuration_test.dart b/dwds/test/sdk_configuration_test.dart index 15a303291..e8e77dd08 100644 --- a/dwds/test/sdk_configuration_test.dart +++ b/dwds/test/sdk_configuration_test.dart @@ -100,7 +100,7 @@ void main() { final sdkLayout = SdkLayout.createDefault(sdkDirectory); final sdkConfiguration = SdkConfiguration.fromSdkLayout(sdkLayout); final sdkSummaryPath = sdkLayout.summaryPath; - final compilerWorkerPath = sdkLayout.dartdevcJitSnapshotPath; + final compilerWorkerPath = sdkLayout.dartdevcSnapshotPath; setUp(() async { fs = MemoryFileSystem(); diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index 64ea55b8b..7218a60e2 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -103,7 +103,6 @@ class TestSdkLayout { 'snapshots', 'frontend_server_aot.dart.snapshot', ), - dartdevcJitSnapshotPath: sdkLayout.dartdevcJitSnapshotPath, dartdevcSnapshotPath: sdkLayout.dartdevcSnapshotPath, kernelWorkerSnapshotPath: p.join( sdkLayout.sdkDirectory, @@ -142,7 +141,6 @@ class TestSdkLayout { final String dartPath; final String dartAotRuntimePath; final String frontendServerSnapshotPath; - final String dartdevcJitSnapshotPath; final String dartdevcSnapshotPath; final String kernelWorkerSnapshotPath; final String devToolsDirectory; @@ -161,7 +159,6 @@ class TestSdkLayout { required this.dartPath, required this.dartAotRuntimePath, required this.frontendServerSnapshotPath, - required this.dartdevcJitSnapshotPath, required this.dartdevcSnapshotPath, required this.kernelWorkerSnapshotPath, required this.devToolsDirectory, @@ -172,7 +169,7 @@ class TestSdkLayout { SdkConfiguration( sdkDirectory: sdkLayout.sdkDirectory, sdkSummaryPath: sdkLayout.summaryPath, - compilerWorkerPath: sdkLayout.dartdevcJitSnapshotPath, + compilerWorkerPath: sdkLayout.dartdevcSnapshotPath, ); } diff --git a/test_common/test/sdk_asset_generator_test.dart b/test_common/test/sdk_asset_generator_test.dart index 403c708d2..da109dd29 100644 --- a/test_common/test/sdk_asset_generator_test.dart +++ b/test_common/test/sdk_asset_generator_test.dart @@ -38,7 +38,7 @@ void main() { final copySdkLayout = TestSdkLayout.createDefault(sdkDirectory); sdkSummaryPath = copySdkLayout.summaryPath; - compilerWorkerPath = copySdkLayout.dartdevcJitSnapshotPath; + compilerWorkerPath = copySdkLayout.dartdevcSnapshotPath; // Copy the SDK directory into a temp directory. await copyDirectory(TestSdkLayout.defaultSdkDirectory, sdkDirectory);