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

Side by Side Diff: tools/testing/dart/compiler_configuration.dart

Issue 2908833002: Revert "Revert "Refactor test option parsing code."" (Closed)
Patch Set: Ignore "—failure-summary" so it doesn't break the bots. Created 3 years, 6 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library compiler_configuration; 5 library compiler_configuration;
6 6
7 import 'dart:io' show Platform; 7 import 'dart:io' show Platform;
8 8
9 import 'runtime_configuration.dart' show RuntimeConfiguration; 9 import 'runtime_configuration.dart' show RuntimeConfiguration;
10 import 'runtime_configuration.dart' show DartPrecompiledAdbRuntimeConfiguration; 10 import 'runtime_configuration.dart' show DartPrecompiledAdbRuntimeConfiguration;
(...skipping 29 matching lines...) Expand all
40 return (path == '' || path.endsWith('/')) ? uri : Uri.parse('$uri/'); 40 return (path == '' || path.endsWith('/')) ? uri : Uri.parse('$uri/');
41 } 41 }
42 42
43 abstract class CompilerConfiguration { 43 abstract class CompilerConfiguration {
44 final bool isDebug; 44 final bool isDebug;
45 final bool isChecked; 45 final bool isChecked;
46 final bool isStrong; 46 final bool isStrong;
47 final bool isHostChecked; 47 final bool isHostChecked;
48 final bool useSdk; 48 final bool useSdk;
49 49
50 /// Only some subclasses support this check, but we statically allow calling
51 /// it on [CompilerConfiguration].
52 bool get useDfe {
53 throw new UnsupportedError("This compiler does not support DFE.");
54 }
55
50 // TODO(ahe): Remove this constructor and move the switch to 56 // TODO(ahe): Remove this constructor and move the switch to
51 // test_options.dart. We probably want to store an instance of 57 // test_options.dart. We probably want to store an instance of
52 // [CompilerConfiguration] in [configuration] there. 58 // [CompilerConfiguration] in [configuration] there.
53 factory CompilerConfiguration(Map configuration) { 59 factory CompilerConfiguration(Map configuration) {
54 String compiler = configuration['compiler']; 60 String compiler = configuration['compiler'];
55 61
56 // TODO(ahe): Move these booleans into a struction configuration object 62 // TODO(ahe): Move these booleans into a struction configuration object
57 // which can eventually completely replace the Map-based configuration 63 // which can eventually completely replace the Map-based configuration
58 // object. 64 // object.
59 bool isDebug = configuration['mode'] == 'debug'; 65 bool isDebug = configuration['mode'] == 'debug';
60 bool isChecked = configuration['checked']; 66 bool isChecked = configuration['checked'];
61 bool isStrong = configuration['strong']; 67 bool isStrong = configuration['strong'];
62 bool isHostChecked = configuration['host_checked']; 68 bool isHostChecked = configuration['host_checked'];
63 bool useSdk = configuration['use_sdk']; 69 bool useSdk = configuration['use_sdk'];
64 bool isCsp = configuration['csp']; 70 bool isCsp = configuration['csp'];
65 bool useCps = configuration['cps_ir'];
66 bool useBlobs = configuration['use_blobs']; 71 bool useBlobs = configuration['use_blobs'];
67 bool hotReload = configuration['hot_reload']; 72 bool hotReload = configuration['hot_reload'];
68 bool hotReloadRollback = configuration['hot_reload_rollback']; 73 bool hotReloadRollback = configuration['hot_reload_rollback'];
69 bool useFastStartup = configuration['fast_startup']; 74 bool useFastStartup = configuration['fast_startup'];
70 bool useKernelInDart2js = configuration['dart2js_with_kernel']; 75 bool useKernelInDart2js = configuration['dart2js_with_kernel'];
71 76
72 switch (compiler) { 77 switch (compiler) {
73 case 'dart2analyzer': 78 case 'dart2analyzer':
74 return new AnalyzerCompilerConfiguration( 79 return new AnalyzerCompilerConfiguration(
75 isDebug: isDebug, 80 isDebug: isDebug,
76 isChecked: isChecked, 81 isChecked: isChecked,
77 isStrong: isStrong, 82 isStrong: isStrong,
78 isHostChecked: isHostChecked, 83 isHostChecked: isHostChecked,
79 useSdk: useSdk); 84 useSdk: useSdk);
80 case 'dart2js': 85 case 'dart2js':
81 return new Dart2jsCompilerConfiguration( 86 return new Dart2jsCompilerConfiguration(
82 isDebug: isDebug, 87 isDebug: isDebug,
83 isChecked: isChecked, 88 isChecked: isChecked,
84 isHostChecked: isHostChecked, 89 isHostChecked: isHostChecked,
85 useCps: useCps,
86 useSdk: useSdk, 90 useSdk: useSdk,
87 isCsp: isCsp, 91 isCsp: isCsp,
88 useFastStartup: useFastStartup, 92 useFastStartup: useFastStartup,
89 useKernel: useKernelInDart2js, 93 useKernel: useKernelInDart2js,
90 extraDart2jsOptions: 94 extraDart2jsOptions:
91 TestUtils.getExtraOptions(configuration, 'dart2js_options')); 95 TestUtils.getExtraOptions(configuration, 'dart2js_options'));
92 case 'app_jit': 96 case 'app_jit':
93 return new AppJitCompilerConfiguration( 97 return new AppJitCompilerConfiguration(
94 isDebug: isDebug, isChecked: isChecked); 98 isDebug: isDebug, isChecked: isChecked);
95 case 'precompiler': 99 case 'precompiler':
96 return new PrecompilerCompilerConfiguration( 100 return new PrecompilerCompilerConfiguration(
97 isDebug: isDebug, 101 isDebug: isDebug,
98 isChecked: isChecked, 102 isChecked: isChecked,
99 arch: configuration['arch'], 103 arch: configuration['arch'],
100 useBlobs: useBlobs, 104 useBlobs: useBlobs,
101 isAndroid: configuration['system'] == 'android'); 105 isAndroid: configuration['system'] == 'android');
102 case 'dartk': 106 case 'dartk':
103 return new NoneCompilerConfiguration( 107 return new NoneCompilerConfiguration(
104 isDebug: isDebug, 108 isDebug: isDebug,
105 isChecked: isChecked, 109 isChecked: isChecked,
106 isHostChecked: isHostChecked, 110 isHostChecked: isHostChecked,
107 useSdk: useSdk, 111 useSdk: useSdk,
108 hotReload: hotReload, 112 hotReload: hotReload,
109 hotReloadRollback: hotReloadRollback, 113 hotReloadRollback: hotReloadRollback,
110 useDFE: true); 114 useDfe: true);
111 case 'dartkp': 115 case 'dartkp':
112 return new PrecompilerCompilerConfiguration( 116 return new PrecompilerCompilerConfiguration(
113 isDebug: isDebug, 117 isDebug: isDebug,
114 isChecked: isChecked, 118 isChecked: isChecked,
115 arch: configuration['arch'], 119 arch: configuration['arch'],
116 useBlobs: useBlobs, 120 useBlobs: useBlobs,
117 isAndroid: configuration['system'] == 'android', 121 isAndroid: configuration['system'] == 'android',
118 useDFE: true); 122 useDfe: true);
119 case 'none': 123 case 'none':
120 return new NoneCompilerConfiguration( 124 return new NoneCompilerConfiguration(
121 isDebug: isDebug, 125 isDebug: isDebug,
122 isChecked: isChecked, 126 isChecked: isChecked,
123 isHostChecked: isHostChecked, 127 isHostChecked: isHostChecked,
124 useSdk: useSdk, 128 useSdk: useSdk,
125 hotReload: hotReload, 129 hotReload: hotReload,
126 hotReloadRollback: hotReloadRollback); 130 hotReloadRollback: hotReloadRollback);
127 default: 131 default:
128 throw "Unknown compiler '$compiler'"; 132 throw "Unknown compiler '$compiler'";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 List<String> originalArguments, 184 List<String> originalArguments,
181 CommandArtifact artifact) { 185 CommandArtifact artifact) {
182 return [artifact.filename]; 186 return [artifact.filename];
183 } 187 }
184 } 188 }
185 189
186 /// The "none" compiler. 190 /// The "none" compiler.
187 class NoneCompilerConfiguration extends CompilerConfiguration { 191 class NoneCompilerConfiguration extends CompilerConfiguration {
188 final bool hotReload; 192 final bool hotReload;
189 final bool hotReloadRollback; 193 final bool hotReloadRollback;
190 final bool useDFE; 194 final bool useDfe;
191 195
192 NoneCompilerConfiguration( 196 NoneCompilerConfiguration(
193 {bool isDebug, 197 {bool isDebug,
194 bool isChecked, 198 bool isChecked,
195 bool isHostChecked, 199 bool isHostChecked,
196 bool useSdk, 200 bool useSdk,
197 bool this.hotReload, 201 bool this.hotReload,
198 bool this.hotReloadRollback, 202 bool this.hotReloadRollback,
199 this.useDFE: false}) 203 this.useDfe: false})
200 : super._subclass( 204 : super._subclass(
201 isDebug: isDebug, 205 isDebug: isDebug,
202 isChecked: isChecked, 206 isChecked: isChecked,
203 isHostChecked: isHostChecked, 207 isHostChecked: isHostChecked,
204 useSdk: useSdk); 208 useSdk: useSdk);
205 209
206 bool get hasCompiler => false; 210 bool get hasCompiler => false;
207 211
208 List<String> computeRuntimeArguments( 212 List<String> computeRuntimeArguments(
209 RuntimeConfiguration runtimeConfiguration, 213 RuntimeConfiguration runtimeConfiguration,
210 String buildDir, 214 String buildDir,
211 TestInformation info, 215 TestInformation info,
212 List<String> vmOptions, 216 List<String> vmOptions,
213 List<String> sharedOptions, 217 List<String> sharedOptions,
214 List<String> originalArguments, 218 List<String> originalArguments,
215 CommandArtifact artifact) { 219 CommandArtifact artifact) {
216 List<String> args = []; 220 List<String> args = [];
217 if (useDFE) { 221 if (useDfe) {
218 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot'); 222 args.add('--dfe=${buildDir}/gen/kernel-service.dart.snapshot');
219 args.add('--platform=${buildDir}/patched_sdk/platform.dill'); 223 args.add('--platform=${buildDir}/patched_sdk/platform.dill');
220 } 224 }
221 if (isChecked) { 225 if (isChecked) {
222 args.add('--enable_asserts'); 226 args.add('--enable_asserts');
223 args.add('--enable_type_checks'); 227 args.add('--enable_type_checks');
224 } 228 }
225 if (hotReload) { 229 if (hotReload) {
226 args.add('--hot-reload-test-mode'); 230 args.add('--hot-reload-test-mode');
227 } else if (hotReloadRollback) { 231 } else if (hotReloadRollback) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 Uri.base 534 Uri.base
531 .resolveUri(nativeDirectoryToUri(buildDir)) 535 .resolveUri(nativeDirectoryToUri(buildDir))
532 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') 536 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot')
533 ]); 537 ]);
534 } 538 }
535 } 539 }
536 540
537 /// Configuration for dart2js compiler. 541 /// Configuration for dart2js compiler.
538 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { 542 class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
539 final bool isCsp; 543 final bool isCsp;
540 final bool useCps;
541 final bool useFastStartup; 544 final bool useFastStartup;
542 final bool useKernel; 545 final bool useKernel;
543 final List<String> extraDart2jsOptions; 546 final List<String> extraDart2jsOptions;
544 // We cache the extended environment to save memory.
545 static Map<String, String> cpsFlagCache;
546 static Map<String, String> environmentOverridesCacheObject;
547 547
548 Dart2jsCompilerConfiguration( 548 Dart2jsCompilerConfiguration(
549 {bool isDebug, 549 {bool isDebug,
550 bool isChecked, 550 bool isChecked,
551 bool isHostChecked, 551 bool isHostChecked,
552 bool useSdk, 552 bool useSdk,
553 bool this.useCps,
554 bool this.isCsp, 553 bool this.isCsp,
555 bool this.useFastStartup, 554 bool this.useFastStartup,
556 this.useKernel, 555 this.useKernel,
557 this.extraDart2jsOptions}) 556 this.extraDart2jsOptions})
558 : super('dart2js', 557 : super('dart2js',
559 isDebug: isDebug, 558 isDebug: isDebug,
560 isChecked: isChecked, 559 isChecked: isChecked,
561 isHostChecked: isHostChecked, 560 isHostChecked: isHostChecked,
562 useSdk: useSdk); 561 useSdk: useSdk);
563 562
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); 596 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
598 return runtimeConfiguration.dart2jsPreambles(preambleDir) 597 return runtimeConfiguration.dart2jsPreambles(preambleDir)
599 ..add(artifact.filename); 598 ..add(artifact.filename);
600 } 599 }
601 } 600 }
602 601
603 class PrecompilerCompilerConfiguration extends CompilerConfiguration { 602 class PrecompilerCompilerConfiguration extends CompilerConfiguration {
604 final String arch; 603 final String arch;
605 final bool useBlobs; 604 final bool useBlobs;
606 final bool isAndroid; 605 final bool isAndroid;
607 final bool useDFE; 606 final bool useDfe;
608 607
609 PrecompilerCompilerConfiguration( 608 PrecompilerCompilerConfiguration(
610 {bool isDebug, 609 {bool isDebug,
611 bool isChecked, 610 bool isChecked,
612 this.arch, 611 this.arch,
613 this.useBlobs, 612 this.useBlobs,
614 this.isAndroid, 613 this.isAndroid,
615 this.useDFE: false}) 614 this.useDfe: false})
616 : super._subclass(isDebug: isDebug, isChecked: isChecked); 615 : super._subclass(isDebug: isDebug, isChecked: isChecked);
617 616
618 int computeTimeoutMultiplier() { 617 int computeTimeoutMultiplier() {
619 int multiplier = 2; 618 int multiplier = 2;
620 if (isDebug) multiplier *= 4; 619 if (isDebug) multiplier *= 4;
621 if (isChecked) multiplier *= 2; 620 if (isChecked) multiplier *= 2;
622 return multiplier; 621 return multiplier;
623 } 622 }
624 623
625 CommandArtifact computeCompilationArtifact( 624 CommandArtifact computeCompilationArtifact(
(...skipping 25 matching lines...) Expand all
651 if (isAndroid) { 650 if (isAndroid) {
652 if (arch == "arm") { 651 if (arch == "arm") {
653 exec = "$buildDir/clang_x86/dart_bootstrap"; 652 exec = "$buildDir/clang_x86/dart_bootstrap";
654 } else if (arch == "arm64") { 653 } else if (arch == "arm64") {
655 exec = "$buildDir/clang_x64/dart_bootstrap"; 654 exec = "$buildDir/clang_x64/dart_bootstrap";
656 } 655 }
657 } else { 656 } else {
658 exec = "$buildDir/dart_bootstrap"; 657 exec = "$buildDir/dart_bootstrap";
659 } 658 }
660 var args = <String>[]; 659 var args = <String>[];
661 if (useDFE) { 660 if (useDfe) {
662 args.add('--dfe=utils/kernel-service/kernel-service.dart'); 661 args.add('--dfe=utils/kernel-service/kernel-service.dart');
663 args.add('--platform=${buildDir}/patched_sdk/platform.dill'); 662 args.add('--platform=${buildDir}/patched_sdk/platform.dill');
664 } 663 }
665 args.add("--snapshot-kind=app-aot"); 664 args.add("--snapshot-kind=app-aot");
666 if (useBlobs) { 665 if (useBlobs) {
667 args.add("--snapshot=$tempDir/out.aotsnapshot"); 666 args.add("--snapshot=$tempDir/out.aotsnapshot");
668 args.add("--use-blobs"); 667 args.add("--use-blobs");
669 } else { 668 } else {
670 args.add("--snapshot=$tempDir/out.S"); 669 args.add("--snapshot=$tempDir/out.S");
671 } 670 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 RuntimeConfiguration runtimeConfiguration, 956 RuntimeConfiguration runtimeConfiguration,
958 String buildDir, 957 String buildDir,
959 TestInformation info, 958 TestInformation info,
960 List<String> vmOptions, 959 List<String> vmOptions,
961 List<String> sharedOptions, 960 List<String> sharedOptions,
962 List<String> originalArguments, 961 List<String> originalArguments,
963 CommandArtifact artifact) { 962 CommandArtifact artifact) {
964 return <String>[]; 963 return <String>[];
965 } 964 }
966 } 965 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698