Chromium Code Reviews| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 if (transformToDynamicInvocation) { | 246 if (transformToDynamicInvocation) { |
| 247 return fromInterceptorToDynamicInvocation(node, node.selector); | 247 return fromInterceptorToDynamicInvocation(node, node.selector); |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 return node; | 251 return node; |
| 252 } | 252 } |
| 253 | 253 |
| 254 bool isFixedSizeListConstructor(HInvokeStatic node) { | 254 bool isFixedSizeListConstructor(HInvokeStatic node) { |
| 255 Element element = node.target.element; | 255 Element element = node.target.element; |
| 256 DartType defaultClass = compiler.listClass.defaultClass; | 256 DartType defaultClass = compiler.listClass.defaultClass; |
|
ngeoffray
2012/11/07 14:27:52
Please add a TODO that this should be cached.
floitsch
2012/11/07 16:42:48
Done.
| |
| 257 if (defaultClass == null) return false; | |
|
ngeoffray
2012/11/07 14:27:52
Also check if element is a constructor.
floitsch
2012/11/07 16:42:48
Done.
| |
| 258 Element fixedListLengthConstructor = compiler.listClass.lookupConstructor( | |
| 259 new Selector.callConstructor(const SourceString("fixedLength"), | |
| 260 compiler.listClass.getLibrary())); | |
| 257 // TODO(ngeoffray): make sure that the only reason the List class is | 261 // TODO(ngeoffray): make sure that the only reason the List class is |
| 258 // not resolved is because it's not being used. | 262 // not resolved is because it's not being used. |
| 259 return element.isConstructor() | 263 return element == fixedListLengthConstructor |
| 260 && defaultClass != null | 264 && element.enclosingElement.declaration == defaultClass.element; |
|
ngeoffray
2012/11/07 14:27:52
Do this check earlier.
floitsch
2012/11/07 16:42:48
Done.
| |
| 261 && element.enclosingElement.declaration == defaultClass.element | |
| 262 && node.inputs.length == 2 | |
| 263 && node.inputs[1].isInteger(types); | |
| 264 } | 265 } |
| 265 | 266 |
| 266 HInstruction visitInvokeStatic(HInvokeStatic node) { | 267 HInstruction visitInvokeStatic(HInvokeStatic node) { |
| 267 if (isFixedSizeListConstructor(node)) { | 268 if (isFixedSizeListConstructor(node)) { |
| 268 node.guaranteedType = HType.FIXED_ARRAY; | 269 node.guaranteedType = HType.FIXED_ARRAY; |
| 269 } | 270 } |
| 270 return node; | 271 return node; |
| 271 } | 272 } |
| 272 | 273 |
| 273 HInstruction visitInvokeDynamic(HInvokeDynamic node) { | 274 HInstruction visitInvokeDynamic(HInvokeDynamic node) { |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 } | 1351 } |
| 1351 | 1352 |
| 1352 // For other fields having setters in the generative constructor body, set | 1353 // For other fields having setters in the generative constructor body, set |
| 1353 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1354 // the type to UNKNOWN to avoid relying on the type set in the initializer |
| 1354 // list. | 1355 // list. |
| 1355 allSetters.forEach((Element element) { | 1356 allSetters.forEach((Element element) { |
| 1356 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1357 backend.registerFieldConstructor(element, HType.UNKNOWN); |
| 1357 }); | 1358 }); |
| 1358 } | 1359 } |
| 1359 } | 1360 } |
| OLD | NEW |