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

Side by Side Diff: pkg/kernel/bin/dartk.dart

Issue 2531873002: Add --verify-ir flag to dartk and test.py. (Closed)
Patch Set: Minor fixes Created 4 years 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/compiler/lib/src/kernel/kernel.dart ('k') | pkg/kernel/bin/transform.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 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'batch_util.dart'; 9 import 'batch_util.dart';
10 10
11 import 'package:args/args.dart'; 11 import 'package:args/args.dart';
12 import 'package:kernel/analyzer/loader.dart'; 12 import 'package:kernel/analyzer/loader.dart';
13 import 'package:kernel/checks.dart'; 13 import 'package:kernel/verifier.dart';
14 import 'package:kernel/kernel.dart'; 14 import 'package:kernel/kernel.dart';
15 import 'package:kernel/log.dart'; 15 import 'package:kernel/log.dart';
16 import 'package:kernel/target/targets.dart'; 16 import 'package:kernel/target/targets.dart';
17 import 'package:path/path.dart' as path; 17 import 'package:path/path.dart' as path;
18 18
19 // Returns the path to the current sdk based on `Platform.resolvedExecutable`. 19 // Returns the path to the current sdk based on `Platform.resolvedExecutable`.
20 String currentSdk() { 20 String currentSdk() {
21 // The dart executable should be inside dart-sdk/bin/dart. 21 // The dart executable should be inside dart-sdk/bin/dart.
22 return path.dirname(path.dirname(path.absolute(Platform.resolvedExecutable))); 22 return path.dirname(path.dirname(path.absolute(Platform.resolvedExecutable)));
23 } 23 }
(...skipping 27 matching lines...) Expand all
51 allowMultiple: true, 51 allowMultiple: true,
52 help: 'A custom url mapping of the form `<scheme>:<name>::<uri>`.') 52 help: 'A custom url mapping of the form `<scheme>:<name>::<uri>`.')
53 ..addFlag('verbose', 53 ..addFlag('verbose',
54 abbr: 'v', 54 abbr: 'v',
55 negatable: false, 55 negatable: false,
56 help: 'Print internal warnings and diagnostics to stderr.') 56 help: 'Print internal warnings and diagnostics to stderr.')
57 ..addFlag('print-metrics', 57 ..addFlag('print-metrics',
58 negatable: false, help: 'Print performance metrics.') 58 negatable: false, help: 'Print performance metrics.')
59 ..addOption('write-dependencies', 59 ..addOption('write-dependencies',
60 help: 'Write all the .dart that were loaded to the given file.') 60 help: 'Write all the .dart that were loaded to the given file.')
61 ..addFlag('sanity-check', help: 'Perform slow internal correctness checks.') 61 ..addFlag('verify-ir', help: 'Perform slow internal correctness checks.')
62 ..addFlag('tolerant', 62 ..addFlag('tolerant',
63 help: 'Generate kernel even if there are compile-time errors.', 63 help: 'Generate kernel even if there are compile-time errors.',
64 defaultsTo: false) 64 defaultsTo: false)
65 ..addOption('D', 65 ..addOption('D',
66 abbr: 'D', 66 abbr: 'D',
67 allowMultiple: true, 67 allowMultiple: true,
68 help: 'Define an environment variable.', 68 help: 'Define an environment variable.',
69 hide: true) 69 hide: true)
70 ..addFlag('show-external', 70 ..addFlag('show-external',
71 help: 'When printing a library as text, also print its dependencies\n' 71 help: 'When printing a library as text, also print its dependencies\n'
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 getLoadedFiles = () => loadedFiles ??= loader.getLoadedFileNames(); 321 getLoadedFiles = () => loadedFiles ??= loader.getLoadedFileNames();
322 } 322 }
323 323
324 bool canContinueCompilation = errors.isEmpty || options['tolerant']; 324 bool canContinueCompilation = errors.isEmpty || options['tolerant'];
325 325
326 int loadTime = watch.elapsedMilliseconds; 326 int loadTime = watch.elapsedMilliseconds;
327 if (shouldReportMetrics) { 327 if (shouldReportMetrics) {
328 print('loader.time = $loadTime ms'); 328 print('loader.time = $loadTime ms');
329 } 329 }
330 330
331 void sanityCheck() { 331 void runVerifier() {
332 if (options['sanity-check']) { 332 if (options['verify-ir']) {
333 runSanityChecks(program); 333 verifyProgram(program);
334 } 334 }
335 } 335 }
336 336
337 if (canContinueCompilation) { 337 if (canContinueCompilation) {
338 sanityCheck(); 338 runVerifier();
339 } 339 }
340 340
341 String outputDependencies = options['write-dependencies']; 341 String outputDependencies = options['write-dependencies'];
342 if (outputDependencies != null) { 342 if (outputDependencies != null) {
343 new File(outputDependencies).writeAsStringSync(getLoadedFiles().join('\n')); 343 new File(outputDependencies).writeAsStringSync(getLoadedFiles().join('\n'));
344 } 344 }
345 345
346 // Apply target-specific transformations. 346 // Apply target-specific transformations.
347 if (target != null && options['link'] && canContinueCompilation) { 347 if (target != null && options['link'] && canContinueCompilation) {
348 target.transformProgram(program); 348 target.transformProgram(program);
349 sanityCheck(); 349 runVerifier();
350 } 350 }
351 351
352 if (options['no-output']) { 352 if (options['no-output']) {
353 return CompilerOutcome.Ok; 353 return CompilerOutcome.Ok;
354 } 354 }
355 355
356 watch.reset(); 356 watch.reset();
357 357
358 Future ioFuture; 358 Future ioFuture;
359 if (canContinueCompilation) { 359 if (canContinueCompilation) {
(...skipping 15 matching lines...) Expand all
375 375
376 await ioFuture; 376 await ioFuture;
377 377
378 if (shouldReportMetrics) { 378 if (shouldReportMetrics) {
379 int flushTime = watch.elapsedMilliseconds - time; 379 int flushTime = watch.elapsedMilliseconds - time;
380 print('writer.flush_time = $flushTime ms'); 380 print('writer.flush_time = $flushTime ms');
381 } 381 }
382 382
383 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; 383 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok;
384 } 384 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel.dart ('k') | pkg/kernel/bin/transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698