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

Side by Side Diff: src/api.cc

Issue 2427623002: Fix OOM handling on a background thread. (Closed)
Patch Set: Created 4 years, 2 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 | no next file » | 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void i::FatalProcessOutOfMemory(const char* location) { 267 void i::FatalProcessOutOfMemory(const char* location) {
268 i::V8::FatalProcessOutOfMemory(location, false); 268 i::V8::FatalProcessOutOfMemory(location, false);
269 } 269 }
270 270
271 // When V8 cannot allocate memory FatalProcessOutOfMemory is called. The default 271 // When V8 cannot allocate memory FatalProcessOutOfMemory is called. The default
272 // OOM error handler is called and execution is stopped. 272 // OOM error handler is called and execution is stopped.
273 void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) { 273 void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
274 i::Isolate* isolate = i::Isolate::Current(); 274 i::Isolate* isolate = i::Isolate::Current();
275 char last_few_messages[Heap::kTraceRingBufferSize + 1]; 275 char last_few_messages[Heap::kTraceRingBufferSize + 1];
276 char js_stacktrace[Heap::kStacktraceBufferSize + 1]; 276 char js_stacktrace[Heap::kStacktraceBufferSize + 1];
277 i::HeapStats heap_stats;
278
279 if (isolate == nullptr) {
280 // On a background thread -> we cannot retrieve memory information from the
281 // Isolate. Write easy-to-recognize values on the stack.
282 memset(last_few_messages, 0x0badc0de, Heap::kTraceRingBufferSize + 1);
283 memset(js_stacktrace, 0x0badc0de, Heap::kStacktraceBufferSize + 1);
284 memset(&heap_stats, 0xbadc0de, sizeof(heap_stats));
285 // Note that the embedder's oom handler won't be called in this case. We
286 // just crash.
287 FATAL("API fatal error handler returned after process out of memory");
288 return;
289 }
290
277 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1); 291 memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1);
278 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1); 292 memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1);
279 293
280 i::HeapStats heap_stats;
281 intptr_t start_marker; 294 intptr_t start_marker;
282 heap_stats.start_marker = &start_marker; 295 heap_stats.start_marker = &start_marker;
283 size_t new_space_size; 296 size_t new_space_size;
284 heap_stats.new_space_size = &new_space_size; 297 heap_stats.new_space_size = &new_space_size;
285 size_t new_space_capacity; 298 size_t new_space_capacity;
286 heap_stats.new_space_capacity = &new_space_capacity; 299 heap_stats.new_space_capacity = &new_space_capacity;
287 size_t old_space_size; 300 size_t old_space_size;
288 heap_stats.old_space_size = &old_space_size; 301 heap_stats.old_space_size = &old_space_size;
289 size_t old_space_capacity; 302 size_t old_space_capacity;
290 heap_stats.old_space_capacity = &old_space_capacity; 303 heap_stats.old_space_capacity = &old_space_capacity;
(...skipping 9124 matching lines...) Expand 10 before | Expand all | Expand 10 after
9415 Address callback_address = 9428 Address callback_address =
9416 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9429 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9417 VMState<EXTERNAL> state(isolate); 9430 VMState<EXTERNAL> state(isolate);
9418 ExternalCallbackScope call_scope(isolate, callback_address); 9431 ExternalCallbackScope call_scope(isolate, callback_address);
9419 callback(info); 9432 callback(info);
9420 } 9433 }
9421 9434
9422 9435
9423 } // namespace internal 9436 } // namespace internal
9424 } // namespace v8 9437 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698