summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/array-buffer-tracker-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/array-buffer-tracker-inl.h')
-rw-r--r--deps/v8/src/heap/array-buffer-tracker-inl.h18
1 files changed, 5 insertions, 13 deletions
diff --git a/deps/v8/src/heap/array-buffer-tracker-inl.h b/deps/v8/src/heap/array-buffer-tracker-inl.h
index 63d4147d41..b2d1115cba 100644
--- a/deps/v8/src/heap/array-buffer-tracker-inl.h
+++ b/deps/v8/src/heap/array-buffer-tracker-inl.h
@@ -20,14 +20,6 @@
namespace v8 {
namespace internal {
-inline size_t PerIsolateAccountingLength(JSArrayBuffer buffer) {
- // TODO(titzer): SharedArrayBuffers and shared WasmMemorys cause problems with
- // accounting for per-isolate external memory. In particular, sharing the same
- // array buffer or memory multiple times, which happens in stress tests, can
- // cause overcounting, leading to GC thrashing. Fix with global accounting?
- return buffer.is_shared() ? 0 : buffer.byte_length();
-}
-
void ArrayBufferTracker::RegisterNew(
Heap* heap, JSArrayBuffer buffer,
std::shared_ptr<BackingStore> backing_store) {
@@ -38,6 +30,7 @@ void ArrayBufferTracker::RegisterNew(
// ArrayBuffer tracking works only for small objects.
DCHECK(!heap->IsLargeObject(buffer));
DCHECK_EQ(backing_store->buffer_start(), buffer.backing_store());
+ const size_t length = backing_store->PerIsolateAccountingLength();
Page* page = Page::FromHeapObject(buffer);
{
@@ -57,7 +50,6 @@ void ArrayBufferTracker::RegisterNew(
// TODO(wez): Remove backing-store from external memory accounting.
// We may go over the limit of externally allocated memory here. We call the
// api function to trigger a GC in this case.
- const size_t length = PerIsolateAccountingLength(buffer);
reinterpret_cast<v8::Isolate*>(heap->isolate())
->AdjustAmountOfExternalAllocatedMemory(length);
}
@@ -66,7 +58,6 @@ std::shared_ptr<BackingStore> ArrayBufferTracker::Unregister(
Heap* heap, JSArrayBuffer buffer) {
std::shared_ptr<BackingStore> backing_store;
- const size_t length = PerIsolateAccountingLength(buffer);
Page* page = Page::FromHeapObject(buffer);
{
base::MutexGuard guard(page->mutex());
@@ -76,6 +67,7 @@ std::shared_ptr<BackingStore> ArrayBufferTracker::Unregister(
}
// TODO(wez): Remove backing-store from external memory accounting.
+ const size_t length = backing_store->PerIsolateAccountingLength();
heap->update_external_memory(-static_cast<intptr_t>(length));
return backing_store;
}
@@ -98,7 +90,7 @@ void LocalArrayBufferTracker::Free(Callback should_free) {
it != array_buffers_.end();) {
// Unchecked cast because the map might already be dead at this point.
JSArrayBuffer buffer = JSArrayBuffer::unchecked_cast(it->first);
- const size_t length = PerIsolateAccountingLength(buffer);
+ const size_t length = it->second->PerIsolateAccountingLength();
if (should_free(buffer)) {
// Destroy the shared pointer, (perhaps) freeing the backing store.
@@ -135,7 +127,7 @@ void ArrayBufferTracker::FreeDead(Page* page, MarkingState* marking_state) {
void LocalArrayBufferTracker::Add(JSArrayBuffer buffer,
std::shared_ptr<BackingStore> backing_store) {
- auto length = PerIsolateAccountingLength(buffer);
+ auto length = backing_store->PerIsolateAccountingLength();
page_->IncrementExternalBackingStoreBytes(
ExternalBackingStoreType::kArrayBuffer, length);
@@ -169,7 +161,7 @@ std::shared_ptr<BackingStore> LocalArrayBufferTracker::Remove(
array_buffers_.erase(it);
// Update accounting.
- auto length = PerIsolateAccountingLength(buffer);
+ auto length = backing_store->PerIsolateAccountingLength();
page_->DecrementExternalBackingStoreBytes(
ExternalBackingStoreType::kArrayBuffer, length);