| 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'; |
| 11 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 11 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 12 import '../common/tasks.dart'; | 12 import '../common/tasks.dart'; |
| 13 import '../compiler.dart'; | 13 import '../compiler.dart'; |
| 14 import '../elements/elements.dart' show JumpTarget; | 14 import '../elements/elements.dart' show JumpTarget; |
| 15 import '../elements/entities.dart'; | 15 import '../elements/entities.dart'; |
| 16 import '../elements/entity_utils.dart' as utils; | 16 import '../elements/entity_utils.dart' as utils; |
| 17 import '../enqueue.dart'; | 17 import '../enqueue.dart'; |
| 18 import '../io/source_information.dart'; | 18 import '../io/source_information.dart'; |
| 19 import '../js/js_source_mapping.dart'; | 19 import '../js/js_source_mapping.dart'; |
| 20 import '../js_backend/backend.dart'; | 20 import '../js_backend/backend.dart'; |
| 21 import '../js_backend/native_data.dart'; | 21 import '../js_backend/native_data.dart'; |
| 22 import '../js_emitter/sorter.dart'; | 22 import '../js_emitter/sorter.dart'; |
| 23 import '../kernel/element_map.dart'; | 23 import '../kernel/element_map.dart'; |
| 24 import '../kernel/element_map_impl.dart'; | 24 import '../kernel/element_map_impl.dart'; |
| 25 import '../native/behavior.dart'; | 25 import '../native/behavior.dart'; |
| 26 import '../options.dart'; |
| 26 import '../ssa/builder_kernel.dart'; | 27 import '../ssa/builder_kernel.dart'; |
| 27 import '../ssa/nodes.dart'; | 28 import '../ssa/nodes.dart'; |
| 28 import '../ssa/ssa.dart'; | 29 import '../ssa/ssa.dart'; |
| 29 import '../ssa/types.dart'; | 30 import '../ssa/types.dart'; |
| 30 import '../types/types.dart'; | 31 import '../types/types.dart'; |
| 31 import '../universe/selector.dart'; | 32 import '../universe/selector.dart'; |
| 32 import '../universe/world_builder.dart'; | 33 import '../universe/world_builder.dart'; |
| 33 import '../universe/world_impact.dart'; | 34 import '../universe/world_impact.dart'; |
| 34 import '../world.dart'; | 35 import '../world.dart'; |
| 35 import 'element_map_impl.dart'; | 36 import 'element_map_impl.dart'; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 SourceInformationStrategy get sourceInformationStrategy => | 89 SourceInformationStrategy get sourceInformationStrategy => |
| 89 const JavaScriptSourceInformationStrategy(); | 90 const JavaScriptSourceInformationStrategy(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 class KernelCodegenWorkItemBuilder implements WorkItemBuilder { | 93 class KernelCodegenWorkItemBuilder implements WorkItemBuilder { |
| 93 final JavaScriptBackend _backend; | 94 final JavaScriptBackend _backend; |
| 94 final ClosedWorld _closedWorld; | 95 final ClosedWorld _closedWorld; |
| 95 | 96 |
| 96 KernelCodegenWorkItemBuilder(this._backend, this._closedWorld); | 97 KernelCodegenWorkItemBuilder(this._backend, this._closedWorld); |
| 97 | 98 |
| 99 CompilerOptions get _options => _backend.compiler.options; |
| 100 |
| 98 @override | 101 @override |
| 99 CodegenWorkItem createWorkItem(MemberEntity entity) { | 102 CodegenWorkItem createWorkItem(MemberEntity entity) { |
| 103 // Codegen inlines field initializers. It only needs to generate |
| 104 // code for checked setters. |
| 105 if (entity.isField && entity.isInstanceMember) { |
| 106 if (!_options.enableTypeAssertions || entity.enclosingClass.isClosure) { |
| 107 return null; |
| 108 } |
| 109 } |
| 110 |
| 100 return new KernelCodegenWorkItem(_backend, _closedWorld, entity); | 111 return new KernelCodegenWorkItem(_backend, _closedWorld, entity); |
| 101 } | 112 } |
| 102 } | 113 } |
| 103 | 114 |
| 104 class KernelCodegenWorkItem extends CodegenWorkItem { | 115 class KernelCodegenWorkItem extends CodegenWorkItem { |
| 105 final JavaScriptBackend _backend; | 116 final JavaScriptBackend _backend; |
| 106 final ClosedWorld _closedWorld; | 117 final ClosedWorld _closedWorld; |
| 107 final MemberEntity element; | 118 final MemberEntity element; |
| 108 final CodegenRegistry registry; | 119 final CodegenRegistry registry; |
| 109 | 120 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 362 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
| 352 return classes.toList() | 363 return classes.toList() |
| 353 ..sort((ClassEntity a, ClassEntity b) { | 364 ..sort((ClassEntity a, ClassEntity b) { |
| 354 int r = _compareLibraries(a.library, b.library); | 365 int r = _compareLibraries(a.library, b.library); |
| 355 if (r != 0) return r; | 366 if (r != 0) return r; |
| 356 return _compareNodes( | 367 return _compareNodes( |
| 357 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); | 368 a, elementMap.getClassNode(a), b, elementMap.getClassNode(b)); |
| 358 }); | 369 }); |
| 359 } | 370 } |
| 360 } | 371 } |
| OLD | NEW |