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

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

Issue 2947473002: Basic support for dev_compiler in test.dart. (Closed)
Patch Set: Merge branch 'master' into ddc-chrome-tests 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'command.dart'; 7 import 'command.dart';
8 import 'configuration.dart'; 8 import 'configuration.dart';
9 import 'path.dart';
9 import 'runtime_configuration.dart'; 10 import 'runtime_configuration.dart';
10 import 'test_suite.dart'; 11 import 'test_suite.dart';
11 import 'utils.dart'; 12 import 'utils.dart';
12 13
13 List<String> replaceDartFileWith(List<String> list, String replacement) { 14 List<String> replaceDartFileWith(List<String> list, String replacement) {
14 var copy = new List<String>.from(list); 15 var copy = new List<String>.from(list);
15 for (var i = 0; i < copy.length; i++) { 16 for (var i = 0; i < copy.length; i++) {
16 if (copy[i].endsWith(".dart")) { 17 if (copy[i].endsWith(".dart")) {
17 copy[i] = replacement; 18 copy[i] = replacement;
18 } 19 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return new Dart2jsCompilerConfiguration( 67 return new Dart2jsCompilerConfiguration(
67 isDebug: configuration.mode.isDebug, 68 isDebug: configuration.mode.isDebug,
68 isChecked: configuration.isChecked, 69 isChecked: configuration.isChecked,
69 isHostChecked: configuration.isHostChecked, 70 isHostChecked: configuration.isHostChecked,
70 useSdk: configuration.useSdk, 71 useSdk: configuration.useSdk,
71 isCsp: configuration.isCsp, 72 isCsp: configuration.isCsp,
72 useFastStartup: configuration.useFastStartup, 73 useFastStartup: configuration.useFastStartup,
73 useKernel: configuration.useDart2JSWithKernel, 74 useKernel: configuration.useDart2JSWithKernel,
74 extraDart2jsOptions: configuration.dart2jsOptions); 75 extraDart2jsOptions: configuration.dart2jsOptions);
75 76
77 case Compiler.dartdevc:
78 return new DartdevcCompilerConfiguration(
79 isDebug: configuration.mode.isDebug,
80 isChecked: configuration.isChecked,
81 isHostChecked: configuration.isHostChecked);
82 break;
83
76 case Compiler.appJit: 84 case Compiler.appJit:
77 return new AppJitCompilerConfiguration( 85 return new AppJitCompilerConfiguration(
78 isDebug: configuration.mode.isDebug, 86 isDebug: configuration.mode.isDebug,
79 isChecked: configuration.isChecked); 87 isChecked: configuration.isChecked);
80 88
81 case Compiler.precompiler: 89 case Compiler.precompiler:
82 return new PrecompilerCompilerConfiguration( 90 return new PrecompilerCompilerConfiguration(
83 isDebug: configuration.mode.isDebug, 91 isDebug: configuration.mode.isDebug,
84 isChecked: configuration.isChecked, 92 isChecked: configuration.isChecked,
85 arch: configuration.architecture, 93 arch: configuration.architecture,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 481 }
474 482
475 Command computeCompilationCommand(String outputFileName, String buildDir, 483 Command computeCompilationCommand(String outputFileName, String buildDir,
476 List<String> arguments, Map<String, String> environmentOverrides) { 484 List<String> arguments, Map<String, String> environmentOverrides) {
477 arguments = arguments.toList(); 485 arguments = arguments.toList();
478 arguments.add('--out=$outputFileName'); 486 arguments.add('--out=$outputFileName');
479 487
480 return Command.compilation( 488 return Command.compilation(
481 moniker, 489 moniker,
482 outputFileName, 490 outputFileName,
483 !useSdk,
484 bootstrapDependencies(buildDir), 491 bootstrapDependencies(buildDir),
485 computeCompilerPath(buildDir), 492 computeCompilerPath(buildDir),
486 arguments, 493 arguments,
487 environmentOverrides); 494 environmentOverrides,
495 alwaysCompile: !useSdk);
488 } 496 }
489 497
490 List<Uri> bootstrapDependencies(String buildDir) { 498 List<Uri> bootstrapDependencies(String buildDir) {
491 if (!useSdk) return const <Uri>[]; 499 if (!useSdk) return const <Uri>[];
492 return _bootstrapDependenciesCache.putIfAbsent( 500 return _bootstrapDependenciesCache.putIfAbsent(
493 buildDir, 501 buildDir,
494 () => [ 502 () => [
495 Uri.base 503 Uri.base
496 .resolveUri(nativeDirectoryToUri(buildDir)) 504 .resolveUri(nativeDirectoryToUri(buildDir))
497 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot') 505 .resolve('dart-sdk/bin/snapshots/dart2js.dart.snapshot')
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 Uri sdk = useSdk 557 Uri sdk = useSdk
550 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/') 558 ? nativeDirectoryToUri(buildDir).resolve('dart-sdk/')
551 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath()) 559 : nativeDirectoryToUri(TestUtils.dartDir.toNativePath())
552 .resolve('sdk/'); 560 .resolve('sdk/');
553 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/'); 561 Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
554 return runtimeConfiguration.dart2jsPreambles(preambleDir) 562 return runtimeConfiguration.dart2jsPreambles(preambleDir)
555 ..add(artifact.filename); 563 ..add(artifact.filename);
556 } 564 }
557 } 565 }
558 566
567 /// Configuration for dart2js compiler.
568 class DartdevcCompilerConfiguration extends CompilerConfiguration {
569 DartdevcCompilerConfiguration(
570 {bool isDebug, bool isChecked, bool isHostChecked})
571 : super._subclass(
572 isDebug: isDebug,
573 isChecked: isChecked,
574 isHostChecked: isHostChecked,
575 useSdk: true);
576
577 String computeCompilerPath(String buildDir) {
578 var dir = useSdk ? "$buildDir/dart-sdk" : "sdk";
Bill Hesse 2017/06/21 16:33:20 This is not currently reachable (the non-sdk case)
Bob Nystrom 2017/06/21 20:18:28 Good catch. I think I wrote this before I required
579 return "$dir/bin/dartdevc$executableScriptSuffix";
580 }
581
582 CommandArtifact computeCompilationArtifact(String buildDir, String tempDir,
583 List<String> arguments, Map<String, String> environmentOverrides) {
584 // TODO(rnystrom): There is a lot of overlap between this code and
585 // _dartdevcCompileCommand() in test_suite.dart. This code path is only hit
586 // when the test is expected to have a compile error. Consider refactoring
587 // to unify the two (and likewise for dart2js).
588
589 // TODO(rnystrom): Are there other arguments here that we need to keep?
590 // What about arguments specified in the test itself?
591 var inputFile = arguments.last;
592
593 var compilerArguments = [
594 "--dart-sdk",
595 "$buildDir/dart-sdk",
596 "--library-root",
597 new Path(inputFile).directoryPath.toString(),
598 "-o",
599 "$tempDir/out.js",
600 inputFile
601 ];
602
603 var command = Command.compilation(
604 Compiler.dartdevc.name,
605 "$tempDir/out.js",
606 bootstrapDependencies(buildDir),
607 computeCompilerPath(buildDir),
608 compilerArguments,
609 environmentOverrides);
610
611 return new CommandArtifact(
612 [command], "$tempDir/out.js", "application/javascript");
613 }
614 }
615
559 class PrecompilerCompilerConfiguration extends CompilerConfiguration { 616 class PrecompilerCompilerConfiguration extends CompilerConfiguration {
560 final Architecture arch; 617 final Architecture arch;
561 final bool useBlobs; 618 final bool useBlobs;
562 final bool isAndroid; 619 final bool isAndroid;
563 final bool useDfe; 620 final bool useDfe;
564 621
565 PrecompilerCompilerConfiguration( 622 PrecompilerCompilerConfiguration(
566 {bool isDebug, 623 {bool isDebug,
567 bool isChecked, 624 bool isChecked,
568 this.arch, 625 this.arch,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 args.add("--snapshot=$tempDir/out.aotsnapshot"); 672 args.add("--snapshot=$tempDir/out.aotsnapshot");
616 args.add("--use-blobs"); 673 args.add("--use-blobs");
617 } else { 674 } else {
618 args.add("--snapshot=$tempDir/out.S"); 675 args.add("--snapshot=$tempDir/out.S");
619 } 676 }
620 if (isAndroid && arch == Architecture.arm) { 677 if (isAndroid && arch == Architecture.arm) {
621 args.add('--no-sim-use-hardfp'); 678 args.add('--no-sim-use-hardfp');
622 } 679 }
623 args.addAll(arguments); 680 args.addAll(arguments);
624 681
625 return Command.compilation('precompiler', tempDir, !useSdk, 682 return Command.compilation('precompiler', tempDir,
626 bootstrapDependencies(buildDir), exec, args, environmentOverrides); 683 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
684 alwaysCompile: !useSdk);
627 } 685 }
628 686
629 Command computeAssembleCommand(String tempDir, String buildDir, 687 Command computeAssembleCommand(String tempDir, String buildDir,
630 List arguments, Map<String, String> environmentOverrides) { 688 List arguments, Map<String, String> environmentOverrides) {
631 String cc, shared, ldFlags; 689 String cc, shared, ldFlags;
632 if (isAndroid) { 690 if (isAndroid) {
633 var ndk = "third_party/android_tools/ndk"; 691 var ndk = "third_party/android_tools/ndk";
634 String triple; 692 String triple;
635 if (arch == Architecture.arm) { 693 if (arch == Architecture.arm) {
636 triple = "arm-linux-androideabi"; 694 triple = "arm-linux-androideabi";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 var exec = cc; 740 var exec = cc;
683 var args = <String>[]; 741 var args = <String>[];
684 if (ccFlags != null) args.add(ccFlags); 742 if (ccFlags != null) args.add(ccFlags);
685 if (ldFlags != null) args.add(ldFlags); 743 if (ldFlags != null) args.add(ldFlags);
686 args.add(shared); 744 args.add(shared);
687 args.add('-nostdlib'); 745 args.add('-nostdlib');
688 args.add('-o'); 746 args.add('-o');
689 args.add('$tempDir/out.aotsnapshot'); 747 args.add('$tempDir/out.aotsnapshot');
690 args.add('$tempDir/out.S'); 748 args.add('$tempDir/out.S');
691 749
692 return Command.compilation('assemble', tempDir, !useSdk, 750 return Command.compilation('assemble', tempDir,
693 bootstrapDependencies(buildDir), exec, args, environmentOverrides); 751 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
752 alwaysCompile: !useSdk);
694 } 753 }
695 754
696 // This step reduces the amount of space needed to run the precompilation 755 // This step reduces the amount of space needed to run the precompilation
697 // tests by 60%. 756 // tests by 60%.
698 Command computeRemoveAssemblyCommand(String tempDir, String buildDir, 757 Command computeRemoveAssemblyCommand(String tempDir, String buildDir,
699 List arguments, Map<String, String> environmentOverrides) { 758 List arguments, Map<String, String> environmentOverrides) {
700 var exec = 'rm'; 759 var exec = 'rm';
701 var args = ['$tempDir/out.S']; 760 var args = ['$tempDir/out.S'];
702 761
703 return Command.compilation('remove_assembly', tempDir, !useSdk, 762 return Command.compilation('remove_assembly', tempDir,
704 bootstrapDependencies(buildDir), exec, args, environmentOverrides); 763 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
764 alwaysCompile: !useSdk);
705 } 765 }
706 766
707 List<String> filterVmOptions(List<String> vmOptions) { 767 List<String> filterVmOptions(List<String> vmOptions) {
708 var filtered = vmOptions.toList(); 768 var filtered = vmOptions.toList();
709 filtered.removeWhere( 769 filtered.removeWhere(
710 (option) => option.startsWith("--optimization-counter-threshold")); 770 (option) => option.startsWith("--optimization-counter-threshold"));
711 filtered.removeWhere( 771 filtered.removeWhere(
712 (option) => option.startsWith("--optimization_counter_threshold")); 772 (option) => option.startsWith("--optimization_counter_threshold"));
713 return filtered; 773 return filtered;
714 } 774 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ], snapshot, 'application/dart-snapshot'); 836 ], snapshot, 'application/dart-snapshot');
777 } 837 }
778 838
779 Command computeCompilationCommand(String tempDir, String buildDir, 839 Command computeCompilationCommand(String tempDir, String buildDir,
780 List<String> arguments, Map<String, String> environmentOverrides) { 840 List<String> arguments, Map<String, String> environmentOverrides) {
781 var exec = "$buildDir/dart"; 841 var exec = "$buildDir/dart";
782 var snapshot = "$tempDir/out.jitsnapshot"; 842 var snapshot = "$tempDir/out.jitsnapshot";
783 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"]; 843 var args = ["--snapshot=$snapshot", "--snapshot-kind=app-jit"];
784 args.addAll(arguments); 844 args.addAll(arguments);
785 845
786 return Command.compilation('app_jit', tempDir, !useSdk, 846 return Command.compilation('app_jit', tempDir,
787 bootstrapDependencies(buildDir), exec, args, environmentOverrides); 847 bootstrapDependencies(buildDir), exec, args, environmentOverrides,
848 alwaysCompile: !useSdk);
788 } 849 }
789 850
790 List<String> computeCompilerArguments( 851 List<String> computeCompilerArguments(
791 vmOptions, sharedOptions, originalArguments) { 852 vmOptions, sharedOptions, originalArguments) {
792 var args = <String>[]; 853 var args = <String>[];
793 if (isChecked) { 854 if (isChecked) {
794 args.add('--enable_asserts'); 855 args.add('--enable_asserts');
795 args.add('--enable_type_checks'); 856 args.add('--enable_type_checks');
796 } 857 }
797 return args 858 return args
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 RuntimeConfiguration runtimeConfiguration, 938 RuntimeConfiguration runtimeConfiguration,
878 String buildDir, 939 String buildDir,
879 TestInformation info, 940 TestInformation info,
880 List<String> vmOptions, 941 List<String> vmOptions,
881 List<String> sharedOptions, 942 List<String> sharedOptions,
882 List<String> originalArguments, 943 List<String> originalArguments,
883 CommandArtifact artifact) { 944 CommandArtifact artifact) {
884 return <String>[]; 945 return <String>[];
885 } 946 }
886 } 947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698