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

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 jochen's comments. 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
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 14d3a823ebf637a75322e464704085812ab6dcb5..991b9eebb6c9e8fff4ce5c6981ec6d26df6a4d0b 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -30,6 +30,7 @@
#include "src/deoptimizer.h"
#include "src/execution.h"
#include "src/global-handles.h"
+#include "src/heap/spaces.h"
#include "src/heap-profiler.h"
#include "src/heap-snapshot-generator-inl.h"
#include "src/icu_util.h"
@@ -5463,6 +5464,13 @@ HeapStatistics::HeapStatistics(): total_heap_size_(0),
heap_size_limit_(0) { }
+HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
+ space_size_(0),
+ space_used_size_(0),
+ space_available_size_(0),
+ physical_space_size_(0) { }
+
+
bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
}
@@ -7000,6 +7008,31 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
}
+size_t Isolate::NumberOfHeapSpaces() {
+ return i::LAST_SPACE - i::FIRST_SPACE + 1;
+}
+
+
+bool Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
+ size_t index) {
+ if (!space_statistics)
+ return false;
+ if (index > i::LAST_SPACE || index < i::FIRST_SPACE)
+ return false;
+
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Heap* heap = isolate->heap();
+ i::Space* space = heap->space(static_cast<int>(index));
+
+ space_statistics->space_name_ = heap->GetSpaceName(static_cast<int>(index));
+ space_statistics->space_size_ = space->CommittedMemory();
+ space_statistics->space_used_size_ = space->Size();
+ space_statistics->space_available_size_ = space->Available();
+ space_statistics->physical_space_size_ = space->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);
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698