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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 isolate->SetUseCounterCallback(&useCounterCallback); | 382 isolate->SetUseCounterCallback(&useCounterCallback); |
383 } | 383 } |
384 | 384 |
385 namespace { | 385 namespace { |
386 | 386 |
387 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 387 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
388 // Allocate() methods return null to signal allocation failure to V8, which | 388 // Allocate() methods return null to signal allocation failure to V8, which |
389 // should respond by throwing a RangeError, per | 389 // should respond by throwing a RangeError, per |
390 // http://www.ecma-international.org/ecma-262/6.0/#sec-createbytedatablock. | 390 // http://www.ecma-international.org/ecma-262/6.0/#sec-createbytedatablock. |
391 void* Allocate(size_t size) override { | 391 void* Allocate(size_t size) override { |
392 void* data; | 392 return WTF::ArrayBufferContents::allocateMemoryOrNull( |
393 WTF::ArrayBufferContents::allocateMemoryOrNull( | 393 size, WTF::ArrayBufferContents::ZeroInitialize); |
394 size, WTF::ArrayBufferContents::ZeroInitialize, data); | |
395 return data; | |
396 } | 394 } |
397 | 395 |
398 void* AllocateUninitialized(size_t size) override { | 396 void* AllocateUninitialized(size_t size) override { |
399 void* data; | 397 return WTF::ArrayBufferContents::allocateMemoryOrNull( |
400 WTF::ArrayBufferContents::allocateMemoryOrNull( | 398 size, WTF::ArrayBufferContents::DontInitialize); |
401 size, WTF::ArrayBufferContents::DontInitialize, data); | |
402 return data; | |
403 } | 399 } |
404 | 400 |
405 void Free(void* data, size_t size) override { | 401 void Free(void* data, size_t size) override { |
406 WTF::ArrayBufferContents::freeMemory(data, size); | 402 WTF::ArrayBufferContents::freeMemory(data); |
407 } | 403 } |
408 }; | 404 }; |
409 | 405 |
410 } // namespace | 406 } // namespace |
411 | 407 |
412 static void adjustAmountOfExternalAllocatedMemory(int64_t diff) { | 408 static void adjustAmountOfExternalAllocatedMemory(int64_t diff) { |
413 #if DCHECK_IS_ON() | 409 #if DCHECK_IS_ON() |
414 DEFINE_THREAD_SAFE_STATIC_LOCAL(int64_t, processTotal, new int64_t(0)); | 410 DEFINE_THREAD_SAFE_STATIC_LOCAL(int64_t, processTotal, new int64_t(0)); |
415 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); | 411 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); |
416 { | 412 { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 v8::Isolate::kMessageLog); | 558 v8::Isolate::kMessageLog); |
563 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 559 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
564 | 560 |
565 uint32_t here; | 561 uint32_t here; |
566 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - | 562 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - |
567 kWorkerMaxStackSize); | 563 kWorkerMaxStackSize); |
568 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 564 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
569 } | 565 } |
570 | 566 |
571 } // namespace blink | 567 } // namespace blink |
OLD | NEW |