Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
| index e969b5088c0332c98f9133cc923018fa8fb0ce46..46f3421da210fbe0c099f1daee28ca5ba2cf2c7d 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" |
| @@ -5668,4 +5669,97 @@ 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) { |
| + const char* msg = "%s: label cannot be null"; |
| + return Api::NewError(msg, CURRENT_FUNC); |
| + } |
| + 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) { |
| + const char* msg = "%s: label cannot be null"; |
| + return Api::NewError(msg, CURRENT_FUNC); |
| + } |
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->Instant(stream, label); |
| + } |
| + return Api::Success(); |
| +} |
| + |
| + |
| +DART_EXPORT int64_t Dart_TimelineAsyncBegin(const char* label) { |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + if (label == NULL) { |
| + FATAL1("%s: label cannot be null", CURRENT_FUNC); |
| + } |
|
siva
2015/06/16 15:42:31
Instead of FATALing out here maybe you could chang
Cutch
2015/06/16 17:08:17
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + return event->AsyncBegin(stream, label); |
| + } |
| + return -1; |
| +} |
| + |
| + |
| +DART_EXPORT void Dart_TimelineAsyncInstant(const char* label, |
| + int64_t async_id) { |
| + if (async_id < 0) { |
| + return; |
| + } |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + if (label == NULL) { |
| + FATAL1("%s: label cannot be null", CURRENT_FUNC); |
| + } |
|
siva
2015/06/16 15:42:31
Ditto.
Cutch
2015/06/16 17:08:17
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->AsyncInstant(stream, label, async_id); |
| + } |
| +} |
| + |
| + |
| +DART_EXPORT void Dart_TimelineAsyncEnd(const char* label, int64_t async_id) { |
| + if (async_id < 0) { |
| + return; |
| + } |
|
siva
2015/06/16 15:42:31
Ditto.
Cutch
2015/06/16 17:08:17
Done.
|
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + if (label == NULL) { |
| + FATAL1("%s: label cannot be null", CURRENT_FUNC); |
| + } |
|
siva
2015/06/16 15:42:31
Ditto.
Cutch
2015/06/16 17:08:17
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->AsyncEnd(stream, label, async_id); |
| + } |
| +} |
| + |
| } // namespace dart |