Skip to content

Commit 9faca2f

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm] Document lifetime requirements of arguments to Dart_TimelineEvent.
Strengthen requirement on `label` to match Fuchsia. Change-Id: Iebc9e0cc7be5984ad2b94dde561b76aec64fe78a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96145 Reviewed-by: Chinmay Garde <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 295ea59 commit 9faca2f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

runtime/include/dart_tools_api.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,17 @@ typedef enum {
360360
/**
361361
* Add a timeline event to the embedder stream.
362362
*
363-
* \param label The name of the evnet.
363+
* \param label The name of the event. Its lifetime must extend at least until
364+
* Dart_Cleanup.
364365
* \param timestamp0 The first timestamp of the event.
365366
* \param timestamp1_or_async_id The second timestamp of the event or
366367
* the async id.
367368
* \param argument_count The number of argument names and values.
368-
* \param argument_names An array of names of the arguments.
369-
* \param argument_values An array of values of the arguments.
369+
* \param argument_names An array of names of the arguments. The lifetime of the
370+
* names must extend at least until Dart_Cleanup. The array may be reclaimed
371+
* when this call returns.
372+
* \param argument_values An array of values of the arguments. The values and
373+
* the array may be reclaimed when this call returns.
370374
*/
371375
DART_EXPORT void Dart_TimelineEvent(const char* label,
372376
int64_t timestamp0,

runtime/vm/dart_api_impl.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5839,7 +5839,6 @@ DART_EXPORT void Dart_TimelineEvent(const char* label,
58395839
if (event == NULL) {
58405840
return;
58415841
}
5842-
label = strdup(label);
58435842
switch (type) {
58445843
case Dart_Timeline_Event_Begin:
58455844
event->Begin(label, timestamp0);
@@ -5877,7 +5876,6 @@ DART_EXPORT void Dart_TimelineEvent(const char* label,
58775876
default:
58785877
FATAL("Unknown Dart_Timeline_Event_Type");
58795878
}
5880-
event->set_owns_label(true);
58815879
event->SetNumArguments(argument_count);
58825880
for (intptr_t i = 0; i < argument_count; i++) {
58835881
event->CopyArgument(i, argument_names[i], argument_values[i]);

0 commit comments

Comments
 (0)