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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2651503007: dart2js-kernel: Pass non-type arguments to constructor body (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index e6d769fbdd1da5f8f32aad983e662e8537e6df65..2699e131c5e5276e9f86d6ede5cd0da9c7cb6476 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -306,7 +306,33 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
List<HInstruction> bodyCallInputs = <HInstruction>[];
bodyCallInputs.add(newObject);
- // TODO(sra): Pass arguments, boxes and type parameters.
+ // Pass uncaptured arguments first, captured arguments in a box, then type
+ // arguments.
+
+ ConstructorElement constructorElement = astAdapter.getElement(body);
+ ClosureClassMap parameterClosureData = compiler.closureToClassMapper
+ .getClosureToClassMapping(constructorElement.resolvedAst);
+
+ var functionSignature = astAdapter.getFunctionSignature(body.function);
+ // Provide the parameters to the generative constructor body.
+ functionSignature.orderedForEachParameter((ParameterElement parameter) {
+ // If [parameter] is boxed, it will be a field in the box passed as the
+ // last parameter. So no need to directly pass it.
+ if (!localsHandler.isBoxed(parameter)) {
+ bodyCallInputs.add(localsHandler.readLocal(parameter));
+ }
+ });
+
+ // If there are locals that escape (i.e. mutated in closures), we pass the
+ // box to the constructor.
+ ClosureScope scopeData = parameterClosureData
+ .capturingScopes[constructorElement.resolvedAst.node];
+ if (scopeData != null) {
+ bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement));
+ }
+
+ // TODO(sra): Pass type arguments.
+
_invokeConstructorBody(body, bodyCallInputs);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698