25
25
#include <inttypes.h>
26
26
#include <stdbool.h>
27
27
28
+ #if defined(__Fuchsia__ )
29
+ #include <zircon/types.h>
30
+ #endif
31
+
28
32
#ifdef __cplusplus
29
33
#define DART_EXTERN_C extern "C"
30
34
#else
@@ -849,7 +853,7 @@ typedef Dart_Handle (*Dart_GetVMServiceAssetsArchive)(void);
849
853
* The current version of the Dart_InitializeFlags. Should be incremented every
850
854
* time Dart_InitializeFlags changes in a binary incompatible way.
851
855
*/
852
- #define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000007 )
856
+ #define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008 )
853
857
854
858
/** Forward declaration */
855
859
struct Dart_CodeObserver ;
@@ -992,6 +996,15 @@ typedef struct {
992
996
* Kernel blob unregistration callback function. See Dart_UnregisterKernelBlobCallback.
993
997
*/
994
998
Dart_UnregisterKernelBlobCallback unregister_kernel_blob ;
999
+
1000
+ #if defined(__Fuchsia__ )
1001
+ /**
1002
+ * The resource needed to use zx_vmo_replace_as_executable. Can be
1003
+ * ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if
1004
+ * executable memory is not needed (e.g., this is an AOT runtime).
1005
+ */
1006
+ zx_handle_t vmex_resource ;
1007
+ #endif
995
1008
} Dart_InitializeParams ;
996
1009
997
1010
/**
@@ -1105,7 +1118,7 @@ Dart_CreateIsolateGroup(const char* script_uri,
1105
1118
* shutdown (may be NULL).
1106
1119
* \param cleanup_callback A callback to be called when the isolate is being
1107
1120
* cleaned up (may be NULL).
1108
- * \param isolate_data The embedder-specific data associated with this isolate.
1121
+ * \param child_isolate_data The embedder-specific data associated with this isolate.
1109
1122
* \param error Set to NULL if creation is successful, set to an error
1110
1123
* message otherwise. The caller is responsible for calling free() on the
1111
1124
* error message.
@@ -1210,7 +1223,7 @@ DART_EXPORT void* Dart_CurrentIsolateGroupData(void);
1210
1223
* It is the responsibility of the caller to free the returned ID.
1211
1224
*/
1212
1225
typedef int64_t Dart_IsolateGroupId ;
1213
- DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId ();
1226
+ DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId (void );
1214
1227
1215
1228
/**
1216
1229
* Returns the callback data associated with the specified isolate group. This
@@ -1228,6 +1241,17 @@ DART_EXPORT void* Dart_IsolateGroupData(Dart_Isolate isolate);
1228
1241
*/
1229
1242
DART_EXPORT Dart_Handle Dart_DebugName (void );
1230
1243
1244
+ /**
1245
+ * Returns the debugging name for the current isolate.
1246
+ *
1247
+ * This name is unique to each isolate and should only be used to make
1248
+ * debugging messages more comprehensible.
1249
+ *
1250
+ * The returned string is scope allocated and is only valid until the next call
1251
+ * to Dart_ExitScope.
1252
+ */
1253
+ DART_EXPORT const char * Dart_DebugNameToCString (void );
1254
+
1231
1255
/**
1232
1256
* Returns the ID for an isolate which is used to query the service protocol.
1233
1257
*
@@ -1270,6 +1294,79 @@ DART_EXPORT void Dart_KillIsolate(Dart_Isolate isolate);
1270
1294
*/
1271
1295
DART_EXPORT void Dart_NotifyIdle (int64_t deadline );
1272
1296
1297
+ typedef void (* Dart_HeapSamplingReportCallback )(void * context ,
1298
+ void * data );
1299
+
1300
+ typedef void * (* Dart_HeapSamplingCreateCallback )(
1301
+ Dart_Isolate isolate ,
1302
+ Dart_IsolateGroup isolate_group ,
1303
+ const char * cls_name ,
1304
+ intptr_t allocation_size );
1305
+ typedef void (* Dart_HeapSamplingDeleteCallback )(void * data );
1306
+
1307
+ /**
1308
+ * Starts the heap sampling profiler for each thread in the VM.
1309
+ */
1310
+ DART_EXPORT void Dart_EnableHeapSampling (void );
1311
+
1312
+ /*
1313
+ * Stops the heap sampling profiler for each thread in the VM.
1314
+ */
1315
+ DART_EXPORT void Dart_DisableHeapSampling (void );
1316
+
1317
+ /* Registers callbacks are invoked once per sampled allocation upon object
1318
+ * allocation and garbage collection.
1319
+ *
1320
+ * |create_callback| can be used to associate additional data with the sampled
1321
+ * allocation, such as a stack trace. This data pointer will be passed to
1322
+ * |delete_callback| to allow for proper disposal when the object associated
1323
+ * with the allocation sample is collected.
1324
+ *
1325
+ * The provided callbacks must not call into the VM and should do as little
1326
+ * work as possible to avoid performance penalities during object allocation and
1327
+ * garbage collection.
1328
+ *
1329
+ * NOTE: It is a fatal error to set either callback to null once they have been
1330
+ * initialized.
1331
+ */
1332
+ DART_EXPORT void Dart_RegisterHeapSamplingCallback (
1333
+ Dart_HeapSamplingCreateCallback create_callback ,
1334
+ Dart_HeapSamplingDeleteCallback delete_callback );
1335
+
1336
+ /*
1337
+ * Reports the surviving allocation samples for all live isolate groups in the
1338
+ * VM.
1339
+ *
1340
+ * When the callback is invoked:
1341
+ * - |context| will be the context object provided when invoking
1342
+ * |Dart_ReportSurvivingAllocations|. This can be safely set to null if not
1343
+ * required.
1344
+ * - |heap_size| will be equal to the size of the allocated object associated
1345
+ * with the sample.
1346
+ * - |cls_name| will be a C String representing
1347
+ * the class name of the allocated object. This string is valid for the
1348
+ * duration of the call to Dart_ReportSurvivingAllocations and can be
1349
+ * freed by the VM at any point after the method returns.
1350
+ * - |data| will be set to the data associated with the sample by
1351
+ * |Dart_HeapSamplingCreateCallback|.
1352
+ *
1353
+ * If |force_gc| is true, a full GC will be performed before reporting the
1354
+ * allocations.
1355
+ */
1356
+ DART_EXPORT void Dart_ReportSurvivingAllocations (
1357
+ Dart_HeapSamplingReportCallback callback ,
1358
+ void * context ,
1359
+ bool force_gc );
1360
+
1361
+ /*
1362
+ * Sets the average heap sampling rate based on a number of |bytes| for each
1363
+ * thread.
1364
+ *
1365
+ * In other words, approximately every |bytes| allocated will create a sample.
1366
+ * Defaults to 512 KiB.
1367
+ */
1368
+ DART_EXPORT void Dart_SetHeapSamplingPeriod (intptr_t bytes );
1369
+
1273
1370
/**
1274
1371
* Notifies the VM that the embedder expects the application's working set has
1275
1372
* recently shrunk significantly and is not expected to rise in the near future.
@@ -1328,7 +1425,7 @@ DART_EXPORT void Dart_StartProfiling(void);
1328
1425
/**
1329
1426
* Stops the CPU sampling profiler.
1330
1427
*
1331
- * Note that some profile samples might still be taken after this fucntion
1428
+ * Note that some profile samples might still be taken after this function
1332
1429
* returns due to the asynchronous nature of the implementation on some
1333
1430
* platforms.
1334
1431
*/
@@ -1663,8 +1760,8 @@ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop(void);
1663
1760
* \param error A non-NULL pointer which will hold an error message if the call
1664
1761
* fails. The error has to be free()ed by the caller.
1665
1762
*
1666
- * \return If successful the VM takes owernship of the isolate and takes care
1667
- * of its message loop. If not successful the caller retains owernship of the
1763
+ * \return If successful the VM takes ownership of the isolate and takes care
1764
+ * of its message loop. If not successful the caller retains ownership of the
1668
1765
* isolate.
1669
1766
*/
1670
1767
DART_EXPORT DART_WARN_UNUSED_RESULT bool Dart_RunLoopAsync (
@@ -1924,7 +2021,7 @@ DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function);
1924
2021
DART_EXPORT Dart_Handle Dart_FunctionOwner (Dart_Handle function );
1925
2022
1926
2023
/**
1927
- * Determines whether a function handle referes to a static function
2024
+ * Determines whether a function handle refers to a static function
1928
2025
* of method.
1929
2026
*
1930
2027
* For the purposes of the embedding API, a top-level function is
@@ -3456,7 +3553,7 @@ DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library);
3456
3553
* \param number_of_type_arguments Number of type arguments.
3457
3554
* For non parametric types the number of type arguments would be 0.
3458
3555
* \param type_arguments Pointer to an array of type arguments.
3459
- * For non parameteric types a NULL would be passed in for this argument.
3556
+ * For non parametric types a NULL would be passed in for this argument.
3460
3557
*
3461
3558
* \return If no error occurs, the type is returned.
3462
3559
* Otherwise an error handle is returned.
@@ -3475,7 +3572,7 @@ DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library,
3475
3572
* \param number_of_type_arguments Number of type arguments.
3476
3573
* For non parametric types the number of type arguments would be 0.
3477
3574
* \param type_arguments Pointer to an array of type arguments.
3478
- * For non parameteric types a NULL would be passed in for this argument.
3575
+ * For non parametric types a NULL would be passed in for this argument.
3479
3576
*
3480
3577
* \return If no error occurs, the type is returned.
3481
3578
* Otherwise an error handle is returned.
@@ -3494,7 +3591,7 @@ DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library,
3494
3591
* \param number_of_type_arguments Number of type arguments.
3495
3592
* For non parametric types the number of type arguments would be 0.
3496
3593
* \param type_arguments Pointer to an array of type arguments.
3497
- * For non parameteric types a NULL would be passed in for this argument.
3594
+ * For non parametric types a NULL would be passed in for this argument.
3498
3595
*
3499
3596
* \return If no error occurs, the type is returned.
3500
3597
* Otherwise an error handle is returned.
@@ -3598,6 +3695,8 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library,
3598
3695
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
3599
3696
Dart_LoadLibraryFromKernel (const uint8_t * kernel_buffer ,
3600
3697
intptr_t kernel_buffer_size );
3698
+ DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
3699
+ Dart_LoadLibrary (Dart_Handle kernel_buffer );
3601
3700
3602
3701
/**
3603
3702
* Indicates that all outstanding load requests have been satisfied.
@@ -3730,43 +3829,6 @@ Dart_CompileToKernel(const char* script_uri,
3730
3829
const char * package_config ,
3731
3830
Dart_KernelCompilationVerbosityLevel verbosity );
3732
3831
3733
- /**
3734
- * Compiles the given `script_uri` to a kernel file.
3735
- *
3736
- * \param platform_kernel A buffer containing the kernel of the platform (e.g.
3737
- * `vm_platform_strong.dill`). The VM does not take ownership of this memory.
3738
- *
3739
- * \param platform_kernel_size The length of the platform_kernel buffer.
3740
- *
3741
- * \param snapshot_compile Set to `true` when the compilation is for a snapshot.
3742
- * This is used by the frontend to determine if compilation related information
3743
- * should be printed to console (e.g., null safety mode).
3744
- *
3745
- * \param null_safety Provides null-safety mode setting for the compiler.
3746
- *
3747
- * \param verbosity Specifies the logging behavior of the kernel compilation
3748
- * service.
3749
- *
3750
- * \return Returns the result of the compilation.
3751
- *
3752
- * On a successful compilation the returned [Dart_KernelCompilationResult] has
3753
- * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size`
3754
- * fields are set. The caller takes ownership of the malloc()ed buffer.
3755
- *
3756
- * On a failed compilation the `error` might be set describing the reason for
3757
- * the failed compilation. The caller takes ownership of the malloc()ed
3758
- * error.
3759
- */
3760
- DART_EXPORT Dart_KernelCompilationResult
3761
- Dart_CompileToKernelWithGivenNullsafety (
3762
- const char * script_uri ,
3763
- const uint8_t * platform_kernel ,
3764
- const intptr_t platform_kernel_size ,
3765
- bool snapshot_compile ,
3766
- const char * package_config ,
3767
- const bool null_safety ,
3768
- Dart_KernelCompilationVerbosityLevel verbosity );
3769
-
3770
3832
typedef struct {
3771
3833
const char * uri ;
3772
3834
const char * source ;
@@ -4095,4 +4157,29 @@ DART_EXPORT void Dart_DumpNativeStackTrace(void* context);
4095
4157
*/
4096
4158
DART_EXPORT void Dart_PrepareToAbort (void );
4097
4159
4160
+ /**
4161
+ * Callback provided by the embedder that is used by the VM to
4162
+ * produce footnotes appended to DWARF stack traces.
4163
+ *
4164
+ * Whenever VM formats a stack trace as a string it would call this callback
4165
+ * passing raw program counters for each frame in the stack trace.
4166
+ *
4167
+ * Embedder can then return a string which if not-null will be appended to the
4168
+ * formatted stack trace.
4169
+ *
4170
+ * Returned string is expected to be `malloc()` allocated. VM takes ownership
4171
+ * of the returned string and will `free()` it.
4172
+ *
4173
+ * \param addresses raw program counter addresses for each frame
4174
+ * \param count number of elements in the addresses array
4175
+ */
4176
+ typedef char * (* Dart_DwarfStackTraceFootnoteCallback )(void * addresses [],
4177
+ intptr_t count );
4178
+
4179
+ /**
4180
+ * Configure DWARF stack trace footnote callback.
4181
+ */
4182
+ DART_EXPORT void Dart_SetDwarfStackTraceFootnoteCallback (
4183
+ Dart_DwarfStackTraceFootnoteCallback callback );
4184
+
4098
4185
#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
0 commit comments