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

Side by Side Diff: pkg/front_end/tool/perf.dart

Issue 2953703002: Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service (Closed)
Patch Set: cl review updates: cleanup in kernel deserialization Created 3 years, 5 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
« no previous file with comments | « pkg/front_end/tool/fasta_perf.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// An entrypoint used to run portions of front_end and measure its performance. 5 /// An entrypoint used to run portions of front_end and measure its performance.
6 library front_end.tool.perf; 6 library front_end.tool.perf;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io' show Directory, File, Platform, exit; 9 import 'dart:io' show Directory, File, Platform, exit;
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 Program program = await _kernelForProgramViaDartk(entryUri, options); 139 Program program = await _kernelForProgramViaDartk(entryUri, options);
140 dartkTimer.stop(); 140 dartkTimer.stop();
141 var suffix = useSdkSummary ? '_sum' : ''; 141 var suffix = useSdkSummary ? '_sum' : '';
142 report('kernel_gen_e2e${suffix}', dartkTimer.elapsedMicroseconds); 142 report('kernel_gen_e2e${suffix}', dartkTimer.elapsedMicroseconds);
143 return program; 143 return program;
144 } 144 }
145 145
146 _kernelForProgramViaDartk(Uri source, CompilerOptions options) async { 146 _kernelForProgramViaDartk(Uri source, CompilerOptions options) async {
147 var loader = await _createLoader(options, entry: source); 147 var loader = await _createLoader(options, entry: source);
148 if (options.compileSdk) {
149 options.additionalLibraries.forEach(loader.loadLibrary);
150 }
151 loader.loadProgram(source, compileSdk: options.compileSdk); 148 loader.loadProgram(source, compileSdk: options.compileSdk);
152 _reportErrors(loader.errors, options.onError); 149 _reportErrors(loader.errors, options.onError);
153 return loader.program; 150 return loader.program;
154 } 151 }
155 152
156 /// Create a [DartLoader] using the provided [options]. 153 /// Create a [DartLoader] using the provided [options].
157 /// 154 ///
158 /// If [options] contain no configuration to resolve `.packages`, the [entry] 155 /// If [options] contain no configuration to resolve `.packages`, the [entry]
159 /// file will be used to search for a `.packages` file. 156 /// file will be used to search for a `.packages` file.
160 Future<DartLoader> _createLoader(CompilerOptions options, 157 Future<DartLoader> _createLoader(CompilerOptions options,
161 {Program program, Uri entry}) async { 158 {Program program, Uri entry}) async {
162 var kernelOptions = _convertOptions(options); 159 var kernelOptions = _convertOptions(options);
163 var packages = await createPackages(_uriToPath(options.packagesFileUri), 160 var packages = await createPackages(_uriToPath(options.packagesFileUri),
164 discoveryPath: entry?.path); 161 discoveryPath: entry?.path);
165 var loader = 162 var loader =
166 new DartLoader(program ?? new Program(), kernelOptions, packages); 163 new DartLoader(program ?? new Program(), kernelOptions, packages);
167 var patchPaths = <String, List<String>>{}; 164 var patchPaths = <String, List<String>>{};
168 165
169 // TODO(sigmund,paulberry): use ProcessedOptions so that we can resolve the 166 // TODO(sigmund,paulberry): use ProcessedOptions so that we can resolve the
170 // URIs correctly even if sdkRoot is inferred and not specified explicitly. 167 // URIs correctly even if sdkRoot is inferred and not specified explicitly.
171 String resolve(Uri patch) => _uriToPath(options.sdkRoot.resolveUri(patch)); 168 String resolve(Uri patch) => _uriToPath(options.sdkRoot.resolveUri(patch));
172 169
173 options.targetPatches.forEach((uri, patches) { 170 options.targetPatches.forEach((name, patches) {
174 patchPaths['$uri'] = patches.map(resolve).toList(); 171 patchPaths['dart:$name'] = patches.map(resolve).toList();
175 }); 172 });
176 AnalysisOptionsImpl analysisOptions = loader.context.analysisOptions; 173 AnalysisOptionsImpl analysisOptions = loader.context.analysisOptions;
177 analysisOptions.patchPaths = patchPaths; 174 analysisOptions.patchPaths = patchPaths;
178 return loader; 175 return loader;
179 } 176 }
180 177
181 DartOptions _convertOptions(CompilerOptions options) { 178 DartOptions _convertOptions(CompilerOptions options) {
182 return new DartOptions( 179 return new DartOptions(
183 strongMode: options.strongMode, 180 strongMode: options.strongMode,
184 sdk: _uriToPath(options.sdkRoot), 181 sdk: _uriToPath(options.sdkRoot),
185 // TODO(sigmund): make it possible to use summaries and still compile the 182 // TODO(sigmund): make it possible to use summaries and still compile the
186 // sdk sources. 183 // sdk sources.
187 sdkSummary: options.compileSdk ? null : _uriToPath(options.sdkSummary), 184 sdkSummary: options.compileSdk ? null : _uriToPath(options.sdkSummary),
188 packagePath: _uriToPath(options.packagesFileUri), 185 packagePath: _uriToPath(options.packagesFileUri),
189 customUriMappings: options.uriOverride,
190 declaredVariables: options.declaredVariables); 186 declaredVariables: options.declaredVariables);
191 } 187 }
192 188
193 String _uriToPath(Uri uri) { 189 String _uriToPath(Uri uri) {
194 if (uri == null) return null; 190 if (uri == null) return null;
195 if (uri.scheme != 'file') { 191 if (uri.scheme != 'file') {
196 throw new StateError('Only file URIs are supported: $uri'); 192 throw new StateError('Only file URIs are supported: $uri');
197 } 193 }
198 return uri.toFilePath(); 194 return uri.toFilePath();
199 } 195 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 class _Scanner extends Scanner { 431 class _Scanner extends Scanner {
436 _Scanner(String contents) : super.create(new CharSequenceReader(contents)) { 432 _Scanner(String contents) : super.create(new CharSequenceReader(contents)) {
437 preserveComments = false; 433 preserveComments = false;
438 } 434 }
439 435
440 @override 436 @override
441 void reportError(errorCode, int offset, List<Object> arguments) { 437 void reportError(errorCode, int offset, List<Object> arguments) {
442 // ignore errors. 438 // ignore errors.
443 } 439 }
444 } 440 }
OLDNEW
« no previous file with comments | « pkg/front_end/tool/fasta_perf.dart ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698