[vm,dyn_modules] Fix Rectangle/MutableRectangle on vm-dyn-aot.

Also allows the --print-classes flag to be used in the AOT runtime if
dynamic modules are enabled and crashes with an appropriate error
message if class finalization fails when loading a member from bytecode.

TEST=co19/LibTest/math/Rectangle co19/LibTest/math/MutableRectangle

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I1921aa0189eb587cd4658c592a779be190af092e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495724
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland
2026-04-16 04:25:37 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 0e1cc0656d
commit 0e89c5e496
4 changed files with 24 additions and 15 deletions
+10 -9
View File
@@ -1157,7 +1157,8 @@ ObjectPtr BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
}
return field;
} else {
if ((flags & kFlagIsConstructor) != 0) {
const bool is_constructor = (flags & kFlagIsConstructor) != 0;
if (is_constructor) {
name = ConstructorName(cls, name);
}
ASSERT(!name.IsNull() && name.IsSymbol());
@@ -1173,15 +1174,15 @@ ObjectPtr BytecodeReaderHelper::ReadObjectContents(uint32_t header) {
return thread_->bytecode_loader()->GetExpressionEvaluationFunction();
}
FunctionPtr function = Function::null();
if ((flags & kFlagIsConstructor) != 0) {
if (cls.EnsureIsAllocateFinalized(thread_) == Error::null()) {
function = Resolver::ResolveFunction(Z, cls, name);
}
} else {
if (cls.EnsureIsFinalized(thread_) == Error::null()) {
function = Resolver::ResolveFunction(Z, cls, name);
}
ErrorPtr finalize_err = is_constructor
? cls.EnsureIsAllocateFinalized(thread_)
: cls.EnsureIsFinalized(thread_);
if (finalize_err != Error::null()) {
FATAL("Unable to finalize class %s%s: %s", cls.ToCString(),
is_constructor ? "" : " for allocation",
Error::Handle(Z, finalize_err).ToErrorCString());
}
function = Resolver::ResolveFunction(Z, cls, name);
if (function == Function::null()) {
// When requesting a getter, also return method extractors.
if (Field::IsGetterName(name)) {
+8 -4
View File
@@ -27,7 +27,9 @@
namespace dart {
#if !defined(PRODUCT)
DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes.");
#endif
DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization.");
DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization.");
@@ -749,7 +751,7 @@ void ClassFinalizer::FinalizeClass(const Class& cls) {
}
// Mark as loaded and finalized.
cls.Finalize();
#if !defined(DART_PRECOMPILED_RUNTIME)
#if !defined(PRODUCT)
if (FLAG_print_classes) {
PrintClassInformation(cls);
}
@@ -844,10 +846,8 @@ ErrorPtr ClassFinalizer::LoadClassMembers(const Class& cls) {
return thread->StealStickyError();
}
}
#endif // !defined(DART_PRECOMPILED_RUNTIME) || defined(DART_DYNAMIC_MODULES)
#if !defined(DART_PRECOMPILED_RUNTIME)
#if !defined(PRODUCT)
void ClassFinalizer::PrintClassInformation(const Class& cls) {
Thread* thread = Thread::Current();
HANDLESCOPE(thread);
@@ -893,6 +893,10 @@ void ClassFinalizer::PrintClassInformation(const Class& cls) {
THR_Print(" %s\n", field.ToCString());
}
}
#endif // !defined(PRODUCT)
#endif // !defined(DART_PRECOMPILED_RUNTIME) || defined(DART_DYNAMIC_MODULES)
#if !defined(DART_PRECOMPILED_RUNTIME)
void ClassFinalizer::VerifyImplicitFieldOffsets() {
#ifdef DEBUG
+2 -2
View File
@@ -92,9 +92,9 @@ class ClassFinalizer : public AllStatic {
#if !defined(DART_PRECOMPILED_RUNTIME) || defined(DART_DYNAMIC_MODULES)
static void FinalizeMemberTypes(const Class& cls);
#endif // !defined(DART_PRECOMPILED_RUNTIME) || defined(DART_DYNAMIC_MODULES)
#if !defined(DART_PRECOMPILED_RUNTIME)
#if !defined(PRODUCT)
static void PrintClassInformation(const Class& cls);
#endif
#endif // !defined(DART_PRECOMPILED_RUNTIME)
#if !defined(DART_PRECOMPILED_RUNTIME)
@@ -46,6 +46,10 @@ callable:
- library: 'dart:io'
- library: 'dart:isolate'
- library: 'dart:math'
# Explicitly add public members of _RectangleBase because they are inherited
# by Rectangle/MutableRectangle.
- library: 'dart:math'
class: '_RectangleBase'
- library: 'dart:nativewrappers'
- library: 'dart:typed_data'
- library: 'dart:vmservice_io'