| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This phase simplifies interceptors in multiple ways: | 8 * This phase simplifies interceptors in multiple ways: |
| 9 * | 9 * |
| 10 * 1) If the interceptor is for an object whose type is known, it | 10 * 1) If the interceptor is for an object whose type is known, it |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 } | 293 } |
| 294 | 294 |
| 295 if (user is HIs) { | 295 if (user is HIs) { |
| 296 // See if we can rewrite the is-check to use 'instanceof', i.e. rewrite | 296 // See if we can rewrite the is-check to use 'instanceof', i.e. rewrite |
| 297 // "getInterceptor(x).$isT" to "x instanceof T". | 297 // "getInterceptor(x).$isT" to "x instanceof T". |
| 298 if (node == user.interceptor) { | 298 if (node == user.interceptor) { |
| 299 JavaScriptBackend backend = compiler.backend; | 299 JavaScriptBackend backend = compiler.backend; |
| 300 if (backend.mayGenerateInstanceofCheck(user.typeExpression)) { | 300 if (backend.mayGenerateInstanceofCheck(user.typeExpression)) { |
| 301 HInstruction instanceofCheck = new HIs.instanceOf( | 301 HInstruction instanceofCheck = new HIs.instanceOf( |
| 302 user.typeExpression, user.expression, user.instructionType); | 302 user.typeExpression, user.expression, user.instructionType); |
| 303 instanceofCheck.sourcePosition = user.sourcePosition; | 303 instanceofCheck.sourceInformation = user.sourceInformation; |
| 304 instanceofCheck.sourceElement = user.sourceElement; | 304 instanceofCheck.sourceElement = user.sourceElement; |
| 305 return replaceUserWith(instanceofCheck); | 305 return replaceUserWith(instanceofCheck); |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 } else if (user is HInvokeDynamic) { | 308 } else if (user is HInvokeDynamic) { |
| 309 if (node == user.inputs[0]) { | 309 if (node == user.inputs[0]) { |
| 310 // Replace the user with a [HOneShotInterceptor]. | 310 // Replace the user with a [HOneShotInterceptor]. |
| 311 HConstant nullConstant = graph.addConstantNull(compiler); | 311 HConstant nullConstant = graph.addConstantNull(compiler); |
| 312 List<HInstruction> inputs = new List<HInstruction>.from(user.inputs); | 312 List<HInstruction> inputs = new List<HInstruction>.from(user.inputs); |
| 313 inputs[0] = nullConstant; | 313 inputs[0] = nullConstant; |
| 314 HOneShotInterceptor oneShotInterceptor = new HOneShotInterceptor( | 314 HOneShotInterceptor oneShotInterceptor = new HOneShotInterceptor( |
| 315 user.selector, inputs, user.instructionType, interceptedClasses); | 315 user.selector, inputs, user.instructionType, interceptedClasses); |
| 316 oneShotInterceptor.sourcePosition = user.sourcePosition; | 316 oneShotInterceptor.sourceInformation = user.sourceInformation; |
| 317 oneShotInterceptor.sourceElement = user.sourceElement; | 317 oneShotInterceptor.sourceElement = user.sourceElement; |
| 318 return replaceUserWith(oneShotInterceptor); | 318 return replaceUserWith(oneShotInterceptor); |
| 319 } | 319 } |
| 320 } | 320 } |
| 321 | 321 |
| 322 return false; | 322 return false; |
| 323 } | 323 } |
| 324 | 324 |
| 325 bool rewriteToUseSelfAsInterceptor(HInterceptor node, HInstruction receiver) { | 325 bool rewriteToUseSelfAsInterceptor(HInterceptor node, HInstruction receiver) { |
| 326 for (HInstruction user in node.usedBy.toList()) { | 326 for (HInstruction user in node.usedBy.toList()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 instruction = new HInvokeDynamicMethod( | 364 instruction = new HInvokeDynamicMethod( |
| 365 selector, inputs, node.instructionType, true); | 365 selector, inputs, node.instructionType, true); |
| 366 } | 366 } |
| 367 | 367 |
| 368 HBasicBlock block = node.block; | 368 HBasicBlock block = node.block; |
| 369 block.addAfter(node, instruction); | 369 block.addAfter(node, instruction); |
| 370 block.rewrite(node, instruction); | 370 block.rewrite(node, instruction); |
| 371 return true; | 371 return true; |
| 372 } | 372 } |
| 373 } | 373 } |
| OLD | NEW |