| 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 Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 Element getTraceFromException() { | 101 Element getTraceFromException() { |
| 102 return compiler.findHelper(const SourceString('getTraceFromException')); | 102 return compiler.findHelper(const SourceString('getTraceFromException')); |
| 103 } | 103 } |
| 104 | 104 |
| 105 Element getEqualsInterceptor() { | 105 Element getEqualsInterceptor() { |
| 106 return compiler.findHelper(const SourceString('eq')); | 106 return compiler.findHelper(const SourceString('eq')); |
| 107 } | 107 } |
| 108 | 108 |
| 109 Element getTripleEqualsInterceptor() { |
| 110 return compiler.findHelper(const SourceString('eqq')); |
| 111 } |
| 112 |
| 109 Element getMapMaker() { | 113 Element getMapMaker() { |
| 110 return compiler.findHelper(const SourceString('makeLiteralMap')); | 114 return compiler.findHelper(const SourceString('makeLiteralMap')); |
| 111 } | 115 } |
| 112 } | 116 } |
| 113 | 117 |
| 114 class SsaBuilderTask extends CompilerTask { | 118 class SsaBuilderTask extends CompilerTask { |
| 115 final Interceptors interceptors; | 119 final Interceptors interceptors; |
| 116 final Map<Node, ClosureData> closureDataCache; | 120 final Map<Node, ClosureData> closureDataCache; |
| 117 | 121 |
| 118 String get name() => 'SSA builder'; | 122 String get name() => 'SSA builder'; |
| (...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 inputs.add(target); | 2140 inputs.add(target); |
| 2137 if (element.kind == ElementKind.FUNCTION || | 2141 if (element.kind == ElementKind.FUNCTION || |
| 2138 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { | 2142 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 2139 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 2143 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 2140 element, inputs); | 2144 element, inputs); |
| 2141 if (!succeeded) { | 2145 if (!succeeded) { |
| 2142 // TODO(ngeoffray): Match the VM behavior and throw an | 2146 // TODO(ngeoffray): Match the VM behavior and throw an |
| 2143 // exception at runtime. | 2147 // exception at runtime. |
| 2144 compiler.cancel('Unimplemented non-matching static call', node: node); | 2148 compiler.cancel('Unimplemented non-matching static call', node: node); |
| 2145 } | 2149 } |
| 2146 push(new HInvokeStatic(selector, inputs)); | 2150 HType type = HType.UNKNOWN; |
| 2151 if (element.isGenerativeConstructor()) { |
| 2152 ClassElement cls = element.enclosingElement; |
| 2153 type = new HNonPrimitiveType(cls.type); |
| 2154 } else if (element.isFactoryConstructor() |
| 2155 && element === compiler.listClass) { |
| 2156 type = HType.MUTABLE_ARRAY; |
| 2157 } |
| 2158 push(new HInvokeStatic(selector, inputs, type)); |
| 2147 } else { | 2159 } else { |
| 2148 if (element.kind == ElementKind.GETTER) { | 2160 if (element.kind == ElementKind.GETTER) { |
| 2149 target = new HInvokeStatic(Selector.GETTER, inputs); | 2161 target = new HInvokeStatic(Selector.GETTER, inputs); |
| 2150 add(target); | 2162 add(target); |
| 2151 inputs = <HInstruction>[target]; | 2163 inputs = <HInstruction>[target]; |
| 2152 } | 2164 } |
| 2153 addDynamicSendArgumentsToList(node, inputs); | 2165 addDynamicSendArgumentsToList(node, inputs); |
| 2154 push(new HInvokeClosure(selector, inputs)); | 2166 push(new HInvokeClosure(selector, inputs)); |
| 2155 } | 2167 } |
| 2156 } | 2168 } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 link = link.tail) { | 2657 link = link.tail) { |
| 2646 visit(link.head); | 2658 visit(link.head); |
| 2647 inputs.addLast(pop()); | 2659 inputs.addLast(pop()); |
| 2648 inputs.addLast(pop()); | 2660 inputs.addLast(pop()); |
| 2649 } | 2661 } |
| 2650 HLiteralList keyValuePairs = new HLiteralList(inputs); | 2662 HLiteralList keyValuePairs = new HLiteralList(inputs); |
| 2651 HStatic mapMaker = new HStatic(interceptors.getMapMaker()); | 2663 HStatic mapMaker = new HStatic(interceptors.getMapMaker()); |
| 2652 add(keyValuePairs); | 2664 add(keyValuePairs); |
| 2653 add(mapMaker); | 2665 add(mapMaker); |
| 2654 inputs = <HInstruction>[mapMaker, keyValuePairs]; | 2666 inputs = <HInstruction>[mapMaker, keyValuePairs]; |
| 2655 push(new HInvokeStatic(Selector.INVOCATION_1, inputs)); | 2667 // TODO(ngeoffray): give the concrete type of our map literal. |
| 2668 push(new HInvokeStatic(Selector.INVOCATION_1, inputs, HType.UNKNOWN)); |
| 2656 } | 2669 } |
| 2657 | 2670 |
| 2658 visitLiteralMapEntry(LiteralMapEntry node) { | 2671 visitLiteralMapEntry(LiteralMapEntry node) { |
| 2659 visit(node.value); | 2672 visit(node.value); |
| 2660 visit(node.key); | 2673 visit(node.key); |
| 2661 } | 2674 } |
| 2662 | 2675 |
| 2663 visitNamedArgument(NamedArgument node) { | 2676 visitNamedArgument(NamedArgument node) { |
| 2664 visit(node.expression); | 2677 visit(node.expression); |
| 2665 } | 2678 } |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 false, | 3103 false, |
| 3091 <HInstruction>[target, input])); | 3104 <HInstruction>[target, input])); |
| 3092 return builder.pop(); | 3105 return builder.pop(); |
| 3093 } | 3106 } |
| 3094 | 3107 |
| 3095 HInstruction result() { | 3108 HInstruction result() { |
| 3096 flushLiterals(); | 3109 flushLiterals(); |
| 3097 return prefix; | 3110 return prefix; |
| 3098 } | 3111 } |
| 3099 } | 3112 } |
| OLD | NEW |