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

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

Issue 1577783004: [v8] don't crash when ArrayBuffer allocation fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a little comment explaining the contract Created 4 years, 11 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue); 322 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue);
323 323
324 v8::Debug::SetLiveEditEnabled(isolate, false); 324 v8::Debug::SetLiveEditEnabled(isolate, false);
325 325
326 isolate->SetAutorunMicrotasks(false); 326 isolate->SetAutorunMicrotasks(false);
327 } 327 }
328 328
329 namespace { 329 namespace {
330 330
331 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 331 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
332 // Allocate() methods return null to signal allocation failure to V8, which should respond by throwing
333 // a RangeError, per http://www.ecma-international.org/ecma-262/6.0/#sec-cre atebytedatablock.
332 void* Allocate(size_t size) override 334 void* Allocate(size_t size) override
333 { 335 {
334 void* data; 336 void* data;
335 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :ZeroInitialize, data); 337 WTF::ArrayBufferContents::allocateMemoryOrNull(size, WTF::ArrayBufferCon tents::ZeroInitialize, data);
336 return data; 338 return data;
337 } 339 }
338 340
339 void* AllocateUninitialized(size_t size) override 341 void* AllocateUninitialized(size_t size) override
340 { 342 {
341 void* data; 343 void* data;
342 WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents: :DontInitialize, data); 344 WTF::ArrayBufferContents::allocateMemoryOrNull(size, WTF::ArrayBufferCon tents::DontInitialize, data);
343 return data; 345 return data;
344 } 346 }
345 347
346 void Free(void* data, size_t size) override 348 void Free(void* data, size_t size) override
347 { 349 {
348 WTF::ArrayBufferContents::freeMemory(data, size); 350 WTF::ArrayBufferContents::freeMemory(data, size);
349 } 351 }
350 }; 352 };
351 353
352 } // namespace 354 } // namespace
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 441
440 isolate->AddMessageListener(messageHandlerInWorker); 442 isolate->AddMessageListener(messageHandlerInWorker);
441 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); 443 isolate->SetFatalErrorHandler(reportFatalErrorInWorker);
442 444
443 uint32_t here; 445 uint32_t here;
444 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 446 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
445 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 447 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
446 } 448 }
447 449
448 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698