OLD | NEW |
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 library dart2js.cps_ir.type_propagation; | 4 library dart2js.cps_ir.type_propagation; |
5 | 5 |
6 import 'optimizers.dart'; | 6 import 'optimizers.dart'; |
7 | 7 |
8 import '../closure.dart' show | 8 import '../closure.dart' show |
9 ClosureClassElement, Identifiers; | 9 ClosureClassElement, Identifiers; |
10 import '../common/names.dart' show | 10 import '../common/names.dart' show |
11 Selectors, Identifiers; | 11 Identifiers, |
| 12 Selectors; |
12 import '../compiler.dart' as dart2js show | 13 import '../compiler.dart' as dart2js show |
13 Compiler; | 14 Compiler; |
14 import '../constants/constant_system.dart'; | 15 import '../constants/constant_system.dart'; |
15 import '../constants/values.dart'; | 16 import '../constants/values.dart'; |
16 import '../dart_types.dart' as types; | 17 import '../dart_types.dart' as types; |
17 import '../diagnostics/invariant.dart' as dart2js show | 18 import '../diagnostics/invariant.dart' as dart2js show |
18 InternalErrorFunction; | 19 InternalErrorFunction; |
19 import '../elements/elements.dart'; | 20 import '../elements/elements.dart'; |
20 import '../io/source_information.dart' show SourceInformation; | 21 import '../io/source_information.dart' show |
21 import '../js_backend/js_backend.dart' show JavaScriptBackend; | 22 SourceInformation; |
22 import '../js_backend/codegen/task.dart' show CpsFunctionCompiler; | 23 import '../js_backend/js_backend.dart' show |
| 24 JavaScriptBackend; |
| 25 import '../js_backend/codegen/task.dart' show |
| 26 CpsFunctionCompiler; |
23 import '../resolution/access_semantics.dart'; | 27 import '../resolution/access_semantics.dart'; |
24 import '../resolution/operators.dart'; | 28 import '../resolution/operators.dart'; |
25 import '../resolution/send_structure.dart'; | 29 import '../resolution/send_structure.dart'; |
26 import '../tree/tree.dart' as ast; | 30 import '../tree/tree.dart' as ast; |
27 import '../types/types.dart'; | 31 import '../types/types.dart'; |
28 import '../types/constants.dart' show computeTypeMask; | 32 import '../types/constants.dart' show |
29 import '../universe/universe.dart'; | 33 computeTypeMask; |
| 34 import '../universe/selector.dart' show |
| 35 Selector; |
30 import '../world.dart' show World; | 36 import '../world.dart' show World; |
31 import 'cps_fragment.dart'; | 37 import 'cps_fragment.dart'; |
32 import 'cps_ir_nodes.dart'; | 38 import 'cps_ir_nodes.dart'; |
33 import 'type_mask_system.dart'; | 39 import 'type_mask_system.dart'; |
34 | 40 |
35 class ConstantPropagationLattice { | 41 class ConstantPropagationLattice { |
36 final TypeMaskSystem typeSystem; | 42 final TypeMaskSystem typeSystem; |
37 final ConstantSystem constantSystem; | 43 final ConstantSystem constantSystem; |
38 final types.DartTypes dartTypes; | 44 final types.DartTypes dartTypes; |
39 final AbstractValue anything; | 45 final AbstractValue anything; |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 // therefore risk duplicating its side effects. | 1340 // therefore risk duplicating its side effects. |
1335 if (!isPure && tearOff.hasMultipleEffectiveUses) return false; | 1341 if (!isPure && tearOff.hasMultipleEffectiveUses) return false; |
1336 | 1342 |
1337 // If the getter call is impure, we risk reordering side effects. | 1343 // If the getter call is impure, we risk reordering side effects. |
1338 if (!isPure && getEffectiveParent(node) != getterCont) { | 1344 if (!isPure && getEffectiveParent(node) != getterCont) { |
1339 return false; | 1345 return false; |
1340 } | 1346 } |
1341 | 1347 |
1342 InvokeMethod invoke = new InvokeMethod.byReference( | 1348 InvokeMethod invoke = new InvokeMethod.byReference( |
1343 new Reference<Primitive>(object), | 1349 new Reference<Primitive>(object), |
1344 new Selector(SelectorKind.CALL, getter.memberName, call.callStructure), | 1350 new Selector.call(getter.memberName, call.callStructure), |
1345 type, | 1351 type, |
1346 node.arguments, | 1352 node.arguments, |
1347 node.continuation, | 1353 node.continuation, |
1348 node.sourceInformation); | 1354 node.sourceInformation); |
1349 node.receiver.unlink(); | 1355 node.receiver.unlink(); |
1350 replaceSubtree(node, invoke, unlink: false); | 1356 replaceSubtree(node, invoke, unlink: false); |
1351 | 1357 |
1352 if (tearOff.hasNoEffectiveUses) { | 1358 if (tearOff.hasNoEffectiveUses) { |
1353 // Eliminate the getter call if it has no more uses. | 1359 // Eliminate the getter call if it has no more uses. |
1354 // This cannot be delegated to other optimizations because we need to | 1360 // This cannot be delegated to other optimizations because we need to |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 processLetPrim(LetPrim node) { | 2666 processLetPrim(LetPrim node) { |
2661 node.primitive.type = null; | 2667 node.primitive.type = null; |
2662 values[node.primitive] = null; | 2668 values[node.primitive] = null; |
2663 } | 2669 } |
2664 | 2670 |
2665 processLetMutable(LetMutable node) { | 2671 processLetMutable(LetMutable node) { |
2666 node.variable.type = null; | 2672 node.variable.type = null; |
2667 values[node.variable] = null; | 2673 values[node.variable] = null; |
2668 } | 2674 } |
2669 } | 2675 } |
OLD | NEW |