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

Unified Diff: src/api.cc

Issue 1058253003: Adding V8 api to get memory statistics of spaces in V8::Heap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixing build. Created 5 years, 8 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 14d3a823ebf637a75322e464704085812ab6dcb5..cfaa34ca7924c6d2c09b9fe202eb3520d5352cc3 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5463,6 +5463,13 @@ HeapStatistics::HeapStatistics(): total_heap_size_(0),
heap_size_limit_(0) { }
+HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
+ space_size_(0),
+ space_used_size_(0),
+ space_avalable_size_(0),
+ physical_space_size_(0) { }
+
+
bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
}
@@ -7000,6 +7007,28 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
}
+int Isolate::NumberOfHeapSpaces() {
+ return i::LAST_SPACE - i::FIRST_SPACE + 1;
+}
+
+
+bool Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
+ int index) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Heap* heap = isolate->heap();
+ if (index > i::LAST_SPACE || index < i::FIRST_SPACE || !space_statistics)
rmcilroy 2015/04/16 13:49:05 nit - move the '!space_statistics' check out to a
ssid 2015/04/16 16:40:29 Done.
+ return false;
+
+ space_statistics->space_name_ = heap->GetSpaceName(index);
+ space_statistics->space_size_ = heap->space(index)->CommittedMemory();
rmcilroy 2015/04/16 13:49:05 nit - factor out: Space space = heap->space(index
ssid 2015/04/16 16:40:29 Done.
+ space_statistics->space_used_size_ = heap->space(index)->Size();
+ space_statistics->space_avalable_size_ = heap->space(index)->Available();
+ space_statistics->physical_space_size_ =
+ heap->space(index)->CommittedPhysicalMemory();
+ 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