Chromium Code Reviews| Index: src/heap/heap.cc |
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
| index e164a398eb88c4594be8c4e829d4cfa0087c56ab..f707f0a6b8e07ad9a5d537a53695eda7a48a3178 100644 |
| --- a/src/heap/heap.cc |
| +++ b/src/heap/heap.cc |
| @@ -150,6 +150,7 @@ Heap::Heap() |
| set_array_buffers_list(Smi::FromInt(0)); |
| set_allocation_sites_list(Smi::FromInt(0)); |
| set_encountered_weak_collections(Smi::FromInt(0)); |
| + set_encountered_weak_cells(Smi::FromInt(0)); |
| // Put a dummy entry in the remembered pages so we can find the list the |
| // minidump even if there are no real unmapped pages. |
| RememberUnmappedPage(NULL, false); |
| @@ -1509,6 +1510,8 @@ void Heap::Scavenge() { |
| // Copy objects reachable from the encountered weak collections list. |
| scavenge_visitor.VisitPointer(&encountered_weak_collections_); |
| + // Copy objects reachable from the encountered weak cells. |
| + scavenge_visitor.VisitPointer(&encountered_weak_cells_); |
| // Copy objects reachable from the code flushing candidates list. |
| MarkCompactCollector* collector = mark_compact_collector(); |
| @@ -2559,6 +2562,7 @@ bool Heap::CreateInitialMaps() { |
| ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell) |
| ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell) |
| + ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell) |
| ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler) |
| ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler) |
| @@ -2685,6 +2689,22 @@ AllocationResult Heap::AllocatePropertyCell() { |
| } |
| +AllocationResult Heap::AllocateWeakCell(HeapObject* value) { |
| + int size = WeakCell::kSize; |
| + STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); |
| + HeapObject* result; |
| + { |
| + AllocationResult allocation = |
| + AllocateRaw(size, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |
| + if (!allocation.To(&result)) return allocation; |
| + } |
| + result->set_map_no_write_barrier(weak_cell_map()); |
| + WeakCell::cast(result)->update_value_from_gc(value); |
|
Erik Corry
2014/10/13 15:56:17
This is from allocation, not from GC, so probably
ulan
2014/10/14 10:17:22
Introduced a new function "initialize" for this an
|
| + WeakCell::cast(result)->set_next(undefined_value()); |
|
Erik Corry
2014/10/13 15:56:17
There's no need to set the write barrier when sett
ulan
2014/10/14 10:17:22
Done.
|
| + return result; |
| +} |
| + |
| + |
| void Heap::CreateApiObjects() { |
| HandleScope scope(isolate()); |
| Factory* factory = isolate()->factory(); |
| @@ -5169,6 +5189,7 @@ bool Heap::CreateHeapObjects() { |
| set_native_contexts_list(undefined_value()); |
| set_array_buffers_list(undefined_value()); |
| set_allocation_sites_list(undefined_value()); |
| + set_encountered_weak_cells(undefined_value()); |
| weak_object_to_code_table_ = undefined_value(); |
| return true; |
| } |