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 /** | 7 /** |
| 8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 compiler.tracer.traceCompilation(name, work.compilationContext); | 98 compiler.tracer.traceCompilation(name, work.compilationContext); |
| 99 compiler.tracer.traceGraph('builder', graph); | 99 compiler.tracer.traceGraph('builder', graph); |
| 100 } | 100 } |
| 101 return graph; | 101 return graph; |
| 102 }); | 102 }); |
| 103 } | 103 } |
| 104 | 104 |
| 105 HGraph compileConstructor(SsaBuilder builder, CodegenWorkItem work) { | 105 HGraph compileConstructor(SsaBuilder builder, CodegenWorkItem work) { |
| 106 // The body of the constructor will be generated in a separate function. | 106 // The body of the constructor will be generated in a separate function. |
| 107 final ClassElement classElement = work.element.getEnclosingClass(); | 107 final ClassElement classElement = work.element.getEnclosingClass(); |
| 108 FunctionElement constructor = work.element.implementation; | |
| 108 return builder.buildFactory(classElement.implementation, | 109 return builder.buildFactory(classElement.implementation, |
| 109 work.element.implementation); | 110 constructor); |
|
ahe
2013/04/15 13:36:46
Why this change?
karlklose
2013/04/25 11:25:53
Reverted.
| |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 | 113 |
| 113 | 114 |
| 114 /** | 115 /** |
| 115 * Keeps track of locals (including parameters and phis) when building. The | 116 * Keeps track of locals (including parameters and phis) when building. The |
| 116 * 'this' reference is treated as parameter and hence handled by this class, | 117 * 'this' reference is treated as parameter and hence handled by this class, |
| 117 * too. | 118 * too. |
| 118 */ | 119 */ |
| 119 class LocalsHandler { | 120 class LocalsHandler { |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 // Don't forget to update the field, if the parameter is of the | 1249 // Don't forget to update the field, if the parameter is of the |
| 1249 // form [:this.x:]. | 1250 // form [:this.x:]. |
| 1250 if (parameter.kind == ElementKind.FIELD_PARAMETER) { | 1251 if (parameter.kind == ElementKind.FIELD_PARAMETER) { |
| 1251 FieldParameterElement fieldParameterElement = parameter; | 1252 FieldParameterElement fieldParameterElement = parameter; |
| 1252 fieldValues[fieldParameterElement.fieldElement] = argument; | 1253 fieldValues[fieldParameterElement.fieldElement] = argument; |
| 1253 } | 1254 } |
| 1254 }); | 1255 }); |
| 1255 | 1256 |
| 1256 // Build the initializers in the context of the new constructor. | 1257 // Build the initializers in the context of the new constructor. |
| 1257 TreeElements oldElements = elements; | 1258 TreeElements oldElements = elements; |
| 1259 if (constructor is ForwardingConstructorElement) { | |
|
ahe
2013/04/15 13:36:46
Is there a method you can call?
| |
| 1260 constructor = constructor.superConstructor; | |
| 1261 } | |
| 1258 elements = | 1262 elements = |
| 1259 compiler.enqueuer.resolution.getCachedElements(constructor); | 1263 compiler.enqueuer.resolution.getCachedElements(constructor); |
| 1260 | |
| 1261 ClosureClassMap oldClosureData = localsHandler.closureData; | 1264 ClosureClassMap oldClosureData = localsHandler.closureData; |
| 1262 Node node = constructor.parseNode(compiler); | 1265 Node node = constructor.parseNode(compiler); |
| 1263 ClosureClassMap newClosureData = | 1266 ClosureClassMap newClosureData = |
| 1264 compiler.closureToClassMapper.computeClosureToClassMapping( | 1267 compiler.closureToClassMapper.computeClosureToClassMapping( |
| 1265 constructor, node, elements); | 1268 constructor, node, elements); |
| 1266 // The [:this:] element now refers to the one in the new closure | 1269 // The [:this:] element now refers to the one in the new closure |
| 1267 // data, that is the [:this:] of the super constructor. We | 1270 // data, that is the [:this:] of the super constructor. We |
| 1268 // update the element to refer to the current [:this:]. | 1271 // update the element to refer to the current [:this:]. |
| 1269 localsHandler.updateLocal(newClosureData.thisElement, | 1272 localsHandler.updateLocal(newClosureData.thisElement, |
| 1270 localsHandler.readThis()); | 1273 localsHandler.readThis()); |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2834 List<HInstruction> list) { | 2837 List<HInstruction> list) { |
| 2835 assert(invariant(element, element.isImplementation)); | 2838 assert(invariant(element, element.isImplementation)); |
| 2836 | 2839 |
| 2837 HInstruction compileArgument(Node argument) { | 2840 HInstruction compileArgument(Node argument) { |
| 2838 visit(argument); | 2841 visit(argument); |
| 2839 return pop(); | 2842 return pop(); |
| 2840 } | 2843 } |
| 2841 | 2844 |
| 2842 HInstruction handleConstant(Element parameter) { | 2845 HInstruction handleConstant(Element parameter) { |
| 2843 Constant constant; | 2846 Constant constant; |
| 2847 if (element is ForwardingConstructorElement) { | |
|
ahe
2013/04/15 13:36:46
Is there a method you can call?
| |
| 2848 element = element.superConstructor; | |
| 2849 } | |
| 2844 TreeElements calleeElements = | 2850 TreeElements calleeElements = |
| 2845 compiler.enqueuer.resolution.getCachedElements(element); | 2851 compiler.enqueuer.resolution.getCachedElements(element); |
| 2846 if (calleeElements.isParameterChecked(parameter)) { | 2852 if (calleeElements.isParameterChecked(parameter)) { |
| 2847 constant = SentinelConstant.SENTINEL; | 2853 constant = SentinelConstant.SENTINEL; |
| 2848 } else { | 2854 } else { |
| 2849 constant = compileConstant(parameter); | 2855 constant = compileConstant(parameter); |
| 2850 } | 2856 } |
| 2851 return graph.addConstant(constant); | 2857 return graph.addConstant(constant); |
| 2852 } | 2858 } |
| 2853 | 2859 |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3361 } else if (element.isGenerativeConstructor()) { | 3367 } else if (element.isGenerativeConstructor()) { |
| 3362 ClassElement cls = element.getEnclosingClass(); | 3368 ClassElement cls = element.getEnclosingClass(); |
| 3363 return new HType.nonNullExact(cls.thisType, compiler); | 3369 return new HType.nonNullExact(cls.thisType, compiler); |
| 3364 } else { | 3370 } else { |
| 3365 return HType.UNKNOWN; | 3371 return HType.UNKNOWN; |
| 3366 } | 3372 } |
| 3367 } | 3373 } |
| 3368 | 3374 |
| 3369 Element constructor = elements[node]; | 3375 Element constructor = elements[node]; |
| 3370 Selector selector = elements.getSelector(node); | 3376 Selector selector = elements.getSelector(node); |
| 3377 if (constructor is ForwardingConstructorElement) { | |
|
ahe
2013/04/15 13:36:46
Is there a method you can call?
| |
| 3378 compiler.unimplemented('forwarded constructor in named mixin application', | |
| 3379 element: constructor.superConstructor); | |
|
ahe
2013/04/15 13:36:46
I don't think this position is helpful. It doesn'
karlklose
2013/04/25 11:25:53
Changed to the enclosing class.
| |
| 3380 } | |
| 3371 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { | 3381 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { |
| 3372 compiler.internalError("Unresolved element: $constructor", node: node); | 3382 compiler.internalError("Unresolved element: $constructor", node: node); |
| 3373 } | 3383 } |
| 3374 FunctionElement functionElement = constructor; | 3384 FunctionElement functionElement = constructor; |
| 3375 constructor = functionElement.redirectionTarget; | 3385 constructor = functionElement.redirectionTarget; |
| 3376 // TODO(5346): Try to avoid the need for calling [declaration] before | 3386 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 3377 // creating an [HStatic]. | 3387 // creating an [HStatic]. |
| 3378 HInstruction target = new HStatic(constructor.declaration); | 3388 HInstruction target = new HStatic(constructor.declaration); |
| 3379 add(target); | 3389 add(target); |
| 3380 var inputs = <HInstruction>[]; | 3390 var inputs = <HInstruction>[]; |
| (...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5231 new HSubGraphBlockInformation(elseBranch.graph)); | 5241 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5232 | 5242 |
| 5233 HBasicBlock conditionStartBlock = conditionBranch.block; | 5243 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5234 conditionStartBlock.setBlockFlow(info, joinBlock); | 5244 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5235 SubGraph conditionGraph = conditionBranch.graph; | 5245 SubGraph conditionGraph = conditionBranch.graph; |
| 5236 HIf branch = conditionGraph.end.last; | 5246 HIf branch = conditionGraph.end.last; |
| 5237 assert(branch is HIf); | 5247 assert(branch is HIf); |
| 5238 branch.blockInformation = conditionStartBlock.blockFlow; | 5248 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5239 } | 5249 } |
| 5240 } | 5250 } |
| OLD | NEW |