| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void i::FatalProcessOutOfMemory(const char* location) { | 208 void i::FatalProcessOutOfMemory(const char* location) { |
| 209 i::V8::FatalProcessOutOfMemory(location, false); | 209 i::V8::FatalProcessOutOfMemory(location, false); |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 213 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
| 214 // The default fatal error handler is called and execution is stopped. | 214 // The default fatal error handler is called and execution is stopped. |
| 215 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { | 215 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
| 216 i::Isolate* isolate = i::Isolate::Current(); | 216 i::Isolate* isolate = i::Isolate::Current(); |
| 217 char last_few_messages[Heap::kTraceRingBufferSize + 1]; | 217 char last_few_messages[Heap::kTraceRingBufferSize + 1]; |
| 218 char js_stacktrace[Heap::kStacktraceBufferSize + 1]; |
| 218 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); | 219 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); |
| 220 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1); |
| 219 | 221 |
| 220 i::HeapStats heap_stats; | 222 i::HeapStats heap_stats; |
| 221 int start_marker; | 223 int start_marker; |
| 222 heap_stats.start_marker = &start_marker; | 224 heap_stats.start_marker = &start_marker; |
| 223 int new_space_size; | 225 int new_space_size; |
| 224 heap_stats.new_space_size = &new_space_size; | 226 heap_stats.new_space_size = &new_space_size; |
| 225 int new_space_capacity; | 227 int new_space_capacity; |
| 226 heap_stats.new_space_capacity = &new_space_capacity; | 228 heap_stats.new_space_capacity = &new_space_capacity; |
| 227 intptr_t old_space_size; | 229 intptr_t old_space_size; |
| 228 heap_stats.old_space_size = &old_space_size; | 230 heap_stats.old_space_size = &old_space_size; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 252 heap_stats.memory_allocator_size = &memory_allocator_size; | 254 heap_stats.memory_allocator_size = &memory_allocator_size; |
| 253 intptr_t memory_allocator_capacity; | 255 intptr_t memory_allocator_capacity; |
| 254 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; | 256 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; |
| 255 int objects_per_type[LAST_TYPE + 1] = {0}; | 257 int objects_per_type[LAST_TYPE + 1] = {0}; |
| 256 heap_stats.objects_per_type = objects_per_type; | 258 heap_stats.objects_per_type = objects_per_type; |
| 257 int size_per_type[LAST_TYPE + 1] = {0}; | 259 int size_per_type[LAST_TYPE + 1] = {0}; |
| 258 heap_stats.size_per_type = size_per_type; | 260 heap_stats.size_per_type = size_per_type; |
| 259 int os_error; | 261 int os_error; |
| 260 heap_stats.os_error = &os_error; | 262 heap_stats.os_error = &os_error; |
| 261 heap_stats.last_few_messages = last_few_messages; | 263 heap_stats.last_few_messages = last_few_messages; |
| 264 heap_stats.js_stacktrace = js_stacktrace; |
| 262 int end_marker; | 265 int end_marker; |
| 263 heap_stats.end_marker = &end_marker; | 266 heap_stats.end_marker = &end_marker; |
| 264 if (isolate->heap()->HasBeenSetUp()) { | 267 if (isolate->heap()->HasBeenSetUp()) { |
| 265 // BUG(1718): Don't use the take_snapshot since we don't support | 268 // BUG(1718): Don't use the take_snapshot since we don't support |
| 266 // HeapIterator here without doing a special GC. | 269 // HeapIterator here without doing a special GC. |
| 267 isolate->heap()->RecordStats(&heap_stats, false); | 270 isolate->heap()->RecordStats(&heap_stats, false); |
| 268 char* first_newline = strchr(last_few_messages, '\n'); | 271 char* first_newline = strchr(last_few_messages, '\n'); |
| 269 if (first_newline == NULL || first_newline[1] == '\0') | 272 if (first_newline == NULL || first_newline[1] == '\0') |
| 270 first_newline = last_few_messages; | 273 first_newline = last_few_messages; |
| 271 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); | 274 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); |
| 275 PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); |
| 272 } | 276 } |
| 273 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); | 277 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); |
| 274 // If the fatal error handler returns, we stop execution. | 278 // If the fatal error handler returns, we stop execution. |
| 275 FATAL("API fatal error handler returned after process out of memory"); | 279 FATAL("API fatal error handler returned after process out of memory"); |
| 276 } | 280 } |
| 277 | 281 |
| 278 | 282 |
| 279 void Utils::ReportApiFailure(const char* location, const char* message) { | 283 void Utils::ReportApiFailure(const char* location, const char* message) { |
| 280 i::Isolate* isolate = i::Isolate::Current(); | 284 i::Isolate* isolate = i::Isolate::Current(); |
| 281 FatalErrorCallback callback = isolate->exception_behavior(); | 285 FatalErrorCallback callback = isolate->exception_behavior(); |
| (...skipping 8105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8387 Address callback_address = | 8391 Address callback_address = |
| 8388 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8392 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8389 VMState<EXTERNAL> state(isolate); | 8393 VMState<EXTERNAL> state(isolate); |
| 8390 ExternalCallbackScope call_scope(isolate, callback_address); | 8394 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8391 callback(info); | 8395 callback(info); |
| 8392 } | 8396 } |
| 8393 | 8397 |
| 8394 | 8398 |
| 8395 } // namespace internal | 8399 } // namespace internal |
| 8396 } // namespace v8 | 8400 } // namespace v8 |
| OLD | NEW |