OLD | NEW |
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.kernel.backend_strategy; | 5 library dart2js.kernel.backend_strategy; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 | 8 |
9 import '../backend_strategy.dart'; | 9 import '../backend_strategy.dart'; |
10 import '../closure.dart'; | 10 import '../closure.dart'; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 @override | 66 @override |
67 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) { | 67 WorkItemBuilder createCodegenWorkItemBuilder(ClosedWorld closedWorld) { |
68 return new KernelCodegenWorkItemBuilder(_compiler.backend, closedWorld); | 68 return new KernelCodegenWorkItemBuilder(_compiler.backend, closedWorld); |
69 } | 69 } |
70 | 70 |
71 @override | 71 @override |
72 CodegenWorldBuilder createCodegenWorldBuilder( | 72 CodegenWorldBuilder createCodegenWorldBuilder( |
73 NativeBasicData nativeBasicData, | 73 NativeBasicData nativeBasicData, |
74 ClosedWorld closedWorld, | 74 ClosedWorld closedWorld, |
75 SelectorConstraintsStrategy selectorConstraintsStrategy) { | 75 SelectorConstraintsStrategy selectorConstraintsStrategy) { |
76 KernelFrontEndStrategy frontendStrategy = _compiler.frontendStrategy; | 76 return new KernelCodegenWorldBuilder(closedWorld.elementEnvironment, |
77 return new KernelCodegenWorldBuilder( | 77 nativeBasicData, closedWorld, selectorConstraintsStrategy); |
78 frontendStrategy.elementMap, | |
79 closedWorld.elementEnvironment, | |
80 nativeBasicData, | |
81 closedWorld, | |
82 selectorConstraintsStrategy); | |
83 } | 78 } |
84 | 79 |
85 @override | 80 @override |
86 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend, | 81 SsaBuilderTask createSsaBuilderTask(JavaScriptBackend backend, |
87 SourceInformationStrategy sourceInformationStrategy) { | 82 SourceInformationStrategy sourceInformationStrategy) { |
88 return new KernelSsaBuilderTask(backend.compiler); | 83 return new KernelSsaBuilderTask(backend.compiler); |
89 } | 84 } |
90 | 85 |
91 @override | 86 @override |
92 SourceInformationStrategy get sourceInformationStrategy => | 87 SourceInformationStrategy get sourceInformationStrategy => |
(...skipping 22 matching lines...) Expand all Loading... |
115 } | 110 } |
116 } | 111 } |
117 | 112 |
118 class KernelCodegenWorkItem extends CodegenWorkItem { | 113 class KernelCodegenWorkItem extends CodegenWorkItem { |
119 final JavaScriptBackend _backend; | 114 final JavaScriptBackend _backend; |
120 final ClosedWorld _closedWorld; | 115 final ClosedWorld _closedWorld; |
121 final MemberEntity element; | 116 final MemberEntity element; |
122 final CodegenRegistry registry; | 117 final CodegenRegistry registry; |
123 | 118 |
124 KernelCodegenWorkItem(this._backend, this._closedWorld, this.element) | 119 KernelCodegenWorkItem(this._backend, this._closedWorld, this.element) |
125 : registry = | 120 : registry = new CodegenRegistry(element); |
126 new CodegenRegistry(_closedWorld.elementEnvironment, element); | |
127 | 121 |
128 @override | 122 @override |
129 WorldImpact run() { | 123 WorldImpact run() { |
130 return _backend.codegen(this, _closedWorld); | 124 return _backend.codegen(this, _closedWorld); |
131 } | 125 } |
132 } | 126 } |
133 | 127 |
134 /// Task for building SSA from kernel IR loaded from .dill. | 128 /// Task for building SSA from kernel IR loaded from .dill. |
135 class KernelSsaBuilderTask extends CompilerTask implements SsaBuilderTask { | 129 class KernelSsaBuilderTask extends CompilerTask implements SsaBuilderTask { |
136 final Compiler _compiler; | 130 final Compiler _compiler; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 259 } |
266 | 260 |
267 @override | 261 @override |
268 void leaveInlinedMember(MemberEntity member) { | 262 void leaveInlinedMember(MemberEntity member) { |
269 assert(member == currentMember); | 263 assert(member == currentMember); |
270 _members.removeLast(); | 264 _members.removeLast(); |
271 } | 265 } |
272 | 266 |
273 @override | 267 @override |
274 JumpTarget getJumpTarget(ir.TreeNode node, {bool isContinueTarget: false}) { | 268 JumpTarget getJumpTarget(ir.TreeNode node, {bool isContinueTarget: false}) { |
275 // TODO(johnniwinther): Support jump targets. | 269 throw new UnimplementedError('KernelToLocalsMapImpl.getJumpTarget'); |
276 return null; | |
277 } | 270 } |
278 | 271 |
279 @override | 272 @override |
280 Local getLocal(ir.VariableDeclaration node) { | 273 Local getLocal(ir.VariableDeclaration node) { |
281 return _map.putIfAbsent(node, () { | 274 return _map.putIfAbsent(node, () { |
282 return new KLocal(node.name, currentMember); | 275 return new KLocal(node.name, currentMember); |
283 }); | 276 }); |
284 } | 277 } |
285 | 278 |
286 @override | 279 @override |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 398 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
406 return classes.toList() | 399 return classes.toList() |
407 ..sort((ClassEntity a, ClassEntity b) { | 400 ..sort((ClassEntity a, ClassEntity b) { |
408 int r = _compareLibraries(a.library, b.library); | 401 int r = _compareLibraries(a.library, b.library); |
409 if (r != 0) return r; | 402 if (r != 0) return r; |
410 return _compareNodes( | 403 return _compareNodes( |
411 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); | 404 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); |
412 }); | 405 }); |
413 } | 406 } |
414 } | 407 } |
OLD | NEW |