| 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 '../constants/values.dart' as values show ConstantValue; | 6 import '../constants/values.dart' as values show ConstantValue; |
| 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../io/source_information.dart' show SourceInformation; | 9 import '../io/source_information.dart' show SourceInformation; |
| 10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 /// True if the primitive can be removed, assuming it has no uses | 93 /// True if the primitive can be removed, assuming it has no uses |
| 94 /// (this getter does not check if there are any uses). | 94 /// (this getter does not check if there are any uses). |
| 95 /// | 95 /// |
| 96 /// False must be returned for primitives that may throw, diverge, or have | 96 /// False must be returned for primitives that may throw, diverge, or have |
| 97 /// observable side-effects. | 97 /// observable side-effects. |
| 98 bool get isSafeForElimination; | 98 bool get isSafeForElimination; |
| 99 | 99 |
| 100 /// True if time-of-evaluation is irrelevant for the given primitive, | 100 /// True if time-of-evaluation is irrelevant for the given primitive, |
| 101 /// assuming its inputs are the same values. | 101 /// assuming its inputs are the same values. |
| 102 bool get isSafeForReordering; | 102 bool get isSafeForReordering; |
| 103 |
| 104 /// The source information associated with this primitive. |
| 105 // TODO(johnniwinther): Require source information for all primitives. |
| 106 SourceInformation get sourceInformation => null; |
| 103 } | 107 } |
| 104 | 108 |
| 105 /// Operands to invocations and primitives are always variables. They point to | 109 /// Operands to invocations and primitives are always variables. They point to |
| 106 /// their definition and are doubly-linked into a list of occurrences. | 110 /// their definition and are doubly-linked into a list of occurrences. |
| 107 class Reference<T extends Definition<T>> { | 111 class Reference<T extends Definition<T>> { |
| 108 T definition; | 112 T definition; |
| 109 Reference<T> previous; | 113 Reference<T> previous; |
| 110 Reference<T> next; | 114 Reference<T> next; |
| 111 | 115 |
| 112 /// A pointer to the parent node. Is null until set by optimization passes. | 116 /// A pointer to the parent node. Is null until set by optimization passes. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 [this.sourceInformation]) | 322 [this.sourceInformation]) |
| 319 : this.receiver = new Reference<Primitive>(receiver), | 323 : this.receiver = new Reference<Primitive>(receiver), |
| 320 this.arguments = _referenceList(arguments), | 324 this.arguments = _referenceList(arguments), |
| 321 this.continuation = new Reference<Continuation>(continuation); | 325 this.continuation = new Reference<Continuation>(continuation); |
| 322 | 326 |
| 323 InvokeMethod.byReference(this.receiver, | 327 InvokeMethod.byReference(this.receiver, |
| 324 this.selector, | 328 this.selector, |
| 325 this.mask, | 329 this.mask, |
| 326 this.arguments, | 330 this.arguments, |
| 327 this.continuation, | 331 this.continuation, |
| 328 [this.sourceInformation]); | 332 this.sourceInformation); |
| 329 | 333 |
| 330 accept(Visitor visitor) => visitor.visitInvokeMethod(this); | 334 accept(Visitor visitor) => visitor.visitInvokeMethod(this); |
| 331 } | 335 } |
| 332 | 336 |
| 333 /// Invoke [target] on [receiver], bypassing dispatch and override semantics. | 337 /// Invoke [target] on [receiver], bypassing dispatch and override semantics. |
| 334 /// | 338 /// |
| 335 /// That is, if [receiver] is an instance of a class that overrides [target] | 339 /// That is, if [receiver] is an instance of a class that overrides [target] |
| 336 /// with a different implementation, the overriding implementation is bypassed | 340 /// with a different implementation, the overriding implementation is bypassed |
| 337 /// and [target]'s implementation is invoked. | 341 /// and [target]'s implementation is invoked. |
| 338 /// | 342 /// |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 473 |
| 470 accept(Visitor visitor) => visitor.visitTypeCast(this); | 474 accept(Visitor visitor) => visitor.visitTypeCast(this); |
| 471 } | 475 } |
| 472 | 476 |
| 473 /// Apply a built-in operator. | 477 /// Apply a built-in operator. |
| 474 /// | 478 /// |
| 475 /// It must be known that the arguments have the proper types. | 479 /// It must be known that the arguments have the proper types. |
| 476 class ApplyBuiltinOperator extends Primitive { | 480 class ApplyBuiltinOperator extends Primitive { |
| 477 BuiltinOperator operator; | 481 BuiltinOperator operator; |
| 478 List<Reference<Primitive>> arguments; | 482 List<Reference<Primitive>> arguments; |
| 483 final SourceInformation sourceInformation; |
| 479 | 484 |
| 480 ApplyBuiltinOperator(this.operator, List<Primitive> arguments) | 485 ApplyBuiltinOperator(this.operator, |
| 486 List<Primitive> arguments, |
| 487 this.sourceInformation) |
| 481 : this.arguments = _referenceList(arguments); | 488 : this.arguments = _referenceList(arguments); |
| 482 | 489 |
| 483 accept(Visitor visitor) => visitor.visitApplyBuiltinOperator(this); | 490 accept(Visitor visitor) => visitor.visitApplyBuiltinOperator(this); |
| 484 | 491 |
| 485 bool get isSafeForElimination => true; | 492 bool get isSafeForElimination => true; |
| 486 bool get isSafeForReordering => true; | 493 bool get isSafeForReordering => true; |
| 487 } | 494 } |
| 488 | 495 |
| 489 /// Throw a value. | 496 /// Throw a value. |
| 490 /// | 497 /// |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 833 |
| 827 accept(Visitor visitor) => visitor.visitCreateInstance(this); | 834 accept(Visitor visitor) => visitor.visitCreateInstance(this); |
| 828 | 835 |
| 829 bool get isSafeForElimination => true; | 836 bool get isSafeForElimination => true; |
| 830 bool get isSafeForReordering => true; | 837 bool get isSafeForReordering => true; |
| 831 } | 838 } |
| 832 | 839 |
| 833 class Interceptor extends Primitive { | 840 class Interceptor extends Primitive { |
| 834 final Reference<Primitive> input; | 841 final Reference<Primitive> input; |
| 835 final Set<ClassElement> interceptedClasses; | 842 final Set<ClassElement> interceptedClasses; |
| 836 Interceptor(Primitive input, this.interceptedClasses) | 843 final SourceInformation sourceInformation; |
| 844 |
| 845 Interceptor(Primitive input, this.interceptedClasses, this.sourceInformation) |
| 837 : this.input = new Reference<Primitive>(input); | 846 : this.input = new Reference<Primitive>(input); |
| 838 accept(Visitor visitor) => visitor.visitInterceptor(this); | 847 accept(Visitor visitor) => visitor.visitInterceptor(this); |
| 839 | 848 |
| 840 bool get isSafeForElimination => true; | 849 bool get isSafeForElimination => true; |
| 841 bool get isSafeForReordering => true; | 850 bool get isSafeForReordering => true; |
| 842 } | 851 } |
| 843 | 852 |
| 844 /// Create an instance of [Invocation] for use in a call to `noSuchMethod`. | 853 /// Create an instance of [Invocation] for use in a call to `noSuchMethod`. |
| 845 class CreateInvocationMirror extends Primitive { | 854 class CreateInvocationMirror extends Primitive { |
| 846 final Selector selector; | 855 final Selector selector; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 const RemovalVisitor(); | 1464 const RemovalVisitor(); |
| 1456 | 1465 |
| 1457 processReference(Reference reference) { | 1466 processReference(Reference reference) { |
| 1458 reference.unlink(); | 1467 reference.unlink(); |
| 1459 } | 1468 } |
| 1460 | 1469 |
| 1461 static void remove(Node node) { | 1470 static void remove(Node node) { |
| 1462 (const RemovalVisitor()).visit(node); | 1471 (const RemovalVisitor()).visit(node); |
| 1463 } | 1472 } |
| 1464 } | 1473 } |
| OLD | NEW |