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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp

Issue 2130293003: Change OOMs to raise custom exception rather than breakpoint on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return V8Location::toImpl(host)->frame(); 85 return V8Location::toImpl(host)->frame();
86 86
87 // This function can handle only those types listed above. 87 // This function can handle only those types listed above.
88 ASSERT_NOT_REACHED(); 88 ASSERT_NOT_REACHED();
89 return 0; 89 return 0;
90 } 90 }
91 91
92 static void reportFatalErrorInMainThread(const char* location, const char* messa ge) 92 static void reportFatalErrorInMainThread(const char* location, const char* messa ge)
93 { 93 {
94 int memoryUsageMB = Platform::current()->actualMemoryUsageMB(); 94 int memoryUsageMB = Platform::current()->actualMemoryUsageMB();
95 printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, locatio n, memoryUsageMB); 95 DVLOG(1) << "V8 error: " << message << " (" << location << "). Current memo ry usage: " << memoryUsageMB << " MB";
96 CRASH(); 96 CRASH();
97 } 97 }
98 98
99 static void reportOOMErrorInMainThread(const char* location, bool isJsHeap)
100 {
101 int memoryUsageMB = Platform::current()->actualMemoryUsageMB();
102 DVLOG(1) << "V8 " << (isJsHeap ? "javascript" : "process") << " OOM: (" << l ocation << "). Current memory usage: " << memoryUsageMB << " MB";
103 OOM_CRASH();
104 }
105
99 static String extractMessageForConsole(v8::Isolate* isolate, v8::Local<v8::Value > data) 106 static String extractMessageForConsole(v8::Isolate* isolate, v8::Local<v8::Value > data)
100 { 107 {
101 if (V8DOMWrapper::isWrapper(isolate, data)) { 108 if (V8DOMWrapper::isWrapper(isolate, data)) {
102 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(data); 109 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(data);
103 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); 110 const WrapperTypeInfo* type = toWrapperTypeInfo(obj);
104 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { 111 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) {
105 DOMException* exception = V8DOMException::toImpl(obj); 112 DOMException* exception = V8DOMException::toImpl(obj);
106 if (exception && !exception->messageForConsole().isEmpty()) 113 if (exception && !exception->messageForConsole().isEmpty())
107 return exception->toStringForConsole(); 114 return exception->toStringForConsole();
108 } 115 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 WTF::ArrayBufferContents::initialize(adjustAmountOfExternalAllocatedMemory); 356 WTF::ArrayBufferContents::initialize(adjustAmountOfExternalAllocatedMemory);
350 357
351 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); 358 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ());
352 auto v8ExtrasMode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() ? gin::IsolateHolder::kStableAndExperimentalV8Extras : gin::IsolateHolder::kStable V8Extras; 359 auto v8ExtrasMode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() ? gin::IsolateHolder::kStableAndExperimentalV8Extras : gin::IsolateHolder::kStable V8Extras;
353 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, v8ExtrasM ode, &arrayBufferAllocator); 360 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, v8ExtrasM ode, &arrayBufferAllocator);
354 361
355 v8::Isolate* isolate = V8PerIsolateData::initialize(); 362 v8::Isolate* isolate = V8PerIsolateData::initialize();
356 363
357 initializeV8Common(isolate); 364 initializeV8Common(isolate);
358 365
366 isolate->SetOOMErrorHandler(reportOOMErrorInMainThread);
359 isolate->SetFatalErrorHandler(reportFatalErrorInMainThread); 367 isolate->SetFatalErrorHandler(reportFatalErrorInMainThread);
360 isolate->AddMessageListener(messageHandlerInMainThread); 368 isolate->AddMessageListener(messageHandlerInMainThread);
361 isolate->SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMai nThread); 369 isolate->SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMai nThread);
362 isolate->SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallba ckInMainThread); 370 isolate->SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallba ckInMainThread);
363 371
364 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { 372 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) {
365 WebScheduler* scheduler = Platform::current()->currentThread()->schedule r(); 373 WebScheduler* scheduler = Platform::current()->currentThread()->schedule r();
366 V8PerIsolateData::enableIdleTasks(isolate, wrapUnique(new V8IdleTaskRunn er(scheduler))); 374 V8PerIsolateData::enableIdleTasks(isolate, wrapUnique(new V8IdleTaskRunn er(scheduler)));
367 } 375 }
368 376
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 453
446 isolate->AddMessageListener(messageHandlerInWorker); 454 isolate->AddMessageListener(messageHandlerInWorker);
447 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); 455 isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
448 456
449 uint32_t here; 457 uint32_t here;
450 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 458 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
451 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 459 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
452 } 460 }
453 461
454 } // namespace blink 462 } // namespace blink
OLDNEW
« no previous file with comments | « skia/ext/SkMemory_new_handler.cpp ('k') | third_party/WebKit/Source/platform/heap/PageMemory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698