e3882c8a77
Change-Id: I30b4aa4a6195bac96ebe3f3f8e9c07acdec9b2d2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464481 Commit-Queue: Daco Harkes <dacoharkes@google.com> Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Alexander Aprelev <aam@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com>
67 lines
1.4 KiB
Dart
67 lines
1.4 KiB
Dart
// Copyright (c) 2025, 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.
|
|
//
|
|
// Tests deoptimization in presence of isolategroup-bound code.
|
|
//
|
|
// VMOptions=--experimental-shared-data --optimization-counter-threshold=10 --no-background-compilation
|
|
|
|
// Test that lazy deoptimization works if the program returns to a function
|
|
// that is scheduled for lazy deoptimization via an exception.
|
|
|
|
import 'package:dart_internal/isolate_group.dart' show IsolateGroup;
|
|
import 'package:expect/expect.dart';
|
|
|
|
class C {
|
|
dynamic x = 42;
|
|
}
|
|
|
|
@pragma('vm:never-inline')
|
|
AA(C c, bool b) {
|
|
if (b) {
|
|
c.x = 2.5;
|
|
throw 123;
|
|
}
|
|
}
|
|
|
|
@pragma('vm:never-inline')
|
|
T1(C c, bool b) {
|
|
try {
|
|
AA(c, b);
|
|
// ignore: nullable_type_in_catch_clause
|
|
} on dynamic {}
|
|
return c.x + 1;
|
|
}
|
|
|
|
@pragma('vm:never-inline')
|
|
T2(C c, bool b) {
|
|
try {
|
|
AA(c, b);
|
|
} on String {
|
|
Expect.isTrue(false);
|
|
} on int catch (e) {
|
|
Expect.equals(e, 123);
|
|
Expect.equals(b, true);
|
|
Expect.equals(c.x, 2.5);
|
|
}
|
|
return c.x + 1;
|
|
}
|
|
|
|
mainBody() {
|
|
var c = new C();
|
|
for (var i = 0; i < 10000; ++i) {
|
|
T1(c, false);
|
|
T2(c, false);
|
|
}
|
|
Expect.equals(43, T1(c, false));
|
|
Expect.equals(43, T2(c, false));
|
|
Expect.equals(3.5, T1(c, true));
|
|
Expect.equals(3.5, T2(c, true));
|
|
}
|
|
|
|
main() {
|
|
IsolateGroup.runSync(() {
|
|
mainBody();
|
|
});
|
|
}
|