| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 <cstdlib> | 5 #include <cstdlib> |
| 6 | 6 |
| 7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (isolate != NULL) { | 375 if (isolate != NULL) { |
| 376 isolate_id_ = isolate->main_port(); | 376 isolate_id_ = isolate->main_port(); |
| 377 } else { | 377 } else { |
| 378 isolate_id_ = ILLEGAL_PORT; | 378 isolate_id_ = ILLEGAL_PORT; |
| 379 } | 379 } |
| 380 label_ = label; | 380 label_ = label; |
| 381 FreeArguments(); | 381 FreeArguments(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 | 384 |
| 385 bool TimelineEvent::Within(int64_t time_origin_micros, |
| 386 int64_t time_extent_micros) { |
| 387 if ((time_origin_micros == -1) || |
| 388 (time_extent_micros == -1)) { |
| 389 // No time range specified. |
| 390 return true; |
| 391 } |
| 392 if (IsFinishedDuration()) { |
| 393 // Event is from e_t0 to e_t1. |
| 394 int64_t e_t0 = TimeOrigin(); |
| 395 int64_t e_t1 = TimeEnd(); |
| 396 ASSERT(e_t0 <= e_t1); |
| 397 // Range is from r_t0 to r_t1. |
| 398 int64_t r_t0 = time_origin_micros; |
| 399 int64_t r_t1 = time_origin_micros + time_extent_micros; |
| 400 ASSERT(r_t0 <= r_t1); |
| 401 return !((r_t1 < e_t0) || (e_t1 < r_t0)); |
| 402 } |
| 403 int64_t delta = TimeOrigin() - time_origin_micros; |
| 404 return (delta >= 0) && (delta <= time_extent_micros); |
| 405 } |
| 406 |
| 407 |
| 385 const char* TimelineEvent::GetSerializedJSON() const { | 408 const char* TimelineEvent::GetSerializedJSON() const { |
| 386 ASSERT(event_type() == kSerializedJSON); | 409 ASSERT(event_type() == kSerializedJSON); |
| 387 ASSERT(arguments_length_ == 1); | 410 ASSERT(arguments_length_ == 1); |
| 388 ASSERT(arguments_ != NULL); | 411 ASSERT(arguments_ != NULL); |
| 389 return arguments_[0].value; | 412 return arguments_[0].value; |
| 390 } | 413 } |
| 391 | 414 |
| 392 | 415 |
| 393 void TimelineEvent::PrintJSON(JSONStream* stream) const { | 416 void TimelineEvent::PrintJSON(JSONStream* stream) const { |
| 394 if (event_type() == kSerializedJSON) { | 417 if (event_type() == kSerializedJSON) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 time_extent_micros_(time_extent_micros) { | 747 time_extent_micros_(time_extent_micros) { |
| 725 ASSERT(time_origin_micros_ >= -1); | 748 ASSERT(time_origin_micros_ >= -1); |
| 726 ASSERT(time_extent_micros_ >= -1); | 749 ASSERT(time_extent_micros_ >= -1); |
| 727 } | 750 } |
| 728 | 751 |
| 729 | 752 |
| 730 TimelineEventFilter::~TimelineEventFilter() { | 753 TimelineEventFilter::~TimelineEventFilter() { |
| 731 } | 754 } |
| 732 | 755 |
| 733 | 756 |
| 734 bool TimelineEventFilter::EventInTimeRange(TimelineEvent* event) { | |
| 735 if (event == NULL) { | |
| 736 return false; | |
| 737 } | |
| 738 if ((time_origin_micros_ == -1) || | |
| 739 (time_extent_micros_ == -1)) { | |
| 740 // No time filter applied. | |
| 741 return true; | |
| 742 } | |
| 743 // TODO(johnmccutchan): Some events span a range of time, check the range and | |
| 744 // not just the start time. | |
| 745 int64_t delta = event->TimeOrigin() - time_origin_micros_; | |
| 746 return (delta >= 0) && (delta <= time_extent_micros_); | |
| 747 } | |
| 748 | |
| 749 | |
| 750 IsolateTimelineEventFilter::IsolateTimelineEventFilter( | 757 IsolateTimelineEventFilter::IsolateTimelineEventFilter( |
| 751 Dart_Port isolate_id, | 758 Dart_Port isolate_id, |
| 752 int64_t time_origin_micros, | 759 int64_t time_origin_micros, |
| 753 int64_t time_extent_micros) | 760 int64_t time_extent_micros) |
| 754 : TimelineEventFilter(time_origin_micros, | 761 : TimelineEventFilter(time_origin_micros, |
| 755 time_extent_micros), | 762 time_extent_micros), |
| 756 isolate_id_(isolate_id) { | 763 isolate_id_(isolate_id) { |
| 757 } | 764 } |
| 758 | 765 |
| 759 | 766 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 return; | 967 return; |
| 961 } | 968 } |
| 962 for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) { | 969 for (intptr_t block_idx = 0; block_idx < num_blocks_; block_idx++) { |
| 963 TimelineEventBlock* block = | 970 TimelineEventBlock* block = |
| 964 blocks_[(block_idx + block_offset) % num_blocks_]; | 971 blocks_[(block_idx + block_offset) % num_blocks_]; |
| 965 if (!filter->IncludeBlock(block)) { | 972 if (!filter->IncludeBlock(block)) { |
| 966 continue; | 973 continue; |
| 967 } | 974 } |
| 968 for (intptr_t event_idx = 0; event_idx < block->length(); event_idx++) { | 975 for (intptr_t event_idx = 0; event_idx < block->length(); event_idx++) { |
| 969 TimelineEvent* event = block->At(event_idx); | 976 TimelineEvent* event = block->At(event_idx); |
| 970 if (filter->IncludeEvent(event) && filter->EventInTimeRange(event)) { | 977 if (filter->IncludeEvent(event) && |
| 978 event->Within(filter->time_origin_micros(), |
| 979 filter->time_extent_micros())) { |
| 971 events->AddValue(event); | 980 events->AddValue(event); |
| 972 } | 981 } |
| 973 } | 982 } |
| 974 } | 983 } |
| 975 } | 984 } |
| 976 | 985 |
| 977 | 986 |
| 978 void TimelineEventRingRecorder::PrintJSON(JSONStream* js, | 987 void TimelineEventRingRecorder::PrintJSON(JSONStream* js, |
| 979 TimelineEventFilter* filter) { | 988 TimelineEventFilter* filter) { |
| 980 JSONObject topLevel(js); | 989 JSONObject topLevel(js); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 MutexLocker ml(&lock_); | 1161 MutexLocker ml(&lock_); |
| 1153 TimelineEventBlock* current = head_; | 1162 TimelineEventBlock* current = head_; |
| 1154 while (current != NULL) { | 1163 while (current != NULL) { |
| 1155 if (!filter->IncludeBlock(current)) { | 1164 if (!filter->IncludeBlock(current)) { |
| 1156 current = current->next(); | 1165 current = current->next(); |
| 1157 continue; | 1166 continue; |
| 1158 } | 1167 } |
| 1159 intptr_t length = current->length(); | 1168 intptr_t length = current->length(); |
| 1160 for (intptr_t i = 0; i < length; i++) { | 1169 for (intptr_t i = 0; i < length; i++) { |
| 1161 TimelineEvent* event = current->At(i); | 1170 TimelineEvent* event = current->At(i); |
| 1162 if (filter->IncludeEvent(event) && filter->EventInTimeRange(event)) { | 1171 if (filter->IncludeEvent(event) && |
| 1172 event->Within(filter->time_origin_micros(), |
| 1173 filter->time_extent_micros())) { |
| 1163 events->AddValue(event); | 1174 events->AddValue(event); |
| 1164 } | 1175 } |
| 1165 } | 1176 } |
| 1166 current = current->next(); | 1177 current = current->next(); |
| 1167 } | 1178 } |
| 1168 } | 1179 } |
| 1169 | 1180 |
| 1170 | 1181 |
| 1171 void TimelineEventEndlessRecorder::Clear() { | 1182 void TimelineEventEndlessRecorder::Clear() { |
| 1172 TimelineEventBlock* current = head_; | 1183 TimelineEventBlock* current = head_; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 | 1316 |
| 1306 | 1317 |
| 1307 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1318 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
| 1308 ASSERT(current_ != NULL); | 1319 ASSERT(current_ != NULL); |
| 1309 TimelineEventBlock* r = current_; | 1320 TimelineEventBlock* r = current_; |
| 1310 current_ = current_->next(); | 1321 current_ = current_->next(); |
| 1311 return r; | 1322 return r; |
| 1312 } | 1323 } |
| 1313 | 1324 |
| 1314 } // namespace dart | 1325 } // namespace dart |
| OLD | NEW |