Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a55712b

Browse files
author
Dart CI
committed
Version 2.19.0-436.0.dev
Merge 78fc03c into dev
2 parents 3ed1fc1 + 78fc03c commit a55712b

21 files changed

+380
-442
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@
8989
[#34233]: https://github.com/dart-lang/sdk/issues/34233
9090
[`ServiceExtensionResponse`]: https://api.dart.dev/stable/2.17.6/dart-developer/ServiceExtensionResponse-class.html#constants
9191

92+
#### `dart:ffi`
93+
94+
- **Breaking change** [#49935][]: The runtime type argument of `Pointer` has
95+
changed to `Never` in preparation of completely removing the runtime type
96+
argument. `Pointer.toString` has changed to not report any type argument.
97+
98+
[#49935]: https://github.com/dart-lang/sdk/issues/49935
9299

93100
#### `dart:html`
94101

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,10 @@ class FileSystemState {
12441244
return _pathToFile[file.path];
12451245
}
12461246

1247+
FileState? getExistingFromPath(String path) {
1248+
return _pathToFile[path];
1249+
}
1250+
12471251
/// Return the [FileState] for the given absolute [path]. The returned file
12481252
/// has the last known state since if was last refreshed.
12491253
/// TODO(scheglov) Merge with [getFileForPath2].

pkg/analyzer/lib/src/dart/analysis/search.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,7 @@ class SearchedFiles {
722722

723723
bool add(String path, Search search) {
724724
final fsState = search._driver.fsState;
725-
final file = fsState.resourceProvider.getFile(path);
726-
final fileState = fsState.getExisting(file);
725+
final fileState = fsState.getExistingFromPath(path);
727726
if (fileState == null) {
728727
return false;
729728
}

runtime/lib/ffi.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ DEFINE_NATIVE_ENTRY(Ffi_nativeCallbackFunction, 1, 2) {
122122
}
123123

124124
DEFINE_NATIVE_ENTRY(Ffi_pointerFromFunction, 1, 1) {
125-
GET_NATIVE_TYPE_ARGUMENT(type_arg, arguments->NativeTypeArgAt(0));
126125
const Function& function =
127126
Function::CheckedHandle(zone, arguments->NativeArg0());
128127

@@ -164,7 +163,7 @@ DEFINE_NATIVE_ENTRY(Ffi_pointerFromFunction, 1, 1) {
164163
}
165164
#endif
166165

167-
return Pointer::New(type_arg, entry_point);
166+
return Pointer::New(entry_point);
168167
}
169168

170169
DEFINE_NATIVE_ENTRY(DartNativeApiFunctionPointer, 0, 1) {

runtime/lib/ffi_dynamic_library.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ DEFINE_NATIVE_ENTRY(Ffi_dl_executableLibrary, 0, 0) {
180180
}
181181

182182
DEFINE_NATIVE_ENTRY(Ffi_dl_lookup, 1, 2) {
183-
GET_NATIVE_TYPE_ARGUMENT(type_arg, arguments->NativeTypeArgAt(0));
184-
185183
GET_NON_NULL_NATIVE_ARGUMENT(DynamicLibrary, dlib, arguments->NativeArgAt(0));
186184
GET_NON_NULL_NATIVE_ARGUMENT(String, argSymbolName,
187185
arguments->NativeArgAt(1));
@@ -197,7 +195,7 @@ DEFINE_NATIVE_ENTRY(Ffi_dl_lookup, 1, 2) {
197195
free(error);
198196
Exceptions::ThrowArgumentError(msg);
199197
}
200-
return Pointer::New(type_arg, pointer);
198+
return Pointer::New(pointer);
201199
}
202200

203201
DEFINE_NATIVE_ENTRY(Ffi_dl_getHandle, 0, 1) {
@@ -291,8 +289,7 @@ static intptr_t FfiResolve(Dart_Handle asset_handle,
291289

292290
// Bootstrap to get the FFI Native resolver through a `native` call.
293291
DEFINE_NATIVE_ENTRY(Ffi_GetFfiNativeResolver, 1, 0) {
294-
GET_NATIVE_TYPE_ARGUMENT(type_arg, arguments->NativeTypeArgAt(0));
295-
return Pointer::New(type_arg, reinterpret_cast<intptr_t>(FfiResolve));
292+
return Pointer::New(reinterpret_cast<intptr_t>(FfiResolve));
296293
}
297294

298295
#endif // defined(USING_SIMULATOR) || \

runtime/vm/compiler/frontend/kernel_to_il.cc

Lines changed: 16 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,29 +1324,15 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
13241324
body +=
13251325
Box(LoadIndexedInstr::RepresentationOfArrayElement(typed_data_cid));
13261326
if (kind == MethodRecognizer::kFfiLoadPointer) {
1327-
const auto class_table = thread_->isolate_group()->class_table();
1328-
ASSERT(class_table->HasValidClassAt(kPointerCid));
13291327
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
13421333
ASSERT(function.NumTypeParameters() == 1);
13431334
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);
13501336
body += AllocateObject(TokenPosition::kNoSource, pointer_class, 1);
13511337
LocalVariable* pointer = MakeTemporary();
13521338
body += LoadLocal(pointer);
@@ -1381,37 +1367,6 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
13811367
LocalVariable* arg_offset = parsed_function_->RawParameterVariable(1);
13821368
LocalVariable* arg_value = parsed_function_->RawParameterVariable(2);
13831369

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-
14151370
ASSERT_EQUAL(function.NumParameters(), 3);
14161371
body += LoadLocal(arg_offset);
14171372
body += CheckNullOptimized(String::ZoneHandle(Z, function.name()));
@@ -1448,14 +1403,14 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
14481403
body += NullConstant();
14491404
} break;
14501405
case MethodRecognizer::kFfiFromAddress: {
1451-
const auto class_table = thread_->isolate_group()->class_table();
1452-
ASSERT(class_table->HasValidClassAt(kPointerCid));
14531406
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());
14551410

14561411
ASSERT(function.NumTypeParameters() == 1);
14571412
ASSERT_EQUAL(function.NumParameters(), 1);
1458-
body += LoadLocal(parsed_function_->RawTypeArgumentsVariable());
1413+
body += Constant(type_arguments);
14591414
body += AllocateObject(TokenPosition::kNoSource, pointer_class, 1);
14601415
body += LoadLocal(MakeTemporary()); // Duplicate Pointer.
14611416
body += LoadLocal(parsed_function_->RawParameterVariable(0)); // Address.
@@ -4306,15 +4261,17 @@ Fragment FlowGraphBuilder::NativeReturn(
43064261
return Fragment(instr).closed();
43074262
}
43084263

4309-
Fragment FlowGraphBuilder::FfiPointerFromAddress(const Type& result_type) {
4264+
Fragment FlowGraphBuilder::FfiPointerFromAddress() {
43104265
LocalVariable* address = MakeTemporary();
43114266
LocalVariable* result = parsed_function_->expression_temp_var();
43124267

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());
43144270
// This class might only be instantiated as a return type of ffi calls.
43154271
result_class.EnsureIsFinalized(thread_);
43164272

4317-
TypeArguments& args = TypeArguments::ZoneHandle(Z, result_type.arguments());
4273+
TypeArguments& args =
4274+
TypeArguments::ZoneHandle(Z, IG->object_store()->type_argument_never());
43184275

43194276
// A kernel transform for FFI in the front-end ensures that type parameters
43204277
// do not appear in the type arguments to a any Pointer classes in an FFI
@@ -4656,8 +4613,7 @@ Fragment FlowGraphBuilder::FfiConvertPrimitiveToDart(
46564613
Fragment body;
46574614
if (marshaller.IsPointer(arg_index)) {
46584615
body += Box(kUnboxedFfiIntPtr);
4659-
body += FfiPointerFromAddress(
4660-
Type::CheckedHandle(Z, marshaller.CType(arg_index)));
4616+
body += FfiPointerFromAddress();
46614617
} else if (marshaller.IsHandle(arg_index)) {
46624618
body += UnwrapHandle();
46634619
} else if (marshaller.IsVoid(arg_index)) {

runtime/vm/compiler/frontend/kernel_to_il.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ class FlowGraphBuilder : public BaseFlowGraphBuilder {
285285
// Converts 0 to false and the rest to true.
286286
Fragment IntToBool();
287287

288-
// Creates an ffi.Pointer holding a given address (TOS).
289-
Fragment FfiPointerFromAddress(const Type& result_type);
288+
// Creates an ffi.Pointer holding a given address.
289+
Fragment FfiPointerFromAddress();
290290

291291
// Pushes an (unboxed) bogus value returned when a native -> Dart callback
292292
// throws an exception.

0 commit comments

Comments
 (0)