[jnigen] Update Dart API headers (https://github.com/dart-lang/jnigen/issues/358)

* Update Dart API
* Remove unnecessary methods in dartjni.h
diff --git a/pkgs/jni/example/pubspec.lock b/pkgs/jni/example/pubspec.lock
index c730dba..1fd2db8 100644
--- a/pkgs/jni/example/pubspec.lock
+++ b/pkgs/jni/example/pubspec.lock
@@ -200,7 +200,7 @@
       path: ".."
       relative: true
     source: path
-    version: "0.6.0-dev.2"
+    version: "0.6.0-wip.2"
   js:
     dependency: transitive
     description:
diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml
index 62b7429..782668e 100644
--- a/pkgs/jni/ffigen.yaml
+++ b/pkgs/jni/ffigen.yaml
@@ -57,9 +57,6 @@
     - 'to_global_ref_result'
     - 'wait_for'
     # keep-sorted end
-    # Native functions in Java. No need to call them from Dart.
-    - 'Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith'
-    - 'Java_com_github_dart_1lang_jni_PortProxy__1invoke'
 structs:
   exclude:
     - 'JniContext'
diff --git a/pkgs/jni/src/dartjni.h b/pkgs/jni/src/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jni/src/dartjni.h
+++ b/pkgs/jni/src/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jni/src/include/dart_api.h b/pkgs/jni/src/include/dart_api.h
index 741447a..99dde6f 100644
--- a/pkgs/jni/src/include/dart_api.h
+++ b/pkgs/jni/src/include/dart_api.h
@@ -25,6 +25,10 @@
 #include <inttypes.h>
 #include <stdbool.h>
 
+#if defined(__Fuchsia__)
+#include <zircon/types.h>
+#endif
+
 #ifdef __cplusplus
 #define DART_EXTERN_C extern "C"
 #else
@@ -849,7 +853,7 @@
  * The current version of the Dart_InitializeFlags. Should be incremented every
  * time Dart_InitializeFlags changes in a binary incompatible way.
  */
-#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000007)
+#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000008)
 
 /** Forward declaration */
 struct Dart_CodeObserver;
@@ -992,6 +996,15 @@
    * Kernel blob unregistration callback function. See Dart_UnregisterKernelBlobCallback.
    */
   Dart_UnregisterKernelBlobCallback unregister_kernel_blob;
+
+#if defined(__Fuchsia__)
+  /**
+   * The resource needed to use zx_vmo_replace_as_executable. Can be
+   * ZX_HANDLE_INVALID if the process has ambient-replace-as-executable or if
+   * executable memory is not needed (e.g., this is an AOT runtime).
+   */
+  zx_handle_t vmex_resource;
+#endif
 } Dart_InitializeParams;
 
 /**
@@ -1105,7 +1118,7 @@
  *   shutdown (may be NULL).
  * \param cleanup_callback A callback to be called when the isolate is being
  *   cleaned up (may be NULL).
- * \param isolate_data The embedder-specific data associated with this isolate.
+ * \param child_isolate_data The embedder-specific data associated with this isolate.
  * \param error Set to NULL if creation is successful, set to an error
  *   message otherwise. The caller is responsible for calling free() on the
  *   error message.
@@ -1210,7 +1223,7 @@
  * It is the responsibility of the caller to free the returned ID.
  */
 typedef int64_t Dart_IsolateGroupId;
-DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId();
+DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId(void);
 
 /**
  * Returns the callback data associated with the specified isolate group. This
@@ -1229,6 +1242,17 @@
 DART_EXPORT Dart_Handle Dart_DebugName(void);
 
 /**
+ * Returns the debugging name for the current isolate.
+ *
+ * This name is unique to each isolate and should only be used to make
+ * debugging messages more comprehensible.
+ *
+ * The returned string is scope allocated and is only valid until the next call
+ * to Dart_ExitScope.
+ */
+DART_EXPORT const char* Dart_DebugNameToCString(void);
+
+/**
  * Returns the ID for an isolate which is used to query the service protocol.
  *
  * It is the responsibility of the caller to free the returned ID.
@@ -1270,6 +1294,79 @@
  */
 DART_EXPORT void Dart_NotifyIdle(int64_t deadline);
 
+typedef void (*Dart_HeapSamplingReportCallback)(void* context,
+                                                void* data);
+
+typedef void* (*Dart_HeapSamplingCreateCallback)(
+    Dart_Isolate isolate,
+    Dart_IsolateGroup isolate_group,
+    const char* cls_name,
+    intptr_t allocation_size);
+typedef void (*Dart_HeapSamplingDeleteCallback)(void* data);
+
+/**
+ * Starts the heap sampling profiler for each thread in the VM.
+ */
+DART_EXPORT void Dart_EnableHeapSampling(void);
+
+/*
+ * Stops the heap sampling profiler for each thread in the VM.
+ */
+DART_EXPORT void Dart_DisableHeapSampling(void);
+
+/* Registers callbacks are invoked once per sampled allocation upon object
+ * allocation and garbage collection.
+ *
+ * |create_callback| can be used to associate additional data with the sampled
+ * allocation, such as a stack trace. This data pointer will be passed to
+ * |delete_callback| to allow for proper disposal when the object associated
+ * with the allocation sample is collected.
+ *
+ * The provided callbacks must not call into the VM and should do as little
+ * work as possible to avoid performance penalities during object allocation and
+ * garbage collection.
+ *
+ * NOTE: It is a fatal error to set either callback to null once they have been
+ * initialized.
+ */
+DART_EXPORT void Dart_RegisterHeapSamplingCallback(
+    Dart_HeapSamplingCreateCallback create_callback,
+    Dart_HeapSamplingDeleteCallback delete_callback);
+
+/*
+ * Reports the surviving allocation samples for all live isolate groups in the
+ * VM.
+ *
+ * When the callback is invoked:
+ *  - |context| will be the context object provided when invoking
+ *    |Dart_ReportSurvivingAllocations|. This can be safely set to null if not
+ *    required.
+ *  - |heap_size| will be equal to the size of the allocated object associated
+ *    with the sample.
+ *  - |cls_name| will be a C String representing
+ *    the class name of the allocated object. This string is valid for the
+ *    duration of the call to Dart_ReportSurvivingAllocations and can be
+ *    freed by the VM at any point after the method returns.
+ *  - |data| will be set to the data associated with the sample by
+ *    |Dart_HeapSamplingCreateCallback|.
+ *
+ * If |force_gc| is true, a full GC will be performed before reporting the
+ * allocations.
+ */
+DART_EXPORT void Dart_ReportSurvivingAllocations(
+    Dart_HeapSamplingReportCallback callback,
+    void* context,
+    bool force_gc);
+
+/*
+ * Sets the average heap sampling rate based on a number of |bytes| for each
+ * thread.
+ *
+ * In other words, approximately every |bytes| allocated will create a sample.
+ * Defaults to 512 KiB.
+ */
+DART_EXPORT void Dart_SetHeapSamplingPeriod(intptr_t bytes);
+
 /**
  * Notifies the VM that the embedder expects the application's working set has
  * recently shrunk significantly and is not expected to rise in the near future.
@@ -1328,7 +1425,7 @@
 /**
  * Stops the CPU sampling profiler.
  *
- * Note that some profile samples might still be taken after this fucntion
+ * Note that some profile samples might still be taken after this function
  * returns due to the asynchronous nature of the implementation on some
  * platforms.
  */
@@ -1663,8 +1760,8 @@
  * \param error A non-NULL pointer which will hold an error message if the call
  *   fails. The error has to be free()ed by the caller.
  *
- * \return If successful the VM takes owernship of the isolate and takes care
- *   of its message loop. If not successful the caller retains owernship of the
+ * \return If successful the VM takes ownership of the isolate and takes care
+ *   of its message loop. If not successful the caller retains ownership of the
  *   isolate.
  */
 DART_EXPORT DART_WARN_UNUSED_RESULT bool Dart_RunLoopAsync(
@@ -1924,7 +2021,7 @@
 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function);
 
 /**
- * Determines whether a function handle referes to a static function
+ * Determines whether a function handle refers to a static function
  * of method.
  *
  * For the purposes of the embedding API, a top-level function is
@@ -3456,7 +3553,7 @@
  * \param number_of_type_arguments Number of type arguments.
  *   For non parametric types the number of type arguments would be 0.
  * \param type_arguments Pointer to an array of type arguments.
- *   For non parameteric types a NULL would be passed in for this argument.
+ *   For non parametric types a NULL would be passed in for this argument.
  *
  * \return If no error occurs, the type is returned.
  *   Otherwise an error handle is returned.
@@ -3475,7 +3572,7 @@
  * \param number_of_type_arguments Number of type arguments.
  *   For non parametric types the number of type arguments would be 0.
  * \param type_arguments Pointer to an array of type arguments.
- *   For non parameteric types a NULL would be passed in for this argument.
+ *   For non parametric types a NULL would be passed in for this argument.
  *
  * \return If no error occurs, the type is returned.
  *   Otherwise an error handle is returned.
@@ -3494,7 +3591,7 @@
  * \param number_of_type_arguments Number of type arguments.
  *   For non parametric types the number of type arguments would be 0.
  * \param type_arguments Pointer to an array of type arguments.
- *   For non parameteric types a NULL would be passed in for this argument.
+ *   For non parametric types a NULL would be passed in for this argument.
  *
  * \return If no error occurs, the type is returned.
  *   Otherwise an error handle is returned.
@@ -3598,6 +3695,8 @@
 DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
 Dart_LoadLibraryFromKernel(const uint8_t* kernel_buffer,
                            intptr_t kernel_buffer_size);
+DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle
+Dart_LoadLibrary(Dart_Handle kernel_buffer);
 
 /**
  * Indicates that all outstanding load requests have been satisfied.
@@ -3730,43 +3829,6 @@
                      const char* package_config,
                      Dart_KernelCompilationVerbosityLevel verbosity);
 
-/**
- * Compiles the given `script_uri` to a kernel file.
- *
- * \param platform_kernel A buffer containing the kernel of the platform (e.g.
- * `vm_platform_strong.dill`). The VM does not take ownership of this memory.
- *
- * \param platform_kernel_size The length of the platform_kernel buffer.
- *
- * \param snapshot_compile Set to `true` when the compilation is for a snapshot.
- * This is used by the frontend to determine if compilation related information
- * should be printed to console (e.g., null safety mode).
- *
- * \param null_safety Provides null-safety mode setting for the compiler.
- *
- * \param verbosity Specifies the logging behavior of the kernel compilation
- * service.
- *
- * \return Returns the result of the compilation.
- *
- * On a successful compilation the returned [Dart_KernelCompilationResult] has
- * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size`
- * fields are set. The caller takes ownership of the malloc()ed buffer.
- *
- * On a failed compilation the `error` might be set describing the reason for
- * the failed compilation. The caller takes ownership of the malloc()ed
- * error.
- */
-DART_EXPORT Dart_KernelCompilationResult
-Dart_CompileToKernelWithGivenNullsafety(
-    const char* script_uri,
-    const uint8_t* platform_kernel,
-    const intptr_t platform_kernel_size,
-    bool snapshot_compile,
-    const char* package_config,
-    const bool null_safety,
-    Dart_KernelCompilationVerbosityLevel verbosity);
-
 typedef struct {
   const char* uri;
   const char* source;
@@ -4095,4 +4157,29 @@
  */
 DART_EXPORT void Dart_PrepareToAbort(void);
 
+/**
+ * Callback provided by the embedder that is used by the VM to
+ * produce footnotes appended to DWARF stack traces.
+ *
+ * Whenever VM formats a stack trace as a string it would call this callback
+ * passing raw program counters for each frame in the stack trace.
+ *
+ * Embedder can then return a string which if not-null will be appended to the
+ * formatted stack trace.
+ *
+ * Returned string is expected to be `malloc()` allocated. VM takes ownership
+ * of the returned string and will `free()` it.
+ *
+ * \param addresses raw program counter addresses for each frame
+ * \param count number of elements in the addresses array
+ */
+typedef char* (*Dart_DwarfStackTraceFootnoteCallback)(void* addresses[],
+                                                      intptr_t count);
+
+/**
+ *  Configure DWARF stack trace footnote callback.
+ */
+DART_EXPORT void Dart_SetDwarfStackTraceFootnoteCallback(
+    Dart_DwarfStackTraceFootnoteCallback callback);
+
 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
diff --git a/pkgs/jni/src/include/dart_api_dl.h b/pkgs/jni/src/include/dart_api_dl.h
index 804b281..cce3450 100644
--- a/pkgs/jni/src/include/dart_api_dl.h
+++ b/pkgs/jni/src/include/dart_api_dl.h
@@ -29,7 +29,7 @@
 // DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION.
 //
 // Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types
-// to trigger compile-time errors if the sybols in those files are updated
+// to trigger compile-time errors if the symbols in those files are updated
 // without updating these.
 //
 // Function return and argument types, and typedefs are carbon copied. Structs
@@ -90,6 +90,10 @@
   F(Dart_UpdateFinalizableExternalSize, void,                                  \
     (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object,          \
      intptr_t external_allocation_size))                                       \
+  /* Isolates */                                                               \
+  F(Dart_CurrentIsolate, Dart_Isolate, (void))                                 \
+  F(Dart_ExitIsolate, void, (void))                                            \
+  F(Dart_EnterIsolate, void, (Dart_Isolate))                                   \
   /* Dart_Port */                                                              \
   F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object))               \
   F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id))                     \
@@ -97,7 +101,9 @@
     (Dart_Handle port, Dart_Port_DL * port_id))                                \
   /* Scopes */                                                                 \
   F(Dart_EnterScope, void, (void))                                             \
-  F(Dart_ExitScope, void, (void))
+  F(Dart_ExitScope, void, (void))                                              \
+  /* Objects */                                                                \
+  F(Dart_IsNull, bool, (Dart_Handle))
 
 #define DART_API_ALL_DL_SYMBOLS(F)                                             \
   DART_NATIVE_API_DL_SYMBOLS(F)                                                \
diff --git a/pkgs/jni/src/include/dart_native_api.h b/pkgs/jni/src/include/dart_native_api.h
index 318a4b7..79194e0 100644
--- a/pkgs/jni/src/include/dart_native_api.h
+++ b/pkgs/jni/src/include/dart_native_api.h
@@ -50,13 +50,15 @@
   Dart_CObject_kArray,
   Dart_CObject_kTypedData,
   Dart_CObject_kExternalTypedData,
-  Dart_CObject_kUnmodifiableExternalTypedData,
   Dart_CObject_kSendPort,
   Dart_CObject_kCapability,
   Dart_CObject_kNativePointer,
   Dart_CObject_kUnsupported,
+  Dart_CObject_kUnmodifiableExternalTypedData,
   Dart_CObject_kNumberOfTypes
 } Dart_CObject_Type;
+// This enum is versioned by DART_API_DL_MAJOR_VERSION, only add at the end
+// and bump the DART_API_DL_MINOR_VERSION.
 
 typedef struct _Dart_CObject {
   Dart_CObject_Type type;
@@ -65,7 +67,7 @@
     int32_t as_int32;
     int64_t as_int64;
     double as_double;
-    char* as_string;
+    const char* as_string;
     struct {
       Dart_Port id;
       Dart_Port origin_id;
diff --git a/pkgs/jni/src/include/dart_tools_api.h b/pkgs/jni/src/include/dart_tools_api.h
index 90687f6..7b706bc 100644
--- a/pkgs/jni/src/include/dart_tools_api.h
+++ b/pkgs/jni/src/include/dart_tools_api.h
@@ -143,7 +143,7 @@
  * \return Returns a pointer to a Dart_EmbedderInformation structure.
  * The embedder keeps the ownership of the structure and any field in it.
  * The embedder must ensure that the structure will remain valid until the
- * next invokation of the callback.
+ * next invocation of the callback.
  */
 typedef void (*Dart_EmbedderInformationCallback)(
     Dart_EmbedderInformation* info);
@@ -254,70 +254,6 @@
                                             const uint8_t* bytes,
                                             intptr_t bytes_length);
 
-/**
- * Usage statistics for a space/generation at a particular moment in time.
- *
- * \param used Amount of memory used, in bytes.
- *
- * \param capacity Memory capacity, in bytes.
- *
- * \param external External memory, in bytes.
- *
- * \param collections How many times the garbage collector has run in this
- *   space.
- *
- * \param time Cumulative time spent collecting garbage in this space, in
- *   seconds.
- *
- * \param avg_collection_period Average time between garbage collector running
- *   in this space, in milliseconds.
- */
-typedef struct {
-  intptr_t used;
-  intptr_t capacity;
-  intptr_t external;
-  intptr_t collections;
-  double time;
-  double avg_collection_period;
-} Dart_GCStats;
-
-/**
- * A Garbage Collection event with memory usage statistics.
- *
- * \param type The event type. Static lifetime.
- *
- * \param reason The reason for the GC event. Static lifetime.
- *
- * \param new_space Data for New Space.
- *
- * \param old_space Data for Old Space.
- */
-typedef struct {
-  const char* type;
-  const char* reason;
-
-  Dart_IsolateGroupId isolate_group_id;
-
-  Dart_GCStats new_space;
-  Dart_GCStats old_space;
-} Dart_GCEvent;
-
-/**
- * A callback invoked when the VM emits a GC event.
- *
- * \param event The GC event data. Pointer only valid for the duration of the
- *   callback.
- */
-typedef void (*Dart_GCEventCallback)(Dart_GCEvent* event);
-
-/**
- * Sets the native GC event callback.
- *
- * \param callback A function pointer to an event handler callback function.
- *   A NULL value removes the existing listen callback function if any.
- */
-DART_EXPORT void Dart_SetGCEventCallback(Dart_GCEventCallback callback);
-
 /*
  * ========
  * Reload support
@@ -364,12 +300,12 @@
  *   "Embedder" - Execution of Dart embedder code
  *   "GC" - Execution of Dart Garbage Collector
  *   "Isolate" - Dart Isolate lifecycle execution
- *   "VM" - Excution in Dart VM runtime code
+ *   "VM" - Execution in Dart VM runtime code
  *   "" - None
  *
  *  When "all" is specified all the categories are enabled.
  *  When a comma separated list of categories is specified, the categories
- *   that are specified will be enabled and the rest will be disabled. 
+ *   that are specified will be enabled and the rest will be disabled.
  *  When "" is specified all the categories are disabled.
  *  The category names are case sensitive.
  *  eg:  Dart_EnableTimelineCategory("all");
@@ -420,11 +356,26 @@
 /**
  * Add a timeline event to the embedder stream.
  *
+ * DEPRECATED: this function will be removed in Dart SDK v3.2.
+ *
  * \param label The name of the event. Its lifetime must extend at least until
  *     Dart_Cleanup.
  * \param timestamp0 The first timestamp of the event.
- * \param timestamp1_or_async_id The second timestamp of the event or
- *     the async id.
+ * \param timestamp1_or_id When reporting an event of type
+ *     |Dart_Timeline_Event_Duration|, the second (end) timestamp of the event
+ *     should be passed through |timestamp1_or_id|. When reporting an event of
+ *     type |Dart_Timeline_Event_Async_Begin|, |Dart_Timeline_Event_Async_End|,
+ *     or |Dart_Timeline_Event_Async_Instant|, the async ID associated with the
+ *     event should be passed through |timestamp1_or_id|. When reporting an
+ *     event of type |Dart_Timeline_Event_Flow_Begin|,
+ *     |Dart_Timeline_Event_Flow_Step|, or |Dart_Timeline_Event_Flow_End|, the
+ *     flow ID associated with the event should be passed through
+ *     |timestamp1_or_id|. When reporting an event of type
+ *     |Dart_Timeline_Event_Begin| or |Dart_Timeline_Event_End|, the event ID
+ *     associated with the event should be passed through |timestamp1_or_id|.
+ *     Note that this event ID will only be used by the MacOS recorder. The
+ *     argument to |timestamp1_or_id| will not be used when reporting events of
+ *     other types.
  * \param argument_count The number of argument names and values.
  * \param argument_names An array of names of the arguments. The lifetime of the
  *     names must extend at least until Dart_Cleanup. The array may be reclaimed
@@ -434,13 +385,65 @@
  */
 DART_EXPORT void Dart_TimelineEvent(const char* label,
                                     int64_t timestamp0,
-                                    int64_t timestamp1_or_async_id,
+                                    int64_t timestamp1_or_id,
                                     Dart_Timeline_Event_Type type,
                                     intptr_t argument_count,
                                     const char** argument_names,
                                     const char** argument_values);
 
 /**
+ * Add a timeline event to the embedder stream.
+ *
+ * Note regarding flow events: events must be associated with flow IDs in two
+ * different ways to allow flow events to be serialized correctly in both
+ * Chrome's JSON trace event format and Perfetto's proto trace format. Events
+ * of type |Dart_Timeline_Event_Flow_Begin|, |Dart_Timeline_Event_Flow_Step|,
+ * and |Dart_Timeline_Event_Flow_End| must be reported to support serialization
+ * in Chrome's trace format. The |flow_ids| argument must be supplied when
+ * reporting events of type |Dart_Timeline_Event_Begin|,
+ * |Dart_Timeline_Event_Duration|, |Dart_Timeline_Event_Instant|,
+ * |Dart_Timeline_Event_Async_Begin|, and |Dart_Timeline_Event_Async_Instant| to
+ * support serialization in Perfetto's proto format.
+ *
+ * \param label The name of the event. Its lifetime must extend at least until
+ *     Dart_Cleanup.
+ * \param timestamp0 The first timestamp of the event.
+ * \param timestamp1_or_id When reporting an event of type
+ *     |Dart_Timeline_Event_Duration|, the second (end) timestamp of the event
+ *     should be passed through |timestamp1_or_id|. When reporting an event of
+ *     type |Dart_Timeline_Event_Async_Begin|, |Dart_Timeline_Event_Async_End|,
+ *     or |Dart_Timeline_Event_Async_Instant|, the async ID associated with the
+ *     event should be passed through |timestamp1_or_id|. When reporting an
+ *     event of type |Dart_Timeline_Event_Flow_Begin|,
+ *     |Dart_Timeline_Event_Flow_Step|, or |Dart_Timeline_Event_Flow_End|, the
+ *     flow ID associated with the event should be passed through
+ *     |timestamp1_or_id|. When reporting an event of type
+ *     |Dart_Timeline_Event_Begin| or |Dart_Timeline_Event_End|, the event ID
+ *     associated with the event should be passed through |timestamp1_or_id|.
+ *     Note that this event ID will only be used by the MacOS recorder. The
+ *     argument to |timestamp1_or_id| will not be used when reporting events of
+ *     other types.
+ * \param flow_id_count The number of flow IDs associated with this event.
+ * \param flow_ids An array of flow IDs associated with this event. The array
+ *     may be reclaimed when this call returns.
+ * \param argument_count The number of argument names and values.
+ * \param argument_names An array of names of the arguments. The lifetime of the
+ *     names must extend at least until Dart_Cleanup. The array may be reclaimed
+ *     when this call returns.
+ * \param argument_values An array of values of the arguments. The values and
+ *     the array may be reclaimed when this call returns.
+ */
+DART_EXPORT void Dart_RecordTimelineEvent(const char* label,
+                                          int64_t timestamp0,
+                                          int64_t timestamp1_or_id,
+                                          intptr_t flow_id_count,
+                                          const int64_t* flow_ids,
+                                          Dart_Timeline_Event_Type type,
+                                          intptr_t argument_count,
+                                          const char** argument_names,
+                                          const char** argument_values);
+
+/**
  * Associates a name with the current thread. This name will be used to name
  * threads in the timeline. Can only be called after a call to Dart_Initialize.
  *
@@ -453,7 +456,7 @@
   const char* value;
 } Dart_TimelineRecorderEvent_Argument;
 
-#define DART_TIMELINE_RECORDER_CURRENT_VERSION (0x00000001)
+#define DART_TIMELINE_RECORDER_CURRENT_VERSION (0x00000002)
 
 typedef struct {
   /* Set to DART_TIMELINE_RECORDER_CURRENT_VERSION */
@@ -467,9 +470,12 @@
    */
   int64_t timestamp0;
 
-  /* For a duration event, this is the end time. For an async event, this is the
-   * async id. */
-  int64_t timestamp1_or_async_id;
+  /**
+   * For a duration event, this is the end time. For an async event, this is the
+   * async ID. For a flow event, this is the flow ID. For a begin or end event,
+   * this is the event ID (which is only referenced by the MacOS recorder).
+   */
+  int64_t timestamp1_or_id;
 
   /* The current isolate of the event, as if by Dart_GetMainPortId, or
    * ILLEGAL_PORT if the event had no current isolate. */
@@ -480,6 +486,12 @@
    * isolate group. */
   Dart_IsolateGroupId isolate_group;
 
+  /* The callback data associated with the isolate if any. */
+  void* isolate_data;
+
+  /* The callback data associated with the isolate group if any. */
+  void* isolate_group_data;
+
   /* The name / label of the event. */
   const char* label;
 
@@ -518,7 +530,7 @@
  * will be remembered. Providing a NULL callback will clear the registration
  * (i.e., a NULL callback produced a no-op instead of a crash).
  *
- * Setting a callback is insuffient to receive events through the callback. The
+ * Setting a callback is insufficient to receive events through the callback. The
  * VM flag `timeline_recorder` must also be set to `callback`.
  */
 DART_EXPORT void Dart_SetTimelineRecorderCallback(
@@ -532,41 +544,19 @@
 
 /**
  * Return metrics gathered for the VM and individual isolates.
- *
- * NOTE: Non-heap metrics are not available in PRODUCT builds of Dart.
- * Calling the non-heap metric functions on a PRODUCT build might return invalid metrics.
  */
-DART_EXPORT int64_t Dart_VMIsolateCountMetric();  // Counter
-DART_EXPORT int64_t Dart_VMCurrentRSSMetric();    // Byte
-DART_EXPORT int64_t Dart_VMPeakRSSMetric();       // Byte
 DART_EXPORT int64_t
 Dart_IsolateGroupHeapOldUsedMetric(Dart_IsolateGroup group);  // Byte
 DART_EXPORT int64_t
-Dart_IsolateGroupHeapOldUsedMaxMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
 Dart_IsolateGroupHeapOldCapacityMetric(Dart_IsolateGroup group);  // Byte
 DART_EXPORT int64_t
-Dart_IsolateGroupHeapOldCapacityMaxMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
 Dart_IsolateGroupHeapOldExternalMetric(Dart_IsolateGroup group);  // Byte
 DART_EXPORT int64_t
 Dart_IsolateGroupHeapNewUsedMetric(Dart_IsolateGroup group);  // Byte
 DART_EXPORT int64_t
-Dart_IsolateGroupHeapNewUsedMaxMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
 Dart_IsolateGroupHeapNewCapacityMetric(Dart_IsolateGroup group);  // Byte
 DART_EXPORT int64_t
-Dart_IsolateGroupHeapNewCapacityMaxMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
 Dart_IsolateGroupHeapNewExternalMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
-Dart_IsolateGroupHeapGlobalUsedMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
-Dart_IsolateGroupHeapGlobalUsedMaxMetric(Dart_IsolateGroup group);  // Byte
-DART_EXPORT int64_t
-Dart_IsolateRunnableLatencyMetric(Dart_Isolate isolate);  // Microsecond
-DART_EXPORT int64_t
-Dart_IsolateRunnableHeapSizeMetric(Dart_Isolate isolate);  // Byte
 
 /*
  * ========
@@ -617,4 +607,52 @@
 DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_GetUserTagLabel(
     Dart_Handle user_tag);
 
+/*
+ * =======
+ * Heap Snapshot
+ * =======
+ */
+
+/**
+ * Callback provided by the caller of `Dart_WriteHeapSnapshot` which is
+ * used to write out chunks of the requested heap snapshot.
+ *
+ * \param context An opaque context which was passed to `Dart_WriteHeapSnapshot`
+ *   together with this callback.
+ *
+ * \param buffer Pointer to the buffer containing a chunk of the snapshot.
+ *   The callback owns the buffer and needs to `free` it.
+ *
+ * \param size Number of bytes in the `buffer` to be written.
+ *
+ * \param is_last Set to `true` for the last chunk. The callback will not
+ *   be invoked again after it was invoked once with `is_last` set to `true`.
+ */
+typedef void (*Dart_HeapSnapshotWriteChunkCallback)(void* context,
+                                                    uint8_t* buffer,
+                                                    intptr_t size,
+                                                    bool is_last);
+
+/**
+ * Generate heap snapshot of the current isolate group and stream it into the
+ * given `callback`. VM would produce snapshot in chunks and send these chunks
+ * one by one back to the embedder by invoking the provided `callback`.
+ *
+ * This API enables embedder to stream snapshot into a file or socket without
+ * allocating a buffer to hold the whole snapshot in memory.
+ *
+ * The isolate group will be paused for the duration of this operation.
+ *
+ * \param write Callback used to write chunks of the heap snapshot.
+ *
+ * \param context Opaque context which would be passed on each invocation of
+ *   `write` callback.
+ *
+ * \returns `nullptr` if the operation is successful otherwise error message.
+ *   Caller owns error message string and needs to `free` it.
+ */
+DART_EXPORT char* Dart_WriteHeapSnapshot(
+    Dart_HeapSnapshotWriteChunkCallback write,
+    void* context);
+
 #endif  // RUNTIME_INCLUDE_DART_TOOLS_API_H_
diff --git a/pkgs/jni/src/include/dart_version.h b/pkgs/jni/src/include/dart_version.h
index b3b4924..e2d3651 100644
--- a/pkgs/jni/src/include/dart_version.h
+++ b/pkgs/jni/src/include/dart_version.h
@@ -11,6 +11,6 @@
 // On backwards compatible changes the minor version is increased.
 // The versioning covers the symbols exposed in dart_api_dl.h
 #define DART_API_DL_MAJOR_VERSION 2
-#define DART_API_DL_MINOR_VERSION 0
+#define DART_API_DL_MINOR_VERSION 3
 
 #endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */
diff --git a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h
+++ b/pkgs/jnigen/example/in_app_java/src/android_utils/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h
+++ b/pkgs/jnigen/example/kotlin_plugin/src/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/example/notification_plugin/src/dartjni.h b/pkgs/jnigen/example/notification_plugin/src/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/example/notification_plugin/src/dartjni.h
+++ b/pkgs/jnigen/example/notification_plugin/src/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h
+++ b/pkgs/jnigen/example/pdfbox_plugin/src/third_party/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h
+++ b/pkgs/jnigen/test/jackson_core_test/third_party/c_based/c_bindings/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h
+++ b/pkgs/jnigen/test/kotlin_test/c_based/c_bindings/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);
diff --git a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h
index 8a07d09..cca31f4 100644
--- a/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h
+++ b/pkgs/jnigen/test/simple_package_test/c_based/c_bindings/dartjni.h
@@ -422,11 +422,6 @@
 
 FFI_PLUGIN_EXPORT void resultFor(CallbackResult* result, jobject object);
 
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortContinuation__1resumeWith(JNIEnv* env,
-                                                             jobject thiz,
-                                                             jlong port,
-                                                             jobject result);
 FFI_PLUGIN_EXPORT
 JniResult PortContinuation__ctor(int64_t j);
 
@@ -434,18 +429,3 @@
 JniResult PortProxy__newInstance(jobject binaryName,
                                  int64_t port,
                                  int64_t functionPtr);
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1invoke(JNIEnv* env,
-                                                  jobject thiz,
-                                                  jlong port,
-                                                  jlong threadId,
-                                                  jlong functionPtr,
-                                                  jobject proxy,
-                                                  jstring methodDescriptor,
-                                                  jobjectArray args);
-
-JNIEXPORT void JNICALL
-Java_com_github_dart_1lang_jni_PortProxy__1cleanUp(JNIEnv* env,
-                                                   jobject thiz,
-                                                   jlong resultPtr);