| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.ir_nodes; | 4 library dart2js.ir_nodes; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'cps_fragment.dart' show CpsFragment; | 7 import 'cps_fragment.dart' show CpsFragment; |
| 8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
| 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 9 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 11 import '../io/source_information.dart' show SourceInformation; | 11 import '../io/source_information.dart' show SourceInformation; |
| 12 import '../types/types.dart' show TypeMask; | 12 import '../types/types.dart' show TypeMask; |
| 13 import '../universe/selector.dart' show Selector; | 13 import '../universe/selector.dart' show Selector; |
| 14 | 14 |
| 15 import 'builtin_operator.dart'; | 15 import 'builtin_operator.dart'; |
| 16 export 'builtin_operator.dart'; | 16 export 'builtin_operator.dart'; |
| 17 | 17 |
| 18 // These imports are only used for the JavaScript specific nodes. If we want to | 18 // These imports are only used for the JavaScript specific nodes. If we want to |
| 19 // support more than one native backend, we should probably create better | 19 // support more than one native backend, we should probably create better |
| 20 // abstractions for native code and its type and effect system. | 20 // abstractions for native code and its type and effect system. |
| 21 import '../js/js.dart' as js show Template; | 21 import '../js/js.dart' as js show Template, isNullGuardOnFirstArgument; |
| 22 import '../native/native.dart' as native show NativeBehavior; | 22 import '../native/native.dart' as native show NativeBehavior; |
| 23 | 23 |
| 24 abstract class Node { | 24 abstract class Node { |
| 25 /// A pointer to the parent node. Is null until set by optimization passes. | 25 /// A pointer to the parent node. Is null until set by optimization passes. |
| 26 Node parent; | 26 Node parent; |
| 27 | 27 |
| 28 /// Workaround for a slow Object.hashCode in the VM. | 28 /// Workaround for a slow Object.hashCode in the VM. |
| 29 static int _usedHashCodes = 0; | 29 static int _usedHashCodes = 0; |
| 30 final int hashCode = ++_usedHashCodes; | 30 final int hashCode = ++_usedHashCodes; |
| 31 | 31 |
| (...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 this.nativeBehavior, {this.dependency}) | 1538 this.nativeBehavior, {this.dependency}) |
| 1539 : this.arguments = _referenceList(arguments); | 1539 : this.arguments = _referenceList(arguments); |
| 1540 | 1540 |
| 1541 accept(Visitor visitor) => visitor.visitForeignCode(this); | 1541 accept(Visitor visitor) => visitor.visitForeignCode(this); |
| 1542 | 1542 |
| 1543 bool get hasValue => true; | 1543 bool get hasValue => true; |
| 1544 | 1544 |
| 1545 void setParentPointers() { | 1545 void setParentPointers() { |
| 1546 _setParentsOnList(arguments, this); | 1546 _setParentsOnList(arguments, this); |
| 1547 } | 1547 } |
| 1548 |
| 1549 bool isNullGuardOnNullFirstArgument() { |
| 1550 if (arguments.length < 1) return false; |
| 1551 // TODO(sra): Fix NativeThrowBehavior to distinguish MAY from |
| 1552 // throws-nsm-on-null-followed-by-MAY and remove |
| 1553 // [isNullGuardForFirstArgument]. |
| 1554 if (nativeBehavior.throwBehavior.isNullNSMGuard) return true; |
| 1555 return js.isNullGuardOnFirstArgument(codeTemplate); |
| 1556 } |
| 1548 } | 1557 } |
| 1549 | 1558 |
| 1550 class Constant extends Primitive { | 1559 class Constant extends Primitive { |
| 1551 final values.ConstantValue value; | 1560 final values.ConstantValue value; |
| 1552 final SourceInformation sourceInformation; | 1561 final SourceInformation sourceInformation; |
| 1553 | 1562 |
| 1554 Constant(this.value, {this.sourceInformation}) { | 1563 Constant(this.value, {this.sourceInformation}) { |
| 1555 assert(value != null); | 1564 assert(value != null); |
| 1556 } | 1565 } |
| 1557 | 1566 |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 plug(new Branch.loose(_definitions.getCopy(node.condition), | 2803 plug(new Branch.loose(_definitions.getCopy(node.condition), |
| 2795 _copies[node.trueContinuation.definition], | 2804 _copies[node.trueContinuation.definition], |
| 2796 _copies[node.falseContinuation.definition]) | 2805 _copies[node.falseContinuation.definition]) |
| 2797 ..isStrictCheck = node.isStrictCheck); | 2806 ..isStrictCheck = node.isStrictCheck); |
| 2798 } | 2807 } |
| 2799 | 2808 |
| 2800 visitUnreachable(Unreachable node) { | 2809 visitUnreachable(Unreachable node) { |
| 2801 plug(new Unreachable()); | 2810 plug(new Unreachable()); |
| 2802 } | 2811 } |
| 2803 } | 2812 } |
| OLD | NEW |