From 7d8b5becb4d6f6b8afa0ee5eb9c2eee6ba73d449 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Tue, 9 Jun 2026 07:54:09 -0700 Subject: [PATCH] [vm,dyn_modules] Remove CompilerState use from CallMarshaller. The CallMarshaller is used not only from the compiler, but also from the FfiCall runtime entry used by the interpreter. Since it only has one use of the thread's CompilerState, looking up the TypedData class, move the storage of that class from the compiler state to the object store and remove this dependency. TEST=ffi/address_of_array_generated_test ffi/address_of_cast_test fii/address_of_struct_generated_test ffi/address_of_typeddata_generated_test Fixes: https://github.com/dart-lang/sdk/issues/61913 Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try Change-Id: Ia4fc5d9ecef370aa9476b998e37cc4ae94ee447f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498563 Commit-Queue: Tess Strickland Reviewed-by: Alexander Markov --- runtime/vm/compiler/compiler_state.cc | 1 - runtime/vm/compiler/compiler_state.h | 2 -- runtime/vm/compiler/ffi/marshaller.cc | 12 +++++++++--- runtime/vm/object_store.h | 1 + runtime/vm/runtime_entry.cc | 4 ---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/vm/compiler/compiler_state.cc b/runtime/vm/compiler/compiler_state.cc index d0834899315..1a8e3b9b6e8 100644 --- a/runtime/vm/compiler/compiler_state.cc +++ b/runtime/vm/compiler/compiler_state.cc @@ -141,7 +141,6 @@ DEFINE_TYPED_LIST_NATIVE_FUNCTION_GETTER(Float64x2, float64x2) return *Lower##_class_; \ } -DEFINE_CLASS_GETTER(TypedData, TypedData, typed_data, TypedData) DEFINE_CLASS_GETTER(TypedData, TypedList, typed_list, _TypedList) #undef DEFINE_CLASS_GETTER diff --git a/runtime/vm/compiler/compiler_state.h b/runtime/vm/compiler/compiler_state.h index 2cd6a392b3a..6820b51d88b 100644 --- a/runtime/vm/compiler/compiler_state.h +++ b/runtime/vm/compiler/compiler_state.h @@ -127,7 +127,6 @@ class CompilerState : public ThreadStackResource { const Function& TypedListSetFloat64x2(); const Class& ErrorClass(); - const Class& TypedDataClass(); const Field& ErrorStackTraceField(); @@ -174,7 +173,6 @@ class CompilerState : public ThreadStackResource { const Class* array_class_ = nullptr; const Class* compound_class_ = nullptr; const Class* struct_class_ = nullptr; - const Class* typed_data_class_ = nullptr; const Class* union_class_ = nullptr; const Field* compound_offset_in_bytes_field_ = nullptr; const Field* compound_typed_data_base_field_ = nullptr; diff --git a/runtime/vm/compiler/ffi/marshaller.cc b/runtime/vm/compiler/ffi/marshaller.cc index c975ef4b377..cf623895062 100644 --- a/runtime/vm/compiler/ffi/marshaller.cc +++ b/runtime/vm/compiler/ffi/marshaller.cc @@ -7,7 +7,6 @@ #include "platform/assert.h" #include "platform/globals.h" #include "vm/class_id.h" -#include "vm/compiler/compiler_state.h" #include "vm/compiler/ffi/frame_rebase.h" #include "vm/compiler/ffi/native_calling_convention.h" #include "vm/compiler/ffi/native_location.h" @@ -194,8 +193,15 @@ bool BaseMarshaller::IsTypedDataPointer(intptr_t arg_index) const { } const auto& type = AbstractType::Handle(zone_, DartType(arg_index)); - return type.type_class() == - Thread::Current()->compiler_state().TypedDataClass().ptr(); + auto* const object_store = Thread::Current()->isolate_group()->object_store(); + auto& typed_data_cls = Class::Handle(zone_, object_store->typed_data_class()); + if (typed_data_cls.IsNull()) { + const auto& lib = Library::Handle(zone_, Library::TypedDataLibrary()); + typed_data_cls = lib.LookupClass(Symbols::TypedData()); + ASSERT(!typed_data_cls.IsNull()); + object_store->set_typed_data_class(typed_data_cls); + } + return type.type_class() == typed_data_cls.ptr(); } static bool IsCompound(Zone* zone, const AbstractType& type) { diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h index 716ebee7723..31f2e5040c9 100644 --- a/runtime/vm/object_store.h +++ b/runtime/vm/object_store.h @@ -213,6 +213,7 @@ class ObjectPointerVisitor; RW(Array, saved_unlinked_calls) \ RW(GrowableObjectArray, megamorphic_cache_table) \ RW(GrowableObjectArray, ffi_callback_code) \ + ARW_AR(Class, typed_data_class) \ RW(Array, ffi_callback_functions) \ /* Roots for JIT/AOT snapshots are up until here (see to_snapshot() below)*/ \ RW(Array, dispatch_table_code_entries) \ diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index 6fd1c1f16b8..023ca158d2c 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -1490,10 +1490,6 @@ DEFINE_RUNTIME_ENTRY(FfiCall, 2) { FunctionType::ZoneHandle(zone, function.FfiCSignature()); const bool is_leaf = function.FfiIsLeaf(); - // Used by compiler::ffi::CallMarshaller. - CompilerState compiler_state(thread, /*is_aot=*/FLAG_precompiled_mode, - /*is_optimizing=*/false); - const char* error = nullptr; const auto marshaller_ptr = compiler::ffi::CallMarshaller::FromFunction( zone, function, first_argument_parameter_offset, c_signature, &error);