| 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 | 4 |
| 5 import '../common/backend_api.dart' show BackendClasses; | 5 import '../common/backend_api.dart' show BackendClasses; |
| 6 import '../compiler.dart' show Compiler; | 6 import '../compiler.dart' show Compiler; |
| 7 import '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
| 8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../js_backend/backend.dart'; | 10 import '../js_backend/backend.dart'; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 if (constantInterceptor == null) return null; | 128 if (constantInterceptor == null) return null; |
| 129 | 129 |
| 130 // If we just happen to be in an instance method of the constant | 130 // If we just happen to be in an instance method of the constant |
| 131 // interceptor, `this` is a shorter alias. | 131 // interceptor, `this` is a shorter alias. |
| 132 if (constantInterceptor == element.enclosingClass && | 132 if (constantInterceptor == element.enclosingClass && |
| 133 graph.thisInstruction != null) { | 133 graph.thisInstruction != null) { |
| 134 return graph.thisInstruction; | 134 return graph.thisInstruction; |
| 135 } | 135 } |
| 136 | 136 |
| 137 ConstantValue constant = | 137 ConstantValue constant = new InterceptorConstantValue(constantInterceptor); |
| 138 new InterceptorConstantValue(constantInterceptor.thisType); | |
| 139 return graph.addConstant(constant, closedWorld); | 138 return graph.addConstant(constant, closedWorld); |
| 140 } | 139 } |
| 141 | 140 |
| 142 ClassElement tryComputeConstantInterceptorFromType( | 141 ClassElement tryComputeConstantInterceptorFromType( |
| 143 TypeMask type, Set<ClassElement> interceptedClasses) { | 142 TypeMask type, Set<ClassElement> interceptedClasses) { |
| 144 if (type.isNullable) { | 143 if (type.isNullable) { |
| 145 if (type.isNull) { | 144 if (type.isNull) { |
| 146 return backendClasses.nullImplementation; | 145 return backendClasses.nullImplementation; |
| 147 } | 146 } |
| 148 } else if (type.containsOnlyInt(closedWorld)) { | 147 } else if (type.containsOnlyInt(closedWorld)) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 if (receiver.canBeNull()) { | 311 if (receiver.canBeNull()) { |
| 313 if (!interceptedClasses.contains(backendClasses.nullImplementation)) { | 312 if (!interceptedClasses.contains(backendClasses.nullImplementation)) { |
| 314 // Can use `(receiver && C)` only if receiver is either null or truthy. | 313 // Can use `(receiver && C)` only if receiver is either null or truthy. |
| 315 if (!(receiver.canBePrimitiveNumber(closedWorld) || | 314 if (!(receiver.canBePrimitiveNumber(closedWorld) || |
| 316 receiver.canBePrimitiveBoolean(closedWorld) || | 315 receiver.canBePrimitiveBoolean(closedWorld) || |
| 317 receiver.canBePrimitiveString(closedWorld))) { | 316 receiver.canBePrimitiveString(closedWorld))) { |
| 318 ClassElement interceptorClass = tryComputeConstantInterceptorFromType( | 317 ClassElement interceptorClass = tryComputeConstantInterceptorFromType( |
| 319 receiver.instructionType.nonNullable(), interceptedClasses); | 318 receiver.instructionType.nonNullable(), interceptedClasses); |
| 320 if (interceptorClass != null) { | 319 if (interceptorClass != null) { |
| 321 HInstruction constantInstruction = graph.addConstant( | 320 HInstruction constantInstruction = graph.addConstant( |
| 322 new InterceptorConstantValue(interceptorClass.thisType), | 321 new InterceptorConstantValue(interceptorClass), closedWorld); |
| 323 closedWorld); | |
| 324 node.conditionalConstantInterceptor = constantInstruction; | 322 node.conditionalConstantInterceptor = constantInstruction; |
| 325 constantInstruction.usedBy.add(node); | 323 constantInstruction.usedBy.add(node); |
| 326 return false; | 324 return false; |
| 327 } | 325 } |
| 328 } | 326 } |
| 329 } | 327 } |
| 330 } | 328 } |
| 331 | 329 |
| 332 // Try creating a one-shot interceptor or optimized is-check | 330 // Try creating a one-shot interceptor or optimized is-check |
| 333 if (compiler.options.hasIncrementalSupport) return false; | 331 if (compiler.options.hasIncrementalSupport) return false; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 instruction = new HInvokeDynamicMethod( | 417 instruction = new HInvokeDynamicMethod( |
| 420 selector, mask, inputs, node.instructionType, true); | 418 selector, mask, inputs, node.instructionType, true); |
| 421 } | 419 } |
| 422 | 420 |
| 423 HBasicBlock block = node.block; | 421 HBasicBlock block = node.block; |
| 424 block.addAfter(node, instruction); | 422 block.addAfter(node, instruction); |
| 425 block.rewrite(node, instruction); | 423 block.rewrite(node, instruction); |
| 426 return true; | 424 return true; |
| 427 } | 425 } |
| 428 } | 426 } |
| OLD | NEW |