Commit cffeea87 authored by mlippautz's avatar mlippautz Committed by Commit bot

Add malloced and peak malloced to OOM handler

- Change sizes and counts to be size_t on the way.

R=hpayer@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2240603003
Cr-Commit-Position: refs/heads/master@{#38601}
parent f93f39f0
......@@ -252,9 +252,8 @@ void i::FatalProcessOutOfMemory(const char* location) {
i::V8::FatalProcessOutOfMemory(location, false);
}
// When V8 cannot allocated memory FatalProcessOutOfMemory is called.
// The default OOM error handler is called and execution is stopped.
// When V8 cannot allocate memory FatalProcessOutOfMemory is called. The default
// OOM error handler is called and execution is stopped.
void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
i::Isolate* isolate = i::Isolate::Current();
char last_few_messages[Heap::kTraceRingBufferSize + 1];
......@@ -263,49 +262,53 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1);
i::HeapStats heap_stats;
int start_marker;
intptr_t start_marker;
heap_stats.start_marker = &start_marker;
int new_space_size;
size_t new_space_size;
heap_stats.new_space_size = &new_space_size;
int new_space_capacity;
size_t new_space_capacity;
heap_stats.new_space_capacity = &new_space_capacity;
intptr_t old_space_size;
size_t old_space_size;
heap_stats.old_space_size = &old_space_size;
intptr_t old_space_capacity;
size_t old_space_capacity;
heap_stats.old_space_capacity = &old_space_capacity;
intptr_t code_space_size;
size_t code_space_size;
heap_stats.code_space_size = &code_space_size;
intptr_t code_space_capacity;
size_t code_space_capacity;
heap_stats.code_space_capacity = &code_space_capacity;
intptr_t map_space_size;
size_t map_space_size;
heap_stats.map_space_size = &map_space_size;
intptr_t map_space_capacity;
size_t map_space_capacity;
heap_stats.map_space_capacity = &map_space_capacity;
intptr_t lo_space_size;
size_t lo_space_size;
heap_stats.lo_space_size = &lo_space_size;
int global_handle_count;
size_t global_handle_count;
heap_stats.global_handle_count = &global_handle_count;
int weak_global_handle_count;
size_t weak_global_handle_count;
heap_stats.weak_global_handle_count = &weak_global_handle_count;
int pending_global_handle_count;
size_t pending_global_handle_count;
heap_stats.pending_global_handle_count = &pending_global_handle_count;
int near_death_global_handle_count;
size_t near_death_global_handle_count;
heap_stats.near_death_global_handle_count = &near_death_global_handle_count;
int free_global_handle_count;
size_t free_global_handle_count;
heap_stats.free_global_handle_count = &free_global_handle_count;
intptr_t memory_allocator_size;
size_t memory_allocator_size;
heap_stats.memory_allocator_size = &memory_allocator_size;
intptr_t memory_allocator_capacity;
size_t memory_allocator_capacity;
heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
int objects_per_type[LAST_TYPE + 1] = {0};
size_t malloced_memory;
heap_stats.malloced_memory = &malloced_memory;
size_t malloced_peak_memory;
heap_stats.malloced_peak_memory = &malloced_peak_memory;
size_t objects_per_type[LAST_TYPE + 1] = {0};
heap_stats.objects_per_type = objects_per_type;
int size_per_type[LAST_TYPE + 1] = {0};
size_t size_per_type[LAST_TYPE + 1] = {0};
heap_stats.size_per_type = size_per_type;
int os_error;
heap_stats.os_error = &os_error;
heap_stats.last_few_messages = last_few_messages;
heap_stats.js_stacktrace = js_stacktrace;
int end_marker;
intptr_t end_marker;
heap_stats.end_marker = &end_marker;
if (isolate->heap()->HasBeenSetUp()) {
// BUG(1718): Don't use the take_snapshot since we don't support
......
......@@ -5055,7 +5055,7 @@ void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
*stats->start_marker = HeapStats::kStartMarker;
*stats->end_marker = HeapStats::kEndMarker;
*stats->new_space_size = new_space_.SizeAsInt();
*stats->new_space_capacity = static_cast<int>(new_space_.Capacity());
*stats->new_space_capacity = new_space_.Capacity();
*stats->old_space_size = old_space_->SizeOfObjects();
*stats->old_space_capacity = old_space_->Capacity();
*stats->code_space_size = code_space_->SizeOfObjects();
......@@ -5068,7 +5068,8 @@ void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
*stats->memory_allocator_capacity =
memory_allocator()->Size() + memory_allocator()->Available();
*stats->os_error = base::OS::GetLastError();
memory_allocator()->Available();
*stats->malloced_memory = isolate_->allocator()->GetCurrentMemoryUsage();
*stats->malloced_peak_memory = isolate_->allocator()->GetMaxMemoryUsage();
if (take_snapshot) {
HeapIterator iterator(this);
for (HeapObject* obj = iterator.next(); obj != NULL;
......
......@@ -2325,29 +2325,31 @@ class HeapStats {
static const int kStartMarker = 0xDECADE00;
static const int kEndMarker = 0xDECADE01;
int* start_marker; // 0
int* new_space_size; // 1
int* new_space_capacity; // 2
intptr_t* old_space_size; // 3
intptr_t* old_space_capacity; // 4
intptr_t* code_space_size; // 5
intptr_t* code_space_capacity; // 6
intptr_t* map_space_size; // 7
intptr_t* map_space_capacity; // 8
intptr_t* lo_space_size; // 9
int* global_handle_count; // 10
int* weak_global_handle_count; // 11
int* pending_global_handle_count; // 12
int* near_death_global_handle_count; // 13
int* free_global_handle_count; // 14
intptr_t* memory_allocator_size; // 15
intptr_t* memory_allocator_capacity; // 16
int* objects_per_type; // 17
int* size_per_type; // 18
int* os_error; // 19
char* last_few_messages; // 20
char* js_stacktrace; // 21
int* end_marker; // 22
intptr_t* start_marker; // 0
size_t* new_space_size; // 1
size_t* new_space_capacity; // 2
size_t* old_space_size; // 3
size_t* old_space_capacity; // 4
size_t* code_space_size; // 5
size_t* code_space_capacity; // 6
size_t* map_space_size; // 7
size_t* map_space_capacity; // 8
size_t* lo_space_size; // 9
size_t* global_handle_count; // 10
size_t* weak_global_handle_count; // 11
size_t* pending_global_handle_count; // 12
size_t* near_death_global_handle_count; // 13
size_t* free_global_handle_count; // 14
size_t* memory_allocator_size; // 15
size_t* memory_allocator_capacity; // 16
size_t* malloced_memory; // 17
size_t* malloced_peak_memory; // 18
size_t* objects_per_type; // 19
size_t* size_per_type; // 20
int* os_error; // 21
char* last_few_messages; // 22
char* js_stacktrace; // 23
intptr_t* end_marker; // 24
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment