OLD | NEW |
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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 public: | 1672 public: |
1673 explicit StringTableCleaner(Heap* heap) : heap_(heap), pointers_removed_(0) {} | 1673 explicit StringTableCleaner(Heap* heap) : heap_(heap), pointers_removed_(0) {} |
1674 | 1674 |
1675 virtual void VisitPointers(Object** start, Object** end) { | 1675 virtual void VisitPointers(Object** start, Object** end) { |
1676 // Visit all HeapObject pointers in [start, end). | 1676 // Visit all HeapObject pointers in [start, end). |
1677 for (Object** p = start; p < end; p++) { | 1677 for (Object** p = start; p < end; p++) { |
1678 Object* o = *p; | 1678 Object* o = *p; |
1679 if (o->IsHeapObject() && | 1679 if (o->IsHeapObject() && |
1680 Marking::IsWhite(Marking::MarkBitFrom(HeapObject::cast(o)))) { | 1680 Marking::IsWhite(Marking::MarkBitFrom(HeapObject::cast(o)))) { |
1681 if (finalize_external_strings) { | 1681 if (finalize_external_strings) { |
1682 DCHECK(o->IsExternalString()); | 1682 // We must never finalize a string that was copied (has a forwarding |
| 1683 // map). |
| 1684 CHECK(o->IsExternalString()); |
1683 heap_->FinalizeExternalString(String::cast(*p)); | 1685 heap_->FinalizeExternalString(String::cast(*p)); |
1684 } else { | 1686 } else { |
1685 pointers_removed_++; | 1687 pointers_removed_++; |
1686 } | 1688 } |
1687 // Set the entry to the_hole_value (as deleted). | 1689 // Set the entry to the_hole_value (as deleted). |
1688 *p = heap_->the_hole_value(); | 1690 *p = heap_->the_hole_value(); |
| 1691 } else { |
| 1692 // Anything in the external string table has to be either a string or |
| 1693 // the hole. |
| 1694 CHECK(!finalize_external_strings || o->IsExternalString() || |
| 1695 o->IsTheHole()); |
1689 } | 1696 } |
1690 } | 1697 } |
1691 } | 1698 } |
1692 | 1699 |
1693 int PointersRemoved() { | 1700 int PointersRemoved() { |
1694 DCHECK(!finalize_external_strings); | 1701 DCHECK(!finalize_external_strings); |
1695 return pointers_removed_; | 1702 return pointers_removed_; |
1696 } | 1703 } |
1697 | 1704 |
1698 private: | 1705 private: |
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4674 SlotsBuffer* buffer = *buffer_address; | 4681 SlotsBuffer* buffer = *buffer_address; |
4675 while (buffer != NULL) { | 4682 while (buffer != NULL) { |
4676 SlotsBuffer* next_buffer = buffer->next(); | 4683 SlotsBuffer* next_buffer = buffer->next(); |
4677 DeallocateBuffer(buffer); | 4684 DeallocateBuffer(buffer); |
4678 buffer = next_buffer; | 4685 buffer = next_buffer; |
4679 } | 4686 } |
4680 *buffer_address = NULL; | 4687 *buffer_address = NULL; |
4681 } | 4688 } |
4682 } // namespace internal | 4689 } // namespace internal |
4683 } // namespace v8 | 4690 } // namespace v8 |
OLD | NEW |