Skip to content

Commit

Permalink
[vm/aot] Disable graph intrinsics for implicit getters with unboxed r…
Browse files Browse the repository at this point in the history
…ecord return values

Unboxing of records involves a more complex code, and such intrinsics
would be similar to the normal code of the implicit getters.

TEST=runtime/tests/vm/dart/regress_52449_test.dart
Fixes #52449

Change-Id: I24867a7e0a3d081c53860f7f44c3be3d90b0b743
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304282
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
  • Loading branch information
alexmarkov authored and Commit Queue committed May 22, 2023
1 parent 862c22d commit 86c1825
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
27 changes: 27 additions & 0 deletions runtime/tests/vm/dart/regress_52449_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

// Verifies that compiler doesn't crash when compiling
// implicit getter with unboxed return value.
// Regression test for https://github.com/dart-lang/sdk/issues/52449.

abstract class A {
(int, int) get foo;
}

class B implements A {
(int, int) get foo => (1, 2);
}

class C implements A {
final (int, int) foo;
C(this.foo);
}

void main() {
final list = [B(), C((3, 4))];
for (var e in list) {
print(e.foo);
}
}
5 changes: 3 additions & 2 deletions runtime/vm/compiler/intrinsifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ bool Intrinsifier::CanIntrinsifyFieldAccessor(
}
} else {
// If the field is boxed, then we can either return the box directly or
// unbox it and return unboxed representation.
return true;
// unbox it and return unboxed representation (unless it is a record
// which requires a more sophisticated unboxing).
return !function.has_unboxed_record_return();
}
} else {
ASSERT(is_setter);
Expand Down

0 comments on commit 86c1825

Please sign in to comment.