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 6201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6212 | 6212 |
6213 void KeyedLookupCache::Clear() { | 6213 void KeyedLookupCache::Clear() { |
6214 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 6214 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
6215 } | 6215 } |
6216 | 6216 |
6217 | 6217 |
6218 void DescriptorLookupCache::Clear() { | 6218 void DescriptorLookupCache::Clear() { |
6219 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; | 6219 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; |
6220 } | 6220 } |
6221 | 6221 |
6222 | 6222 template <Heap::ExternalStringTable::CleanupMode mode> |
6223 void Heap::ExternalStringTable::CleanUp() { | 6223 void Heap::ExternalStringTable::CleanUp() { |
6224 int last = 0; | 6224 int last = 0; |
6225 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6225 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6226 if (new_space_strings_[i] == heap_->the_hole_value()) { | 6226 if (new_space_strings_[i] == heap_->the_hole_value()) { |
6227 continue; | 6227 continue; |
6228 } | 6228 } |
6229 DCHECK(new_space_strings_[i]->IsExternalString()); | 6229 DCHECK(new_space_strings_[i]->IsExternalString()); |
6230 if (heap_->InNewSpace(new_space_strings_[i])) { | 6230 if (heap_->InNewSpace(new_space_strings_[i])) { |
6231 new_space_strings_[last++] = new_space_strings_[i]; | 6231 new_space_strings_[last++] = new_space_strings_[i]; |
6232 } else { | 6232 } else { |
6233 old_space_strings_.Add(new_space_strings_[i]); | 6233 old_space_strings_.Add(new_space_strings_[i]); |
6234 } | 6234 } |
6235 } | 6235 } |
6236 new_space_strings_.Rewind(last); | 6236 new_space_strings_.Rewind(last); |
6237 new_space_strings_.Trim(); | 6237 new_space_strings_.Trim(); |
6238 | 6238 |
6239 last = 0; | 6239 if (mode == CleanupMode::kFull) { |
6240 for (int i = 0; i < old_space_strings_.length(); ++i) { | 6240 last = 0; |
6241 if (old_space_strings_[i] == heap_->the_hole_value()) { | 6241 for (int i = 0; i < old_space_strings_.length(); ++i) { |
6242 continue; | 6242 if (old_space_strings_[i] == heap_->the_hole_value()) { |
| 6243 continue; |
| 6244 } |
| 6245 DCHECK(old_space_strings_[i]->IsExternalString()); |
| 6246 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); |
| 6247 old_space_strings_[last++] = old_space_strings_[i]; |
6243 } | 6248 } |
6244 DCHECK(old_space_strings_[i]->IsExternalString()); | 6249 old_space_strings_.Rewind(last); |
6245 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); | 6250 old_space_strings_.Trim(); |
6246 old_space_strings_[last++] = old_space_strings_[i]; | |
6247 } | 6251 } |
6248 old_space_strings_.Rewind(last); | |
6249 old_space_strings_.Trim(); | |
6250 #ifdef VERIFY_HEAP | 6252 #ifdef VERIFY_HEAP |
6251 if (FLAG_verify_heap) { | 6253 if (FLAG_verify_heap) { |
6252 Verify(); | 6254 Verify(); |
6253 } | 6255 } |
6254 #endif | 6256 #endif |
6255 } | 6257 } |
6256 | 6258 |
| 6259 template void Heap::ExternalStringTable::CleanUp< |
| 6260 Heap::ExternalStringTable::CleanupMode::kFull>(); |
| 6261 template void Heap::ExternalStringTable::CleanUp< |
| 6262 Heap::ExternalStringTable::CleanupMode::kPromoteOnly>(); |
6257 | 6263 |
6258 void Heap::ExternalStringTable::TearDown() { | 6264 void Heap::ExternalStringTable::TearDown() { |
6259 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6265 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6260 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); | 6266 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i])); |
6261 } | 6267 } |
6262 new_space_strings_.Free(); | 6268 new_space_strings_.Free(); |
6263 for (int i = 0; i < old_space_strings_.length(); ++i) { | 6269 for (int i = 0; i < old_space_strings_.length(); ++i) { |
6264 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); | 6270 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i])); |
6265 } | 6271 } |
6266 old_space_strings_.Free(); | 6272 old_space_strings_.Free(); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6436 } | 6442 } |
6437 | 6443 |
6438 | 6444 |
6439 // static | 6445 // static |
6440 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6446 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6441 return StaticVisitorBase::GetVisitorId(map); | 6447 return StaticVisitorBase::GetVisitorId(map); |
6442 } | 6448 } |
6443 | 6449 |
6444 } // namespace internal | 6450 } // namespace internal |
6445 } // namespace v8 | 6451 } // namespace v8 |
OLD | NEW |