| 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'; |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 /// - the input is an intercepted value but is bypassed by [interceptedClasses] | 1477 /// - the input is an intercepted value but is bypassed by [interceptedClasses] |
| 1478 /// | 1478 /// |
| 1479 /// The [flags] field indicates which of the above cases may happen, with | 1479 /// The [flags] field indicates which of the above cases may happen, with |
| 1480 /// additional special cases for null (which can either by intercepted or | 1480 /// additional special cases for null (which can either by intercepted or |
| 1481 /// bypassed). | 1481 /// bypassed). |
| 1482 class Interceptor extends Primitive { | 1482 class Interceptor extends Primitive { |
| 1483 final Reference<Primitive> input; | 1483 final Reference<Primitive> input; |
| 1484 final Set<ClassElement> interceptedClasses = new Set<ClassElement>(); | 1484 final Set<ClassElement> interceptedClasses = new Set<ClassElement>(); |
| 1485 final SourceInformation sourceInformation; | 1485 final SourceInformation sourceInformation; |
| 1486 | 1486 |
| 1487 /// The input was a self-interceptor. | |
| 1488 static const int SELF_INTERCEPT = 1 << 0; | |
| 1489 | |
| 1490 /// A non-null value was mapped to an interceptor that was mentioned in | |
| 1491 /// [interceptedClasses]. | |
| 1492 static const int NON_NULL_INTERCEPT_EXACT = 1 << 1; | |
| 1493 | |
| 1494 /// A non-null value was mapped to an interceptor that is a subclass of | |
| 1495 /// one mentioned in [interceptedClasses]. | |
| 1496 static const int NON_NULL_INTERCEPT_SUBCLASS = 1 << 2; | |
| 1497 | |
| 1498 /// A non-null intercepted value was bypassed because none of its supertypes | |
| 1499 /// were mentioned in [interceptedClasses]. | |
| 1500 static const int NON_NULL_BYPASS = 1 << 3; | |
| 1501 | |
| 1502 /// Null was returned as-is. | |
| 1503 static const int NULL_BYPASS = 1 << 4; | |
| 1504 | |
| 1505 /// Null was mapped to JSNull, which was mentioned in [interceptedClasses]. | |
| 1506 static const int NULL_INTERCEPT_EXACT = 1 << 5; | |
| 1507 | |
| 1508 /// Null was mapped to JSNull, because a superclass thereof (the interceptor | |
| 1509 /// root class) was mentioned in [interceptedClasses]. | |
| 1510 static const int NULL_INTERCEPT_SUBCLASS = 1 << 6; | |
| 1511 | |
| 1512 static const int NON_NULL_INTERCEPT = NON_NULL_INTERCEPT_EXACT | | |
| 1513 NON_NULL_INTERCEPT_SUBCLASS; | |
| 1514 static const int NULL_INTERCEPT = NULL_INTERCEPT_EXACT | | |
| 1515 NULL_INTERCEPT_SUBCLASS; | |
| 1516 static const int NULL = NULL_BYPASS | | |
| 1517 NULL_INTERCEPT; | |
| 1518 static const int INTERCEPT_EXACT = NON_NULL_INTERCEPT_EXACT | | |
| 1519 NULL_INTERCEPT_EXACT; | |
| 1520 static const int INTERCEPT_SUBCLASS = NON_NULL_INTERCEPT_SUBCLASS | | |
| 1521 NULL_INTERCEPT_SUBCLASS; | |
| 1522 static const int INTERCEPT = NULL_INTERCEPT | NON_NULL_INTERCEPT; | |
| 1523 static const int BYPASS = NULL_BYPASS | NON_NULL_BYPASS; | |
| 1524 | |
| 1525 static const int ALL_FLAGS = SELF_INTERCEPT | BYPASS | INTERCEPT; | |
| 1526 | |
| 1527 /// Which of the above cases may happen at runtime. Set by type propagation. | |
| 1528 int flags = ALL_FLAGS; | |
| 1529 | |
| 1530 void clearFlag(int flag) { | |
| 1531 flags &= ~flag; | |
| 1532 } | |
| 1533 | |
| 1534 bool get isAlwaysIntercepted => flags & ~INTERCEPT == 0; | |
| 1535 bool get isAlwaysNullOrIntercepted => flags & ~(NULL | INTERCEPT) == 0; | |
| 1536 | |
| 1537 /// If the value is intercepted, it always matches exactly a class in | |
| 1538 /// [interceptedClasses]. | |
| 1539 bool get isInterceptedClassAlwaysExact { | |
| 1540 return flags & (INTERCEPT & ~INTERCEPT_EXACT) == 0; | |
| 1541 } | |
| 1542 | |
| 1543 Interceptor(Primitive input, this.sourceInformation) | 1487 Interceptor(Primitive input, this.sourceInformation) |
| 1544 : this.input = new Reference<Primitive>(input); | 1488 : this.input = new Reference<Primitive>(input); |
| 1545 | 1489 |
| 1546 accept(Visitor visitor) => visitor.visitInterceptor(this); | 1490 accept(Visitor visitor) => visitor.visitInterceptor(this); |
| 1547 | 1491 |
| 1548 bool get hasValue => true; | 1492 bool get hasValue => true; |
| 1549 bool get isSafeForElimination => true; | 1493 bool get isSafeForElimination => true; |
| 1550 bool get isSafeForReordering => true; | 1494 bool get isSafeForReordering => true; |
| 1551 | 1495 |
| 1552 void setParentPointers() { | 1496 void setParentPointers() { |
| (...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 plug(new Branch.loose(_definitions.getCopy(node.condition), | 2781 plug(new Branch.loose(_definitions.getCopy(node.condition), |
| 2838 _copies[node.trueContinuation.definition], | 2782 _copies[node.trueContinuation.definition], |
| 2839 _copies[node.falseContinuation.definition]) | 2783 _copies[node.falseContinuation.definition]) |
| 2840 ..isStrictCheck = node.isStrictCheck); | 2784 ..isStrictCheck = node.isStrictCheck); |
| 2841 } | 2785 } |
| 2842 | 2786 |
| 2843 visitUnreachable(Unreachable node) { | 2787 visitUnreachable(Unreachable node) { |
| 2844 plug(new Unreachable()); | 2788 plug(new Unreachable()); |
| 2845 } | 2789 } |
| 2846 } | 2790 } |
| OLD | NEW |