Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: tests/compiler/dart2js/kernel/compiler_helper.dart

Issue 2865693002: Create closed world for hello world using .dill file (Closed)
Patch Set: Update and fix. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Partial test that the closed world computed from [WorldImpact]s derived from 5 // Partial test that the closed world computed from [WorldImpact]s derived from
6 // kernel is equivalent to the original computed from resolution. 6 // kernel is equivalent to the original computed from resolution.
7 library dart2js.kernel.compiler_helper; 7 library dart2js.kernel.compiler_helper;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:io';
10 11
11 import 'package:compiler/src/commandline_options.dart'; 12 import 'package:compiler/src/commandline_options.dart';
12 import 'package:compiler/src/common.dart'; 13 import 'package:compiler/src/common.dart';
13 import 'package:compiler/src/common/names.dart'; 14 import 'package:compiler/src/common/names.dart';
14 import 'package:compiler/src/common/tasks.dart'; 15 import 'package:compiler/src/common/tasks.dart';
15 import 'package:compiler/src/compiler.dart'; 16 import 'package:compiler/src/compiler.dart';
16 import 'package:compiler/src/elements/elements.dart'; 17 import 'package:compiler/src/elements/elements.dart';
17 import 'package:compiler/src/kernel/element_map_impl.dart'; 18 import 'package:compiler/src/kernel/element_map_impl.dart';
18 import 'package:compiler/src/kernel/kernel_strategy.dart'; 19 import 'package:compiler/src/kernel/kernel_strategy.dart';
19 import 'package:compiler/src/library_loader.dart'; 20 import 'package:compiler/src/library_loader.dart';
20 import 'package:compiler/src/universe/world_builder.dart'; 21 import 'package:compiler/src/universe/world_builder.dart';
21 import 'package:compiler/src/util/util.dart'; 22 import 'package:compiler/src/util/util.dart';
22 import 'package:expect/expect.dart'; 23 import 'package:expect/expect.dart';
23 import 'package:kernel/ast.dart' as ir; 24 import 'package:kernel/ast.dart' as ir;
24 import '../memory_compiler.dart'; 25 import '../memory_compiler.dart';
26 import '../../../../pkg/compiler/tool/generate_kernel.dart' as generate;
25 27
26 typedef Future<Compiler> CompileFunction(); 28 typedef Future<Compiler> CompileFunction();
27 29
28 /// Create multiple compilations for a list of [sources]. 30 /// Create multiple compilations for a list of [sources].
29 /// 31 ///
30 /// This methods speeds up testing kernel based compilation by creating the IR 32 /// This methods speeds up testing kernel based compilation by creating the IR
31 /// nodes for all [sources] at the same time. The returned list of 33 /// nodes for all [sources] at the same time. The returned list of
32 /// [CompileFunction]s compiles one of the [source] at a time using the kernel 34 /// [CompileFunction]s compiles one of the [source] at a time using the kernel
33 /// based compiler. 35 /// based compiler.
34 /// 36 ///
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 MemoryDillLibraryLoaderTask(KernelToElementMapImpl elementMap, 131 MemoryDillLibraryLoaderTask(KernelToElementMapImpl elementMap,
130 DiagnosticReporter reporter, Measurer measurer, this.program) 132 DiagnosticReporter reporter, Measurer measurer, this.program)
131 : super(elementMap, null, null, reporter, measurer); 133 : super(elementMap, null, null, reporter, measurer);
132 134
133 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, 135 Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
134 {bool skipFileWithPartOfTag: false}) async { 136 {bool skipFileWithPartOfTag: false}) async {
135 return createLoadedLibraries(program); 137 return createLoadedLibraries(program);
136 } 138 }
137 } 139 }
140
141 Future<Compiler> compileWithDill(
142 Uri entryPoint, Map<String, String> memorySourceFiles,
143 {bool printSteps: false}) async {
144 if (memorySourceFiles.isNotEmpty) {
145 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill');
146 if (printSteps) {
147 print('--- create temp directory $dir -------------------------------');
148 }
149 memorySourceFiles.forEach((String name, String source) {
150 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source);
151 });
152 entryPoint = dir.uri.resolve(entryPoint.path);
153 }
154 if (printSteps) {
155 print('---- generate dill -----------------------------------------------');
156 }
157
158 Uri dillFile = Uri.parse('$entryPoint.dill');
159 /*ProcessResult processResult = await Process.runSync(
Siggi Cherem (dart-lang) 2017/05/15 17:05:50 delete commented code
Johnni Winther 2017/05/16 08:29:54 Done.
160 'pkg/compiler/tool/generate_kernel',
161 ['--platform=out/ReleaseX64/patched_dart2js_sdk/platform.dill',
162 '$entryPoint']);
163 if (processResult.exitCode != 0) {
164 print(processResult.stderr);
165 exit(processResult.exitCode);
166 }*/
167 await generate.main([
168 '--platform=out/ReleaseX64/patched_dart2js_sdk/platform.dill',
169 '$entryPoint'
170 ]);
171
172 if (printSteps) {
173 print('---- closed world from dill $dillFile ----------------------------');
174 }
175 Compiler compiler = compilerFor(entryPoint: dillFile, options: [
176 Flags.analyzeOnly,
177 Flags.enableAssertMessage,
178 Flags.loadFromDill
179 ]);
180 ElementResolutionWorldBuilder.useInstantiationMap = true;
181 compiler.resolution.retainCachesForTesting = true;
182 await compiler.run(dillFile);
183 return compiler;
184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698