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 5023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6254 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 6256 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
6255 } | 6257 } |
6256 | 6258 |
6257 | 6259 |
6258 void DescriptorLookupCache::Clear() { | 6260 void DescriptorLookupCache::Clear() { |
6259 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; | 6261 for (int index = 0; index < kLength; index++) keys_[index].source = NULL; |
6260 } | 6262 } |
6261 | 6263 |
6262 void Heap::ExternalStringTable::CleanUp() { | 6264 void Heap::ExternalStringTable::CleanUp() { |
6263 int last = 0; | 6265 int last = 0; |
| 6266 Isolate* isolate = heap_->isolate(); |
6264 for (int i = 0; i < new_space_strings_.length(); ++i) { | 6267 for (int i = 0; i < new_space_strings_.length(); ++i) { |
6265 if (new_space_strings_[i] == heap_->the_hole_value()) { | 6268 if (new_space_strings_[i]->IsTheHole(isolate)) { |
6266 continue; | 6269 continue; |
6267 } | 6270 } |
6268 DCHECK(new_space_strings_[i]->IsExternalString()); | 6271 DCHECK(new_space_strings_[i]->IsExternalString()); |
6269 if (heap_->InNewSpace(new_space_strings_[i])) { | 6272 if (heap_->InNewSpace(new_space_strings_[i])) { |
6270 new_space_strings_[last++] = new_space_strings_[i]; | 6273 new_space_strings_[last++] = new_space_strings_[i]; |
6271 } else { | 6274 } else { |
6272 old_space_strings_.Add(new_space_strings_[i]); | 6275 old_space_strings_.Add(new_space_strings_[i]); |
6273 } | 6276 } |
6274 } | 6277 } |
6275 new_space_strings_.Rewind(last); | 6278 new_space_strings_.Rewind(last); |
6276 new_space_strings_.Trim(); | 6279 new_space_strings_.Trim(); |
6277 | 6280 |
6278 last = 0; | 6281 last = 0; |
6279 for (int i = 0; i < old_space_strings_.length(); ++i) { | 6282 for (int i = 0; i < old_space_strings_.length(); ++i) { |
6280 if (old_space_strings_[i] == heap_->the_hole_value()) { | 6283 if (old_space_strings_[i]->IsTheHole(isolate)) { |
6281 continue; | 6284 continue; |
6282 } | 6285 } |
6283 DCHECK(old_space_strings_[i]->IsExternalString()); | 6286 DCHECK(old_space_strings_[i]->IsExternalString()); |
6284 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); | 6287 DCHECK(!heap_->InNewSpace(old_space_strings_[i])); |
6285 old_space_strings_[last++] = old_space_strings_[i]; | 6288 old_space_strings_[last++] = old_space_strings_[i]; |
6286 } | 6289 } |
6287 old_space_strings_.Rewind(last); | 6290 old_space_strings_.Rewind(last); |
6288 old_space_strings_.Trim(); | 6291 old_space_strings_.Trim(); |
6289 #ifdef VERIFY_HEAP | 6292 #ifdef VERIFY_HEAP |
6290 if (FLAG_verify_heap) { | 6293 if (FLAG_verify_heap) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6405 } | 6408 } |
6406 | 6409 |
6407 | 6410 |
6408 // static | 6411 // static |
6409 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6412 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6410 return StaticVisitorBase::GetVisitorId(map); | 6413 return StaticVisitorBase::GetVisitorId(map); |
6411 } | 6414 } |
6412 | 6415 |
6413 } // namespace internal | 6416 } // namespace internal |
6414 } // namespace v8 | 6417 } // namespace v8 |
OLD | NEW |