Revert "[dart2js] Throw in BlockExpression should not generate exit edge"
This reverts commit 6bdf3c042a473f6df5da7b05a1beb5e5eb249996.
Reason for revert: b/276976255
Original change's description:
> [dart2js] Throw in BlockExpression should not generate exit edge
>
> dart2js's CFG builder can't handle exit edges from expressions, so
> don't generate one for a throw nested in a BlockExpression.
>
> Bug: #51847
> Change-Id: I8afeb2785fc62c32ea07500ecb7a0b61fd4756b5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293162
> Commit-Queue: Stephen Adams <sra@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
Bug: #51847
Change-Id: I94172897dd272f9d8896faa06de9ed5f0d3a1b97
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293641
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 2158ade..da8e9b1 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -268,9 +268,6 @@
/// [isAborted].
bool _isReachable = true;
- /// Is the current statement or expression nested in a [ir.BlockExpression]?
- bool _inBlockExpression = false;
-
HLocalValue? lastAddedParameter;
Map<Local, HInstruction> parameters = {};
@@ -1905,13 +1902,7 @@
void visitExpressionStatement(ir.ExpressionStatement node) {
if (!_isReachable) return;
ir.Expression expression = node.expression;
-
- // Handle a `throw` expression in statement-position, with control flow to
- // the exit. (In expression position the throw does not create control-flow
- // out of CFG region for the expression).
- if (expression is ir.Throw &&
- _inliningStack.isEmpty &&
- !_inBlockExpression) {
+ if (expression is ir.Throw && _inliningStack.isEmpty) {
_visitThrowExpression(expression.expression);
_handleInTryStatement();
final sourceInformation =
@@ -1975,9 +1966,7 @@
return;
}
}
- if (_isReachable) {
- _emitReturn(value, sourceInformation);
- }
+ _emitReturn(value, sourceInformation);
}
@override
@@ -3868,11 +3857,7 @@
HInstruction initializedValue = pop();
// TODO(sra): Apply inferred type information.
_letBindings[variable] = initializedValue;
- if (!_isReachable) {
- stack.add(graph.addConstantUnreachable(closedWorld));
- } else {
- node.body.accept(this);
- }
+ node.body.accept(this);
}
@override
@@ -3883,13 +3868,7 @@
if (!_isReachable) {
stack.add(graph.addConstantUnreachable(closedWorld));
} else {
- final previous = _inBlockExpression;
- try {
- _inBlockExpression = true;
- node.value.accept(this);
- } finally {
- _inBlockExpression = previous;
- }
+ node.value.accept(this);
}
}