Skip to content

Commit 0cc9a8b

Browse files
committed
Roll new version of the DL API from Dart SDK
1 parent 17ac821 commit 0cc9a8b

File tree

6 files changed

+49
-50
lines changed

6 files changed

+49
-50
lines changed

third_party/dart-sdk/src/runtime/include/dart_api.h

Lines changed: 38 additions & 36 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.
@@ -921,7 +914,7 @@ typedef struct {
921914
/**
922915
* Initializes the VM.
923916
*
924-
* \param flags A struct containing initialization information. The version
917+
* \param params A struct containing initialization information. The version
925918
* field of the struct must be DART_INITIALIZE_PARAMS_CURRENT_VERSION.
926919
*
927920
* \return NULL if initialization is successful. Returns an error message
@@ -1242,14 +1235,17 @@ DART_EXPORT void Dart_ExitIsolate();
12421235
* snapshot. This buffer is scope allocated and is only valid
12431236
* until the next call to Dart_ExitScope.
12441237
* \param size Returns the size of the buffer.
1238+
* \param is_core Create a snapshot containing core libraries.
1239+
* Such snapshot should be agnostic to null safety mode.
12451240
*
12461241
* \return A valid handle if no error occurs during the operation.
12471242
*/
12481243
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
12491244
Dart_CreateSnapshot(uint8_t** vm_snapshot_data_buffer,
12501245
intptr_t* vm_snapshot_data_size,
12511246
uint8_t** isolate_snapshot_data_buffer,
1252-
intptr_t* isolate_snapshot_data_size);
1247+
intptr_t* isolate_snapshot_data_size,
1248+
bool is_core);
12531249

12541250
/**
12551251
* Returns whether the buffer contains a kernel file.
@@ -2043,7 +2039,7 @@ Dart_NewExternalLatin1String(const uint8_t* latin1_array,
20432039
intptr_t length,
20442040
void* peer,
20452041
intptr_t external_allocation_size,
2046-
Dart_WeakPersistentHandleFinalizer callback);
2042+
Dart_HandleFinalizer callback);
20472043

20482044
/**
20492045
* Returns a String which references an external array of UTF-16 encoded
@@ -2064,7 +2060,7 @@ Dart_NewExternalUTF16String(const uint16_t* utf16_array,
20642060
intptr_t length,
20652061
void* peer,
20662062
intptr_t external_allocation_size,
2067-
Dart_WeakPersistentHandleFinalizer callback);
2063+
Dart_HandleFinalizer callback);
20682064

20692065
/**
20702066
* Gets the C string representation of a String.
@@ -2437,13 +2433,13 @@ DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type,
24372433
* \return The TypedData object if no error occurs. Otherwise returns
24382434
* an error handle.
24392435
*/
2440-
DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer(
2441-
Dart_TypedData_Type type,
2442-
void* data,
2443-
intptr_t length,
2444-
void* peer,
2445-
intptr_t external_allocation_size,
2446-
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);
24472443

24482444
/**
24492445
* Returns a ByteBuffer object for the typed data.
@@ -3695,22 +3691,28 @@ DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris(intptr_t loading_unit_id);
36953691
#define kSnapshotBuildIdCSymbol "kDartSnapshotBuildId"
36963692
#define kVmSnapshotDataCSymbol "kDartVmSnapshotData"
36973693
#define kVmSnapshotInstructionsCSymbol "kDartVmSnapshotInstructions"
3694+
#define kVmSnapshotBssCSymbol "kDartVmSnapshotBss"
36983695
#define kIsolateSnapshotDataCSymbol "kDartIsolateSnapshotData"
36993696
#define kIsolateSnapshotInstructionsCSymbol "kDartIsolateSnapshotInstructions"
3697+
#define kIsolateSnapshotBssCSymbol "kDartIsolateSnapshotBss"
37003698
#else
37013699
#define kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId"
37023700
#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData"
37033701
#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions"
3702+
#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss"
37043703
#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData"
37053704
#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions"
3705+
#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss"
37063706
#endif
37073707

37083708
#define kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId"
37093709
#define kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData"
37103710
#define kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions"
3711+
#define kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss"
37113712
#define kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData"
37123713
#define kIsolateSnapshotInstructionsAsmSymbol \
37133714
"_kDartIsolateSnapshotInstructions"
3715+
#define kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss"
37143716

37153717
/**
37163718
* Creates a precompiled snapshot.

third_party/dart-sdk/src/runtime/include/dart_api_dl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* BSD-style license that can be found in the LICENSE file.
55
*/
66

7-
#include "include/dart_api_dl.h"
8-
#include "include/dart_version.h"
9-
#include "include/internal/dart_api_dl_impl.h"
7+
#include "dart_api_dl.h" /* NOLINT */
8+
#include "dart_version.h" /* NOLINT */
9+
#include "internal/dart_api_dl_impl.h" /* NOLINT */
1010

1111
#include <string.h>
1212

third_party/dart-sdk/src/runtime/include/dart_api_dl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#ifndef RUNTIME_INCLUDE_DART_API_DL_H_
88
#define RUNTIME_INCLUDE_DART_API_DL_H_
99

10-
#include "include/dart_api.h"
11-
#include "include/dart_native_api.h"
10+
#include "dart_api.h" /* NOLINT */
11+
#include "dart_native_api.h" /* NOLINT */
1212

1313
/** \mainpage Dynamically Linked Dart API
1414
*
@@ -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)) \

third_party/dart-sdk/src/runtime/include/dart_native_api.h

Lines changed: 2 additions & 5 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;
@@ -178,8 +177,6 @@ DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
178177
*/
179178
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll();
180179

181-
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_ReadAllBytecode();
182-
183180
/**
184181
* Finalizes all classes.
185182
*/

third_party/dart-sdk/src/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 */

tool/update-dart-sdk.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
ROOT_PATH = os.path.dirname(TOOL_PATH)
2929

3030
DARTSDK_REPOSITORY = 'https://dart.googlesource.com/sdk/'
31-
DARTSDK_REVISION = '1d603120c5cb7890ca20184b3e263908f3081446'
31+
DARTSDK_REVISION = '09481aa6ca60a12a5885db108aa5152cecb73fb1'
3232

3333

3434
def cleanup():

0 commit comments

Comments
 (0)