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

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: 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
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) { 148
149 options.additionalLibraries.forEach(loader.loadLibrary); 149 /// CODE REVIEW COMMENT: additionalLibraries was empty
150 }
151 loader.loadProgram(source, compileSdk: options.compileSdk); 150 loader.loadProgram(source, compileSdk: options.compileSdk);
152 _reportErrors(loader.errors, options.onError); 151 _reportErrors(loader.errors, options.onError);
153 return loader.program; 152 return loader.program;
154 } 153 }
155 154
156 /// Create a [DartLoader] using the provided [options]. 155 /// Create a [DartLoader] using the provided [options].
157 /// 156 ///
158 /// If [options] contain no configuration to resolve `.packages`, the [entry] 157 /// If [options] contain no configuration to resolve `.packages`, the [entry]
159 /// file will be used to search for a `.packages` file. 158 /// file will be used to search for a `.packages` file.
160 Future<DartLoader> _createLoader(CompilerOptions options, 159 Future<DartLoader> _createLoader(CompilerOptions options,
(...skipping 18 matching lines...) Expand all
179 } 178 }
180 179
181 DartOptions _convertOptions(CompilerOptions options) { 180 DartOptions _convertOptions(CompilerOptions options) {
182 return new DartOptions( 181 return new DartOptions(
183 strongMode: options.strongMode, 182 strongMode: options.strongMode,
184 sdk: _uriToPath(options.sdkRoot), 183 sdk: _uriToPath(options.sdkRoot),
185 // TODO(sigmund): make it possible to use summaries and still compile the 184 // TODO(sigmund): make it possible to use summaries and still compile the
186 // sdk sources. 185 // sdk sources.
187 sdkSummary: options.compileSdk ? null : _uriToPath(options.sdkSummary), 186 sdkSummary: options.compileSdk ? null : _uriToPath(options.sdkSummary),
188 packagePath: _uriToPath(options.packagesFileUri), 187 packagePath: _uriToPath(options.packagesFileUri),
189 customUriMappings: options.uriOverride,
190 declaredVariables: options.declaredVariables); 188 declaredVariables: options.declaredVariables);
191 } 189 }
192 190
193 String _uriToPath(Uri uri) { 191 String _uriToPath(Uri uri) {
194 if (uri == null) return null; 192 if (uri == null) return null;
195 if (uri.scheme != 'file') { 193 if (uri.scheme != 'file') {
196 throw new StateError('Only file URIs are supported: $uri'); 194 throw new StateError('Only file URIs are supported: $uri');
197 } 195 }
198 return uri.toFilePath(); 196 return uri.toFilePath();
199 } 197 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 class _Scanner extends Scanner { 433 class _Scanner extends Scanner {
436 _Scanner(String contents) : super.create(new CharSequenceReader(contents)) { 434 _Scanner(String contents) : super.create(new CharSequenceReader(contents)) {
437 preserveComments = false; 435 preserveComments = false;
438 } 436 }
439 437
440 @override 438 @override
441 void reportError(errorCode, int offset, List<Object> arguments) { 439 void reportError(errorCode, int offset, List<Object> arguments) {
442 // ignore errors. 440 // ignore errors.
443 } 441 }
444 } 442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698