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

Side by Side Diff: src/api.cc

Issue 1873443002: Improved diagnostic message for JS heap out of memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code review fix, use ternary operator Created 4 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
« no previous file with comments | « no previous file | src/heap/heap.h » ('j') | 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // --- E x c e p t i o n B e h a v i o r --- 234 // --- E x c e p t i o n B e h a v i o r ---
235 235
236 236
237 void i::FatalProcessOutOfMemory(const char* location) { 237 void i::FatalProcessOutOfMemory(const char* location) {
238 i::V8::FatalProcessOutOfMemory(location, false); 238 i::V8::FatalProcessOutOfMemory(location, false);
239 } 239 }
240 240
241 241
242 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. 242 // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
243 // The default fatal error handler is called and execution is stopped. 243 // The default fatal error handler is called and execution is stopped.
244 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { 244 void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
245 i::Isolate* isolate = i::Isolate::Current(); 245 i::Isolate* isolate = i::Isolate::Current();
246 char last_few_messages[Heap::kTraceRingBufferSize + 1]; 246 char last_few_messages[Heap::kTraceRingBufferSize + 1];
247 char js_stacktrace[Heap::kStacktraceBufferSize + 1]; 247 char js_stacktrace[Heap::kStacktraceBufferSize + 1];
248 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); 248 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1);
249 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1); 249 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1);
250 250
251 i::HeapStats heap_stats; 251 i::HeapStats heap_stats;
252 int start_marker; 252 int start_marker;
253 heap_stats.start_marker = &start_marker; 253 heap_stats.start_marker = &start_marker;
254 int new_space_size; 254 int new_space_size;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (isolate->heap()->HasBeenSetUp()) { 296 if (isolate->heap()->HasBeenSetUp()) {
297 // BUG(1718): Don't use the take_snapshot since we don't support 297 // BUG(1718): Don't use the take_snapshot since we don't support
298 // HeapIterator here without doing a special GC. 298 // HeapIterator here without doing a special GC.
299 isolate->heap()->RecordStats(&heap_stats, false); 299 isolate->heap()->RecordStats(&heap_stats, false);
300 char* first_newline = strchr(last_few_messages, '\n'); 300 char* first_newline = strchr(last_few_messages, '\n');
301 if (first_newline == NULL || first_newline[1] == '\0') 301 if (first_newline == NULL || first_newline[1] == '\0')
302 first_newline = last_few_messages; 302 first_newline = last_few_messages;
303 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline); 303 PrintF("\n<--- Last few GCs --->\n%s\n", first_newline);
304 PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace); 304 PrintF("\n<--- JS stacktrace --->\n%s\n", js_stacktrace);
305 } 305 }
306 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); 306 Utils::ApiCheck(false, location, is_heap_oom
307 ? "Allocation failed - JavaScript heap out of memory"
308 : "Allocation failed - process out of memory");
307 // If the fatal error handler returns, we stop execution. 309 // If the fatal error handler returns, we stop execution.
308 FATAL("API fatal error handler returned after process out of memory"); 310 FATAL("API fatal error handler returned after process out of memory");
309 } 311 }
310 312
311 313
312 void Utils::ReportApiFailure(const char* location, const char* message) { 314 void Utils::ReportApiFailure(const char* location, const char* message) {
313 i::Isolate* isolate = i::Isolate::Current(); 315 i::Isolate* isolate = i::Isolate::Current();
314 FatalErrorCallback callback = isolate->exception_behavior(); 316 FatalErrorCallback callback = isolate->exception_behavior();
315 if (callback == NULL) { 317 if (callback == NULL) {
316 base::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", location, 318 base::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", location,
(...skipping 8465 matching lines...) Expand 10 before | Expand all | Expand 10 after
8782 Address callback_address = 8784 Address callback_address =
8783 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8785 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8784 VMState<EXTERNAL> state(isolate); 8786 VMState<EXTERNAL> state(isolate);
8785 ExternalCallbackScope call_scope(isolate, callback_address); 8787 ExternalCallbackScope call_scope(isolate, callback_address);
8786 callback(info); 8788 callback(info);
8787 } 8789 }
8788 8790
8789 8791
8790 } // namespace internal 8792 } // namespace internal
8791 } // namespace v8 8793 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698