| 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 3543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 // to the runtime type information for type variables as instructions. | 3554 // to the runtime type information for type variables as instructions. |
| 3555 if (type.isTypeVariable) { | 3555 if (type.isTypeVariable) { |
| 3556 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); | 3556 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); |
| 3557 } else { | 3557 } else { |
| 3558 assert(type.element.isClass); | 3558 assert(type.element.isClass); |
| 3559 InterfaceType interface = type; | 3559 InterfaceType interface = type; |
| 3560 List<HInstruction> inputs = <HInstruction>[]; | 3560 List<HInstruction> inputs = <HInstruction>[]; |
| 3561 bool first = true; | 3561 bool first = true; |
| 3562 List<js.Expression> templates = <js.Expression>[]; | 3562 List<js.Expression> templates = <js.Expression>[]; |
| 3563 for (DartType argument in interface.typeArguments) { | 3563 for (DartType argument in interface.typeArguments) { |
| 3564 templates.add(rti.getTypeRepresentationWithPlaceholders(argument, (varia
ble) { | 3564 // As we construct the template in stages, we have to make sure that for |
| 3565 HInstruction runtimeType = addTypeVariableReference(variable); | 3565 // each part the generated sub-template's holes match the index of the |
| 3566 inputs.add(runtimeType); | 3566 // inputs that are later used to instantiate it. We do this by starting |
| 3567 }, firstPlaceholderIndex : inputs.length)); | 3567 // the indexing with the number of inputs from previous sub-templates. |
| 3568 templates.add( |
| 3569 rti.getTypeRepresentationWithPlaceholders(argument, (variable) { |
| 3570 HInstruction runtimeType = addTypeVariableReference(variable); |
| 3571 inputs.add(runtimeType); |
| 3572 }, firstPlaceholderIndex: inputs.length)); |
| 3568 } | 3573 } |
| 3569 // TODO(sra): This is a fresh template each time. We can't let the | 3574 // TODO(sra): This is a fresh template each time. We can't let the |
| 3570 // template manager build them. | 3575 // template manager build them. |
| 3571 js.Template code = new js.Template(null, | 3576 js.Template code = new js.Template(null, |
| 3572 new js.ArrayInitializer(templates)); | 3577 new js.ArrayInitializer(templates)); |
| 3573 HInstruction representation = | 3578 HInstruction representation = |
| 3574 new HForeignCode(code, backend.readableArrayType, inputs, | 3579 new HForeignCode(code, backend.readableArrayType, inputs, |
| 3575 nativeBehavior: native.NativeBehavior.PURE_ALLOCATION); | 3580 nativeBehavior: native.NativeBehavior.PURE_ALLOCATION); |
| 3576 return representation; | 3581 return representation; |
| 3577 } | 3582 } |
| (...skipping 4086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7664 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7669 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 7665 unaliased.accept(this, builder); | 7670 unaliased.accept(this, builder); |
| 7666 } | 7671 } |
| 7667 | 7672 |
| 7668 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7673 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 7669 JavaScriptBackend backend = builder.compiler.backend; | 7674 JavaScriptBackend backend = builder.compiler.backend; |
| 7670 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 7675 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 7671 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 7676 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 7672 } | 7677 } |
| 7673 } | 7678 } |
| OLD | NEW |