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

Commit b43baaa

Browse files
author
Dart CI
committed
Version 2.12.0-15.0.dev
Merge commit '52783837369de45d3372cb6c6b7cdd63e71cd829' into 'dev'
2 parents 933439b + 5278383 commit b43baaa

35 files changed

+1101
-361
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ opted out of null safety by adding `// @dart=2.9` to the beginning of the file.
2727

2828
### Dart VM
2929

30+
* **Breaking Change** [#42312][]: `Dart_WeakPersistentHandle`s will no longer
31+
auto-delete themselves when the referenced object is garbage collected to
32+
avoid race conditions, but they are still automatically deleted when the
33+
isolate group shuts down.
34+
* **Breaking Change** [#42312][]: `Dart_WeakPersistentHandleFinalizer`
35+
is renamed to `Dart_HandleFinalizer` and had its `handle` argument removed.
36+
All api functions using that type have been updated.
37+
38+
[#42312]: https://github.com/dart-lang/sdk/issues/42312
39+
3040
### Dart2JS
3141

3242
* Removed `--no-defer-class-types` and `--no-new-deferred-split`.

runtime/bin/dartutils.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -905,11 +905,10 @@ Dart_CObject* CObject::NewUint32Array(intptr_t length) {
905905
return cobject;
906906
}
907907

908-
Dart_CObject* CObject::NewExternalUint8Array(
909-
intptr_t length,
910-
uint8_t* data,
911-
void* peer,
912-
Dart_WeakPersistentHandleFinalizer callback) {
908+
Dart_CObject* CObject::NewExternalUint8Array(intptr_t length,
909+
uint8_t* data,
910+
void* peer,
911+
Dart_HandleFinalizer callback) {
913912
Dart_CObject* cobject = New(Dart_CObject_kExternalTypedData);
914913
cobject->value.as_external_typed_data.type = Dart_TypedData_kUint8;
915914
cobject->value.as_external_typed_data.length = length;
@@ -937,7 +936,7 @@ Dart_CObject* CObject::NewIOBuffer(int64_t length) {
937936
void CObject::FreeIOBufferData(Dart_CObject* cobject) {
938937
ASSERT(cobject->type == Dart_CObject_kExternalTypedData);
939938
cobject->value.as_external_typed_data.callback(
940-
NULL, NULL, cobject->value.as_external_typed_data.peer);
939+
NULL, cobject->value.as_external_typed_data.peer);
941940
cobject->value.as_external_typed_data.data = NULL;
942941
}
943942

runtime/bin/dartutils.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,10 @@ class CObject {
344344
static Dart_CObject* NewArray(intptr_t length);
345345
static Dart_CObject* NewUint8Array(intptr_t length);
346346
static Dart_CObject* NewUint32Array(intptr_t length);
347-
static Dart_CObject* NewExternalUint8Array(
348-
intptr_t length,
349-
uint8_t* data,
350-
void* peer,
351-
Dart_WeakPersistentHandleFinalizer callback);
347+
static Dart_CObject* NewExternalUint8Array(intptr_t length,
348+
uint8_t* data,
349+
void* peer,
350+
Dart_HandleFinalizer callback);
352351

353352
static Dart_CObject* NewIOBuffer(int64_t length);
354353
static void FreeIOBufferData(Dart_CObject* object);
@@ -571,7 +570,7 @@ class CObjectExternalUint8Array : public CObject {
571570
}
572571
uint8_t* Data() const { return cobject_->value.as_external_typed_data.data; }
573572
void* Peer() const { return cobject_->value.as_external_typed_data.peer; }
574-
Dart_WeakPersistentHandleFinalizer Callback() const {
573+
Dart_HandleFinalizer Callback() const {
575574
return cobject_->value.as_external_typed_data.callback;
576575
}
577576

runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ DART_EXPORT void ExecuteCallback(Work* work_ptr) {
475475

476476
Dart_Port send_port_;
477477

478-
static void FreeFinalizer(void*, Dart_WeakPersistentHandle, void* value) {
478+
static void FreeFinalizer(void*, void* value) {
479479
free(value);
480480
}
481481

@@ -776,9 +776,7 @@ DART_EXPORT void ThreadPoolTest_BarrierSync(
776776
// vmspecific_handle_test.dart (statically linked).
777777
// vmspecific_handle_dynamically_linked_test.dart (dynamically linked).
778778

779-
static void RunFinalizer(void* isolate_callback_data,
780-
Dart_WeakPersistentHandle handle,
781-
void* peer) {
779+
static void RunFinalizer(void* isolate_callback_data, void* peer) {
782780
printf("Running finalizer for weak handle.\n");
783781
}
784782

runtime/bin/io_buffer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class IOBuffer {
2525
static void Free(void* buffer) { free(buffer); }
2626

2727
// Function for finalizing external byte arrays used as IO buffers.
28-
static void Finalizer(void* isolate_callback_data,
29-
Dart_WeakPersistentHandle handle,
30-
void* buffer) {
28+
static void Finalizer(void* isolate_callback_data, void* buffer) {
3129
Free(buffer);
3230
}
3331

runtime/include/dart_api.h

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ typedef struct _Dart_IsolateGroup* Dart_IsolateGroup;
244244
* the object is garbage collected. It is never safe to use these handles
245245
* unless you know the object is still reachable.
246246
*
247-
* WeakPersistentHandles are persistent handles which are auto deleted
248-
* when the object is garbage collected.
247+
* WeakPersistentHandles are persistent handles which are automatically set
248+
* to point Dart_Null when the object is garbage collected. They are not auto
249+
* deleted, so it is safe to use them after the object has become unreachable.
249250
*/
250251
typedef struct _Dart_Handle* Dart_Handle;
251252
typedef Dart_Handle Dart_PersistentHandle;
@@ -254,10 +255,6 @@ typedef struct _Dart_FinalizableHandle* Dart_FinalizableHandle;
254255
// These structs are versioned by DART_API_DL_MAJOR_VERSION, bump the
255256
// version when changing this struct.
256257

257-
typedef void (*Dart_WeakPersistentHandleFinalizer)(
258-
void* isolate_callback_data,
259-
Dart_WeakPersistentHandle handle,
260-
void* peer);
261258
typedef void (*Dart_HandleFinalizer)(void* isolate_callback_data, void* peer);
262259

263260
/**
@@ -423,6 +420,8 @@ DART_EXPORT Dart_Handle Dart_HandleFromPersistent(Dart_PersistentHandle object);
423420

424421
/**
425422
* Allocates a handle in the current scope from a weak persistent handle.
423+
*
424+
* This will be a handle to Dart_Null if the object has been garbage collected.
426425
*/
427426
DART_EXPORT Dart_Handle
428427
Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object);
@@ -461,24 +460,18 @@ DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object);
461460
/**
462461
* Allocates a weak persistent handle for an object.
463462
*
464-
* This handle has the lifetime of the current isolate unless the object
465-
* pointed to by the handle is garbage collected, in this case the VM
466-
* automatically deletes the handle after invoking the callback associated
467-
* with the handle. The handle can also be explicitly deallocated by
468-
* calling Dart_DeleteWeakPersistentHandle.
469-
*
470-
* If the object becomes unreachable the callback is invoked with the weak
471-
* persistent handle and the peer as arguments. The callback can be executed on
472-
* any thread, will have an isolate group, but will not have a current isolate.
473-
* The callback can only call Dart_DeletePersistentHandle or
474-
* Dart_DeleteWeakPersistentHandle. The callback must not call
475-
* Dart_DeleteWeakPersistentHandle for the handle being finalized, as it is
476-
* automatically deleted by the VM after the callback returns. This gives the
477-
* embedder the ability to cleanup data associated with the object and clear
478-
* out any cached references to the handle. All references to this handle after
479-
* the callback will be invalid. It is illegal to call into the VM with any
480-
* other Dart_* functions from the callback. If the handle is deleted before
481-
* the object becomes unreachable, the callback is never invoked.
463+
* This handle has the lifetime of the current isolate. The handle can also be
464+
* explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
465+
*
466+
* If the object becomes unreachable the callback is invoked with the peer as
467+
* argument. The callback can be executed on any thread, will have a current
468+
* isolate group, but will not have a current isolate. The callback can only
469+
* call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This
470+
* gives the embedder the ability to cleanup data associated with the object.
471+
* The handle will point to the Dart_Null object after the finalizer has been
472+
* run. It is illegal to call into the VM with any other Dart_* functions from
473+
* the callback. If the handle is deleted before the object becomes
474+
* unreachable, the callback is never invoked.
482475
*
483476
* Requires there to be a current isolate.
484477
*
@@ -498,7 +491,7 @@ DART_EXPORT Dart_WeakPersistentHandle
498491
Dart_NewWeakPersistentHandle(Dart_Handle object,
499492
void* peer,
500493
intptr_t external_allocation_size,
501-
Dart_WeakPersistentHandleFinalizer callback);
494+
Dart_HandleFinalizer callback);
502495

503496
/**
504497
* Deletes the given weak persistent [object] handle.
@@ -2046,7 +2039,7 @@ Dart_NewExternalLatin1String(const uint8_t* latin1_array,
20462039
intptr_t length,
20472040
void* peer,
20482041
intptr_t external_allocation_size,
2049-
Dart_WeakPersistentHandleFinalizer callback);
2042+
Dart_HandleFinalizer callback);
20502043

20512044
/**
20522045
* Returns a String which references an external array of UTF-16 encoded
@@ -2067,7 +2060,7 @@ Dart_NewExternalUTF16String(const uint16_t* utf16_array,
20672060
intptr_t length,
20682061
void* peer,
20692062
intptr_t external_allocation_size,
2070-
Dart_WeakPersistentHandleFinalizer callback);
2063+
Dart_HandleFinalizer callback);
20712064

20722065
/**
20732066
* Gets the C string representation of a String.
@@ -2440,13 +2433,13 @@ DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type,
24402433
* \return The TypedData object if no error occurs. Otherwise returns
24412434
* an error handle.
24422435
*/
2443-
DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer(
2444-
Dart_TypedData_Type type,
2445-
void* data,
2446-
intptr_t length,
2447-
void* peer,
2448-
intptr_t external_allocation_size,
2449-
Dart_WeakPersistentHandleFinalizer callback);
2436+
DART_EXPORT Dart_Handle
2437+
Dart_NewExternalTypedDataWithFinalizer(Dart_TypedData_Type type,
2438+
void* data,
2439+
intptr_t length,
2440+
void* peer,
2441+
intptr_t external_allocation_size,
2442+
Dart_HandleFinalizer callback);
24502443

24512444
/**
24522445
* Returns a ByteBuffer object for the typed data.

runtime/include/dart_api_dl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id,
8484
F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \
8585
F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \
8686
(Dart_Handle object, void* peer, intptr_t external_allocation_size, \
87-
Dart_WeakPersistentHandleFinalizer callback)) \
87+
Dart_HandleFinalizer callback)) \
8888
F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \
8989
F(Dart_UpdateExternalSize, void, \
9090
(Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \

runtime/include/dart_native_api.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
* The data for kTypedData is copied on message send and ownership remains with
3232
* the caller. The ownership of data for kExternalTyped is passed to the VM on
3333
* message send and returned when the VM invokes the
34-
* Dart_WeakPersistentHandleFinalizer callback; a non-NULL callback must be
35-
* provided.
34+
* Dart_HandleFinalizer callback; a non-NULL callback must be provided.
3635
*/
3736
typedef enum {
3837
Dart_CObject_kNull = 0,
@@ -79,7 +78,7 @@ typedef struct _Dart_CObject {
7978
intptr_t length;
8079
uint8_t* data;
8180
void* peer;
82-
Dart_WeakPersistentHandleFinalizer callback;
81+
Dart_HandleFinalizer callback;
8382
} as_external_typed_data;
8483
} value;
8584
} Dart_CObject;

runtime/include/dart_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// On breaking changes the major version is increased.
1111
// On backwards compatible changes the minor version is increased.
1212
// The versioning covers the symbols exposed in dart_api_dl.h
13-
#define DART_API_DL_MAJOR_VERSION 1
14-
#define DART_API_DL_MINOR_VERSION 1
13+
#define DART_API_DL_MAJOR_VERSION 2
14+
#define DART_API_DL_MINOR_VERSION 0
1515

1616
#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */

runtime/lib/vmservice.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ DEFINE_NATIVE_ENTRY(VMService_SendRootServiceMessage, 0, 1) {
7272
DEFINE_NATIVE_ENTRY(VMService_SendObjectRootServiceMessage, 0, 1) {
7373
#ifndef PRODUCT
7474
GET_NON_NULL_NATIVE_ARGUMENT(Array, message, arguments->NativeArgAt(0));
75-
return Service::HandleObjectRootMessage(message);
75+
return Service::HandleObjectRootMessage(message);
7676
#endif
7777
return Object::null();
7878
}
@@ -307,16 +307,12 @@ class TarArchive {
307307
DISALLOW_COPY_AND_ASSIGN(TarArchive);
308308
};
309309

310-
static void ContentsFinalizer(void* isolate_callback_data,
311-
Dart_WeakPersistentHandle handle,
312-
void* peer) {
310+
static void ContentsFinalizer(void* isolate_callback_data, void* peer) {
313311
uint8_t* data = reinterpret_cast<uint8_t*>(peer);
314312
delete[] data;
315313
}
316314

317-
static void FilenameFinalizer(void* isolate_callback_data,
318-
Dart_WeakPersistentHandle handle,
319-
void* peer) {
315+
static void FilenameFinalizer(void* isolate_callback_data, void* peer) {
320316
char* filename = reinterpret_cast<char*>(peer);
321317
delete[] filename;
322318
}

0 commit comments

Comments
 (0)