@@ -3776,10 +3776,11 @@ Fragment FlowGraphBuilder::BitCast(Representation from, Representation to) {
3776
3776
return Fragment (instr);
3777
3777
}
3778
3778
3779
- Fragment FlowGraphBuilder::WrapTypedDataBaseInStruct (
3780
- const AbstractType& struct_type) {
3781
- const auto & struct_sub_class = Class::ZoneHandle (Z, struct_type.type_class ());
3782
- struct_sub_class.EnsureIsFinalized (thread_);
3779
+ Fragment FlowGraphBuilder::WrapTypedDataBaseInCompound (
3780
+ const AbstractType& compound_type) {
3781
+ const auto & compound_sub_class =
3782
+ Class::ZoneHandle (Z, compound_type.type_class ());
3783
+ compound_sub_class.EnsureIsFinalized (thread_);
3783
3784
const auto & lib_ffi = Library::Handle (Z, Library::FfiLibrary ());
3784
3785
const auto & compound_class =
3785
3786
Class::Handle (Z, lib_ffi.LookupClassAllowPrivate (Symbols::Compound ()));
@@ -3790,16 +3791,16 @@ Fragment FlowGraphBuilder::WrapTypedDataBaseInStruct(
3790
3791
3791
3792
Fragment body;
3792
3793
LocalVariable* typed_data = MakeTemporary (" typed_data_base" );
3793
- body += AllocateObject (TokenPosition::kNoSource , struct_sub_class , 0 );
3794
- body += LoadLocal (MakeTemporary (" struct " )); // Duplicate Struct.
3794
+ body += AllocateObject (TokenPosition::kNoSource , compound_sub_class , 0 );
3795
+ body += LoadLocal (MakeTemporary (" compound " )); // Duplicate Struct or Union .
3795
3796
body += LoadLocal (typed_data);
3796
3797
body += StoreInstanceField (compound_typed_data_base,
3797
3798
StoreInstanceFieldInstr::Kind::kInitializing );
3798
3799
body += DropTempsPreserveTop (1 ); // Drop TypedData.
3799
3800
return body;
3800
3801
}
3801
3802
3802
- Fragment FlowGraphBuilder::LoadTypedDataBaseFromStruct () {
3803
+ Fragment FlowGraphBuilder::LoadTypedDataBaseFromCompound () {
3803
3804
const auto & lib_ffi = Library::Handle (Z, Library::FfiLibrary ());
3804
3805
const auto & compound_class =
3805
3806
Class::Handle (Z, lib_ffi.LookupClassAllowPrivate (Symbols::Compound ()));
@@ -3813,15 +3814,15 @@ Fragment FlowGraphBuilder::LoadTypedDataBaseFromStruct() {
3813
3814
return body;
3814
3815
}
3815
3816
3816
- Fragment FlowGraphBuilder::CopyFromStructToStack (
3817
+ Fragment FlowGraphBuilder::CopyFromCompoundToStack (
3817
3818
LocalVariable* variable,
3818
3819
const GrowableArray<Representation>& representations) {
3819
3820
Fragment body;
3820
3821
const intptr_t num_defs = representations.length ();
3821
3822
int offset_in_bytes = 0 ;
3822
3823
for (intptr_t i = 0 ; i < num_defs; i++) {
3823
3824
body += LoadLocal (variable);
3824
- body += LoadTypedDataBaseFromStruct ();
3825
+ body += LoadTypedDataBaseFromCompound ();
3825
3826
body += LoadUntagged (compiler::target::Pointer::data_field_offset ());
3826
3827
body += IntConstant (offset_in_bytes);
3827
3828
const Representation representation = representations[i];
@@ -3959,7 +3960,7 @@ Fragment FlowGraphBuilder::CopyFromUnboxedAddressToTypedDataBase(
3959
3960
return body;
3960
3961
}
3961
3962
3962
- Fragment FlowGraphBuilder::FfiCallConvertStructArgumentToNative (
3963
+ Fragment FlowGraphBuilder::FfiCallConvertCompoundArgumentToNative (
3963
3964
LocalVariable* variable,
3964
3965
const compiler::ffi::BaseMarshaller& marshaller,
3965
3966
intptr_t arg_index) {
@@ -3970,29 +3971,29 @@ Fragment FlowGraphBuilder::FfiCallConvertStructArgumentToNative(
3970
3971
// separate definitions into the FFI call.
3971
3972
GrowableArray<Representation> representations;
3972
3973
marshaller.RepsInFfiCall (arg_index, &representations);
3973
- body += CopyFromStructToStack (variable, representations);
3974
+ body += CopyFromCompoundToStack (variable, representations);
3974
3975
} else {
3975
3976
ASSERT (native_loc.IsPointerToMemory ());
3976
3977
// Only load the typed data, do copying in the FFI call machine code.
3977
3978
body += LoadLocal (variable); // User-defined struct.
3978
- body += LoadTypedDataBaseFromStruct ();
3979
+ body += LoadTypedDataBaseFromCompound ();
3979
3980
}
3980
3981
return body;
3981
3982
}
3982
3983
3983
- Fragment FlowGraphBuilder::FfiCallConvertStructReturnToDart (
3984
+ Fragment FlowGraphBuilder::FfiCallConvertCompoundReturnToDart (
3984
3985
const compiler::ffi::BaseMarshaller& marshaller,
3985
3986
intptr_t arg_index) {
3986
3987
Fragment body;
3987
3988
// The typed data is allocated before the FFI call, and is populated in
3988
3989
// machine code. So, here, it only has to be wrapped in the struct class.
3989
- const auto & struct_type =
3990
+ const auto & compound_type =
3990
3991
AbstractType::Handle (Z, marshaller.CType (arg_index));
3991
- body += WrapTypedDataBaseInStruct (struct_type );
3992
+ body += WrapTypedDataBaseInCompound (compound_type );
3992
3993
return body;
3993
3994
}
3994
3995
3995
- Fragment FlowGraphBuilder::FfiCallbackConvertStructArgumentToDart (
3996
+ Fragment FlowGraphBuilder::FfiCallbackConvertCompoundArgumentToDart (
3996
3997
const compiler::ffi::BaseMarshaller& marshaller,
3997
3998
intptr_t arg_index,
3998
3999
ZoneGrowableArray<LocalVariable*>* definitions) {
@@ -4012,39 +4013,39 @@ Fragment FlowGraphBuilder::FfiCallbackConvertStructArgumentToDart(
4012
4013
} else {
4013
4014
ASSERT (marshaller.Location (arg_index).IsPointerToMemory ());
4014
4015
// Allocate a TypedData and copy contents pointed to by an address into it.
4015
- LocalVariable* address_of_struct = MakeTemporary (" address_of_struct " );
4016
+ LocalVariable* address_of_compound = MakeTemporary (" address_of_compound " );
4016
4017
body += IntConstant (length_in_bytes);
4017
4018
body +=
4018
4019
AllocateTypedData (TokenPosition::kNoSource , kTypedDataUint8ArrayCid );
4019
4020
LocalVariable* typed_data_base = MakeTemporary (" typed_data_base" );
4020
- body += LoadLocal (address_of_struct );
4021
+ body += LoadLocal (address_of_compound );
4021
4022
body += LoadLocal (typed_data_base);
4022
4023
body += CopyFromUnboxedAddressToTypedDataBase (length_in_bytes);
4023
- body += DropTempsPreserveTop (1 ); // address_of_struct .
4024
+ body += DropTempsPreserveTop (1 ); // address_of_compound .
4024
4025
}
4025
- // Wrap typed data in struct class.
4026
- const auto & struct_type =
4026
+ // Wrap typed data in compound class.
4027
+ const auto & compound_type =
4027
4028
AbstractType::Handle (Z, marshaller.CType (arg_index));
4028
- body += WrapTypedDataBaseInStruct (struct_type );
4029
+ body += WrapTypedDataBaseInCompound (compound_type );
4029
4030
return body;
4030
4031
}
4031
4032
4032
- Fragment FlowGraphBuilder::FfiCallbackConvertStructReturnToNative (
4033
+ Fragment FlowGraphBuilder::FfiCallbackConvertCompoundReturnToNative (
4033
4034
const compiler::ffi::CallbackMarshaller& marshaller,
4034
4035
intptr_t arg_index) {
4035
4036
Fragment body;
4036
4037
const auto & native_loc = marshaller.Location (arg_index);
4037
4038
if (native_loc.IsMultiple ()) {
4038
4039
// We pass in typed data to native return instruction, and do the copying
4039
4040
// in machine code.
4040
- body += LoadTypedDataBaseFromStruct ();
4041
+ body += LoadTypedDataBaseFromCompound ();
4041
4042
} else {
4042
4043
ASSERT (native_loc.IsPointerToMemory ());
4043
4044
// We copy the data into the right location in IL.
4044
4045
const intptr_t length_in_bytes =
4045
4046
marshaller.Location (arg_index).payload_type ().SizeInBytes ();
4046
4047
4047
- body += LoadTypedDataBaseFromStruct ();
4048
+ body += LoadTypedDataBaseFromCompound ();
4048
4049
LocalVariable* typed_data_base = MakeTemporary (" typed_data_base" );
4049
4050
4050
4051
auto * pointer_to_return =
@@ -4065,7 +4066,7 @@ Fragment FlowGraphBuilder::FfiCallbackConvertStructReturnToNative(
4065
4066
Fragment FlowGraphBuilder::FfiConvertPrimitiveToDart (
4066
4067
const compiler::ffi::BaseMarshaller& marshaller,
4067
4068
intptr_t arg_index) {
4068
- ASSERT (!marshaller.IsStruct (arg_index));
4069
+ ASSERT (!marshaller.IsCompound (arg_index));
4069
4070
4070
4071
Fragment body;
4071
4072
if (marshaller.IsPointer (arg_index)) {
@@ -4093,7 +4094,7 @@ Fragment FlowGraphBuilder::FfiConvertPrimitiveToNative(
4093
4094
const compiler::ffi::BaseMarshaller& marshaller,
4094
4095
intptr_t arg_index,
4095
4096
LocalVariable* api_local_scope) {
4096
- ASSERT (!marshaller.IsStruct (arg_index));
4097
+ ASSERT (!marshaller.IsCompound (arg_index));
4097
4098
4098
4099
Fragment body;
4099
4100
if (marshaller.IsPointer (arg_index)) {
@@ -4195,8 +4196,8 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) {
4195
4196
4196
4197
// Unbox and push the arguments.
4197
4198
for (intptr_t i = 0 ; i < marshaller.num_args (); i++) {
4198
- if (marshaller.IsStruct (i)) {
4199
- body += FfiCallConvertStructArgumentToNative (
4199
+ if (marshaller.IsCompound (i)) {
4200
+ body += FfiCallConvertCompoundArgumentToNative (
4200
4201
parsed_function_->ParameterVariable (kFirstArgumentParameterOffset +
4201
4202
i),
4202
4203
marshaller, i);
@@ -4246,9 +4247,9 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) {
4246
4247
body += Drop ();
4247
4248
}
4248
4249
4249
- if (marshaller.IsStruct (compiler::ffi::kResultIndex )) {
4250
- body += FfiCallConvertStructReturnToDart (marshaller,
4251
- compiler::ffi::kResultIndex );
4250
+ if (marshaller.IsCompound (compiler::ffi::kResultIndex )) {
4251
+ body += FfiCallConvertCompoundReturnToDart (marshaller,
4252
+ compiler::ffi::kResultIndex );
4252
4253
} else {
4253
4254
body += FfiConvertPrimitiveToDart (marshaller, compiler::ffi::kResultIndex );
4254
4255
}
@@ -4322,8 +4323,8 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiCallback(const Function& function) {
4322
4323
defs->Add (def);
4323
4324
}
4324
4325
4325
- if (marshaller.IsStruct (i)) {
4326
- body += FfiCallbackConvertStructArgumentToDart (marshaller, i, defs);
4326
+ if (marshaller.IsCompound (i)) {
4327
+ body += FfiCallbackConvertCompoundArgumentToDart (marshaller, i, defs);
4327
4328
} else {
4328
4329
body += FfiConvertPrimitiveToDart (marshaller, i);
4329
4330
}
@@ -4346,9 +4347,9 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiCallback(const Function& function) {
4346
4347
String::ZoneHandle (Z, marshaller.function_name ()));
4347
4348
}
4348
4349
4349
- if (marshaller.IsStruct (compiler::ffi::kResultIndex )) {
4350
- body += FfiCallbackConvertStructReturnToNative (marshaller,
4351
- compiler::ffi::kResultIndex );
4350
+ if (marshaller.IsCompound (compiler::ffi::kResultIndex )) {
4351
+ body += FfiCallbackConvertCompoundReturnToNative (
4352
+ marshaller, compiler::ffi::kResultIndex );
4352
4353
} else {
4353
4354
body += FfiConvertPrimitiveToNative (marshaller, compiler::ffi::kResultIndex ,
4354
4355
/* api_local_scope=*/ nullptr );
@@ -4379,7 +4380,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiCallback(const Function& function) {
4379
4380
FfiConvertPrimitiveToNative (marshaller, compiler::ffi::kResultIndex ,
4380
4381
/* api_local_scope=*/ nullptr );
4381
4382
4382
- } else if (marshaller.IsStruct (compiler::ffi::kResultIndex )) {
4383
+ } else if (marshaller.IsCompound (compiler::ffi::kResultIndex )) {
4383
4384
ASSERT (function.FfiCallbackExceptionalReturn () == Object::null ());
4384
4385
// Manufacture empty result.
4385
4386
const intptr_t size =
@@ -4390,9 +4391,9 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiCallback(const Function& function) {
4390
4391
catch_body += IntConstant (size);
4391
4392
catch_body +=
4392
4393
AllocateTypedData (TokenPosition::kNoSource , kTypedDataUint8ArrayCid );
4393
- catch_body += WrapTypedDataBaseInStruct (
4394
+ catch_body += WrapTypedDataBaseInCompound (
4394
4395
AbstractType::Handle (Z, marshaller.CType (compiler::ffi::kResultIndex )));
4395
- catch_body += FfiCallbackConvertStructReturnToNative (
4396
+ catch_body += FfiCallbackConvertCompoundReturnToNative (
4396
4397
marshaller, compiler::ffi::kResultIndex );
4397
4398
4398
4399
} else {
0 commit comments