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 4556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4567 DartType instance = type.asInstanceOf(supertype.element); | 4567 DartType instance = type.asInstanceOf(supertype.element); |
| 4568 compiler.types.checkTypeVariableBounds(instance, | 4568 compiler.types.checkTypeVariableBounds(instance, |
| 4569 addTypeVariableBoundCheck); | 4569 addTypeVariableBoundCheck); |
| 4570 if (definitelyFails) { | 4570 if (definitelyFails) { |
| 4571 return true; | 4571 return true; |
| 4572 } | 4572 } |
| 4573 } | 4573 } |
| 4574 return false; | 4574 return false; |
| 4575 } | 4575 } |
| 4576 | 4576 |
| 4577 visitAssertSend(node) { | 4577 @override |
| 4578 visitAssert(ast.Send node, ast.Node expression, _) { | |
| 4578 if (!compiler.enableUserAssertions) { | 4579 if (!compiler.enableUserAssertions) { |
| 4579 stack.add(graph.addConstantNull(compiler)); | 4580 stack.add(graph.addConstantNull(compiler)); |
| 4580 return; | 4581 return; |
| 4581 } | 4582 } |
| 4582 // TODO(johnniwinther): Don't handle assert like a regular static call. | 4583 assert(invariant(node, node.arguments.tail.isEmpty, |
| 4583 // It breaks the selector name check since the assert helper method cannot | 4584 message: "Invalid assertion: $node")); |
| 4584 // be called `assert` and therefore does not match the selector like a | 4585 buildStaticFunctionInvoke( |
| 4585 // regular method. | 4586 node, backend.assertMethod, CallStructure.ONE_ARG); |
| 4586 visitStaticSend(node); | |
| 4587 } | 4587 } |
| 4588 | 4588 |
| 4589 visitStaticSend(ast.Send node) { | 4589 visitStaticSend(ast.Send node) { |
| 4590 CallStructure callStructure = elements.getSelector(node).callStructure; | 4590 CallStructure callStructure = elements.getSelector(node).callStructure; |
| 4591 Element element = elements[node]; | 4591 Element element = elements[node]; |
| 4592 if (elements.isAssert(node)) { | 4592 if (elements.isAssert(node)) { |
| 4593 element = backend.assertMethod; | 4593 element = backend.assertMethod; |
| 4594 } | 4594 } |
| 4595 if (element.isForeign(backend) && element.isFunction) { | 4595 if (element.isForeign(backend) && element.isFunction) { |
| 4596 visitForeignSend(node); | 4596 visitForeignSend(node); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 4611 } | 4611 } |
| 4612 invariant(element, !element.isGenerativeConstructor); | 4612 invariant(element, !element.isGenerativeConstructor); |
| 4613 generateIsDeferredLoadedCheckIfNeeded(node); | 4613 generateIsDeferredLoadedCheckIfNeeded(node); |
| 4614 if (element.isFunction) { | 4614 if (element.isFunction) { |
| 4615 // TODO(5347): Try to avoid the need for calling [implementation] before | 4615 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 4616 // calling [makeStaticArgumentList]. | 4616 // calling [makeStaticArgumentList]. |
| 4617 if (!callStructure.signatureApplies(element.implementation)) { | 4617 if (!callStructure.signatureApplies(element.implementation)) { |
| 4618 generateWrongArgumentCountError(node, element, node.arguments); | 4618 generateWrongArgumentCountError(node, element, node.arguments); |
| 4619 return; | 4619 return; |
| 4620 } | 4620 } |
| 4621 | 4621 buildStaticFunctionInvoke(node, element, callStructure); |
| 4622 List<HInstruction> inputs = | |
| 4623 makeStaticArgumentList(callStructure, | |
| 4624 node.arguments, | |
| 4625 element.implementation); | |
| 4626 | |
| 4627 if (element == compiler.identicalFunction) { | |
| 4628 pushWithPosition( | |
| 4629 new HIdentity(inputs[0], inputs[1], null, backend.boolType), node); | |
| 4630 return; | |
| 4631 } | |
| 4632 | |
| 4633 pushInvokeStatic(node, element, inputs); | |
| 4634 } else { | 4622 } else { |
| 4635 generateGetter(node, element); | 4623 generateGetter(node, element); |
| 4636 List<HInstruction> inputs = <HInstruction>[pop()]; | 4624 List<HInstruction> inputs = <HInstruction>[pop()]; |
| 4637 addDynamicSendArgumentsToList(node, inputs); | 4625 addDynamicSendArgumentsToList(node, inputs); |
| 4638 Selector closureSelector = callStructure.callSelector; | 4626 Selector closureSelector = callStructure.callSelector; |
| 4639 pushWithPosition( | 4627 pushWithPosition( |
| 4640 new HInvokeClosure(closureSelector, inputs, backend.dynamicType), | 4628 new HInvokeClosure(closureSelector, inputs, backend.dynamicType), |
| 4641 node); | 4629 node); |
| 4642 } | 4630 } |
| 4643 } | 4631 } |
| 4644 | 4632 |
| 4633 void buildStaticFunctionInvoke( | |
| 4634 ast.Send node, | |
| 4635 FunctionElement element, | |
| 4636 CallStructure callStructure) { | |
| 4637 List<HInstruction> inputs = makeStaticArgumentList( | |
| 4638 callStructure, | |
| 4639 node.arguments, | |
| 4640 element.implementation); | |
| 4641 | |
| 4642 if (element == compiler.identicalFunction) { | |
| 4643 pushWithPosition( | |
| 4644 new HIdentity(inputs[0], inputs[1], null, backend.boolType), node); | |
| 4645 return; | |
| 4646 } | |
|
karlklose
2015/04/15 07:18:03
if (element == compiler.identicalFunction) {
Johnni Winther
2015/04/15 10:37:10
Done.
| |
| 4647 | |
| 4648 pushInvokeStatic(node, element, inputs); | |
| 4649 } | |
| 4650 | |
| 4645 HConstant addConstantString(String string) { | 4651 HConstant addConstantString(String string) { |
| 4646 ast.DartString dartString = new ast.DartString.literal(string); | 4652 ast.DartString dartString = new ast.DartString.literal(string); |
| 4647 ConstantValue constant = constantSystem.createString(dartString); | 4653 ConstantValue constant = constantSystem.createString(dartString); |
| 4648 return graph.addConstant(constant, compiler); | 4654 return graph.addConstant(constant, compiler); |
| 4649 } | 4655 } |
| 4650 | 4656 |
| 4651 visitTypePrefixSend(ast.Send node) { | |
| 4652 compiler.internalError(node, "visitTypePrefixSend should not be called."); | |
| 4653 } | |
| 4654 | |
| 4655 visitTypeLiteralSend(ast.Send node) { | 4657 visitTypeLiteralSend(ast.Send node) { |
| 4656 DartType type = elements.getTypeLiteralType(node); | 4658 DartType type = elements.getTypeLiteralType(node); |
| 4657 if (type.isInterfaceType || type.isTypedef || type.isDynamic) { | 4659 if (type.isInterfaceType || type.isTypedef || type.isDynamic) { |
| 4658 // TODO(karlklose): add type representation | 4660 // TODO(karlklose): add type representation |
| 4659 if (node.isCall) { | 4661 if (node.isCall) { |
| 4660 // The node itself is not a constant but we register the selector (the | 4662 // The node itself is not a constant but we register the selector (the |
| 4661 // identifier that refers to the class/typedef) as a constant. | 4663 // identifier that refers to the class/typedef) as a constant. |
| 4662 stack.add(addConstant(node.selector)); | 4664 stack.add(addConstant(node.selector)); |
| 4663 } else { | 4665 } else { |
| 4664 stack.add(addConstant(node)); | 4666 stack.add(addConstant(node)); |
| (...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7001 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7003 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 7002 unaliased.accept(this, builder); | 7004 unaliased.accept(this, builder); |
| 7003 } | 7005 } |
| 7004 | 7006 |
| 7005 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7007 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 7006 JavaScriptBackend backend = builder.compiler.backend; | 7008 JavaScriptBackend backend = builder.compiler.backend; |
| 7007 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 7009 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
| 7008 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 7010 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
| 7009 } | 7011 } |
| 7010 } | 7012 } |
| OLD | NEW |