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

Unified Diff: src/heap/heap.cc

Issue 1325643002: [heap] Fix recursive GCs caused by adjusting externally allocated memory (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index ab52719fd8ed293df0df459a867a2784e0571695..a4357f11fd2810df88382b46e6482cedf957d5af 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1800,6 +1800,9 @@ void Heap::RegisterNewArrayBuffer(bool in_new_space, void* data,
RegisterNewArrayBufferHelper(live_array_buffers_for_scavenge_, data,
length);
}
+
+ // We may go over the limit of externally allocated memory here. We call the
+ // api function to trigger a GC in this case.
reinterpret_cast<v8::Isolate*>(isolate_)
->AdjustAmountOfExternalAllocatedMemory(length);
}
@@ -1842,16 +1845,13 @@ void Heap::FreeDeadArrayBuffers(bool from_scavenge) {
live_array_buffers_for_scavenge_.erase(buffer.first);
}
}
- size_t freed_memory = FreeDeadArrayBuffersHelper(
+
+ // Do not call through the api as this code is triggered while doing a GC.
+ amount_of_external_allocated_memory_ += FreeDeadArrayBuffersHelper(
fedor.indutny 2015/08/31 20:48:18 This should be `-=`, right?
isolate_,
from_scavenge ? live_array_buffers_for_scavenge_ : live_array_buffers_,
from_scavenge ? not_yet_discovered_array_buffers_for_scavenge_
: not_yet_discovered_array_buffers_);
- if (freed_memory) {
- reinterpret_cast<v8::Isolate*>(isolate_)
- ->AdjustAmountOfExternalAllocatedMemory(
- -static_cast<int64_t>(freed_memory));
- }
}
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698