| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
| 5 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 ConstantValue constant = | 997 ConstantValue constant = |
| 998 new DummyConstantValue(const TypeMask.nonNullEmpty()); | 998 new DummyConstantValue(const TypeMask.nonNullEmpty()); |
| 999 zapInstructionCache = analyzer.graph.addConstant(constant, compiler); | 999 zapInstructionCache = analyzer.graph.addConstant(constant, compiler); |
| 1000 } | 1000 } |
| 1001 return zapInstructionCache; | 1001 return zapInstructionCache; |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 /// Returns true of [foreign] will throw an noSuchMethod error if | 1004 /// Returns true of [foreign] will throw an noSuchMethod error if |
| 1005 /// receiver is `null` before having any other side-effects. | 1005 /// receiver is `null` before having any other side-effects. |
| 1006 bool templateThrowsNSMonNull(HForeignCode foreign, HInstruction receiver) { | 1006 bool templateThrowsNSMonNull(HForeignCode foreign, HInstruction receiver) { |
| 1007 if (foreign.inputs.length < 1) return false; |
| 1008 if (foreign.inputs.first != receiver) return false; |
| 1009 if (foreign.throwBehavior.isNullNSMGuard) return true; |
| 1010 |
| 1011 // TODO(sra): Fix NativeThrowBehavior to distinguish MAY from |
| 1012 // throws-nsm-on-null-followed-by-MAY and remove all the code below. |
| 1013 |
| 1007 // We look for a template of the form | 1014 // We look for a template of the form |
| 1008 // | 1015 // |
| 1009 // #.something -or- #.something() | 1016 // #.something -or- #.something() |
| 1010 // | 1017 // |
| 1011 // where # is substituted by receiver. | 1018 // where # is substituted by receiver. |
| 1012 js.Template template = foreign.codeTemplate; | 1019 js.Template template = foreign.codeTemplate; |
| 1013 js.Node node = template.ast; | 1020 js.Node node = template.ast; |
| 1014 // #.something = ... | 1021 // #.something = ... |
| 1015 if (node is js.Assignment) { | 1022 if (node is js.Assignment) { |
| 1016 js.Assignment assignment = node; | 1023 js.Assignment assignment = node; |
| 1017 node = assignment.leftHandSide; | 1024 node = assignment.leftHandSide; |
| 1018 } | 1025 } |
| 1019 | 1026 |
| 1020 // #.something | 1027 // #.something |
| 1021 if (node is js.PropertyAccess) { | 1028 if (node is js.PropertyAccess) { |
| 1022 js.PropertyAccess access = node; | 1029 js.PropertyAccess access = node; |
| 1023 if (access.receiver is js.InterpolatedExpression) { | 1030 if (access.receiver is js.InterpolatedExpression) { |
| 1024 js.InterpolatedExpression hole = access.receiver; | 1031 js.InterpolatedExpression hole = access.receiver; |
| 1025 return hole.isPositional && foreign.inputs.first == receiver; | 1032 return hole.isPositional && hole.nameOrPosition == 0; |
| 1026 } | 1033 } |
| 1027 } | 1034 } |
| 1028 return false; | 1035 return false; |
| 1029 } | 1036 } |
| 1030 | 1037 |
| 1031 /// Returns whether the next throwing instruction that may have side | 1038 /// Returns whether the next throwing instruction that may have side |
| 1032 /// effects after [instruction], throws [NoSuchMethodError] on the | 1039 /// effects after [instruction], throws [NoSuchMethodError] on the |
| 1033 /// same receiver of [instruction]. | 1040 /// same receiver of [instruction]. |
| 1034 bool hasFollowingThrowingNSM(HInstruction instruction) { | 1041 bool hasFollowingThrowingNSM(HInstruction instruction) { |
| 1035 HInstruction receiver = instruction.getDartReceiver(compiler); | 1042 HInstruction receiver = instruction.getDartReceiver(compiler); |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2236 | 2243 |
| 2237 keyedValues.forEach((receiver, values) { | 2244 keyedValues.forEach((receiver, values) { |
| 2238 result.keyedValues[receiver] = | 2245 result.keyedValues[receiver] = |
| 2239 new Map<HInstruction, HInstruction>.from(values); | 2246 new Map<HInstruction, HInstruction>.from(values); |
| 2240 }); | 2247 }); |
| 2241 | 2248 |
| 2242 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2249 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2243 return result; | 2250 return result; |
| 2244 } | 2251 } |
| 2245 } | 2252 } |
| OLD | NEW |