@@ -1324,29 +1324,15 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
1324
1324
body +=
1325
1325
Box (LoadIndexedInstr::RepresentationOfArrayElement (typed_data_cid));
1326
1326
if (kind == MethodRecognizer::kFfiLoadPointer ) {
1327
- const auto class_table = thread_->isolate_group ()->class_table ();
1328
- ASSERT (class_table->HasValidClassAt (kPointerCid ));
1329
1327
const auto & pointer_class =
1330
- Class::ZoneHandle (H.zone (), class_table->At (kPointerCid ));
1331
-
1332
- // We find the reified type to use for the pointer allocation.
1333
- //
1334
- // Call sites to this recognized method are guaranteed to pass a
1335
- // Pointer<Pointer<X>> as RawParameterVariable(0). This function
1336
- // will return a Pointer<X> object - for which we inspect the
1337
- // reified type on the argument.
1338
- //
1339
- // The following is safe to do, as (1) we are guaranteed to have a
1340
- // Pointer<Pointer<X>> as argument, and (2) the bound on the pointer
1341
- // type parameter guarantees X is an interface type.
1328
+ Class::ZoneHandle (Z, IG->object_store ()->ffi_pointer_class ());
1329
+ const auto & type_arguments = TypeArguments::ZoneHandle (
1330
+ Z, IG->object_store ()->type_argument_never ());
1331
+
1332
+ // We do not reify Pointer type arguments
1342
1333
ASSERT (function.NumTypeParameters () == 1 );
1343
1334
LocalVariable* address = MakeTemporary ();
1344
- body += LoadLocal (parsed_function_->RawParameterVariable (0 ));
1345
- body += LoadNativeField (
1346
- Slot::GetTypeArgumentsSlotFor (thread_, pointer_class));
1347
- body += LoadNativeField (Slot::GetTypeArgumentsIndexSlot (
1348
- thread_, Pointer::kNativeTypeArgPos ));
1349
- body += LoadNativeField (Slot::Type_arguments ());
1335
+ body += Constant (type_arguments);
1350
1336
body += AllocateObject (TokenPosition::kNoSource , pointer_class, 1 );
1351
1337
LocalVariable* pointer = MakeTemporary ();
1352
1338
body += LoadLocal (pointer);
@@ -1381,37 +1367,6 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
1381
1367
LocalVariable* arg_offset = parsed_function_->RawParameterVariable (1 );
1382
1368
LocalVariable* arg_value = parsed_function_->RawParameterVariable (2 );
1383
1369
1384
- if (kind == MethodRecognizer::kFfiStorePointer ) {
1385
- // Do type check before anything untagged is on the stack.
1386
- const auto class_table = thread_->isolate_group ()->class_table ();
1387
- ASSERT (class_table->HasValidClassAt (kPointerCid ));
1388
- const auto & pointer_class =
1389
- Class::ZoneHandle (H.zone (), class_table->At (kPointerCid ));
1390
- const auto & pointer_type_param =
1391
- TypeParameter::ZoneHandle (pointer_class.TypeParameterAt (0 ));
1392
-
1393
- // But we type check it as a method on a generic class at runtime.
1394
- body += LoadLocal (arg_value); // value.
1395
- body += Constant (pointer_type_param); // dst_type.
1396
- // We pass the Pointer type argument as instantiator_type_args.
1397
- //
1398
- // Call sites to this recognized method are guaranteed to pass a
1399
- // Pointer<Pointer<X>> as RawParameterVariable(0). This function
1400
- // will takes a Pointer<X> object - for which we inspect the
1401
- // reified type on the argument.
1402
- //
1403
- // The following is safe to do, as (1) we are guaranteed to have a
1404
- // Pointer<Pointer<X>> as argument, and (2) the bound on the pointer
1405
- // type parameter guarantees X is an interface type.
1406
- body += LoadLocal (arg_pointer);
1407
- body += CheckNullOptimized (String::ZoneHandle (Z, function.name ()));
1408
- body += LoadNativeField (
1409
- Slot::GetTypeArgumentsSlotFor (thread_, pointer_class));
1410
- body += NullConstant (); // function_type_args.
1411
- body += AssertAssignable (TokenPosition::kNoSource , Symbols::Empty ());
1412
- body += Drop ();
1413
- }
1414
-
1415
1370
ASSERT_EQUAL (function.NumParameters (), 3 );
1416
1371
body += LoadLocal (arg_offset);
1417
1372
body += CheckNullOptimized (String::ZoneHandle (Z, function.name ()));
@@ -1448,14 +1403,14 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
1448
1403
body += NullConstant ();
1449
1404
} break ;
1450
1405
case MethodRecognizer::kFfiFromAddress : {
1451
- const auto class_table = thread_->isolate_group ()->class_table ();
1452
- ASSERT (class_table->HasValidClassAt (kPointerCid ));
1453
1406
const auto & pointer_class =
1454
- Class::ZoneHandle (H.zone (), class_table->At (kPointerCid ));
1407
+ Class::ZoneHandle (Z, IG->object_store ()->ffi_pointer_class ());
1408
+ const auto & type_arguments = TypeArguments::ZoneHandle (
1409
+ Z, IG->object_store ()->type_argument_never ());
1455
1410
1456
1411
ASSERT (function.NumTypeParameters () == 1 );
1457
1412
ASSERT_EQUAL (function.NumParameters (), 1 );
1458
- body += LoadLocal (parsed_function_-> RawTypeArgumentsVariable () );
1413
+ body += Constant (type_arguments );
1459
1414
body += AllocateObject (TokenPosition::kNoSource , pointer_class, 1 );
1460
1415
body += LoadLocal (MakeTemporary ()); // Duplicate Pointer.
1461
1416
body += LoadLocal (parsed_function_->RawParameterVariable (0 )); // Address.
@@ -4306,15 +4261,17 @@ Fragment FlowGraphBuilder::NativeReturn(
4306
4261
return Fragment (instr).closed ();
4307
4262
}
4308
4263
4309
- Fragment FlowGraphBuilder::FfiPointerFromAddress (const Type& result_type ) {
4264
+ Fragment FlowGraphBuilder::FfiPointerFromAddress () {
4310
4265
LocalVariable* address = MakeTemporary ();
4311
4266
LocalVariable* result = parsed_function_->expression_temp_var ();
4312
4267
4313
- Class& result_class = Class::ZoneHandle (Z, result_type.type_class ());
4268
+ Class& result_class =
4269
+ Class::ZoneHandle (Z, IG->object_store ()->ffi_pointer_class ());
4314
4270
// This class might only be instantiated as a return type of ffi calls.
4315
4271
result_class.EnsureIsFinalized (thread_);
4316
4272
4317
- TypeArguments& args = TypeArguments::ZoneHandle (Z, result_type.arguments ());
4273
+ TypeArguments& args =
4274
+ TypeArguments::ZoneHandle (Z, IG->object_store ()->type_argument_never ());
4318
4275
4319
4276
// A kernel transform for FFI in the front-end ensures that type parameters
4320
4277
// do not appear in the type arguments to a any Pointer classes in an FFI
@@ -4656,8 +4613,7 @@ Fragment FlowGraphBuilder::FfiConvertPrimitiveToDart(
4656
4613
Fragment body;
4657
4614
if (marshaller.IsPointer (arg_index)) {
4658
4615
body += Box (kUnboxedFfiIntPtr );
4659
- body += FfiPointerFromAddress (
4660
- Type::CheckedHandle (Z, marshaller.CType (arg_index)));
4616
+ body += FfiPointerFromAddress ();
4661
4617
} else if (marshaller.IsHandle (arg_index)) {
4662
4618
body += UnwrapHandle ();
4663
4619
} else if (marshaller.IsVoid (arg_index)) {
0 commit comments