diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index 19abc984295..74482c6cdc8 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -388,13 +388,23 @@ class _DebuggingSession { ) async { final sdkDir = dirname(sdk.dart); final fullSdk = sdkDir.endsWith('bin'); - final ddsSnapshot = fullSdk - ? sdk.ddsSnapshot - : absolute(sdkDir, 'gen', 'dds.dart.snapshot'); final devToolsBinaries = fullSdk ? sdk.devToolsBinaries : absolute(sdkDir, 'devtools'); - if (!Sdk.checkArtifactExists(ddsSnapshot)) { - return false; + String snapshotName = fullSdk + ? sdk.ddsAotSnapshot + : absolute(sdkDir, 'gen', 'dds_aot.dart.snapshot'); + String execName = sdk.dartAotRuntime; + if (!Sdk.checkArtifactExists(snapshotName)) { + // An AOT snapshot of dds is not available, we could + // be running on the ia32 platform so check for a regular + // kernel file being present. + snapshotName = fullSdk + ? sdk.ddsSnapshot + : absolute(sdkDir, 'gen', 'dds.dart.snapshot'); + if (!Sdk.checkArtifactExists(snapshotName)) { + return false; + } + execName = sdk.dart; } ServiceProtocolInfo serviceInfo = await Service.getInfo(); // Wait for VM service to publish its connection info. @@ -403,10 +413,10 @@ class _DebuggingSession { serviceInfo = await Service.getInfo(); } final process = await Process.start( - sdk.dart, + execName, [ if (debugDds) '--enable-vm-service=0', - ddsSnapshot, + snapshotName, serviceInfo.serverUri.toString(), host, port, diff --git a/pkg/dartdev/lib/src/sdk.dart b/pkg/dartdev/lib/src/sdk.dart index b12e57b42e6..962dbdf6d59 100644 --- a/pkg/dartdev/lib/src/sdk.dart +++ b/pkg/dartdev/lib/src/sdk.dart @@ -52,6 +52,13 @@ class Sdk { 'dds.dart.snapshot', ); + String get ddsAotSnapshot => path.absolute( + sdkPath, + 'bin', + 'snapshots', + 'dds_aot.dart.snapshot', + ); + String get frontendServerSnapshot => path.absolute( sdkPath, 'bin', diff --git a/pkg/dartdev/test/sdk_test.dart b/pkg/dartdev/test/sdk_test.dart index 34dbfc70033..de399660df7 100644 --- a/pkg/dartdev/test/sdk_test.dart +++ b/pkg/dartdev/test/sdk_test.dart @@ -26,7 +26,7 @@ void _sdk() { }); test('dds snapshot', () { - expectFileExists(Sdk().ddsSnapshot); + expectSnapshotExists(Sdk().ddsAotSnapshot, Sdk().ddsSnapshot); }); test('dart2js snapshot', () { @@ -45,6 +45,10 @@ void expectFileExists(String path) { expect(File(path).existsSync(), isTrue); } +void expectSnapshotExists(String aotpath, String jitpath) { + expect(File(aotpath).existsSync() || File(jitpath).existsSync(), isTrue); +} + void expectDirectoryExists(String path) { expect(Directory(path).existsSync(), isTrue); } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index ca36cf5a8bf..79722f65212 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -46,7 +46,7 @@ declare_args() { # ........dart2wasm_product.snapshot (if not on ia32) # ........dartdev.dart.snapshot (app-jit snapshot or kernel dill file) # ........dartdevc.dart.snapshot -# ........dds.dart.snapshot +# ........dds_aot.dart.snapshot (AOT snapshot) or dds.dart.snapshot (ia32) # ........frontend_server_aot.dart.snapshot (AOT snapshot, if not on ia32) # ........frontend_server.dart.snapshot # ........gen_kernel.dart.snapshot (if not on ia32) @@ -116,15 +116,22 @@ _platform_sdk_snapshots = [ "dartdev", "../utils/dartdev:dartdev", ], - [ - "dds", - "../utils/dds:dds", - ], [ "frontend_server", "../utils/kernel-service:frontend_server", ], ] +if (dart_target_arch != "ia32" && dart_target_arch != "x86") { + _platform_sdk_snapshots += [ [ + "dds_aot", + "../utils/dds:dds_aot", + ] ] +} else { + _platform_sdk_snapshots += [ [ + "dds", + "../utils/dds:dds", + ] ] +} if (dart_snapshot_kind == "app-jit") { _platform_sdk_snapshots += [ [ "kernel-service", diff --git a/sdk/lib/_internal/vm/bin/vmservice_io.dart b/sdk/lib/_internal/vm/bin/vmservice_io.dart index 668734fca12..bdd4db05871 100644 --- a/sdk/lib/_internal/vm/bin/vmservice_io.dart +++ b/sdk/lib/_internal/vm/bin/vmservice_io.dart @@ -81,11 +81,24 @@ class _DebuggingSession { final fullSdk = dartDir.endsWith('bin'); - final ddsSnapshot = [ + final dartAotPath = [ + dartDir, + fullSdk ? 'dartaotruntime' : 'dart_precompiled_runtime_product', + ].join('/'); + String snapshotName = [ dartDir, fullSdk ? 'snapshots' : 'gen', - 'dds.dart.snapshot', + 'dds_aot.dart.snapshot', ].join('/'); + String execName = dartAotPath; + if (!File(snapshotName).existsSync()) { + snapshotName = [ + dartDir, + fullSdk ? 'snapshots' : 'gen', + 'dds.dart.snapshot', + ].join('/'); + execName = dartPath.toString(); + } final devToolsBinaries = [ dartDir, @@ -95,9 +108,9 @@ class _DebuggingSession { const enableLogging = false; _process = await Process.start( - dartPath.toString(), + execName, [ - ddsSnapshot, + snapshotName, server!.serverAddress!.toString(), host, port, diff --git a/utils/dds/BUILD.gn b/utils/dds/BUILD.gn index 2a5d36f2092..68d48a73b7d 100644 --- a/utils/dds/BUILD.gn +++ b/utils/dds/BUILD.gn @@ -2,12 +2,17 @@ # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. +import("../aot_snapshot.gni") import("../application_snapshot.gni") group("dds") { public_deps = [ ":copy_dds_snapshot" ] } +group("dds_aot") { + public_deps = [ ":copy_dds_aot_snapshot" ] +} + copy("copy_dds_snapshot") { visibility = [ ":dds" ] public_deps = [ ":generate_dds_snapshot" ] @@ -15,8 +20,28 @@ copy("copy_dds_snapshot") { outputs = [ "$root_out_dir/dds.dart.snapshot" ] } +copy("copy_dds_aot_snapshot") { + visibility = [ ":dds_aot" ] + public_deps = [ ":generate_dds_aot_snapshot" ] + sources = [ "$root_gen_dir/dds_aot.dart.snapshot" ] + outputs = [ "$root_out_dir/dds_aot.dart.snapshot" ] +} + application_snapshot("generate_dds_snapshot") { main_dart = "../../pkg/dds/bin/dds.dart" training_args = [] output = "$root_gen_dir/dds.dart.snapshot" } + +aot_snapshot("generate_dds_aot_snapshot") { + main_dart = "../../pkg/dds/bin/dds.dart" + output = "$root_gen_dir/dds_aot.dart.snapshot" + + # dartaotruntime has dart_product_config applied to it, + # so it is built in # product mode in both release and + # product builds, and is only built in debug mode in debug + # builds. The following line ensures that the dartaotruntime + # and frontend_server_aot snapshot in an SDK build are + # always compatible with each other. + force_product_mode = !dart_debug +}