Skip to content

Commit 11ab2df

Browse files
bkonyiCommit Queue
authored andcommitted
Revert "[SDK] Switch dds and dtd to use an AOT snapshot"
This reverts commit 6450d76. Reason for revert: Breaking Flutter G3 roll Original change's description: > [SDK] Switch dds and dtd to use an AOT snapshot > > TEST=ci > > Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133 > Reviewed-by: Ben Konyi <[email protected]> > Commit-Queue: Siva Annamalai <[email protected]> Change-Id: I9985919063cacfc8673b3e2946eaa163e90c9cc3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411200 Auto-Submit: Ben Konyi <[email protected]> Reviewed-by: Siva Annamalai <[email protected]> Bot-Commit: Rubber Stamper <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent bc7feac commit 11ab2df

File tree

11 files changed

+64
-343
lines changed

11 files changed

+64
-343
lines changed

pkg/dartdev/lib/src/commands/development_service.dart

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io';
76

87
import 'package:dds/src/arg_parser.dart';
9-
import 'package:path/path.dart';
108

119
import '../core.dart';
1210
import '../sdk.dart';
13-
import '../vm_interop_handler.dart';
11+
import '../utils.dart';
1412

1513
class DevelopmentServiceCommand extends DartdevCommand {
1614
static const String commandName = 'development-service';
@@ -32,50 +30,14 @@ class DevelopmentServiceCommand extends DartdevCommand {
3230

3331
@override
3432
Future<int> run() async {
35-
final sdkDir = dirname(sdk.dart);
36-
final fullSdk = sdkDir.endsWith('bin');
37-
var script = fullSdk
38-
? sdk.dartAotRuntime
39-
: absolute(sdkDir, 'dartaotruntime${Platform.isWindows ? '.exe' : ''}');
40-
var snapshot = fullSdk
41-
? sdk.ddsAotSnapshot
42-
: absolute(sdkDir, 'gen', 'dds_aot.dart.snapshot');
43-
var useExecProcess = true;
44-
final args = argResults!.arguments;
45-
46-
if (!Sdk.checkArtifactExists(snapshot, logError: false)) {
47-
// On ia32 platforms we do not have an AOT snapshot and so we need
48-
// to run the JIT snapshot.
49-
useExecProcess = false;
50-
script = fullSdk
51-
? sdk.ddsSnapshot
52-
: absolute(sdkDir, 'gen', 'dds.dart.snapshot');
53-
if (!Sdk.checkArtifactExists(script, logError: false)) {
54-
log.stderr('Error: launching development server failed : '
55-
'Unable to find snapshot for the development server');
56-
return 255;
57-
}
58-
}
59-
final ddsCommand = [
60-
if (useExecProcess) snapshot,
61-
// Add the remaining args.
62-
if (args.isNotEmpty) ...args,
63-
];
64-
try {
65-
VmInteropHandler.run(
66-
script,
67-
ddsCommand,
68-
packageConfigOverride: null,
69-
useExecProcess: useExecProcess,
70-
);
71-
return 0;
72-
} catch (e, st) {
73-
log.stderr('Error: launching development server failed');
74-
log.stderr(e.toString());
75-
if (verbose) {
76-
log.stderr(st.toString());
77-
}
78-
return 255;
79-
}
33+
// Need to make a copy as argResults!.arguments is an
34+
// UnmodifiableListView object which cannot be passed as
35+
// the args for spawnUri.
36+
final args = [...argResults!.arguments];
37+
return await runFromSnapshot(
38+
snapshot: sdk.ddsSnapshot,
39+
args: args,
40+
verbose: verbose,
41+
);
8042
}
8143
}

pkg/dartdev/lib/src/commands/tooling_daemon.dart

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:dtd_impl/dtd.dart' as dtd show DartToolingDaemonOptions;
88

99
import '../core.dart';
1010
import '../sdk.dart';
11-
import '../vm_interop_handler.dart';
11+
import '../utils.dart';
1212

1313
class ToolingDaemonCommand extends DartdevCommand {
1414
static const String commandName = 'tooling-daemon';
@@ -30,37 +30,14 @@ class ToolingDaemonCommand extends DartdevCommand {
3030

3131
@override
3232
Future<int> run() async {
33-
var script = sdk.dartAotRuntime;
34-
var snapshot = sdk.dtdAotSnapshot;
35-
var useExecProcess = true;
36-
final args = argResults!.arguments;
37-
38-
if (!Sdk.checkArtifactExists(sdk.dtdAotSnapshot, logError: false)) {
39-
// On ia32 platforms we do not have an AOT snapshot and so we need
40-
// to run the JIT snapshot.
41-
useExecProcess = false;
42-
script = sdk.dtdSnapshot;
43-
}
44-
final dtdCommand = [
45-
if (useExecProcess) snapshot,
46-
// Add the remaining args.
47-
if (args.isNotEmpty) ...args,
48-
];
49-
try {
50-
VmInteropHandler.run(
51-
script,
52-
dtdCommand,
53-
packageConfigOverride: null,
54-
useExecProcess : useExecProcess,
55-
);
56-
return 0;
57-
} catch (e, st) {
58-
log.stderr('Error: launching tooling daemon failed');
59-
log.stderr(e.toString());
60-
if (verbose) {
61-
log.stderr(st.toString());
62-
}
63-
return 255;
64-
}
33+
// Need to make a copy as argResults!.arguments is an
34+
// UnmodifiableListView object which cannot be passed as
35+
// the args for spawnUri.
36+
final args = [...argResults!.arguments];
37+
return await runFromSnapshot(
38+
snapshot: sdk.dtdSnapshot,
39+
args: args,
40+
verbose: verbose,
41+
);
6542
}
6643
}

pkg/dartdev/lib/src/dds_runner.dart

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,11 @@ class DDSRunner {
2424
}) async {
2525
final sdkDir = dirname(sdk.dart);
2626
final fullSdk = sdkDir.endsWith('bin');
27-
var execName = fullSdk
28-
? sdk.dartAotRuntime
29-
: absolute(sdkDir, 'dartaotruntime${Platform.isWindows ? '.exe' : ''}');
30-
var snapshotName = fullSdk
31-
? sdk.ddsAotSnapshot
32-
: absolute(sdkDir, 'gen', 'dds_aot.dart.snapshot');
33-
final isAot = Sdk.checkArtifactExists(snapshotName) ? true : false;
34-
if (!isAot) {
35-
// On ia32 sdks we do not have an AOT runtime and so we would be
36-
// using the regular executable.
37-
snapshotName = fullSdk
38-
? sdk.ddsSnapshot
39-
: absolute(sdkDir, 'gen', 'dds.dart.snapshot');
40-
if (!Sdk.checkArtifactExists(snapshotName)) {
41-
return false;
42-
}
43-
execName = sdk.dart;
27+
final execName = sdk.dart;
28+
final snapshotName =
29+
fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot');
30+
if (!Sdk.checkArtifactExists(snapshotName)) {
31+
return false;
4432
}
4533

4634
final process = await Process.start(

pkg/dartdev/lib/src/sdk.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ class Sdk {
119119
'dart_tooling_daemon.dart.snapshot',
120120
);
121121

122-
String get dtdAotSnapshot => _snapshotPathFor(
123-
'dart_tooling_daemon_aot.dart.snapshot',
124-
);
125-
126122
String get devToolsBinaries => path.absolute(
127123
_runFromBuildRoot
128124
? sdkPath

pkg/dds/lib/src/devtools/dtd.dart

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,15 @@ import 'package:path/path.dart' as path;
1212

1313
import 'utils.dart';
1414

15-
String getDTDSnapshotDir() {
16-
// This logic is originally from pkg/dartdev/lib/src/sdk.dart
17-
//
18-
// Find SDK path.
19-
(String, bool)? trySDKPath(String executablePath) {
20-
// The common case, and how cli_util.dart computes the Dart SDK directory,
21-
// [path.dirname] called twice on Platform.executable. We confirm by
22-
// asserting that the directory `./bin/snapshots/` exists in this directory:
23-
var sdkPath = path.absolute(path.dirname(path.dirname(executablePath)));
24-
var snapshotsDir = path.join(sdkPath, 'bin', 'snapshots');
25-
var runFromBuildRoot = false;
26-
final type = FileSystemEntity.typeSync(snapshotsDir);
27-
if (type != FileSystemEntityType.directory &&
28-
type != FileSystemEntityType.link) {
29-
// This is the less common case where the user is in
30-
// the checked out Dart SDK, and is executing `dart` via:
31-
// ./out/ReleaseX64/dart ... or in google3.
32-
sdkPath = path.absolute(path.dirname(executablePath));
33-
snapshotsDir = sdkPath;
34-
runFromBuildRoot = true;
35-
}
36-
37-
// Try to locate the DartDev snapshot to determine if we're able to find
38-
// the SDK snapshots with this SDK path. This is meant to handle
39-
// non-standard SDK layouts that can involve symlinks (e.g., Brew
40-
// installations, google3 tests, etc).
41-
if (!File(
42-
path.join(snapshotsDir, 'dartdev.dart.snapshot'),
43-
).existsSync()) {
44-
return null;
45-
}
46-
return (sdkPath, runFromBuildRoot);
47-
}
48-
49-
final (sdkPath, runFromBuildRoot) = trySDKPath(Platform.resolvedExecutable) ??
50-
trySDKPath(Platform.executable)!;
51-
52-
final String snapshotDir;
53-
if (runFromBuildRoot) {
54-
snapshotDir = sdkPath;
55-
} else {
56-
snapshotDir = path.absolute(sdkPath, 'bin', 'snapshots');
57-
}
58-
59-
return snapshotDir;
60-
}
61-
6215
Future<DtdInfo?> startDtd({
6316
required bool machineMode,
6417
required bool printDtdUri,
6518
}) async {
66-
final snapshotDir = getDTDSnapshotDir();
67-
final dtdAotSnapshot = path.absolute(
68-
snapshotDir,
69-
'dart_tooling_daemon_aot.dart.snapshot',
70-
);
71-
final dtdSnapshot = path.absolute(
72-
snapshotDir,
19+
final sdkPath = File(Platform.resolvedExecutable).parent.parent.path;
20+
final dtdSnapshot = path.absolute(
21+
sdkPath,
22+
'bin',
23+
'snapshots',
7324
'dart_tooling_daemon.dart.snapshot',
7425
);
7526

@@ -114,29 +65,15 @@ Future<DtdInfo?> startDtd({
11465
});
11566

11667
try {
117-
// Try to spawn an isolate using the AOT snapshot of the tooling daemon.
11868
await Isolate.spawnUri(
119-
Uri.file(dtdAotSnapshot),
69+
Uri.file(dtdSnapshot),
12070
['--machine'],
12171
receivePort.sendPort,
12272
onExit: exitPort.sendPort,
12373
onError: errorPort.sendPort,
12474
);
12575
} catch (_, __) {
126-
// Spawning an isolate using the AOT snapshot of the tooling daemon failed,
127-
// we are probably in a JIT VM, try again using the JIT snapshot of the
128-
// tooling daemon.
129-
try {
130-
await Isolate.spawnUri(
131-
Uri.file(dtdSnapshot),
132-
['--machine'],
133-
receivePort.sendPort,
134-
onExit: exitPort.sendPort,
135-
onError: errorPort.sendPort,
136-
);
137-
} catch (_, __) {
138-
completeForError();
139-
}
76+
completeForError();
14077
}
14178

14279
final result = await completer.future.timeout(

runtime/bin/process_win.cc

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -573,45 +573,13 @@ class ProcessStarter {
573573
}
574574

575575
int StartForExec() {
576-
ASSERT(mode_ == kInheritStdio);
577-
ASSERT(Process::ModeIsAttached(mode_));
578-
ASSERT(!Process::ModeHasStdio(mode_));
579-
580576
// Setup info
581577
STARTUPINFOEXW startup_info;
582578
ZeroMemory(&startup_info, sizeof(startup_info));
583579
startup_info.StartupInfo.cb = sizeof(startup_info);
584-
585-
// Setup the handles to inherit. We only want to inherit the three
586-
// handles for stdin, stdout and stderr.
587-
HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
588-
HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
589-
HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
590-
startup_info.StartupInfo.hStdInput = stdin_handle;
591-
startup_info.StartupInfo.hStdOutput = stdout_handle;
592-
startup_info.StartupInfo.hStdError = stderr_handle;
593-
startup_info.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
594-
SIZE_T size = 0;
595-
// The call to determine the size of an attribute list always fails with
596-
// ERROR_INSUFFICIENT_BUFFER and that error should be ignored.
597-
if (!InitializeProcThreadAttributeList(nullptr, 1, 0, &size) &&
598-
(GetLastError() != ERROR_INSUFFICIENT_BUFFER)) {
599-
return CleanupAndReturnError();
600-
}
601-
attribute_list_ = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(
602-
Dart_ScopeAllocate(size));
603-
ZeroMemory(attribute_list_, size);
604-
if (!InitializeProcThreadAttributeList(attribute_list_, 1, 0, &size)) {
605-
return CleanupAndReturnError();
606-
}
607-
inherited_handles_ = {stdin_handle, stdout_handle, stderr_handle};
608-
if (!UpdateProcThreadAttribute(
609-
attribute_list_, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
610-
inherited_handles_.data(),
611-
inherited_handles_.size() * sizeof(HANDLE), nullptr, nullptr)) {
612-
return CleanupAndReturnError();
613-
}
614-
startup_info.lpAttributeList = attribute_list_;
580+
ASSERT(mode_ == kInheritStdio);
581+
ASSERT(Process::ModeIsAttached(mode_));
582+
ASSERT(!Process::ModeHasStdio(mode_));
615583

616584
PROCESS_INFORMATION process_info;
617585
ZeroMemory(&process_info, sizeof(process_info));
@@ -633,9 +601,6 @@ class ProcessStarter {
633601
}
634602
child_process_handle_ = process_info.hProcess;
635603
CloseHandle(process_info.hThread);
636-
CloseHandle(stdin_handle);
637-
CloseHandle(stdout_handle);
638-
CloseHandle(stderr_handle);
639604

640605
// Return process id.
641606
*id_ = process_info.dwProcessId;

sdk/BUILD.gn

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ declare_args() {
4949
# ........dartdev.dart.snapshot (app-jit snapshot or kernel dill file)
5050
# ........dartdevc_aot.dart.snapshot (AOT snapshot, if not on ia32)
5151
# ........dartdevc.dart.snapshot (JIT snapshot only on ia32)
52-
# ........dds_aot.dart.snapshot (AOT snapshot, if not on ia32)
53-
# ........dds.dart.snapshot (JIT snapshot only on ia32)
54-
# ........dart_tooling_daemon_aot.dart.snapshot (AOT snapshot, if not on ia32)
55-
# ........dart_tooling_daemon.dart.snapshot (JIT snapshot only on ia32)
52+
# ........dds.dart.snapshot
53+
# ........dart_tooling_daemon.dart.snapshot
5654
# ........frontend_server_aot.dart.snapshot (AOT snapshot, if not on ia32)
5755
# ........frontend_server.dart.snapshot (JIT snapshot only on ia32)
5856
# ........gen_kernel_aot.dart.snapshot (if not on ia32)
@@ -130,38 +128,24 @@ _platform_sdk_snapshots = [
130128
"../utils/dtd:dtd",
131129
"dart_tooling_daemon",
132130
],
131+
[
132+
"dds",
133+
"../utils/dds:dds",
134+
"dds",
135+
],
133136
]
134137
if (dart_target_arch != "ia32" && dart_target_arch != "x86") {
135-
_platform_sdk_snapshots += [
136-
[
137-
"frontend_server_aot_product",
138-
"../utils/kernel-service:frontend_server_aot_product",
139-
"frontend_server_aot",
140-
],
141-
[
142-
"dds_aot_product",
143-
"../utils/dds:dds_aot",
144-
"dds_aot",
145-
],
146-
[
147-
"dart_tooling_daemon_aot_product",
148-
"../utils/dtd:dtd_aot",
149-
"dart_tooling_daemon_aot",
150-
],
151-
]
138+
_platform_sdk_snapshots += [ [
139+
"frontend_server_aot_product",
140+
"../utils/kernel-service:frontend_server_aot_product",
141+
"frontend_server_aot",
142+
] ]
152143
} else {
153-
_platform_sdk_snapshots += [
154-
[
155-
"frontend_server",
156-
"../utils/kernel-service:frontend_server",
157-
"frontend_server",
158-
],
159-
[
160-
"dds",
161-
"../utils/dds:dds",
162-
"dds",
163-
],
164-
]
144+
_platform_sdk_snapshots += [ [
145+
"frontend_server",
146+
"../utils/kernel-service:frontend_server",
147+
"frontend_server",
148+
] ]
165149
}
166150
if (dart_snapshot_kind == "app-jit") {
167151
_platform_sdk_snapshots += [ [

0 commit comments

Comments
 (0)