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

Unified Diff: src/heap/array-buffer-tracker.cc

Issue 2870683003: [heap] Factor out marking state of array buffer tracker (Closed)
Patch Set: Get MarkingState out of thin air Created 3 years, 7 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/heap/array-buffer-tracker.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/array-buffer-tracker.cc
diff --git a/src/heap/array-buffer-tracker.cc b/src/heap/array-buffer-tracker.cc
index 5423dfaed9c731de3835aede1c577c7a650b0811..8602dcdedf48b1a0795075d030d683aa55bb586a 100644
--- a/src/heap/array-buffer-tracker.cc
+++ b/src/heap/array-buffer-tracker.cc
@@ -5,6 +5,7 @@
#include "src/heap/array-buffer-tracker.h"
#include "src/heap/array-buffer-tracker-inl.h"
#include "src/heap/heap.h"
+#include "src/heap/spaces.h"
namespace v8 {
namespace internal {
@@ -13,16 +14,13 @@ LocalArrayBufferTracker::~LocalArrayBufferTracker() {
CHECK(array_buffers_.empty());
}
-template <LocalArrayBufferTracker::FreeMode free_mode>
-void LocalArrayBufferTracker::Free() {
+template <typename Callback>
+void LocalArrayBufferTracker::Free(Callback should_free) {
size_t freed_memory = 0;
for (TrackingData::iterator it = array_buffers_.begin();
it != array_buffers_.end();) {
JSArrayBuffer* buffer = reinterpret_cast<JSArrayBuffer*>(it->first);
- // TODO(mlippautz): Create a dependency on the collector to avoid getting
- // the marking state out of thin air.
- if ((free_mode == kFreeAll) ||
- ObjectMarking::IsWhite(buffer, MarkingState::Internal(buffer))) {
+ if (should_free(buffer)) {
const size_t len = it->second;
heap_->isolate()->array_buffer_allocator()->Free(buffer->backing_store(),
len);
@@ -88,12 +86,14 @@ void ArrayBufferTracker::FreeDeadInNewSpace(Heap* heap) {
heap->account_external_memory_concurrently_freed();
}
-void ArrayBufferTracker::FreeDead(Page* page) {
+void ArrayBufferTracker::FreeDead(Page* page,
+ const MarkingState& marking_state) {
// Callers need to ensure having the page lock.
LocalArrayBufferTracker* tracker = page->local_tracker();
if (tracker == nullptr) return;
- DCHECK(!page->SweepingDone());
- tracker->Free<LocalArrayBufferTracker::kFreeDead>();
+ tracker->Free([&marking_state](JSArrayBuffer* buffer) {
+ return ObjectMarking::IsWhite(buffer, marking_state);
+ });
if (tracker->IsEmpty()) {
page->ReleaseLocalTracker();
}
@@ -102,7 +102,7 @@ void ArrayBufferTracker::FreeDead(Page* page) {
void ArrayBufferTracker::FreeAll(Page* page) {
LocalArrayBufferTracker* tracker = page->local_tracker();
if (tracker == nullptr) return;
- tracker->Free<LocalArrayBufferTracker::kFreeAll>();
+ tracker->Free([](JSArrayBuffer* buffer) { return true; });
if (tracker->IsEmpty()) {
page->ReleaseLocalTracker();
}
« no previous file with comments | « src/heap/array-buffer-tracker.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698