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