Chromium Code Reviews

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: Made changes. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6948 matching lines...)
6959 6959
6960 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { 6960 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
6961 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6961 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6962 i::Heap* heap = isolate->heap(); 6962 i::Heap* heap = isolate->heap();
6963 heap_statistics->total_heap_size_ = heap->CommittedMemory(); 6963 heap_statistics->total_heap_size_ = heap->CommittedMemory();
6964 heap_statistics->total_heap_size_executable_ = 6964 heap_statistics->total_heap_size_executable_ =
6965 heap->CommittedMemoryExecutable(); 6965 heap->CommittedMemoryExecutable();
6966 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); 6966 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6967 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); 6967 heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6968 heap_statistics->heap_size_limit_ = heap->MaxReserved(); 6968 heap_statistics->heap_size_limit_ = heap->MaxReserved();
6969
6970 HeapStatistics::SpaceStatistics new_space_stats(
6971 heap->new_space()->Size(), heap->new_space()->CommittedMemory(),
6972 heap->new_space()->Available());
6973 heap_statistics->spaces_statistics().push_back(new_space_stats);
6974
6975 for (int space = i::AllocationSpace::FIRST_PAGED_SPACE;
6976 space < i::AllocationSpace::LAST_PAGED_SPACE; space++) {
6977 HeapStatistics::SpaceStatistics space_stats(
6978 heap->paged_space(space)->Size(),
rmcilroy 2015/04/13 17:40:08 This should be SizeOfObjects()
ssid 2015/04/14 16:59:16 Done.
6979 heap->paged_space(space)->CommittedMemory(),
6980 heap->paged_space(space)->Available());
6981 heap_statistics->spaces_statistics().push_back(space_stats);
6982 }
6983 HeapStatistics::SpaceStatistics lo_space_stats(
rmcilroy 2015/04/13 17:40:08 nit - newline above
ssid 2015/04/14 16:59:16 Done.
6984 heap->lo_space()->Size(), heap->lo_space()->CommittedMemory(),
6985 heap->lo_space()->Available());
6986 heap_statistics->spaces_statistics().push_back(lo_space_stats);
6969 } 6987 }
6970 6988
6971 6989
6972 void Isolate::GetStackSample(const RegisterState& state, void** frames, 6990 void Isolate::GetStackSample(const RegisterState& state, void** frames,
6973 size_t frames_limit, SampleInfo* sample_info) { 6991 size_t frames_limit, SampleInfo* sample_info) {
6974 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6992 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6975 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, 6993 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame,
6976 frames, frames_limit, sample_info); 6994 frames, frames_limit, sample_info);
6977 } 6995 }
6978 6996
(...skipping 1100 matching lines...)
8079 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8097 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8080 Address callback_address = 8098 Address callback_address =
8081 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8099 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8082 VMState<EXTERNAL> state(isolate); 8100 VMState<EXTERNAL> state(isolate);
8083 ExternalCallbackScope call_scope(isolate, callback_address); 8101 ExternalCallbackScope call_scope(isolate, callback_address);
8084 callback(info); 8102 callback(info);
8085 } 8103 }
8086 8104
8087 8105
8088 } } // namespace v8::internal 8106 } } // namespace v8::internal
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine