[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 <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Tess Strickland
2026-06-09 07:54:09 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 061e843207
commit 7d8b5becb4
5 changed files with 10 additions and 10 deletions
-1
View File
@@ -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
-2
View File
@@ -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;
+9 -3
View File
@@ -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) {
+1
View File
@@ -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) \
-4
View File
@@ -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);