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

Side by Side 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: Adding new APIs for space statistics. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 5444 matching lines...) Expand 10 before | Expand all | Expand 10 after
5455 } 5455 }
5456 5456
5457 5457
5458 HeapStatistics::HeapStatistics(): total_heap_size_(0), 5458 HeapStatistics::HeapStatistics(): total_heap_size_(0),
5459 total_heap_size_executable_(0), 5459 total_heap_size_executable_(0),
5460 total_physical_size_(0), 5460 total_physical_size_(0),
5461 used_heap_size_(0), 5461 used_heap_size_(0),
5462 heap_size_limit_(0) { } 5462 heap_size_limit_(0) { }
5463 5463
5464 5464
5465 HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
5466 space_size_(0),
5467 space_used_size_(0),
5468 space_avalable_size_(0),
5469 physical_space_size_(0) { }
5470
5471
5465 bool v8::V8::InitializeICU(const char* icu_data_file) { 5472 bool v8::V8::InitializeICU(const char* icu_data_file) {
5466 return i::InitializeICU(icu_data_file); 5473 return i::InitializeICU(icu_data_file);
5467 } 5474 }
5468 5475
5469 5476
5470 const char* v8::V8::GetVersion() { 5477 const char* v8::V8::GetVersion() {
5471 return i::Version::GetVersion(); 5478 return i::Version::GetVersion();
5472 } 5479 }
5473 5480
5474 5481
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
6992 i::Heap* heap = isolate->heap(); 6999 i::Heap* heap = isolate->heap();
6993 heap_statistics->total_heap_size_ = heap->CommittedMemory(); 7000 heap_statistics->total_heap_size_ = heap->CommittedMemory();
6994 heap_statistics->total_heap_size_executable_ = 7001 heap_statistics->total_heap_size_executable_ =
6995 heap->CommittedMemoryExecutable(); 7002 heap->CommittedMemoryExecutable();
6996 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); 7003 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6997 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); 7004 heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6998 heap_statistics->heap_size_limit_ = heap->MaxReserved(); 7005 heap_statistics->heap_size_limit_ = heap->MaxReserved();
6999 } 7006 }
7000 7007
7001 7008
7009 int Isolate::NumberOfHeapSpaces() { return i::LAST_SPACE - i::FIRST_SPACE + 1; }
rmcilroy 2015/04/15 10:21:42 nit - newline for body
ssid 2015/04/15 10:43:58 Done.
7010
7011
7012 void Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
7013 int index) {
7014 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7015 i::Heap* heap = isolate->heap();
rmcilroy 2015/04/15 10:21:42 check for space_statistics being null.
rmcilroy 2015/04/15 10:21:42 check for index out-of-bounds
ssid 2015/04/15 10:43:57 Done.
7016 if (index == i::NEW_SPACE) {
7017 space_statistics->space_name_ = heap->GetSpaceName(i::NEW_SPACE);
7018 space_statistics->space_size_ = heap->new_space()->CommittedMemory();
7019 space_statistics->space_used_size_ = heap->new_space()->Size();
rmcilroy 2015/04/15 10:21:42 SizeOfObjects
ssid 2015/04/15 10:29:20 PrintShortHeapStatistics() uses Size() and not Siz
rmcilroy 2015/04/15 12:17:40 SizeOfObjects() calls Size() for the newspace, so
7020 space_statistics->space_avalable_size_ = heap->new_space()->Available();
7021 space_statistics->physical_space_size_ =
7022 heap->new_space()->CommittedPhysicalMemory();
7023 } else if (index >= i::FIRST_PAGED_SPACE && index <= i::LAST_PAGED_SPACE) {
7024 space_statistics->space_name_ = heap->GetSpaceName(index);
7025 space_statistics->space_size_ = heap->paged_space(index)->CommittedMemory();
7026 space_statistics->space_used_size_ =
7027 heap->paged_space(index)->SizeOfObjects();
7028 space_statistics->space_avalable_size_ =
7029 heap->paged_space(index)->Available();
7030 space_statistics->physical_space_size_ =
7031 heap->paged_space(index)->CommittedPhysicalMemory();
7032 } else if (index == i::LO_SPACE) {
7033 space_statistics->space_name_ = heap->GetSpaceName(i::LO_SPACE);
7034 space_statistics->space_size_ = heap->lo_space()->CommittedMemory();
7035 space_statistics->space_used_size_ = heap->lo_space()->SizeOfObjects();
7036 space_statistics->space_avalable_size_ = heap->lo_space()->Available();
rmcilroy 2015/04/15 10:21:42 Does the Spaces superclass have these methods defi
ssid 2015/04/15 10:29:20 The only line i can pull out of these three cases
rmcilroy 2015/04/15 12:17:40 +hpayer As mentioned, you could you make these fu
Hannes Payer (out of office) 2015/04/15 21:09:23 Hmm, should be possible. I cannot think of any rea
7037 space_statistics->physical_space_size_ =
7038 heap->lo_space()->CommittedPhysicalMemory();
7039 }
7040 }
7041
7042
7002 void Isolate::GetStackSample(const RegisterState& state, void** frames, 7043 void Isolate::GetStackSample(const RegisterState& state, void** frames,
7003 size_t frames_limit, SampleInfo* sample_info) { 7044 size_t frames_limit, SampleInfo* sample_info) {
7004 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7045 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7005 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, 7046 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame,
7006 frames, frames_limit, sample_info); 7047 frames, frames_limit, sample_info);
7007 } 7048 }
7008 7049
7009 7050
7010 void Isolate::SetEventLogger(LogEventCallback that) { 7051 void Isolate::SetEventLogger(LogEventCallback that) {
7011 // Do not overwrite the event logger if we want to log explicitly. 7052 // Do not overwrite the event logger if we want to log explicitly.
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
8109 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8150 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8110 Address callback_address = 8151 Address callback_address =
8111 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8152 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8112 VMState<EXTERNAL> state(isolate); 8153 VMState<EXTERNAL> state(isolate);
8113 ExternalCallbackScope call_scope(isolate, callback_address); 8154 ExternalCallbackScope call_scope(isolate, callback_address);
8114 callback(info); 8155 callback(info);
8115 } 8156 }
8116 8157
8117 8158
8118 } } // namespace v8::internal 8159 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698