| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 890319c4b351ffda756b2a3226999c5214579488..62972a58e5b83ef3c17d66484af0cdd7d7bfc802 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -36,6 +36,7 @@
|
| #include "vm/stack_frame.h"
|
| #include "vm/symbols.h"
|
| #include "vm/tags.h"
|
| +#include "vm/timeline.h"
|
| #include "vm/timer.h"
|
| #include "vm/unicode.h"
|
| #include "vm/verifier.h"
|
| @@ -5673,4 +5674,103 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
|
| Service::RegisterRootEmbedderCallback(name, callback, user_data);
|
| }
|
|
|
| +
|
| +DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label,
|
| + int64_t start_micros,
|
| + int64_t end_micros) {
|
| + Isolate* isolate = Isolate::Current();
|
| + CHECK_ISOLATE(isolate);
|
| + if (label == NULL) {
|
| + RETURN_NULL_ERROR(label);
|
| + }
|
| + if (start_micros > end_micros) {
|
| + const char* msg = "%s: start_micros must be <= end_micros";
|
| + return Api::NewError(msg, CURRENT_FUNC);
|
| + }
|
| + TimelineStream* stream = isolate->GetEmbedderStream();
|
| + ASSERT(stream != NULL);
|
| + TimelineEvent* event = stream->RecordEvent();
|
| + if (event != NULL) {
|
| + event->Duration(stream, label, start_micros, end_micros);
|
| + }
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label) {
|
| + Isolate* isolate = Isolate::Current();
|
| + CHECK_ISOLATE(isolate);
|
| + if (label == NULL) {
|
| + RETURN_NULL_ERROR(label);
|
| + }
|
| + TimelineStream* stream = isolate->GetEmbedderStream();
|
| + ASSERT(stream != NULL);
|
| + TimelineEvent* event = stream->RecordEvent();
|
| + if (event != NULL) {
|
| + event->Instant(stream, label);
|
| + }
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
|
| + int64_t* async_id) {
|
| + Isolate* isolate = Isolate::Current();
|
| + CHECK_ISOLATE(isolate);
|
| + if (label == NULL) {
|
| + RETURN_NULL_ERROR(label);
|
| + }
|
| + if (async_id == NULL) {
|
| + RETURN_NULL_ERROR(async_id);
|
| + }
|
| + *async_id = -1;
|
| + TimelineStream* stream = isolate->GetEmbedderStream();
|
| + ASSERT(stream != NULL);
|
| + TimelineEvent* event = stream->RecordEvent();
|
| + if (event != NULL) {
|
| + *async_id = event->AsyncBegin(stream, label);
|
| + }
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label,
|
| + int64_t async_id) {
|
| + if (async_id < 0) {
|
| + return Api::Success();
|
| + }
|
| + Isolate* isolate = Isolate::Current();
|
| + CHECK_ISOLATE(isolate);
|
| + if (label == NULL) {
|
| + RETURN_NULL_ERROR(label);
|
| + }
|
| + TimelineStream* stream = isolate->GetEmbedderStream();
|
| + ASSERT(stream != NULL);
|
| + TimelineEvent* event = stream->RecordEvent();
|
| + if (event != NULL) {
|
| + event->AsyncInstant(stream, label, async_id);
|
| + }
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
|
| + int64_t async_id) {
|
| + if (async_id < 0) {
|
| + return Api::Success();
|
| + }
|
| + Isolate* isolate = Isolate::Current();
|
| + CHECK_ISOLATE(isolate);
|
| + if (label == NULL) {
|
| + RETURN_NULL_ERROR(label);
|
| + }
|
| + TimelineStream* stream = isolate->GetEmbedderStream();
|
| + ASSERT(stream != NULL);
|
| + TimelineEvent* event = stream->RecordEvent();
|
| + if (event != NULL) {
|
| + event->AsyncEnd(stream, label, async_id);
|
| + }
|
| + return Api::Success();
|
| +}
|
| +
|
| } // namespace dart
|
|
|