Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 1173333007: Refactor some Timeline interfaces to be simpler and support streaming (Closed) Base URL: git@github.com:dart-lang/sdk.git@timeline2
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 5671 matching lines...) Expand 10 before | Expand all | Expand 10 after
5682 CHECK_ISOLATE(isolate); 5682 CHECK_ISOLATE(isolate);
5683 if (label == NULL) { 5683 if (label == NULL) {
5684 RETURN_NULL_ERROR(label); 5684 RETURN_NULL_ERROR(label);
5685 } 5685 }
5686 if (start_micros > end_micros) { 5686 if (start_micros > end_micros) {
5687 const char* msg = "%s: start_micros must be <= end_micros"; 5687 const char* msg = "%s: start_micros must be <= end_micros";
5688 return Api::NewError(msg, CURRENT_FUNC); 5688 return Api::NewError(msg, CURRENT_FUNC);
5689 } 5689 }
5690 TimelineStream* stream = isolate->GetEmbedderStream(); 5690 TimelineStream* stream = isolate->GetEmbedderStream();
5691 ASSERT(stream != NULL); 5691 ASSERT(stream != NULL);
5692 TimelineEvent* event = stream->RecordEvent(); 5692 TimelineEvent* event = stream->StartEvent();
5693 if (event != NULL) { 5693 if (event != NULL) {
5694 event->Duration(stream, label, start_micros, end_micros); 5694 event->Duration(label, start_micros, end_micros);
5695 event->Complete();
5695 } 5696 }
5696 return Api::Success(); 5697 return Api::Success();
5697 } 5698 }
5698 5699
5699 5700
5700 DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label) { 5701 DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label) {
5701 Isolate* isolate = Isolate::Current(); 5702 Isolate* isolate = Isolate::Current();
5702 CHECK_ISOLATE(isolate); 5703 CHECK_ISOLATE(isolate);
5703 if (label == NULL) { 5704 if (label == NULL) {
5704 RETURN_NULL_ERROR(label); 5705 RETURN_NULL_ERROR(label);
5705 } 5706 }
5706 TimelineStream* stream = isolate->GetEmbedderStream(); 5707 TimelineStream* stream = isolate->GetEmbedderStream();
5707 ASSERT(stream != NULL); 5708 ASSERT(stream != NULL);
5708 TimelineEvent* event = stream->RecordEvent(); 5709 TimelineEvent* event = stream->StartEvent();
5709 if (event != NULL) { 5710 if (event != NULL) {
5710 event->Instant(stream, label); 5711 event->Instant(label);
5712 event->Complete();
5711 } 5713 }
5712 return Api::Success(); 5714 return Api::Success();
5713 } 5715 }
5714 5716
5715 5717
5716 DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label, 5718 DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
5717 int64_t* async_id) { 5719 int64_t* async_id) {
5718 Isolate* isolate = Isolate::Current(); 5720 Isolate* isolate = Isolate::Current();
5719 CHECK_ISOLATE(isolate); 5721 CHECK_ISOLATE(isolate);
5720 if (label == NULL) { 5722 if (label == NULL) {
5721 RETURN_NULL_ERROR(label); 5723 RETURN_NULL_ERROR(label);
5722 } 5724 }
5723 if (async_id == NULL) { 5725 if (async_id == NULL) {
5724 RETURN_NULL_ERROR(async_id); 5726 RETURN_NULL_ERROR(async_id);
5725 } 5727 }
5726 *async_id = -1; 5728 *async_id = -1;
5727 TimelineStream* stream = isolate->GetEmbedderStream(); 5729 TimelineStream* stream = isolate->GetEmbedderStream();
5728 ASSERT(stream != NULL); 5730 ASSERT(stream != NULL);
5729 TimelineEvent* event = stream->RecordEvent(); 5731 TimelineEvent* event = stream->StartEvent();
5730 if (event != NULL) { 5732 if (event != NULL) {
5731 *async_id = event->AsyncBegin(stream, label); 5733 *async_id = event->AsyncBegin(label);
5734 event->Complete();
5732 } 5735 }
5733 return Api::Success(); 5736 return Api::Success();
5734 } 5737 }
5735 5738
5736 5739
5737 DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label, 5740 DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label,
5738 int64_t async_id) { 5741 int64_t async_id) {
5739 if (async_id < 0) { 5742 if (async_id < 0) {
5740 return Api::Success(); 5743 return Api::Success();
5741 } 5744 }
5742 Isolate* isolate = Isolate::Current(); 5745 Isolate* isolate = Isolate::Current();
5743 CHECK_ISOLATE(isolate); 5746 CHECK_ISOLATE(isolate);
5744 if (label == NULL) { 5747 if (label == NULL) {
5745 RETURN_NULL_ERROR(label); 5748 RETURN_NULL_ERROR(label);
5746 } 5749 }
5747 TimelineStream* stream = isolate->GetEmbedderStream(); 5750 TimelineStream* stream = isolate->GetEmbedderStream();
5748 ASSERT(stream != NULL); 5751 ASSERT(stream != NULL);
5749 TimelineEvent* event = stream->RecordEvent(); 5752 TimelineEvent* event = stream->StartEvent();
5750 if (event != NULL) { 5753 if (event != NULL) {
5751 event->AsyncInstant(stream, label, async_id); 5754 event->AsyncInstant(label, async_id);
5755 event->Complete();
5752 } 5756 }
5753 return Api::Success(); 5757 return Api::Success();
5754 } 5758 }
5755 5759
5756 5760
5757 DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label, 5761 DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
5758 int64_t async_id) { 5762 int64_t async_id) {
5759 if (async_id < 0) { 5763 if (async_id < 0) {
5760 return Api::Success(); 5764 return Api::Success();
5761 } 5765 }
5762 Isolate* isolate = Isolate::Current(); 5766 Isolate* isolate = Isolate::Current();
5763 CHECK_ISOLATE(isolate); 5767 CHECK_ISOLATE(isolate);
5764 if (label == NULL) { 5768 if (label == NULL) {
5765 RETURN_NULL_ERROR(label); 5769 RETURN_NULL_ERROR(label);
5766 } 5770 }
5767 TimelineStream* stream = isolate->GetEmbedderStream(); 5771 TimelineStream* stream = isolate->GetEmbedderStream();
5768 ASSERT(stream != NULL); 5772 ASSERT(stream != NULL);
5769 TimelineEvent* event = stream->RecordEvent(); 5773 TimelineEvent* event = stream->StartEvent();
5770 if (event != NULL) { 5774 if (event != NULL) {
5771 event->AsyncEnd(stream, label, async_id); 5775 event->AsyncEnd(label, async_id);
5776 event->Complete();
5772 } 5777 }
5773 return Api::Success(); 5778 return Api::Success();
5774 } 5779 }
5775 5780
5776 } // namespace dart 5781 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698