Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 } | 440 } |
| 441 | 441 |
| 442 // TODO: if other transferables start accounting for their external | 442 // TODO: if other transferables start accounting for their external |
| 443 // allocations with V8, extend this with corresponding cases. | 443 // allocations with V8, extend this with corresponding cases. |
| 444 if (m_arrayBufferContentsArray && | 444 if (m_arrayBufferContentsArray && |
| 445 !m_transferablesNeedExternalAllocationRegistration) { | 445 !m_transferablesNeedExternalAllocationRegistration) { |
| 446 for (auto& buffer : *m_arrayBufferContentsArray) | 446 for (auto& buffer : *m_arrayBufferContentsArray) |
| 447 buffer.unregisterExternalAllocationWithCurrentContext(); | 447 buffer.unregisterExternalAllocationWithCurrentContext(); |
| 448 m_transferablesNeedExternalAllocationRegistration = true; | 448 m_transferablesNeedExternalAllocationRegistration = true; |
| 449 } | 449 } |
| 450 | |
| 451 if (m_imageBitmapContentsArray && | |
| 452 !m_transferablesNeedExternalAllocationRegistration) { | |
| 453 for (auto& buffer : *m_imageBitmapContentsArray) | |
| 454 buffer->unregisterExternalAllocationWithCurrentContext(); | |
| 455 m_transferablesNeedExternalAllocationRegistration = true; | |
|
jbroman
2017/04/04 15:44:56
This would need to be fused with the one above. Ot
| |
| 456 } | |
| 450 } | 457 } |
| 451 | 458 |
| 452 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { | 459 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { |
| 453 if (m_hasRegisteredExternalAllocation) | 460 if (m_hasRegisteredExternalAllocation) |
| 454 return; | 461 return; |
| 455 | 462 |
| 456 m_hasRegisteredExternalAllocation = true; | 463 m_hasRegisteredExternalAllocation = true; |
| 457 int64_t diff = static_cast<int64_t>(dataLengthInBytes()); | 464 int64_t diff = static_cast<int64_t>(dataLengthInBytes()); |
| 458 DCHECK_GE(diff, 0); | 465 DCHECK_GE(diff, 0); |
| 459 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); | 466 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(diff); |
| 460 | 467 |
| 461 // Only (re)register allocation cost for transferables if this | 468 // Only (re)register allocation cost for transferables if this |
| 462 // SerializedScriptValue has explicitly unregistered them before. | 469 // SerializedScriptValue has explicitly unregistered them before. |
| 463 if (m_arrayBufferContentsArray && | 470 if (m_arrayBufferContentsArray && |
| 464 m_transferablesNeedExternalAllocationRegistration) { | 471 m_transferablesNeedExternalAllocationRegistration) { |
| 465 for (auto& buffer : *m_arrayBufferContentsArray) | 472 for (auto& buffer : *m_arrayBufferContentsArray) |
| 466 buffer.registerExternalAllocationWithCurrentContext(); | 473 buffer.registerExternalAllocationWithCurrentContext(); |
| 467 } | 474 } |
| 475 | |
| 476 if (m_imageBitmapContentsArray && | |
| 477 m_transferablesNeedExternalAllocationRegistration) { | |
| 478 for (auto& buffer : *m_imageBitmapContentsArray) | |
| 479 buffer->registerExternalAllocationWithCurrentContext(); | |
| 480 } | |
| 468 } | 481 } |
| 469 | 482 |
| 470 } // namespace blink | 483 } // namespace blink |
| OLD | NEW |