Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1567103006: Null check remover understands JS fragments. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 plug(new Branch.loose(_definitions.getCopy(node.condition), 2830 plug(new Branch.loose(_definitions.getCopy(node.condition),
2822 _copies[node.trueContinuation.definition], 2831 _copies[node.trueContinuation.definition],
2823 _copies[node.falseContinuation.definition]) 2832 _copies[node.falseContinuation.definition])
2824 ..isStrictCheck = node.isStrictCheck); 2833 ..isStrictCheck = node.isStrictCheck);
2825 } 2834 }
2826 2835
2827 visitUnreachable(Unreachable node) { 2836 visitUnreachable(Unreachable node) {
2828 plug(new Unreachable()); 2837 plug(new Unreachable());
2829 } 2838 }
2830 } 2839 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/backward_null_check_remover.dart ('k') | pkg/compiler/lib/src/js/js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698