| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return data; | 352 return data; |
| 353 } | 353 } |
| 354 | 354 |
| 355 void Free(void* data, size_t size) override { | 355 void Free(void* data, size_t size) override { |
| 356 WTF::ArrayBufferContents::freeMemory(data, size); | 356 WTF::ArrayBufferContents::freeMemory(data, size); |
| 357 } | 357 } |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 } // namespace | 360 } // namespace |
| 361 | 361 |
| 362 static void adjustAmountOfExternalAllocatedMemory(int64_t size) { | 362 static void adjustAmountOfExternalAllocatedMemory(int64_t diff) { |
| 363 #if ENABLE(ASSERT) | 363 #if ENABLE(ASSERT) |
| 364 static int64_t totalSize = 0; | 364 DEFINE_THREAD_SAFE_STATIC_LOCAL(int64_t, processTotal, new int64_t(0)); |
| 365 totalSize += size; | 365 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); |
| 366 DCHECK_GE(totalSize, 0); | 366 { |
| 367 MutexLocker locker(mutex); |
| 368 |
| 369 processTotal += diff; |
| 370 DCHECK_GE(processTotal, 0) << "total amount = " << processTotal |
| 371 << ", diff = " << diff; |
| 372 } |
| 367 #endif | 373 #endif |
| 368 | 374 |
| 369 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size); | 375 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); |
| 370 } | 376 } |
| 371 | 377 |
| 372 void V8Initializer::initializeMainThread() { | 378 void V8Initializer::initializeMainThread() { |
| 373 ASSERT(isMainThread()); | 379 ASSERT(isMainThread()); |
| 374 | 380 |
| 375 WTF::ArrayBufferContents::initialize(adjustAmountOfExternalAllocatedMemory); | 381 WTF::ArrayBufferContents::initialize(adjustAmountOfExternalAllocatedMemory); |
| 376 | 382 |
| 377 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); | 383 DEFINE_STATIC_LOCAL(ArrayBufferAllocator, arrayBufferAllocator, ()); |
| 378 auto v8ExtrasMode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() | 384 auto v8ExtrasMode = RuntimeEnabledFeatures::experimentalV8ExtrasEnabled() |
| 379 ? gin::IsolateHolder::kStableAndExperimentalV8Extras | 385 ? gin::IsolateHolder::kStableAndExperimentalV8Extras |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 isolate->AddMessageListener(messageHandlerInWorker); | 492 isolate->AddMessageListener(messageHandlerInWorker); |
| 487 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 493 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
| 488 | 494 |
| 489 uint32_t here; | 495 uint32_t here; |
| 490 isolate->SetStackLimit(reinterpret_cast<uintptr_t>( | 496 isolate->SetStackLimit(reinterpret_cast<uintptr_t>( |
| 491 &here - kWorkerMaxStackSize / sizeof(uint32_t*))); | 497 &here - kWorkerMaxStackSize / sizeof(uint32_t*))); |
| 492 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 498 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 493 } | 499 } |
| 494 | 500 |
| 495 } // namespace blink | 501 } // namespace blink |
| OLD | NEW |