mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:58:05 +00:00
[dart2wasm] Fix reversal of break labels crossing finally.
The block starts and ends for the entry points to the finally block instances corresponding to break paths were emitted in the same order, causing the jump targets to be reversed. Change-Id: Ifc8a6b6320ba7341140606c98333f5825d2228ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283042 Commit-Queue: Aske Simon Christensen <askesc@google.com> Reviewed-by: Ömer Ağacan <omersa@google.com>
This commit is contained in:
parent
51a29c1218
commit
7a63ff2604
|
@ -1044,7 +1044,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
|
|||
w.Label tryFinallyBlock = b.block();
|
||||
|
||||
// Create one block for each wrapping label
|
||||
for (final labelBlocks in breakFinalizers.values) {
|
||||
for (final labelBlocks in breakFinalizers.values.toList().reversed) {
|
||||
labelBlocks.add(b.block());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
String test(int n) {
|
||||
String s = "$n";
|
||||
a:
|
||||
{
|
||||
b:
|
||||
{
|
||||
try {
|
||||
if (n == 1) {
|
||||
break a;
|
||||
} else {
|
||||
break b;
|
||||
}
|
||||
s += "/";
|
||||
} finally {
|
||||
s += "-";
|
||||
}
|
||||
s += "*";
|
||||
}
|
||||
return s + "b";
|
||||
}
|
||||
return s + "a";
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals("1-a", test(1));
|
||||
Expect.equals("2-b", test(2));
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
String test(int n) {
|
||||
String s = "$n";
|
||||
a:
|
||||
{
|
||||
b:
|
||||
{
|
||||
try {
|
||||
if (n == 1) {
|
||||
break a;
|
||||
} else {
|
||||
break b;
|
||||
}
|
||||
s += "/";
|
||||
} finally {
|
||||
s += "-";
|
||||
}
|
||||
s += "*";
|
||||
}
|
||||
return s + "b";
|
||||
}
|
||||
return s + "a";
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals("1-a", test(1));
|
||||
Expect.equals("2-b", test(2));
|
||||
}
|
Loading…
Reference in a new issue