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

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

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 isolate->SetAutorunMicrotasks(false); 346 isolate->SetAutorunMicrotasks(false);
347 } 347 }
348 348
349 namespace { 349 namespace {
350 350
351 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 351 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
352 void* Allocate(size_t size) override 352 void* Allocate(size_t size) override
353 { 353 {
354 void* data; 354 void* data;
355 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data); 355 // TODO(junov): crbug.com/536816
356 // Use AllocateMemoryOrNull. Requires verification that all
357 // call sites can handle allocation failures (nullptr) gracefully.
358 WTF::ArrayBufferContents::deprecatedAllocateMemoryOrCrash(size, WTF::Arr ayBufferContents::ZeroInitialize, data);
356 return data; 359 return data;
357 } 360 }
358 361
359 void* AllocateUninitialized(size_t size) override 362 void* AllocateUninitialized(size_t size) override
360 { 363 {
361 void* data; 364 void* data;
362 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :DontInitialize, data); 365 // TODO(junov): crbug.com/536816
366 // Use AllocateMemoryOrNull. Requires verification that all
367 // call sites can handle allocation failures (nullptr) gracefully.
368 WTF::ArrayBufferContents::deprecatedAllocateMemoryOrCrash(size, WTF::Arr ayBufferContents::DontInitialize, data);
363 return data; 369 return data;
364 } 370 }
365 371
366 void Free(void* data, size_t size) override 372 void Free(void* data, size_t size) override
367 { 373 {
368 WTF::ArrayBufferContents::freeMemory(data, size); 374 WTF::ArrayBufferContents::freeMemory(data, size);
369 } 375 }
370 }; 376 };
371 377
372 } // namespace 378 } // namespace
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 465
460 v8::V8::AddMessageListener(messageHandlerInWorker); 466 v8::V8::AddMessageListener(messageHandlerInWorker);
461 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 467 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
462 468
463 uint32_t here; 469 uint32_t here;
464 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 470 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
465 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 471 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
466 } 472 }
467 473
468 } // namespace blink 474 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698