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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 | 9 |
| 10 String generateMethod(WorkItem work, HGraph graph) { | 10 String generateMethod(WorkItem work, HGraph graph) { |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1020 node.name.printOn(buffer); | 1020 node.name.printOn(buffer); |
| 1021 visitArguments(node.inputs); | 1021 visitArguments(node.inputs); |
| 1022 } else { | 1022 } else { |
| 1023 buffer.add(compiler.namer.instanceMethodInvocationName( | 1023 buffer.add(compiler.namer.instanceMethodInvocationName( |
| 1024 currentLibrary, node.name, node.selector)); | 1024 currentLibrary, node.name, node.selector)); |
| 1025 visitArguments(node.inputs); | 1025 visitArguments(node.inputs); |
| 1026 if (node.element !== null) { | 1026 if (node.element !== null) { |
| 1027 // If we know we're calling a specific method, register that | 1027 // If we know we're calling a specific method, register that |
| 1028 // method only. | 1028 // method only. |
| 1029 compiler.registerDynamicInvocationOf(node.element); | 1029 compiler.registerDynamicInvocationOf(node.element); |
| 1030 } else if (node.inputs[0] is HThis) { | |
| 1031 // TODO(ngeoffray): We should propagate an union type in | |
| 1032 // earlier phases instead of just checking if the receiver is 'this'. | |
| 1033 ClassElement cls = work.element.enclosingElement; | |
| 1034 Element method = cls.lookupMember(node.name); | |
|
floitsch
2012/04/23 13:58:30
Is this just to reduce the number of typed invocat
ngeoffray
2012/04/23 14:09:33
Yes.
floitsch
2012/04/23 15:01:51
Yes. I think that would be the more "correct" vers
ngeoffray
2012/04/23 15:22:47
Added a comment.
| |
| 1035 if (method !== null) { | |
| 1036 cls = method.enclosingElement; | |
| 1037 } | |
| 1038 Type type = cls.computeType(compiler); | |
| 1039 compiler.registerDynamicInvocation( | |
| 1040 node.name, new TypedInvocation(type, node.selector)); | |
| 1030 } else { | 1041 } else { |
| 1031 compiler.registerDynamicInvocation(node.name, node.selector); | 1042 compiler.registerDynamicInvocation(node.name, node.selector); |
| 1032 } | 1043 } |
| 1033 } | 1044 } |
| 1034 endExpression(JSPrecedence.CALL_PRECEDENCE); | 1045 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 1035 } | 1046 } |
| 1036 | 1047 |
| 1037 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 1048 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
| 1038 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 1049 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 1039 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1050 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1952 startBailoutSwitch(); | 1963 startBailoutSwitch(); |
| 1953 } | 1964 } |
| 1954 } | 1965 } |
| 1955 | 1966 |
| 1956 void endElse(HIf node) { | 1967 void endElse(HIf node) { |
| 1957 if (node.elseBlock.hasGuards()) { | 1968 if (node.elseBlock.hasGuards()) { |
| 1958 endBailoutSwitch(); | 1969 endBailoutSwitch(); |
| 1959 } | 1970 } |
| 1960 } | 1971 } |
| 1961 } | 1972 } |
| OLD | NEW |