Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 966763002: Fix order of box and types for constructor-body invocations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added tests. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/constructor12_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 FunctionSignature functionSignature = body.functionSignature; 2221 FunctionSignature functionSignature = body.functionSignature;
2222 // Provide the parameters to the generative constructor body. 2222 // Provide the parameters to the generative constructor body.
2223 functionSignature.orderedForEachParameter((ParameterElement parameter) { 2223 functionSignature.orderedForEachParameter((ParameterElement parameter) {
2224 // If [parameter] is boxed, it will be a field in the box passed as the 2224 // If [parameter] is boxed, it will be a field in the box passed as the
2225 // last parameter. So no need to directly pass it. 2225 // last parameter. So no need to directly pass it.
2226 if (!localsHandler.isBoxed(parameter)) { 2226 if (!localsHandler.isBoxed(parameter)) {
2227 bodyCallInputs.add(localsHandler.readLocal(parameter)); 2227 bodyCallInputs.add(localsHandler.readLocal(parameter));
2228 } 2228 }
2229 }); 2229 });
2230 2230
2231 // If there are locals that escape (ie mutated in closures), we
2232 // pass the box to the constructor.
2233 // The box must be passed before any type variable.
2234 ClosureScope scopeData = parameterClosureData.capturingScopes[node];
2235 if (scopeData != null) {
2236 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement));
2237 }
2238
2239 // Type variables arguments must come after the box (if there is one).
2231 ClassElement currentClass = constructor.enclosingClass; 2240 ClassElement currentClass = constructor.enclosingClass;
2232 if (backend.classNeedsRti(currentClass)) { 2241 if (backend.classNeedsRti(currentClass)) {
2233 // If [currentClass] needs RTI, we add the type variables as 2242 // If [currentClass] needs RTI, we add the type variables as
2234 // parameters of the generative constructor body. 2243 // parameters of the generative constructor body.
2235 currentClass.typeVariables.forEach((TypeVariableType argument) { 2244 currentClass.typeVariables.forEach((TypeVariableType argument) {
2236 // TODO(johnniwinther): Substitute [argument] with 2245 // TODO(johnniwinther): Substitute [argument] with
2237 // `localsHandler.substInContext(argument)`. 2246 // `localsHandler.substInContext(argument)`.
2238 bodyCallInputs.add(localsHandler.readLocal( 2247 bodyCallInputs.add(localsHandler.readLocal(
2239 localsHandler.getTypeVariableAsLocal(argument))); 2248 localsHandler.getTypeVariableAsLocal(argument)));
2240 }); 2249 });
2241 } 2250 }
2242 2251
2243 // If there are locals that escape (ie mutated in closures), we
2244 // pass the box to the constructor.
2245 ClosureScope scopeData = parameterClosureData.capturingScopes[node];
2246 if (scopeData != null) {
2247 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement));
2248 }
2249
2250 if (!isNativeUpgradeFactory && // TODO(13836): Fix inlining. 2252 if (!isNativeUpgradeFactory && // TODO(13836): Fix inlining.
2251 tryInlineMethod(body, null, bodyCallInputs, function)) { 2253 tryInlineMethod(body, null, bodyCallInputs, function)) {
2252 pop(); 2254 pop();
2253 } else { 2255 } else {
2254 HInvokeConstructorBody invoke = new HInvokeConstructorBody( 2256 HInvokeConstructorBody invoke = new HInvokeConstructorBody(
2255 body.declaration, bodyCallInputs, backend.nonNullType); 2257 body.declaration, bodyCallInputs, backend.nonNullType);
2256 invoke.sideEffects = 2258 invoke.sideEffects =
2257 compiler.world.getSideEffectsOfElement(constructor); 2259 compiler.world.getSideEffectsOfElement(constructor);
2258 add(invoke); 2260 add(invoke);
2259 } 2261 }
(...skipping 4662 matching lines...) Expand 10 before | Expand all | Expand 10 after
6922 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6924 if (unaliased is TypedefType) throw 'unable to unalias $type';
6923 unaliased.accept(this, builder); 6925 unaliased.accept(this, builder);
6924 } 6926 }
6925 6927
6926 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6928 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6927 JavaScriptBackend backend = builder.compiler.backend; 6929 JavaScriptBackend backend = builder.compiler.backend;
6928 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 6930 ClassElement cls = backend.findHelper('DynamicRuntimeType');
6929 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 6931 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
6930 } 6932 }
6931 } 6933 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/constructor12_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698