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

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: 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
« 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 12 matching lines...) Expand all
23 #include "src/code-stubs.h" 23 #include "src/code-stubs.h"
24 #include "src/compiler.h" 24 #include "src/compiler.h"
25 #include "src/contexts.h" 25 #include "src/contexts.h"
26 #include "src/conversions-inl.h" 26 #include "src/conversions-inl.h"
27 #include "src/counters.h" 27 #include "src/counters.h"
28 #include "src/cpu-profiler.h" 28 #include "src/cpu-profiler.h"
29 #include "src/debug.h" 29 #include "src/debug.h"
30 #include "src/deoptimizer.h" 30 #include "src/deoptimizer.h"
31 #include "src/execution.h" 31 #include "src/execution.h"
32 #include "src/global-handles.h" 32 #include "src/global-handles.h"
33 #include "src/heap/spaces.h"
33 #include "src/heap-profiler.h" 34 #include "src/heap-profiler.h"
34 #include "src/heap-snapshot-generator-inl.h" 35 #include "src/heap-snapshot-generator-inl.h"
35 #include "src/icu_util.h" 36 #include "src/icu_util.h"
36 #include "src/json-parser.h" 37 #include "src/json-parser.h"
37 #include "src/messages.h" 38 #include "src/messages.h"
38 #include "src/parser.h" 39 #include "src/parser.h"
39 #include "src/pending-compilation-error-handler.h" 40 #include "src/pending-compilation-error-handler.h"
40 #include "src/profile-generator-inl.h" 41 #include "src/profile-generator-inl.h"
41 #include "src/property.h" 42 #include "src/property.h"
42 #include "src/property-details.h" 43 #include "src/property-details.h"
(...skipping 6907 matching lines...) Expand 10 before | Expand all | Expand 10 after
6950 : isolate_(reinterpret_cast<i::Isolate*>(isolate)) { 6951 : isolate_(reinterpret_cast<i::Isolate*>(isolate)) {
6951 isolate_->handle_scope_implementer()->IncrementCallDepth(); 6952 isolate_->handle_scope_implementer()->IncrementCallDepth();
6952 } 6953 }
6953 6954
6954 6955
6955 Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() { 6956 Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() {
6956 isolate_->handle_scope_implementer()->DecrementCallDepth(); 6957 isolate_->handle_scope_implementer()->DecrementCallDepth();
6957 } 6958 }
6958 6959
6959 6960
6961 class HeapStatisticsHelper {
rmcilroy 2015/04/13 12:48:23 I don't think we should have a seperate class just
6962 public:
6963 static void ExtractHeapStatistics(HeapStatistics* heap_statistics,
6964 i::Heap* heap) {
6965 heap_statistics->total_heap_size_ = heap->CommittedMemory();
6966 heap_statistics->total_heap_size_executable_ =
6967 heap->CommittedMemoryExecutable();
6968 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6969 heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6970 heap_statistics->heap_size_limit_ = heap->MaxReserved();
6971
6972 heap_statistics->new_space_statistics()->size_of_objects_ =
6973 heap->new_space()->Size();
6974 heap_statistics->new_space_statistics()->available_memory_ =
6975 heap->new_space()->Available();
6976 heap_statistics->new_space_statistics()->committed_memory_ =
6977 heap->new_space()->CommittedMemory();
6978
6979 heap_statistics->lo_space_statistics()->size_of_objects_ =
6980 heap->lo_space()->SizeOfObjects();
6981 heap_statistics->lo_space_statistics()->available_memory_ =
6982 heap->lo_space()->Available();
6983 heap_statistics->lo_space_statistics()->committed_memory_ =
6984 heap->lo_space()->CommittedMemory();
6985
6986 ExtractSpaceStatisticsFromPagedSpace(
6987 heap->old_space(), heap_statistics->old_space_statistics());
6988 ExtractSpaceStatisticsFromPagedSpace(
6989 heap->code_space(), heap_statistics->code_space_statistics());
6990 ExtractSpaceStatisticsFromPagedSpace(
6991 heap->map_space(), heap_statistics->map_space_statistics());
6992 ExtractSpaceStatisticsFromPagedSpace(
6993 heap->cell_space(), heap_statistics->cell_space_statistics());
6994 }
6995
6996 static void ExtractSpaceStatisticsFromPagedSpace(
6997 i::PagedSpace* paged_space,
6998 HeapStatistics::SpaceStatistics* space_stats) {
6999 space_stats->size_of_objects_ = paged_space->SizeOfObjects();
7000 space_stats->committed_memory_ = paged_space->CommittedMemory();
7001 space_stats->available_memory_ = paged_space->Available();
7002 }
7003 };
7004
7005
6960 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { 7006 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
6961 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7007 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6962 i::Heap* heap = isolate->heap(); 7008 i::Heap* heap = isolate->heap();
6963 heap_statistics->total_heap_size_ = heap->CommittedMemory(); 7009 HeapStatisticsHelper::ExtractHeapStatistics(heap_statistics, heap);
6964 heap_statistics->total_heap_size_executable_ =
6965 heap->CommittedMemoryExecutable();
6966 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6967 heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6968 heap_statistics->heap_size_limit_ = heap->MaxReserved();
6969 } 7010 }
6970 7011
6971 7012
6972 void Isolate::GetStackSample(const RegisterState& state, void** frames, 7013 void Isolate::GetStackSample(const RegisterState& state, void** frames,
6973 size_t frames_limit, SampleInfo* sample_info) { 7014 size_t frames_limit, SampleInfo* sample_info) {
6974 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 7015 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6975 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, 7016 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame,
6976 frames, frames_limit, sample_info); 7017 frames, frames_limit, sample_info);
6977 } 7018 }
6978 7019
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8079 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8120 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8080 Address callback_address = 8121 Address callback_address =
8081 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8122 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8082 VMState<EXTERNAL> state(isolate); 8123 VMState<EXTERNAL> state(isolate);
8083 ExternalCallbackScope call_scope(isolate, callback_address); 8124 ExternalCallbackScope call_scope(isolate, callback_address);
8084 callback(info); 8125 callback(info);
8085 } 8126 }
8086 8127
8087 8128
8088 } } // namespace v8::internal 8129 } } // 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
This is Rietveld 408576698