| OLD | NEW |
| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 // --- E x c e p t i o n B e h a v i o r --- | 248 // --- E x c e p t i o n B e h a v i o r --- |
| 249 | 249 |
| 250 | 250 |
| 251 void i::FatalProcessOutOfMemory(const char* location) { | 251 void i::FatalProcessOutOfMemory(const char* location) { |
| 252 i::V8::FatalProcessOutOfMemory(location, false); | 252 i::V8::FatalProcessOutOfMemory(location, false); |
| 253 } | 253 } |
| 254 | 254 |
| 255 | 255 // When V8 cannot allocate memory FatalProcessOutOfMemory is called. The default |
| 256 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 256 // OOM error handler is called and execution is stopped. |
| 257 // The default OOM error handler is called and execution is stopped. | |
| 258 void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) { | 257 void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) { |
| 259 i::Isolate* isolate = i::Isolate::Current(); | 258 i::Isolate* isolate = i::Isolate::Current(); |
| 260 char last_few_messages[Heap::kTraceRingBufferSize + 1]; | 259 char last_few_messages[Heap::kTraceRingBufferSize + 1]; |
| 261 char js_stacktrace[Heap::kStacktraceBufferSize + 1]; | 260 char js_stacktrace[Heap::kStacktraceBufferSize + 1]; |
| 262 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); | 261 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); |
| 263 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1); | 262 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1); |
| 264 | 263 |
| 265 i::HeapStats heap_stats; | 264 i::HeapStats heap_stats; |
| 266 int start_marker; | 265 intptr_t start_marker; |
| 267 heap_stats.start_marker = &start_marker; | 266 heap_stats.start_marker = &start_marker; |
| 268 int new_space_size; | 267 size_t new_space_size; |
| 269 heap_stats.new_space_size = &new_space_size; | 268 heap_stats.new_space_size = &new_space_size; |
| 270 int new_space_capacity; | 269 size_t new_space_capacity; |
| 271 heap_stats.new_space_capacity = &new_space_capacity; | 270 heap_stats.new_space_capacity = &new_space_capacity; |
| 272 intptr_t old_space_size; | 271 size_t old_space_size; |
| 273 heap_stats.old_space_size = &old_space_size; | 272 heap_stats.old_space_size = &old_space_size; |
| 274 intptr_t old_space_capacity; | 273 size_t old_space_capacity; |
| 275 heap_stats.old_space_capacity = &old_space_capacity; | 274 heap_stats.old_space_capacity = &old_space_capacity; |
| 276 intptr_t code_space_size; | 275 size_t code_space_size; |
| 277 heap_stats.code_space_size = &code_space_size; | 276 heap_stats.code_space_size = &code_space_size; |
| 278 intptr_t code_space_capacity; | 277 size_t code_space_capacity; |
| 279 heap_stats.code_space_capacity = &code_space_capacity; | 278 heap_stats.code_space_capacity = &code_space_capacity; |
| 280 intptr_t map_space_size; | 279 size_t map_space_size; |
| 281 heap_stats.map_space_size = &map_space_size; | 280 heap_stats.map_space_size = &map_space_size; |
| 282 intptr_t map_space_capacity; | 281 size_t map_space_capacity; |
| 283 heap_stats.map_space_capacity = &map_space_capacity; | 282 heap_stats.map_space_capacity = &map_space_capacity; |
| 284 intptr_t lo_space_size; | 283 size_t lo_space_size; |
| 285 heap_stats.lo_space_size = &lo_space_size; | 284 heap_stats.lo_space_size = &lo_space_size; |
| 286 int global_handle_count; | 285 size_t global_handle_count; |
| 287 heap_stats.global_handle_count = &global_handle_count; | 286 heap_stats.global_handle_count = &global_handle_count; |
| 288 int weak_global_handle_count; | 287 size_t weak_global_handle_count; |
| 289 heap_stats.weak_global_handle_count = &weak_global_handle_count; | 288 heap_stats.weak_global_handle_count = &weak_global_handle_count; |
| 290 int pending_global_handle_count; | 289 size_t pending_global_handle_count; |
| 291 heap_stats.pending_global_handle_count = &pending_global_handle_count; | 290 heap_stats.pending_global_handle_count = &pending_global_handle_count; |
| 292 int near_death_global_handle_count; | 291 size_t near_death_global_handle_count; |
| 293 heap_stats.near_death_global_handle_count = &near_death_global_handle_count; | 292 heap_stats.near_death_global_handle_count = &near_death_global_handle_count; |
| 294 int free_global_handle_count; | 293 size_t free_global_handle_count; |
| 295 heap_stats.free_global_handle_count = &free_global_handle_count; | 294 heap_stats.free_global_handle_count = &free_global_handle_count; |
| 296 intptr_t memory_allocator_size; | 295 size_t memory_allocator_size; |
| 297 heap_stats.memory_allocator_size = &memory_allocator_size; | 296 heap_stats.memory_allocator_size = &memory_allocator_size; |
| 298 intptr_t memory_allocator_capacity; | 297 size_t memory_allocator_capacity; |
| 299 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; | 298 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; |
| 300 int objects_per_type[LAST_TYPE + 1] = {0}; | 299 size_t malloced_memory; |
| 300 heap_stats.malloced_memory = &malloced_memory; |
| 301 size_t malloced_peak_memory; |
| 302 heap_stats.malloced_peak_memory = &malloced_peak_memory; |
| 303 size_t objects_per_type[LAST_TYPE + 1] = {0}; |
| 301 heap_stats.objects_per_type = objects_per_type; | 304 heap_stats.objects_per_type = objects_per_type; |
| 302 int size_per_type[LAST_TYPE + 1] = {0}; | 305 size_t size_per_type[LAST_TYPE + 1] = {0}; |
| 303 heap_stats.size_per_type = size_per_type; | 306 heap_stats.size_per_type = size_per_type; |
| 304 int os_error; | 307 int os_error; |
| 305 heap_stats.os_error = &os_error; | 308 heap_stats.os_error = &os_error; |
| 306 heap_stats.last_few_messages = last_few_messages; | 309 heap_stats.last_few_messages = last_few_messages; |
| 307 heap_stats.js_stacktrace = js_stacktrace; | 310 heap_stats.js_stacktrace = js_stacktrace; |
| 308 int end_marker; | 311 intptr_t end_marker; |
| 309 heap_stats.end_marker = &end_marker; | 312 heap_stats.end_marker = &end_marker; |
| 310 if (isolate->heap()->HasBeenSetUp()) { | 313 if (isolate->heap()->HasBeenSetUp()) { |
| 311 // BUG(1718): Don't use the take_snapshot since we don't support | 314 // BUG(1718): Don't use the take_snapshot since we don't support |
| 312 // HeapIterator here without doing a special GC. | 315 // HeapIterator here without doing a special GC. |
| 313 isolate->heap()->RecordStats(&heap_stats, false); | 316 isolate->heap()->RecordStats(&heap_stats, false); |
| 314 char* first_newline = strchr(last_few_messages, '\n'); | 317 char* first_newline = strchr(last_few_messages, '\n'); |
| 315 if (first_newline == NULL || first_newline[1] == '\0') | 318 if (first_newline == NULL || first_newline[1] == '\0') |
| 316 first_newline = last_few_messages; | 319 first_newline = last_few_messages; |
| 317 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); | 320 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); |
| 318 PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); | 321 PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); |
| (...skipping 8695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9014 Address callback_address = | 9017 Address callback_address = |
| 9015 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9018 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9016 VMState<EXTERNAL> state(isolate); | 9019 VMState<EXTERNAL> state(isolate); |
| 9017 ExternalCallbackScope call_scope(isolate, callback_address); | 9020 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9018 callback(info); | 9021 callback(info); |
| 9019 } | 9022 } |
| 9020 | 9023 |
| 9021 | 9024 |
| 9022 } // namespace internal | 9025 } // namespace internal |
| 9023 } // namespace v8 | 9026 } // namespace v8 |
| OLD | NEW |