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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 | 207 |
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(); |
| 217 char last_few_messages[Heap::kTraceRingBufferSize + 1]; |
| 218 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); |
| 219 |
216 i::HeapStats heap_stats; | 220 i::HeapStats heap_stats; |
217 int start_marker; | 221 int start_marker; |
218 heap_stats.start_marker = &start_marker; | 222 heap_stats.start_marker = &start_marker; |
219 int new_space_size; | 223 int new_space_size; |
220 heap_stats.new_space_size = &new_space_size; | 224 heap_stats.new_space_size = &new_space_size; |
221 int new_space_capacity; | 225 int new_space_capacity; |
222 heap_stats.new_space_capacity = &new_space_capacity; | 226 heap_stats.new_space_capacity = &new_space_capacity; |
223 intptr_t old_space_size; | 227 intptr_t old_space_size; |
224 heap_stats.old_space_size = &old_space_size; | 228 heap_stats.old_space_size = &old_space_size; |
225 intptr_t old_space_capacity; | 229 intptr_t old_space_capacity; |
(...skipping 21 matching lines...) Expand all Loading... |
247 intptr_t memory_allocator_size; | 251 intptr_t memory_allocator_size; |
248 heap_stats.memory_allocator_size = &memory_allocator_size; | 252 heap_stats.memory_allocator_size = &memory_allocator_size; |
249 intptr_t memory_allocator_capacity; | 253 intptr_t memory_allocator_capacity; |
250 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; | 254 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; |
251 int objects_per_type[LAST_TYPE + 1] = {0}; | 255 int objects_per_type[LAST_TYPE + 1] = {0}; |
252 heap_stats.objects_per_type = objects_per_type; | 256 heap_stats.objects_per_type = objects_per_type; |
253 int size_per_type[LAST_TYPE + 1] = {0}; | 257 int size_per_type[LAST_TYPE + 1] = {0}; |
254 heap_stats.size_per_type = size_per_type; | 258 heap_stats.size_per_type = size_per_type; |
255 int os_error; | 259 int os_error; |
256 heap_stats.os_error = &os_error; | 260 heap_stats.os_error = &os_error; |
| 261 heap_stats.last_few_messages = last_few_messages; |
257 int end_marker; | 262 int end_marker; |
258 heap_stats.end_marker = &end_marker; | 263 heap_stats.end_marker = &end_marker; |
259 i::Isolate* isolate = i::Isolate::Current(); | |
260 if (isolate->heap()->HasBeenSetUp()) { | 264 if (isolate->heap()->HasBeenSetUp()) { |
261 // BUG(1718): Don't use the take_snapshot since we don't support | 265 // BUG(1718): Don't use the take_snapshot since we don't support |
262 // HeapIterator here without doing a special GC. | 266 // HeapIterator here without doing a special GC. |
263 isolate->heap()->RecordStats(&heap_stats, false); | 267 isolate->heap()->RecordStats(&heap_stats, false); |
| 268 char* first_newline = strchr(last_few_messages, '\n'); |
| 269 if (first_newline == NULL || first_newline[1] == '\0') |
| 270 first_newline = last_few_messages; |
| 271 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); |
264 } | 272 } |
265 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); | 273 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); |
266 // If the fatal error handler returns, we stop execution. | 274 // If the fatal error handler returns, we stop execution. |
267 FATAL("API fatal error handler returned after process out of memory"); | 275 FATAL("API fatal error handler returned after process out of memory"); |
268 } | 276 } |
269 | 277 |
270 | 278 |
271 void Utils::ReportApiFailure(const char* location, const char* message) { | 279 void Utils::ReportApiFailure(const char* location, const char* message) { |
272 i::Isolate* isolate = i::Isolate::Current(); | 280 i::Isolate* isolate = i::Isolate::Current(); |
273 FatalErrorCallback callback = isolate->exception_behavior(); | 281 FatalErrorCallback callback = isolate->exception_behavior(); |
(...skipping 7747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8021 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8029 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8022 Address callback_address = | 8030 Address callback_address = |
8023 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8031 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8024 VMState<EXTERNAL> state(isolate); | 8032 VMState<EXTERNAL> state(isolate); |
8025 ExternalCallbackScope call_scope(isolate, callback_address); | 8033 ExternalCallbackScope call_scope(isolate, callback_address); |
8026 callback(info); | 8034 callback(info); |
8027 } | 8035 } |
8028 | 8036 |
8029 | 8037 |
8030 } } // namespace v8::internal | 8038 } } // namespace v8::internal |
OLD | NEW |