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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 | 1104 |
1105 | 1105 |
1106 #ifdef VERIFY_HEAP | 1106 #ifdef VERIFY_HEAP |
1107 // Helper class for verifying the string table. | 1107 // Helper class for verifying the string table. |
1108 class StringTableVerifier : public ObjectVisitor { | 1108 class StringTableVerifier : public ObjectVisitor { |
1109 public: | 1109 public: |
1110 void VisitPointers(Object** start, Object** end) override { | 1110 void VisitPointers(Object** start, Object** end) override { |
1111 // Visit all HeapObject pointers in [start, end). | 1111 // Visit all HeapObject pointers in [start, end). |
1112 for (Object** p = start; p < end; p++) { | 1112 for (Object** p = start; p < end; p++) { |
1113 if ((*p)->IsHeapObject()) { | 1113 if ((*p)->IsHeapObject()) { |
| 1114 HeapObject* object = HeapObject::cast(*p); |
| 1115 Isolate* isolate = object->GetIsolate(); |
1114 // Check that the string is actually internalized. | 1116 // Check that the string is actually internalized. |
1115 CHECK((*p)->IsTheHole() || (*p)->IsUndefined() || | 1117 CHECK(object->IsTheHole(isolate) || object->IsUndefined(isolate) || |
1116 (*p)->IsInternalizedString()); | 1118 object->IsInternalizedString()); |
1117 } | 1119 } |
1118 } | 1120 } |
1119 } | 1121 } |
1120 }; | 1122 }; |
1121 | 1123 |
1122 | 1124 |
1123 static void VerifyStringTable(Heap* heap) { | 1125 static void VerifyStringTable(Heap* heap) { |
1124 StringTableVerifier verifier; | 1126 StringTableVerifier verifier; |
1125 heap->string_table()->IterateElements(&verifier); | 1127 heap->string_table()->IterateElements(&verifier); |
1126 } | 1128 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 } | 1207 } |
1206 | 1208 |
1207 | 1209 |
1208 void Heap::ClearNormalizedMapCaches() { | 1210 void Heap::ClearNormalizedMapCaches() { |
1209 if (isolate_->bootstrapper()->IsActive() && | 1211 if (isolate_->bootstrapper()->IsActive() && |
1210 !incremental_marking()->IsMarking()) { | 1212 !incremental_marking()->IsMarking()) { |
1211 return; | 1213 return; |
1212 } | 1214 } |
1213 | 1215 |
1214 Object* context = native_contexts_list(); | 1216 Object* context = native_contexts_list(); |
1215 while (!context->IsUndefined()) { | 1217 while (!context->IsUndefined(isolate())) { |
1216 // GC can happen when the context is not fully initialized, | 1218 // GC can happen when the context is not fully initialized, |
1217 // so the cache can be undefined. | 1219 // so the cache can be undefined. |
1218 Object* cache = | 1220 Object* cache = |
1219 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); | 1221 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); |
1220 if (!cache->IsUndefined()) { | 1222 if (!cache->IsUndefined(isolate())) { |
1221 NormalizedMapCache::cast(cache)->Clear(); | 1223 NormalizedMapCache::cast(cache)->Clear(); |
1222 } | 1224 } |
1223 context = Context::cast(context)->next_context_link(); | 1225 context = Context::cast(context)->next_context_link(); |
1224 } | 1226 } |
1225 } | 1227 } |
1226 | 1228 |
1227 | 1229 |
1228 void Heap::UpdateSurvivalStatistics(int start_new_space_size) { | 1230 void Heap::UpdateSurvivalStatistics(int start_new_space_size) { |
1229 if (start_new_space_size == 0) return; | 1231 if (start_new_space_size == 0) return; |
1230 | 1232 |
(...skipping 5009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6240 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 6242 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
6241 } | 6243 } |
6242 | 6244 |
6243 | 6245 |
6244 void DescriptorLookupCache::Clear() { | 6246 void DescriptorLookupCache::Clear() { |
6245 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; | 6247 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; |
6246 } | 6248 } |
6247 | 6249 |
6248 void Heap::ExternalStringTable::CleanUp() { | 6250 void Heap::ExternalStringTable::CleanUp() { |
6249 int last = 0; | 6251 int last = 0; |
| 6252 Isolate* isolate = heap_->isolate(); |
6250 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6253 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6251 if (new_space_strings_[i] == heap_->the_hole_value()) { | 6254 if (new_space_strings_[i]->IsTheHole(isolate)) { |
6252 continue; | 6255 continue; |
6253 } | 6256 } |
6254 DCHECK(new_space_strings_[i]->IsExternalString()); | 6257 DCHECK(new_space_strings_[i]->IsExternalString()); |
6255 if (heap_->InNewSpace(new_space_strings_[i])) { | 6258 if (heap_->InNewSpace(new_space_strings_[i])) { |
6256 new_space_strings_[last++] = new_space_strings_[i]; | 6259 new_space_strings_[last++] = new_space_strings_[i]; |
6257 } else { | 6260 } else { |
6258 old_space_strings_.Add(new_space_strings_[i]); | 6261 old_space_strings_.Add(new_space_strings_[i]); |
6259 } | 6262 } |
6260 } | 6263 } |
6261 new_space_strings_.Rewind(last); | 6264 new_space_strings_.Rewind(last); |
6262 new_space_strings_.Trim(); | 6265 new_space_strings_.Trim(); |
6263 | 6266 |
6264 last = 0; | 6267 last = 0; |
6265 for (int i = 0; i < old_space_strings_.length(); ++i) { | 6268 for (int i = 0; i < old_space_strings_.length(); ++i) { |
6266 if (old_space_strings_[i] == heap_->the_hole_value()) { | 6269 if (old_space_strings_[i]->IsTheHole(isolate)) { |
6267 continue; | 6270 continue; |
6268 } | 6271 } |
6269 DCHECK(old_space_strings_[i]->IsExternalString()); | 6272 DCHECK(old_space_strings_[i]->IsExternalString()); |
6270 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); | 6273 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); |
6271 old_space_strings_[last++] = old_space_strings_[i]; | 6274 old_space_strings_[last++] = old_space_strings_[i]; |
6272 } | 6275 } |
6273 old_space_strings_.Rewind(last); | 6276 old_space_strings_.Rewind(last); |
6274 old_space_strings_.Trim(); | 6277 old_space_strings_.Trim(); |
6275 #ifdef VERIFY_HEAP | 6278 #ifdef VERIFY_HEAP |
6276 if (FLAG_verify_heap) { | 6279 if (FLAG_verify_heap) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6391 } | 6394 } |
6392 | 6395 |
6393 | 6396 |
6394 // static | 6397 // static |
6395 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6398 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6396 return StaticVisitorBase::GetVisitorId(map); | 6399 return StaticVisitorBase::GetVisitorId(map); |
6397 } | 6400 } |
6398 | 6401 |
6399 } // namespace internal | 6402 } // namespace internal |
6400 } // namespace v8 | 6403 } // namespace v8 |
OLD | NEW |