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

Side by Side Diff: pkg/compiler/lib/src/js_model/js_strategy.dart

Issue 2938203003: Compute KernelClosureRepresentationInfo.variableIsUsedInTryOrSync (Closed)
Patch Set: Merge KernelClosureConversionTask and KernelClosureDataLookup 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 dart2js.js_model.strategy; 5 library dart2js.js_model.strategy;
6 6
7 import '../backend_strategy.dart'; 7 import '../backend_strategy.dart';
8 import '../closure.dart' show ClosureConversionTask; 8 import '../closure.dart' show ClosureConversionTask;
9 import '../common/tasks.dart'; 9 import '../common/tasks.dart';
10 import '../common_elements.dart'; 10 import '../common_elements.dart';
11 import '../compiler.dart'; 11 import '../compiler.dart';
12 import '../elements/elements.dart' show TypedefElement; 12 import '../elements/elements.dart' show TypedefElement;
13 import '../elements/entities.dart'; 13 import '../elements/entities.dart';
14 import '../enqueue.dart'; 14 import '../enqueue.dart';
15 import '../io/source_information.dart'; 15 import '../io/source_information.dart';
16 import '../js_emitter/sorter.dart'; 16 import '../js_emitter/sorter.dart';
17 import '../js/js_source_mapping.dart'; 17 import '../js/js_source_mapping.dart';
18 import '../js_backend/backend.dart'; 18 import '../js_backend/backend.dart';
19 import '../js_backend/backend_usage.dart'; 19 import '../js_backend/backend_usage.dart';
20 import '../js_backend/constant_system_javascript.dart'; 20 import '../js_backend/constant_system_javascript.dart';
21 import '../js_backend/interceptor_data.dart'; 21 import '../js_backend/interceptor_data.dart';
22 import '../js_backend/native_data.dart'; 22 import '../js_backend/native_data.dart';
23 import '../kernel/closure.dart';
23 import '../kernel/element_map.dart'; 24 import '../kernel/element_map.dart';
24 import '../kernel/element_map_impl.dart'; 25 import '../kernel/element_map_impl.dart';
25 import '../kernel/kernel_backend_strategy.dart'; 26 import '../kernel/kernel_backend_strategy.dart';
26 import '../kernel/kernel_strategy.dart'; 27 import '../kernel/kernel_strategy.dart';
27 import '../ssa/ssa.dart'; 28 import '../ssa/ssa.dart';
28 import '../universe/class_set.dart'; 29 import '../universe/class_set.dart';
29 import '../universe/world_builder.dart'; 30 import '../universe/world_builder.dart';
30 import '../util/emptyset.dart'; 31 import '../util/emptyset.dart';
31 import '../world.dart'; 32 import '../world.dart';
32 import 'elements.dart'; 33 import 'elements.dart';
33 34
34 class JsBackendStrategy implements BackendStrategy { 35 class JsBackendStrategy implements BackendStrategy {
35 final Compiler _compiler; 36 final Compiler _compiler;
36 final JsToFrontendMap _map = new JsToFrontendMapImpl(); 37 final JsToFrontendMap _map = new JsToFrontendMapImpl();
37 ElementEnvironment _elementEnvironment; 38 ElementEnvironment _elementEnvironment;
38 CommonElements _commonElements; 39 CommonElements _commonElements;
40 KernelToElementMap __elementMap;
Emily Fortuna 2017/06/19 17:44:41 not thrilled with the double underscore naming con
Johnni Winther 2017/06/20 10:33:12 Acknowledged.
41 ClosureConversionTask _closureDataLookup;
42 GlobalLocalsMap _globalLocalsMap = new GlobalLocalsMap();
39 43
40 JsBackendStrategy(this._compiler); 44 JsBackendStrategy(this._compiler);
41 45
46 KernelToElementMap get _elementMap {
47 if (__elementMap == null) {
48 KernelFrontEndStrategy strategy = _compiler.frontendStrategy;
49 KernelToElementMap elementMap = strategy.elementMap;
50 __elementMap = new JsKernelToElementMap(
51 _map, _elementEnvironment, _commonElements, elementMap);
52 }
53 return __elementMap;
54 }
55
42 @override 56 @override
43 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld) { 57 ClosedWorldRefiner createClosedWorldRefiner(ClosedWorld closedWorld) {
44 _elementEnvironment = 58 _elementEnvironment =
45 new JsElementEnvironment(_map, closedWorld.elementEnvironment); 59 new JsElementEnvironment(_map, closedWorld.elementEnvironment);
46 _commonElements = new JsCommonElements(_map, closedWorld.commonElements); 60 _commonElements = new JsCommonElements(_map, closedWorld.commonElements);
47 BackendUsage backendUsage = 61 BackendUsage backendUsage =
48 new JsBackendUsage(_map, closedWorld.backendUsage); 62 new JsBackendUsage(_map, closedWorld.backendUsage);
49 NativeData nativeData = new JsNativeData(_map, closedWorld.nativeData); 63 NativeData nativeData = new JsNativeData(_map, closedWorld.nativeData);
50 InterceptorData interceptorData = new InterceptorDataImpl( 64 InterceptorData interceptorData = new InterceptorDataImpl(
51 nativeData, 65 nativeData,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // TODO(johnniwinther): Support this. 123 // TODO(johnniwinther): Support this.
110 allTypedefs: new ImmutableEmptySet<TypedefElement>()); 124 allTypedefs: new ImmutableEmptySet<TypedefElement>());
111 } 125 }
112 126
113 @override 127 @override
114 Sorter get sorter { 128 Sorter get sorter {
115 throw new UnimplementedError('JsBackendStrategy.sorter'); 129 throw new UnimplementedError('JsBackendStrategy.sorter');
116 } 130 }
117 131
118 @override 132 @override
119 ClosureConversionTask createClosureConversionTask(Compiler compiler) => 133 ClosureConversionTask get closureDataLookup =>
120 new KernelClosureConversionTask(compiler.measurer); 134 _closureDataLookup ??= new KernelClosureConversionTask(
135 _compiler.measurer, _elementMap, _globalLocalsMap);
121 136
122 @override 137 @override
123 SourceInformationStrategy get sourceInformationStrategy => 138 SourceInformationStrategy get sourceInformationStrategy =>
124 const JavaScriptSourceInformationStrategy(); 139 const JavaScriptSourceInformationStrategy();
125 140
126 @override 141 @override
127 SsaBuilder createSsaBuilder(CompilerTask task, JavaScriptBackend backend, 142 SsaBuilder createSsaBuilder(CompilerTask task, JavaScriptBackend backend,
128 SourceInformationStrategy sourceInformationStrategy) { 143 SourceInformationStrategy sourceInformationStrategy) {
129 KernelFrontEndStrategy strategy = backend.compiler.frontendStrategy; 144 return new KernelSsaBuilder(
130 KernelToElementMap elementMap = strategy.elementMap; 145 task, backend.compiler, _elementMap, _globalLocalsMap);
131 JsKernelToElementMap jsElementMap = new JsKernelToElementMap(
132 _map, _elementEnvironment, _commonElements, elementMap);
133 return new KernelSsaBuilder(task, backend.compiler, jsElementMap);
134 } 146 }
135 147
136 @override 148 @override
137 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) { 149 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) {
138 return new KernelCodegenWorkItemBuilder(_compiler.backend, closedWorld); 150 return new KernelCodegenWorkItemBuilder(_compiler.backend, closedWorld);
139 } 151 }
140 152
141 @override 153 @override
142 CodegenWorldBuilder createCodegenWorldBuilder( 154 CodegenWorldBuilder createCodegenWorldBuilder(
143 NativeBasicData nativeBasicData, 155 NativeBasicData nativeBasicData,
144 ClosedWorld closedWorld, 156 ClosedWorld closedWorld,
145 SelectorConstraintsStrategy selectorConstraintsStrategy) { 157 SelectorConstraintsStrategy selectorConstraintsStrategy) {
146 KernelFrontEndStrategy frontendStrategy = _compiler.frontendStrategy;
147 return new KernelCodegenWorldBuilder( 158 return new KernelCodegenWorldBuilder(
148 frontendStrategy.elementMap, 159 _elementMap,
149 closedWorld.elementEnvironment, 160 closedWorld.elementEnvironment,
150 nativeBasicData, 161 nativeBasicData,
151 closedWorld, 162 closedWorld,
152 selectorConstraintsStrategy); 163 selectorConstraintsStrategy);
153 } 164 }
154 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698