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

Unified Diff: src/api.cc

Issue 1113233002: Adding api to get last gc object statistics for chrome://tracing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixing comments. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9986df8bf2dd399a8ed836af7b6b353a5221d59c..ddd10309a1b2ea249380590d8f1f83080ae3c4e2 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5348,6 +5348,10 @@ HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
physical_space_size_(0) { }
+HeapObjectStatistics::HeapObjectStatistics(): object_type_(nullptr),
+ object_count_(0),
+ object_size_(0) { }
+
bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
}
@@ -6921,6 +6925,38 @@ bool Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
}
+size_t Isolate::NumberOfHeapObjectsTypes() {
+ return i::Heap::OBJECT_STATS_COUNT;
+}
ulan 2015/05/06 12:46:02 Two new-lines between functions. Please run "git c
ssid 2015/05/07 13:53:03 Done.
+
+bool Isolate::GetLastGcObjectStatistics(HeapObjectStatistics* object_statistics,
+ size_t type_index) {
+ if (!object_statistics)
+ return false;
ulan 2015/05/06 12:46:02 Either use {} or put return statements in the prev
ssid 2015/05/07 13:53:03 Done.
+ if (type_index >= i::Heap::OBJECT_STATS_COUNT)
+ return false;
+ if (!i::FLAG_track_gc_object_stats)
+ return false;
+
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Heap* heap = isolate->heap();
+ const char* object_type = heap->GetObjectTypeName(type_index);
+ size_t object_count = heap->object_count_last_gc(type_index);
+ size_t object_size = heap->object_size_last_gc(type_index);
+ if (object_type == nullptr) {
ulan 2015/05/06 12:46:02 This case shouldn't be happening. Could you please
ssid 2015/05/07 13:53:03 As discussed offline, there are string categories
+ // There should be no objects counted when the type is unknown.
+ DCHECK_EQ(object_count, 0);
+ DCHECK_EQ(object_size, 0);
+ return false;
+ }
+
+ object_statistics->object_type_ = object_type;
+ object_statistics->object_count_ = object_count;
+ object_statistics->object_size_ = object_size;
+ return true;
+}
+
+
void Isolate::GetStackSample(const RegisterState& state, void** frames,
size_t frames_limit, SampleInfo* sample_info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);

Powered by Google App Engine
This is Rietveld 408576698