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/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 return NULL; | 1758 return NULL; |
1759 } | 1759 } |
1760 | 1760 |
1761 // String is still reachable. | 1761 // String is still reachable. |
1762 return String::cast(first_word.ToForwardingAddress()); | 1762 return String::cast(first_word.ToForwardingAddress()); |
1763 } | 1763 } |
1764 | 1764 |
1765 | 1765 |
1766 void Heap::UpdateNewSpaceReferencesInExternalStringTable( | 1766 void Heap::UpdateNewSpaceReferencesInExternalStringTable( |
1767 ExternalStringTableUpdaterCallback updater_func) { | 1767 ExternalStringTableUpdaterCallback updater_func) { |
1768 #ifdef VERIFY_HEAP | |
1769 if (FLAG_verify_heap) { | |
1770 external_string_table_.Verify(); | |
1771 } | |
1772 #endif | |
1773 | |
1774 if (external_string_table_.new_space_strings_.is_empty()) return; | 1768 if (external_string_table_.new_space_strings_.is_empty()) return; |
1775 | 1769 |
1776 Object** start = &external_string_table_.new_space_strings_[0]; | 1770 Object** start = &external_string_table_.new_space_strings_[0]; |
1777 Object** end = start + external_string_table_.new_space_strings_.length(); | 1771 Object** end = start + external_string_table_.new_space_strings_.length(); |
1778 Object** last = start; | 1772 Object** last = start; |
1779 | 1773 |
1780 for (Object** p = start; p < end; ++p) { | 1774 for (Object** p = start; p < end; ++p) { |
1781 DCHECK(InFromSpace(*p)); | |
1782 String* target = updater_func(this, p); | 1775 String* target = updater_func(this, p); |
1783 | 1776 |
1784 if (target == NULL) continue; | 1777 if (target == NULL) continue; |
1785 | 1778 |
1786 DCHECK(target->IsExternalString()); | 1779 DCHECK(target->IsExternalString()); |
1787 | 1780 |
1788 if (InNewSpace(target)) { | 1781 if (InNewSpace(target)) { |
1789 // String is still in new space. Update the table entry. | 1782 // String is still in new space. Update the table entry. |
1790 *last = target; | 1783 *last = target; |
1791 ++last; | 1784 ++last; |
(...skipping 4418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6210 | 6203 |
6211 void KeyedLookupCache::Clear() { | 6204 void KeyedLookupCache::Clear() { |
6212 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 6205 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
6213 } | 6206 } |
6214 | 6207 |
6215 | 6208 |
6216 void DescriptorLookupCache::Clear() { | 6209 void DescriptorLookupCache::Clear() { |
6217 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; | 6210 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; |
6218 } | 6211 } |
6219 | 6212 |
6220 | |
6221 void Heap::ExternalStringTable::CleanUp() { | 6213 void Heap::ExternalStringTable::CleanUp() { |
6222 int last = 0; | 6214 int last = 0; |
6223 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6215 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6224 if (new_space_strings_[i] == heap_->the_hole_value()) { | 6216 if (new_space_strings_[i] == heap_->the_hole_value()) { |
6225 continue; | 6217 continue; |
6226 } | 6218 } |
6227 DCHECK(new_space_strings_[i]->IsExternalString()); | 6219 DCHECK(new_space_strings_[i]->IsExternalString()); |
6228 if (heap_->InNewSpace(new_space_strings_[i])) { | 6220 if (heap_->InNewSpace(new_space_strings_[i])) { |
6229 new_space_strings_[last++] = new_space_strings_[i]; | 6221 new_space_strings_[last++] = new_space_strings_[i]; |
6230 } else { | 6222 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
6245 } | 6237 } |
6246 old_space_strings_.Rewind(last); | 6238 old_space_strings_.Rewind(last); |
6247 old_space_strings_.Trim(); | 6239 old_space_strings_.Trim(); |
6248 #ifdef VERIFY_HEAP | 6240 #ifdef VERIFY_HEAP |
6249 if (FLAG_verify_heap) { | 6241 if (FLAG_verify_heap) { |
6250 Verify(); | 6242 Verify(); |
6251 } | 6243 } |
6252 #endif | 6244 #endif |
6253 } | 6245 } |
6254 | 6246 |
6255 | |
6256 void Heap::ExternalStringTable::TearDown() { | 6247 void Heap::ExternalStringTable::TearDown() { |
6257 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6248 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6258 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); | 6249 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); |
6259 } | 6250 } |
6260 new_space_strings_.Free(); | 6251 new_space_strings_.Free(); |
6261 for (int i = 0; i < old_space_strings_.length(); ++i) { | 6252 for (int i = 0; i < old_space_strings_.length(); ++i) { |
6262 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); | 6253 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); |
6263 } | 6254 } |
6264 old_space_strings_.Free(); | 6255 old_space_strings_.Free(); |
6265 } | 6256 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6434 } | 6425 } |
6435 | 6426 |
6436 | 6427 |
6437 // static | 6428 // static |
6438 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6429 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6439 return StaticVisitorBase::GetVisitorId(map); | 6430 return StaticVisitorBase::GetVisitorId(map); |
6440 } | 6431 } |
6441 | 6432 |
6442 } // namespace internal | 6433 } // namespace internal |
6443 } // namespace v8 | 6434 } // namespace v8 |
OLD | NEW |