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

Side by Side Diff: src/heap/mark-compact.cc

Issue 637253004: Use smi zero instead of undefine_value to zap dead weak cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 } 2737 }
2738 heap()->set_encountered_weak_collections(Smi::FromInt(0)); 2738 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2739 } 2739 }
2740 2740
2741 2741
2742 void MarkCompactCollector::ProcessAndClearWeakCells() { 2742 void MarkCompactCollector::ProcessAndClearWeakCells() {
2743 HeapObject* undefined = heap()->undefined_value(); 2743 HeapObject* undefined = heap()->undefined_value();
2744 Object* weak_cell_obj = heap()->encountered_weak_cells(); 2744 Object* weak_cell_obj = heap()->encountered_weak_cells();
2745 while (weak_cell_obj != Smi::FromInt(0)) { 2745 while (weak_cell_obj != Smi::FromInt(0)) {
2746 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); 2746 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj);
2747 HeapObject* value = weak_cell->value(); 2747 // We do not insert cleared weak cells into the list, so the value
2748 // cannot be a Smi here.
2749 HeapObject* value = HeapObject::cast(weak_cell->value());
2748 if (!MarkCompactCollector::IsMarked(value)) { 2750 if (!MarkCompactCollector::IsMarked(value)) {
2749 weak_cell->clear(undefined); 2751 weak_cell->clear();
2750 } else { 2752 } else {
2751 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); 2753 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset);
2752 heap()->mark_compact_collector()->RecordSlot(slot, slot, value); 2754 heap()->mark_compact_collector()->RecordSlot(slot, slot, value);
2753 } 2755 }
2754 weak_cell_obj = weak_cell->next(); 2756 weak_cell_obj = weak_cell->next();
2755 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER); 2757 weak_cell->set_next(undefined, SKIP_WRITE_BARRIER);
2756 } 2758 }
2757 heap()->set_encountered_weak_cells(Smi::FromInt(0)); 2759 heap()->set_encountered_weak_cells(Smi::FromInt(0));
2758 } 2760 }
2759 2761
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
4449 SlotsBuffer* buffer = *buffer_address; 4451 SlotsBuffer* buffer = *buffer_address;
4450 while (buffer != NULL) { 4452 while (buffer != NULL) {
4451 SlotsBuffer* next_buffer = buffer->next(); 4453 SlotsBuffer* next_buffer = buffer->next();
4452 DeallocateBuffer(buffer); 4454 DeallocateBuffer(buffer);
4453 buffer = next_buffer; 4455 buffer = next_buffer;
4454 } 4456 }
4455 *buffer_address = NULL; 4457 *buffer_address = NULL;
4456 } 4458 }
4457 } 4459 }
4458 } // namespace v8::internal 4460 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698