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

Unified Diff: src/heap/heap.cc

Issue 2188713004: [heap] Prepare Heap::CopyFixedArrayWithMap for black allocation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 4 years, 5 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 | « no previous file | 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 6b098a3f5bd187e3cec25be32bd55fe5df45e5aa..8e7596916ac12f031c9c2f537677c530540cdb67 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3822,17 +3822,20 @@ AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) {
if (!allocation.To(&obj)) return allocation;
}
obj->set_map_no_write_barrier(map);
- if (InNewSpace(obj)) {
+
+ FixedArray* result = FixedArray::cast(obj);
+ DisallowHeapAllocation no_gc;
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
+
+ // Eliminate the write barrier if possible.
+ if (mode == SKIP_WRITE_BARRIER) {
CopyBlock(obj->address() + kPointerSize, src->address() + kPointerSize,
FixedArray::SizeFor(len) - kPointerSize);
return obj;
}
- FixedArray* result = FixedArray::cast(obj);
- result->set_length(len);
- // Copy the content.
- DisallowHeapAllocation no_gc;
- WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
+ // Slow case: Just copy the content one-by-one.
+ result->set_length(len);
for (int i = 0; i < len; i++) result->set(i, src->get(i), mode);
return result;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698