| 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 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
| 8 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
| 9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
| 10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
| (...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 // Call the JavaScript constructor with the fields as argument. | 2020 // Call the JavaScript constructor with the fields as argument. |
| 2021 List<HInstruction> constructorArguments = <HInstruction>[]; | 2021 List<HInstruction> constructorArguments = <HInstruction>[]; |
| 2022 List<Element> fields = <Element>[]; | 2022 List<Element> fields = <Element>[]; |
| 2023 | 2023 |
| 2024 classElement.forEachInstanceField( | 2024 classElement.forEachInstanceField( |
| 2025 (ClassElement enclosingClass, VariableElement member) { | 2025 (ClassElement enclosingClass, VariableElement member) { |
| 2026 HInstruction value = fieldValues[member]; | 2026 HInstruction value = fieldValues[member]; |
| 2027 if (value == null) { | 2027 if (value == null) { |
| 2028 // Uninitialized native fields are pre-initialized by the native | 2028 // Uninitialized native fields are pre-initialized by the native |
| 2029 // implementation. | 2029 // implementation. |
| 2030 assert(isNativeUpgradeFactory); | 2030 assert(invariant( |
| 2031 member, isNativeUpgradeFactory || compiler.compilationFailed)); |
| 2031 } else { | 2032 } else { |
| 2032 fields.add(member); | 2033 fields.add(member); |
| 2033 DartType type = localsHandler.substInContext(member.type); | 2034 DartType type = localsHandler.substInContext(member.type); |
| 2034 constructorArguments.add(potentiallyCheckOrTrustType(value, type)); | 2035 constructorArguments.add(potentiallyCheckOrTrustType(value, type)); |
| 2035 } | 2036 } |
| 2036 }, | 2037 }, |
| 2037 includeSuperAndInjectedMembers: true); | 2038 includeSuperAndInjectedMembers: true); |
| 2038 | 2039 |
| 2039 InterfaceType type = classElement.thisType; | 2040 InterfaceType type = classElement.thisType; |
| 2040 TypeMask ssaType = | 2041 TypeMask ssaType = |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 if (element.isSetter) { | 3267 if (element.isSetter) { |
| 3267 pushInvokeStatic(location, element, <HInstruction>[value]); | 3268 pushInvokeStatic(location, element, <HInstruction>[value]); |
| 3268 pop(); | 3269 pop(); |
| 3269 } else { | 3270 } else { |
| 3270 VariableElement field = element; | 3271 VariableElement field = element; |
| 3271 value = potentiallyCheckOrTrustType(value, field.type); | 3272 value = potentiallyCheckOrTrustType(value, field.type); |
| 3272 addWithPosition(new HStaticStore(element, value), location); | 3273 addWithPosition(new HStaticStore(element, value), location); |
| 3273 } | 3274 } |
| 3274 stack.add(value); | 3275 stack.add(value); |
| 3275 } else if (Elements.isErroneousElement(element)) { | 3276 } else if (Elements.isErroneousElement(element)) { |
| 3276 List<HInstruction> arguments = | 3277 if (element is ErroneousElement) { |
| 3277 send == null ? const <HInstruction>[] : <HInstruction>[value]; | 3278 List<HInstruction> arguments = |
| 3278 // An erroneous element indicates an unresolved static setter. | 3279 send == null ? const <HInstruction>[] : <HInstruction>[value]; |
| 3279 generateThrowNoSuchMethod(location, | 3280 // An erroneous element indicates an unresolved static setter. |
| 3280 noSuchMethodTargetSymbolString(element, 'set'), | 3281 generateThrowNoSuchMethod( |
| 3281 argumentValues: arguments); | 3282 location, noSuchMethodTargetSymbolString(element, 'set'), |
| 3283 argumentValues: arguments); |
| 3284 } else { |
| 3285 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
| 3286 stack.add(graph.addConstantNull(compiler)); |
| 3287 } |
| 3282 } else { | 3288 } else { |
| 3283 stack.add(value); | 3289 stack.add(value); |
| 3284 LocalElement local = element; | 3290 LocalElement local = element; |
| 3285 // If the value does not already have a name, give it here. | 3291 // If the value does not already have a name, give it here. |
| 3286 if (value.sourceElement == null) { | 3292 if (value.sourceElement == null) { |
| 3287 value.sourceElement = local; | 3293 value.sourceElement = local; |
| 3288 } | 3294 } |
| 3289 HInstruction checkedOrTrusted = | 3295 HInstruction checkedOrTrusted = |
| 3290 potentiallyCheckOrTrustType(value, local.type); | 3296 potentiallyCheckOrTrustType(value, local.type); |
| 3291 if (!identical(checkedOrTrusted, value)) { | 3297 if (!identical(checkedOrTrusted, value)) { |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4482 Selector selector = elements.getSelector(node); | 4488 Selector selector = elements.getSelector(node); |
| 4483 Element element = elements[node]; | 4489 Element element = elements[node]; |
| 4484 if (elements.isAssert(node)) { | 4490 if (elements.isAssert(node)) { |
| 4485 element = backend.assertMethod; | 4491 element = backend.assertMethod; |
| 4486 } | 4492 } |
| 4487 if (element.isForeign(backend) && element.isFunction) { | 4493 if (element.isForeign(backend) && element.isFunction) { |
| 4488 visitForeignSend(node); | 4494 visitForeignSend(node); |
| 4489 return; | 4495 return; |
| 4490 } | 4496 } |
| 4491 if (element.isErroneous) { | 4497 if (element.isErroneous) { |
| 4492 // An erroneous element indicates that the funciton could not be resolved | 4498 if (element is ErroneousElement) { |
| 4493 // (a warning has been issued). | 4499 // An erroneous element indicates that the funciton could not be |
| 4494 generateThrowNoSuchMethod(node, | 4500 // resolved (a warning has been issued). |
| 4495 noSuchMethodTargetSymbolString(element), | 4501 generateThrowNoSuchMethod(node, |
| 4496 argumentNodes: node.arguments); | 4502 noSuchMethodTargetSymbolString(element), |
| 4503 argumentNodes: node.arguments); |
| 4504 } else { |
| 4505 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
| 4506 stack.add(graph.addConstantNull(compiler)); |
| 4507 } |
| 4497 return; | 4508 return; |
| 4498 } | 4509 } |
| 4499 invariant(element, !element.isGenerativeConstructor); | 4510 invariant(element, !element.isGenerativeConstructor); |
| 4500 generateIsDeferredLoadedCheckIfNeeded(node); | 4511 generateIsDeferredLoadedCheckIfNeeded(node); |
| 4501 if (element.isFunction) { | 4512 if (element.isFunction) { |
| 4502 // TODO(5347): Try to avoid the need for calling [implementation] before | 4513 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 4503 // calling [makeStaticArgumentList]. | 4514 // calling [makeStaticArgumentList]. |
| 4504 if (!selector.applies(element.implementation, compiler.world)) { | 4515 if (!selector.applies(element.implementation, compiler.world)) { |
| 4505 generateWrongArgumentCountError(node, element, node.arguments); | 4516 generateWrongArgumentCountError(node, element, node.arguments); |
| 4506 return; | 4517 return; |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6659 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 6670 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 6660 unaliased.accept(this, builder); | 6671 unaliased.accept(this, builder); |
| 6661 } | 6672 } |
| 6662 | 6673 |
| 6663 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 6674 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 6664 JavaScriptBackend backend = builder.compiler.backend; | 6675 JavaScriptBackend backend = builder.compiler.backend; |
| 6665 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 6676 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 6666 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 6677 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 6667 } | 6678 } |
| 6668 } | 6679 } |
| OLD | NEW |