Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index 4e0e8a67c2217213c0c0a28939d8d147f01fec47..336608daf116c116c1f66dff6264f0671faf91ab 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -5038,6 +5038,27 @@ MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) { |
} |
+MaybeObject* Heap::CopyAndTenureFixedCOWArray(FixedArray* src) { |
+ ASSERT(InNewSpace(src)); |
Hannes Payer (out of office)
2014/03/17 09:37:18
This ASSERT may be wrong here, but it should hold
mvstanton
2014/03/17 12:25:28
Great idea, thx, done.
|
+ int len = src->length(); |
+ Object* obj; |
+ { MaybeObject* maybe_obj = AllocateRawFixedArray(len, TENURED); |
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
+ } |
+ HeapObject::cast(obj)->set_map_no_write_barrier(fixed_array_map()); |
Hannes Payer (out of office)
2014/03/17 09:37:18
Can you set fixed_cow_array_map() here?
mvstanton
2014/03/17 12:25:28
No because of protections in FixedArray::set() aga
|
+ FixedArray* result = FixedArray::cast(obj); |
+ result->set_length(len); |
+ |
+ // Copy the content |
+ DisallowHeapAllocation no_gc; |
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
+ for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
+ |
+ HeapObject::cast(obj)->set_map_no_write_barrier(fixed_cow_array_map()); |
+ return result; |
+} |
+ |
+ |
MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
int len = src->length(); |
Object* obj; |