| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "v8/include/v8-debug.h" | 69 #include "v8/include/v8-debug.h" |
| 70 #include "v8/include/v8-profiler.h" | 70 #include "v8/include/v8-profiler.h" |
| 71 | 71 |
| 72 namespace blink { | 72 namespace blink { |
| 73 | 73 |
| 74 static void ReportFatalErrorInMainThread(const char* location, | 74 static void ReportFatalErrorInMainThread(const char* location, |
| 75 const char* message) { | 75 const char* message) { |
| 76 int memory_usage_mb = Platform::Current()->ActualMemoryUsageMB(); | 76 int memory_usage_mb = Platform::Current()->ActualMemoryUsageMB(); |
| 77 DVLOG(1) << "V8 error: " << message << " (" << location | 77 DVLOG(1) << "V8 error: " << message << " (" << location |
| 78 << "). Current memory usage: " << memory_usage_mb << " MB"; | 78 << "). Current memory usage: " << memory_usage_mb << " MB"; |
| 79 CRASH(); | 79 IMMEDIATE_CRASH(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 static void ReportOOMErrorInMainThread(const char* location, bool is_js_heap) { | 82 static void ReportOOMErrorInMainThread(const char* location, bool is_js_heap) { |
| 83 int memory_usage_mb = Platform::Current()->ActualMemoryUsageMB(); | 83 int memory_usage_mb = Platform::Current()->ActualMemoryUsageMB(); |
| 84 DVLOG(1) << "V8 " << (is_js_heap ? "javascript" : "process") << " OOM: (" | 84 DVLOG(1) << "V8 " << (is_js_heap ? "javascript" : "process") << " OOM: (" |
| 85 << location << "). Current memory usage: " << memory_usage_mb | 85 << location << "). Current memory usage: " << memory_usage_mb |
| 86 << " MB"; | 86 << " MB"; |
| 87 OOM_CRASH(); | 87 OOM_CRASH(); |
| 88 } | 88 } |
| 89 | 89 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 V8PerIsolateData::From(isolate)->SetThreadDebugger( | 478 V8PerIsolateData::From(isolate)->SetThreadDebugger( |
| 479 WTF::MakeUnique<MainThreadDebugger>(isolate)); | 479 WTF::MakeUnique<MainThreadDebugger>(isolate)); |
| 480 | 480 |
| 481 BindingSecurity::InitWrapperCreationSecurityCheck(); | 481 BindingSecurity::InitWrapperCreationSecurityCheck(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 static void ReportFatalErrorInWorker(const char* location, | 484 static void ReportFatalErrorInWorker(const char* location, |
| 485 const char* message) { | 485 const char* message) { |
| 486 // FIXME: We temporarily deal with V8 internal error situations such as | 486 // FIXME: We temporarily deal with V8 internal error situations such as |
| 487 // out-of-memory by crashing the worker. | 487 // out-of-memory by crashing the worker. |
| 488 CRASH(); | 488 IMMEDIATE_CRASH(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 static void MessageHandlerInWorker(v8::Local<v8::Message> message, | 491 static void MessageHandlerInWorker(v8::Local<v8::Message> message, |
| 492 v8::Local<v8::Value> data) { | 492 v8::Local<v8::Value> data) { |
| 493 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 493 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 494 V8PerIsolateData* per_isolate_data = V8PerIsolateData::From(isolate); | 494 V8PerIsolateData* per_isolate_data = V8PerIsolateData::From(isolate); |
| 495 | 495 |
| 496 // During the frame teardown, there may not be a valid context. | 496 // During the frame teardown, there may not be a valid context. |
| 497 ScriptState* script_state = ScriptState::Current(isolate); | 497 ScriptState* script_state = ScriptState::Current(isolate); |
| 498 if (!script_state->ContextIsValid()) | 498 if (!script_state->ContextIsValid()) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 v8::Isolate::kMessageLog); | 558 v8::Isolate::kMessageLog); |
| 559 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); | 559 isolate->SetFatalErrorHandler(ReportFatalErrorInWorker); |
| 560 | 560 |
| 561 uint32_t here; | 561 uint32_t here; |
| 562 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - | 562 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - |
| 563 kWorkerMaxStackSize); | 563 kWorkerMaxStackSize); |
| 564 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); | 564 isolate->SetPromiseRejectCallback(PromiseRejectHandlerInWorker); |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace blink | 567 } // namespace blink |
| OLD | NEW |