Skip to content

Commit 836d9bf

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
Reapply "[vm, bytecode] Fix missing dependencies in --snapshot-deps output."
Avoid Windows path differences. Skip for simulators (i.e., running from kernel file instead of source). Change-Id: I7045591f026c392d92f2ec3247ed5b6e1b5e25df Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120023 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
1 parent 9271895 commit 836d9bf

File tree

3 files changed

+59
-12
lines changed

3 files changed

+59
-12
lines changed

pkg/vm/bin/kernel_service.dart

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const int kNotifyIsolateShutdownTag = 6;
7474
bool allowDartInternalImport = false;
7575

7676
abstract class Compiler {
77+
final int isolateId;
7778
final FileSystem fileSystem;
7879
final Uri platformKernelPath;
7980
final bool suppressWarnings;
@@ -91,7 +92,7 @@ abstract class Compiler {
9192

9293
CompilerOptions options;
9394

94-
Compiler(this.fileSystem, this.platformKernelPath,
95+
Compiler(this.isolateId, this.fileSystem, this.platformKernelPath,
9596
{this.suppressWarnings: false,
9697
this.enableAsserts: false,
9798
this.experimentalFlags: null,
@@ -162,6 +163,12 @@ abstract class Compiler {
162163
CompilerResult compilerResult = await compileInternal(script);
163164
Component component = compilerResult.component;
164165

166+
if (errors.isEmpty) {
167+
// Record dependencies only if compilation was error free, and before
168+
// createFreshComponentWithBytecode drops the uriToSource table.
169+
_recordDependencies(isolateId, component, options.packagesFileUri);
170+
}
171+
165172
if (options.bytecode && errors.isEmpty) {
166173
await runWithFrontEndCompilerContext(script, options, component, () {
167174
// TODO(alexmarkov): disable local variables info,
@@ -250,13 +257,14 @@ class FileSink implements Sink<List<int>> {
250257
class IncrementalCompilerWrapper extends Compiler {
251258
IncrementalCompiler generator;
252259

253-
IncrementalCompilerWrapper(FileSystem fileSystem, Uri platformKernelPath,
260+
IncrementalCompilerWrapper(
261+
int isolateId, FileSystem fileSystem, Uri platformKernelPath,
254262
{bool suppressWarnings: false,
255263
bool enableAsserts: false,
256264
List<String> experimentalFlags: null,
257265
bool bytecode: false,
258266
String packageConfig: null})
259-
: super(fileSystem, platformKernelPath,
267+
: super(isolateId, fileSystem, platformKernelPath,
260268
suppressWarnings: suppressWarnings,
261269
enableAsserts: enableAsserts,
262270
experimentalFlags: experimentalFlags,
@@ -281,7 +289,7 @@ class IncrementalCompilerWrapper extends Compiler {
281289

282290
Future<IncrementalCompilerWrapper> clone(int isolateId) async {
283291
IncrementalCompilerWrapper clone = IncrementalCompilerWrapper(
284-
fileSystem, platformKernelPath,
292+
isolateId, fileSystem, platformKernelPath,
285293
suppressWarnings: suppressWarnings,
286294
enableAsserts: enableAsserts,
287295
experimentalFlags: experimentalFlags,
@@ -309,14 +317,15 @@ class IncrementalCompilerWrapper extends Compiler {
309317
class SingleShotCompilerWrapper extends Compiler {
310318
final bool requireMain;
311319

312-
SingleShotCompilerWrapper(FileSystem fileSystem, Uri platformKernelPath,
320+
SingleShotCompilerWrapper(
321+
int isolateId, FileSystem fileSystem, Uri platformKernelPath,
313322
{this.requireMain: false,
314323
bool suppressWarnings: false,
315324
bool enableAsserts: false,
316325
List<String> experimentalFlags: null,
317326
bool bytecode: false,
318327
String packageConfig: null})
319-
: super(fileSystem, platformKernelPath,
328+
: super(isolateId, fileSystem, platformKernelPath,
320329
suppressWarnings: suppressWarnings,
321330
enableAsserts: enableAsserts,
322331
experimentalFlags: experimentalFlags,
@@ -373,7 +382,8 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
373382
// destroyed when corresponding isolate is shut down. To achieve that kernel
374383
// isolate needs to receive a message indicating that particular
375384
// isolate was shut down. Message should be handled here in this script.
376-
compiler = new IncrementalCompilerWrapper(fileSystem, platformKernelPath,
385+
compiler = new IncrementalCompilerWrapper(
386+
isolateId, fileSystem, platformKernelPath,
377387
suppressWarnings: suppressWarnings,
378388
enableAsserts: enableAsserts,
379389
experimentalFlags: experimentalFlags,
@@ -476,7 +486,7 @@ Future _processExpressionCompilationRequest(request) async {
476486
}
477487

478488
void _recordDependencies(
479-
int isolateId, Component component, String packageConfig) {
489+
int isolateId, Component component, Uri packageConfig) {
480490
final dependencies = isolateDependencies[isolateId] ??= new List<Uri>();
481491

482492
if (component != null) {
@@ -497,7 +507,7 @@ void _recordDependencies(
497507
}
498508

499509
if (packageConfig != null) {
500-
dependencies.add(Uri.parse(packageConfig));
510+
dependencies.add(packageConfig);
501511
}
502512
}
503513

@@ -653,7 +663,8 @@ Future _processLoadRequest(request) async {
653663
} else {
654664
FileSystem fileSystem = _buildFileSystem(
655665
sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
656-
compiler = new SingleShotCompilerWrapper(fileSystem, platformKernelPath,
666+
compiler = new SingleShotCompilerWrapper(
667+
isolateId, fileSystem, platformKernelPath,
657668
requireMain: false,
658669
suppressWarnings: suppressWarnings,
659670
enableAsserts: enableAsserts,
@@ -678,8 +689,6 @@ Future _processLoadRequest(request) async {
678689
result = new CompilationResult.errors(compiler.errors, null);
679690
}
680691
} else {
681-
// Record dependencies only if compilation was error free.
682-
_recordDependencies(isolateId, component, packageConfig);
683692
// We serialize the component excluding vm_platform.dill because the VM has
684693
// these sources built-in. Everything loaded as a summary in
685694
// [kernelForProgram] is marked `external`, so we can use that bit to
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
import 'dart:io';
7+
8+
import 'package:expect/expect.dart';
9+
import 'package:path/path.dart' as p;
10+
11+
import 'snapshot_test_helper.dart';
12+
13+
Future<void> main(List<String> args) async {
14+
if (!Platform.script.toFilePath().endsWith('.dart')) {
15+
print('This test must run from source');
16+
return;
17+
}
18+
19+
await withTempDir((String temp) async {
20+
final snapshotPath = p.join(temp, 'snapshot_depfile_test.snapshot');
21+
final depfilePath = p.join(temp, 'snapshot_depfile_test.snapshot.d');
22+
23+
await runDart('GENERATE SNAPSHOT', [
24+
'--snapshot=$snapshotPath',
25+
'--snapshot-depfile=$depfilePath',
26+
Platform.script.toFilePath(),
27+
'--child',
28+
]);
29+
30+
var depfileContents = await new File(depfilePath).readAsString();
31+
print(depfileContents);
32+
Expect.isTrue(depfileContents.contains('snapshot_depfile_test.snapshot:'),
33+
'depfile contains output');
34+
Expect.isTrue(depfileContents.contains('snapshot_depfile_test.dart'),
35+
'depfile contains input');
36+
});
37+
}

runtime/tests/vm/vm.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ dart/entrypoints/jit/*: SkipByDesign # These tests should only run on JIT.
103103
[ $compiler != dartk && $compiler != dartkb && $compiler != none ]
104104
dart/appjit*: SkipByDesign # Test needs to run from source
105105
dart/kernel_determinism_test: SkipByDesign # Test needs to run from source
106+
dart/snapshot_depfile_test: SkipByDesign # Test needs to run from source
106107

107108
[ $compiler == dartkp && ($runtime == dart_precompiled || $runtime == vm) ]
108109
dart/redirection_type_shuffling_test: SkipByDesign # Includes dart:mirrors.

0 commit comments

Comments
 (0)