dart-sdk/tests/language/vm/deopt_during_field_init_test.dart
Vyacheslav Egorov 2c33d87a69 [vm/compiler] Fix lazy deopt from LoadField
When converting InstanceCall to LoadField don't adjust deoptimization
environment because when we deoptimize from LoadField back to
InstanceCall we would expect to have receiver on the stack.

This is a different situation from LoadField to LoadField lazy
deoptimization in which case receiver should not be on the stack.

Regression test provided by Ryan.

Fixed: 42900
Change-Id: I6041ff02abf22a2bae0fdcd65d5b49ef8aec6204
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157182
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-06 15:45:24 +00:00

43 lines
860 B
Dart

// Copyright (c) 2020, 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.
// Test that we don't hit unbalanced stack after deoptimization from LoadField
// back to getter call.
// VMOptions=--no-use-osr --optimization-counter-threshold=10 --no-background-compilation
int counter = 0;
class A {
late final Object field = init();
@pragma('vm:never-inline')
int init() {
counter++;
if (counter > 20) {
finalizeB();
}
return counter;
}
}
class B extends A {
final Object field = "Foo";
}
@pragma('vm:never-inline')
finalizeB() {
print(new B().field);
}
@pragma('vm:never-inline')
test(A a) {
print(a.field);
}
main() {
for (var i = 0; i < 100; i++) {
test(new A());
}
}