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

Side by Side Diff: pkg/kernel/lib/target/targets.dart

Issue 2918923003: Revert "Use backend targets to run Kernel transformations in Fasta" (Closed)
Patch Set: 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
« no previous file with comments | « pkg/kernel/lib/target/flutter.dart ('k') | pkg/kernel/lib/target/vm.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 // 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 library kernel.target.targets; 4 library kernel.target.targets;
5 5
6 import '../ast.dart'; 6 import '../ast.dart';
7 import '../class_hierarchy.dart'; 7 import '../class_hierarchy.dart';
8 import '../core_types.dart'; 8 import '../core_types.dart';
9 import '../transformations/treeshaker.dart' show ProgramRoot; 9 import '../transformations/treeshaker.dart' show ProgramRoot;
10 import 'flutter.dart' show FlutterTarget; 10 import 'flutter.dart';
11 import 'vm.dart' show VmTarget; 11 import 'vm.dart';
12 import 'vm_fasta.dart' show VmFastaTarget; 12 import 'vmcc.dart';
13 import 'vmcc.dart' show VmClosureConvertedTarget; 13 import 'vmreify.dart';
14 import 'vmreify.dart' show VmGenericTypesReifiedTarget;
15 14
16 final List<String> targetNames = targets.keys.toList(); 15 final List<String> targetNames = targets.keys.toList();
17 16
18 class TargetFlags { 17 class TargetFlags {
19 bool strongMode; 18 bool strongMode;
20 bool treeShake; 19 bool treeShake;
21 List<ProgramRoot> programRoots; 20 List<ProgramRoot> programRoots;
22 Uri kernelRuntime; 21 Uri kernelRuntime;
23 22
24 TargetFlags( 23 TargetFlags(
25 {this.strongMode: false, 24 {this.strongMode: false,
26 this.treeShake: false, 25 this.treeShake: false,
27 this.programRoots: const <ProgramRoot>[], 26 this.programRoots: const <ProgramRoot>[],
28 this.kernelRuntime}); 27 this.kernelRuntime});
29 } 28 }
30 29
31 typedef Target _TargetBuilder(TargetFlags flags); 30 typedef Target _TargetBuilder(TargetFlags flags);
32 31
33 final Map<String, _TargetBuilder> targets = <String, _TargetBuilder>{ 32 final Map<String, _TargetBuilder> targets = <String, _TargetBuilder>{
34 'none': (TargetFlags flags) => new NoneTarget(flags), 33 'none': (TargetFlags flags) => new NoneTarget(flags),
35 'vm': (TargetFlags flags) => new VmTarget(flags), 34 'vm': (TargetFlags flags) => new VmTarget(flags),
36 'vm_fasta': (TargetFlags flags) => new VmFastaTarget(flags),
37 'vmcc': (TargetFlags flags) => new VmClosureConvertedTarget(flags), 35 'vmcc': (TargetFlags flags) => new VmClosureConvertedTarget(flags),
38 'vmreify': (TargetFlags flags) => new VmGenericTypesReifiedTarget(flags), 36 'vmreify': (TargetFlags flags) => new VmGenericTypesReifiedTarget(flags),
39 'flutter': (TargetFlags flags) => new FlutterTarget(flags), 37 'flutter': (TargetFlags flags) => new FlutterTarget(flags),
40 }; 38 };
41 39
42 Target getTarget(String name, TargetFlags flags) { 40 Target getTarget(String name, TargetFlags flags) {
43 var builder = targets[name]; 41 var builder = targets[name];
44 if (builder == null) return null; 42 if (builder == null) return null;
45 return builder(flags); 43 return builder(flags);
46 } 44 }
(...skipping 16 matching lines...) Expand all
63 61
64 /// Classes from the SDK whose interface is required for the modular 62 /// Classes from the SDK whose interface is required for the modular
65 /// transformations. 63 /// transformations.
66 Map<String, List<String>> get requiredSdkClasses => CoreTypes.requiredClasses; 64 Map<String, List<String>> get requiredSdkClasses => CoreTypes.requiredClasses;
67 65
68 bool get strongMode; 66 bool get strongMode;
69 67
70 /// If true, the SDK should be loaded in strong mode. 68 /// If true, the SDK should be loaded in strong mode.
71 bool get strongModeSdk => strongMode; 69 bool get strongModeSdk => strongMode;
72 70
73 /// Perform target-specific modular transformations on the given program. 71 /// Perform target-specific modular transformations.
74 /// 72 ///
75 /// These transformations should not be whole-program transformations. They 73 /// These transformations should not be whole-program transformations. They
76 /// should expect that the program will contain external libraries. 74 /// should expect that the program will contain external libraries.
77 void performModularTransformationsOnProgram( 75 void performModularTransformations(
78 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program, 76 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program);
79 {void logger(String msg)}) {
80 performModularTransformationsOnLibraries(
81 coreTypes, hierarchy, program.libraries,
82 logger: logger);
83 }
84
85 /// Perform target-specific modular transformations on the given libraries.
86 ///
87 /// The intent of this method is to perform the transformations only on some
88 /// subset of the program libraries and avoid packing them into a temporary
89 /// [Program] instance to pass into [performModularTransformationsOnProgram].
90 ///
91 /// Note that the following should be equivalent:
92 ///
93 /// target.performModularTransformationsOnProgram(coreTypes, program);
94 ///
95 /// and
96 ///
97 /// target.performModularTransformationsOnLibraries(
98 /// coreTypes, program.libraries);
99 void performModularTransformationsOnLibraries(
100 CoreTypes coreTypes, ClassHierarchy hierarchy, List<Library> libraries,
101 {void logger(String msg)});
102 77
103 /// Perform target-specific whole-program transformations. 78 /// Perform target-specific whole-program transformations.
104 /// 79 ///
105 /// These transformations should be optimizations and not required for 80 /// These transformations should be optimizations and not required for
106 /// correctness. Everything should work if a simple and fast linker chooses 81 /// correctness. Everything should work if a simple and fast linker chooses
107 /// not to apply these transformations. 82 /// not to apply these transformations.
108 /// 83 void performGlobalTransformations(CoreTypes coreTypes, Program program);
109 /// Note that [performGlobalTransformations] doesn't have -OnProgram and
110 /// -OnLibraries alternatives, because the global knowledge required by the
111 /// transformations is assumed to be retrieved from a [Program] instance.
112 void performGlobalTransformations(CoreTypes coreTypes, Program program,
113 {void logger(String msg)});
114 84
115 /// Builds an expression that instantiates an [Invocation] that can be passed 85 /// Builds an expression that instantiates an [Invocation] that can be passed
116 /// to [noSuchMethod]. 86 /// to [noSuchMethod].
117 Expression instantiateInvocation(Member target, Expression receiver, 87 Expression instantiateInvocation(Member target, Expression receiver,
118 String name, Arguments arguments, int offset, bool isSuper); 88 String name, Arguments arguments, int offset, bool isSuper);
119 89
120 String toString() => 'Target($name)'; 90 String toString() => 'Target($name)';
121 } 91 }
122 92
123 class NoneTarget extends Target { 93 class NoneTarget extends Target {
124 final TargetFlags flags; 94 final TargetFlags flags;
125 95
126 NoneTarget(this.flags); 96 NoneTarget(this.flags);
127 97
128 bool get strongMode => flags.strongMode; 98 bool get strongMode => flags.strongMode;
129 String get name => 'none'; 99 String get name => 'none';
130 List<String> get extraRequiredLibraries => <String>[]; 100 List<String> get extraRequiredLibraries => <String>[];
131 void performModularTransformationsOnLibraries( 101 void performModularTransformations(
132 CoreTypes coreTypes, ClassHierarchy hierarchy, List<Library> libraries, 102 CoreTypes coreTypes, ClassHierarchy hierarchy, Program program) {}
133 {void logger(String msg)}) {} 103 void performGlobalTransformations(CoreTypes coreTypes, Program program) {}
134 void performGlobalTransformations(CoreTypes coreTypes, Program program,
135 {void logger(String msg)}) {}
136 104
137 @override 105 @override
138 Expression instantiateInvocation(Member target, Expression receiver, 106 Expression instantiateInvocation(Member target, Expression receiver,
139 String name, Arguments arguments, int offset, bool isSuper) { 107 String name, Arguments arguments, int offset, bool isSuper) {
140 return new InvalidExpression(); 108 return new InvalidExpression();
141 } 109 }
142 } 110 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/target/flutter.dart ('k') | pkg/kernel/lib/target/vm.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698