[dart2js] Pass box to inlined generative constructor body

There was a rare mismatch between arguments and parameters when
inlining a constructor body.

The full arguments at the call site of a constructor body (always in a
generative constructor factory) and the parameters at inlining would
not agree on needing a 'box' for the constructor's closed-over mutated
variables (parameters and locals) when the box was needed only for
locals closed over in an assertion.

The fix is to make the condition for accepting a box match the test
for generating the box in the caller.

Bug: 45943
Change-Id: I3b056cb710ffac72bec6943809e04472a838e5bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198741
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams 2021-05-07 22:50:27 +00:00 committed by commit-bot@chromium.org
parent b7d2dbe9b5
commit 90127334ea
3 changed files with 3 additions and 5 deletions

View file

@ -6130,7 +6130,6 @@ class KernelSsaGraphBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
}
ir.Member memberContextNode = _elementMap.getMemberContextNode(function);
bool hasBox = false;
KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(function);
forEachOrderedParameter(_elementMap, function,
(ir.VariableDeclaration variable, {bool isElided}) {
@ -6144,14 +6143,13 @@ class KernelSsaGraphBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
scopeData.isBoxedVariable(_localsMap, local)) {
// The parameter will be a field in the box passed as the last
// parameter. So no need to have it.
hasBox = true;
return;
}
HInstruction argument = compiledArguments[argumentIndex++];
localsHandler.updateLocal(local, argument);
});
if (hasBox) {
if (forGenerativeConstructorBody && scopeData.requiresContextBox) {
HInstruction box = compiledArguments[argumentIndex++];
assert(box is HCreateBox);
// TODO(sra): Make inlining of closures work. We should always call

View file

@ -12,7 +12,7 @@ class _InspectorOverlayLayer {
return true;
}());
if (inDebugMode == false) {
throw Error();
print('Error');
}
}
}

View file

@ -12,7 +12,7 @@ class _InspectorOverlayLayer {
return true;
}());
if (inDebugMode == false) {
throw Error();
print('Error');
}
}
}