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 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 3538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3549 HInstruction buildTypeArgumentRepresentations(DartType type) { | 3549 HInstruction buildTypeArgumentRepresentations(DartType type) { |
| 3550 // Compute the representation of the type arguments, including access | 3550 // Compute the representation of the type arguments, including access |
| 3551 // to the runtime type information for type variables as instructions. | 3551 // to the runtime type information for type variables as instructions. |
| 3552 if (type.isTypeVariable) { | 3552 if (type.isTypeVariable) { |
| 3553 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); | 3553 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); |
| 3554 } else { | 3554 } else { |
| 3555 assert(type.element.isClass); | 3555 assert(type.element.isClass); |
| 3556 InterfaceType interface = type; | 3556 InterfaceType interface = type; |
| 3557 List<HInstruction> inputs = <HInstruction>[]; | 3557 List<HInstruction> inputs = <HInstruction>[]; |
| 3558 bool first = true; | 3558 bool first = true; |
| 3559 List<String> templates = <String>[]; | 3559 List<js.Expression> templates = <js.Expression>[]; |
| 3560 for (DartType argument in interface.typeArguments) { | 3560 for (DartType argument in interface.typeArguments) { |
| 3561 templates.add(rti.getTypeRepresentationWithHashes(argument, (variable) { | 3561 templates.add(rti.getTypeRepresentationWithHashes(argument, (variable) { |
| 3562 HInstruction runtimeType = addTypeVariableReference(variable); | 3562 HInstruction runtimeType = addTypeVariableReference(variable); |
| 3563 inputs.add(runtimeType); | 3563 inputs.add(runtimeType); |
| 3564 })); | 3564 })); |
| 3565 } | 3565 } |
| 3566 String template = '[${templates.join(', ')}]'; | |
| 3567 // TODO(sra): This is a fresh template each time. We can't let the | 3566 // TODO(sra): This is a fresh template each time. We can't let the |
| 3568 // template manager build them. | 3567 // template manager build them. |
| 3569 js.Template code = js.js.uncachedExpressionTemplate(template); | 3568 js.Template code = new js.Template.withExpressionResult( |
| 3569 new js.ArrayInitializer(templates), hasPlaceholders : true); | |
| 3570 HInstruction representation = | 3570 HInstruction representation = |
| 3571 new HForeignCode(code, backend.readableArrayType, inputs, | 3571 new HForeignCode(code, backend.readableArrayType, inputs, |
| 3572 nativeBehavior: native.NativeBehavior.PURE_ALLOCATION); | 3572 nativeBehavior: native.NativeBehavior.PURE_ALLOCATION); |
| 3573 return representation; | 3573 return representation; |
| 3574 } | 3574 } |
| 3575 } | 3575 } |
| 3576 | 3576 |
| 3577 @override | 3577 @override |
| 3578 void visitAs(ast.Send node, ast.Node expression, DartType type, _) { | 3578 void visitAs(ast.Send node, ast.Node expression, DartType type, _) { |
| 3579 HInstruction expressionInstruction = visitAndPop(expression); | 3579 HInstruction expressionInstruction = visitAndPop(expression); |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4616 // Represent [dynamic] as [null]. | 4616 // Represent [dynamic] as [null]. |
| 4617 return graph.addConstantNull(compiler); | 4617 return graph.addConstantNull(compiler); |
| 4618 } | 4618 } |
| 4619 | 4619 |
| 4620 if (argument.isTypeVariable) { | 4620 if (argument.isTypeVariable) { |
| 4621 return addTypeVariableReference(argument); | 4621 return addTypeVariableReference(argument); |
| 4622 } | 4622 } |
| 4623 | 4623 |
| 4624 List<HInstruction> inputs = <HInstruction>[]; | 4624 List<HInstruction> inputs = <HInstruction>[]; |
| 4625 | 4625 |
| 4626 String template = rti.getTypeRepresentationWithHashes(argument, (variable) { | 4626 js.Expression template = |
| 4627 inputs.add(addTypeVariableReference(variable)); | 4627 rti.getTypeRepresentationWithHashes(argument, |
|
floitsch
2015/05/19 13:43:35
looks like it fits on one line.
herhut
2015/05/19 14:08:09
Done.
| |
| 4628 }); | 4628 (variable) { |
| 4629 inputs.add(addTypeVariableReference(variable)); | |
| 4630 }); | |
| 4629 | 4631 |
| 4630 js.Template code = js.js.uncachedExpressionTemplate(template); | 4632 js.Template code = |
| 4633 new js.Template.withExpressionResult(template, hasPlaceholders : true); | |
| 4631 HInstruction result = new HForeignCode(code, backend.stringType, inputs, | 4634 HInstruction result = new HForeignCode(code, backend.stringType, inputs, |
| 4632 nativeBehavior: native.NativeBehavior.PURE); | 4635 nativeBehavior: native.NativeBehavior.PURE); |
| 4633 add(result); | 4636 add(result); |
| 4634 return result; | 4637 return result; |
| 4635 } | 4638 } |
| 4636 | 4639 |
| 4637 HInstruction handleListConstructor(InterfaceType type, | 4640 HInstruction handleListConstructor(InterfaceType type, |
| 4638 ast.Node currentNode, | 4641 ast.Node currentNode, |
| 4639 HInstruction newObject) { | 4642 HInstruction newObject) { |
| 4640 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { | 4643 if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { |
| (...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7668 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7671 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 7669 unaliased.accept(this, builder); | 7672 unaliased.accept(this, builder); |
| 7670 } | 7673 } |
| 7671 | 7674 |
| 7672 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7675 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 7673 JavaScriptBackend backend = builder.compiler.backend; | 7676 JavaScriptBackend backend = builder.compiler.backend; |
| 7674 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 7677 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 7675 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 7678 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 7676 } | 7679 } |
| 7677 } | 7680 } |
| OLD | NEW |