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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1230 isolate_->compilation_cache()->MarkCompactPrologue(); | 1230 isolate_->compilation_cache()->MarkCompactPrologue(); |
1231 | 1231 |
1232 CompletelyClearInstanceofCache(); | 1232 CompletelyClearInstanceofCache(); |
1233 | 1233 |
1234 FlushNumberStringCache(); | 1234 FlushNumberStringCache(); |
1235 if (FLAG_cleanup_code_caches_at_gc) { | 1235 if (FLAG_cleanup_code_caches_at_gc) { |
1236 polymorphic_code_cache()->set_cache(undefined_value()); | 1236 polymorphic_code_cache()->set_cache(undefined_value()); |
1237 } | 1237 } |
1238 | 1238 |
1239 ClearNormalizedMapCaches(); | 1239 ClearNormalizedMapCaches(); |
1240 | |
1241 if (mark_compact_collector_.reduce_memory_footprint()) { | |
1242 embedded_map_cache_ = undefined_value(); | |
1243 } else { | |
1244 if (embedded_map_cache_->IsEmbeddedMapCache()) { | |
1245 EmbeddedMapCache::cast(embedded_map_cache_)->Age(); | |
1246 } | |
1247 } | |
Hannes Payer (out of office)
2014/11/17 17:34:33
Factor that code out into a function to keep the p
| |
1240 } | 1248 } |
1241 | 1249 |
1242 | 1250 |
1243 // Helper class for copying HeapObjects | 1251 // Helper class for copying HeapObjects |
1244 class ScavengeVisitor : public ObjectVisitor { | 1252 class ScavengeVisitor : public ObjectVisitor { |
1245 public: | 1253 public: |
1246 explicit ScavengeVisitor(Heap* heap) : heap_(heap) {} | 1254 explicit ScavengeVisitor(Heap* heap) : heap_(heap) {} |
1247 | 1255 |
1248 void VisitPointer(Object** p) { ScavengePointer(p); } | 1256 void VisitPointer(Object** p) { ScavengePointer(p); } |
1249 | 1257 |
(...skipping 3652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4902 // empty. However the next thing we do is create the partial snapshot, | 4910 // empty. However the next thing we do is create the partial snapshot, |
4903 // filling up the partial snapshot cache with objects it needs as we go. | 4911 // filling up the partial snapshot cache with objects it needs as we go. |
4904 SerializerDeserializer::Iterate(isolate_, v); | 4912 SerializerDeserializer::Iterate(isolate_, v); |
4905 // We don't do a v->Synchronize call here, because in debug mode that will | 4913 // We don't do a v->Synchronize call here, because in debug mode that will |
4906 // output a flag to the snapshot. However at this point the serializer and | 4914 // output a flag to the snapshot. However at this point the serializer and |
4907 // deserializer are deliberately a little unsynchronized (see above) so the | 4915 // deserializer are deliberately a little unsynchronized (see above) so the |
4908 // checking of the sync flag in the snapshot would fail. | 4916 // checking of the sync flag in the snapshot would fail. |
4909 } | 4917 } |
4910 | 4918 |
4911 | 4919 |
4920 void Heap::IterateEmbeddedMapCache(ObjectVisitor* visitor) { | |
4921 visitor->VisitPointer(&embedded_map_cache_); | |
4922 } | |
4923 | |
4924 | |
4912 // TODO(1236194): Since the heap size is configurable on the command line | 4925 // TODO(1236194): Since the heap size is configurable on the command line |
4913 // and through the API, we should gracefully handle the case that the heap | 4926 // and through the API, we should gracefully handle the case that the heap |
4914 // size is not big enough to fit all the initial objects. | 4927 // size is not big enough to fit all the initial objects. |
4915 bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, | 4928 bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, |
4916 int max_executable_size, size_t code_range_size) { | 4929 int max_executable_size, size_t code_range_size) { |
4917 if (HasBeenSetUp()) return false; | 4930 if (HasBeenSetUp()) return false; |
4918 | 4931 |
4919 // Overwrite default configuration. | 4932 // Overwrite default configuration. |
4920 if (max_semi_space_size > 0) { | 4933 if (max_semi_space_size > 0) { |
4921 max_semi_space_size_ = max_semi_space_size * MB; | 4934 max_semi_space_size_ = max_semi_space_size * MB; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5272 CreateApiObjects(); | 5285 CreateApiObjects(); |
5273 | 5286 |
5274 // Create initial objects | 5287 // Create initial objects |
5275 CreateInitialObjects(); | 5288 CreateInitialObjects(); |
5276 CHECK_EQ(0, gc_count_); | 5289 CHECK_EQ(0, gc_count_); |
5277 | 5290 |
5278 set_native_contexts_list(undefined_value()); | 5291 set_native_contexts_list(undefined_value()); |
5279 set_array_buffers_list(undefined_value()); | 5292 set_array_buffers_list(undefined_value()); |
5280 set_allocation_sites_list(undefined_value()); | 5293 set_allocation_sites_list(undefined_value()); |
5281 weak_object_to_code_table_ = undefined_value(); | 5294 weak_object_to_code_table_ = undefined_value(); |
5295 embedded_map_cache_ = undefined_value(); | |
5282 return true; | 5296 return true; |
5283 } | 5297 } |
5284 | 5298 |
5285 | 5299 |
5286 void Heap::SetStackLimits() { | 5300 void Heap::SetStackLimits() { |
5287 DCHECK(isolate_ != NULL); | 5301 DCHECK(isolate_ != NULL); |
5288 DCHECK(isolate_ == isolate()); | 5302 DCHECK(isolate_ == isolate()); |
5289 // On 64 bit machines, pointers are generally out of range of Smis. We write | 5303 // On 64 bit machines, pointers are generally out of range of Smis. We write |
5290 // something that looks like an out of range Smi to the GC. | 5304 // something that looks like an out of range Smi to the GC. |
5291 | 5305 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5482 | 5496 |
5483 void Heap::EnsureWeakObjectToCodeTable() { | 5497 void Heap::EnsureWeakObjectToCodeTable() { |
5484 if (!weak_object_to_code_table()->IsHashTable()) { | 5498 if (!weak_object_to_code_table()->IsHashTable()) { |
5485 set_weak_object_to_code_table( | 5499 set_weak_object_to_code_table( |
5486 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, | 5500 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, |
5487 TENURED)); | 5501 TENURED)); |
5488 } | 5502 } |
5489 } | 5503 } |
5490 | 5504 |
5491 | 5505 |
5506 void Heap::CacheEmbeddedMap(Handle<Map> map) { | |
5507 HandleScope scope(isolate()); | |
5508 if (!embedded_map_cache_->IsHashTable()) { | |
5509 embedded_map_cache_ = | |
5510 *EmbeddedMapCache::New(isolate(), 512, USE_DEFAULT_MINIMUM_CAPACITY, | |
5511 TENURED); | |
5512 } | |
5513 Handle<EmbeddedMapCache> cache(EmbeddedMapCache::cast(embedded_map_cache_), | |
5514 isolate()); | |
5515 embedded_map_cache_ = *EmbeddedMapCache::Put(cache, map); | |
5516 } | |
5517 | |
5518 | |
5492 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { | 5519 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
5493 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); | 5520 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); |
5494 } | 5521 } |
5495 | 5522 |
5496 #ifdef DEBUG | 5523 #ifdef DEBUG |
5497 | 5524 |
5498 class PrintHandleVisitor : public ObjectVisitor { | 5525 class PrintHandleVisitor : public ObjectVisitor { |
5499 public: | 5526 public: |
5500 void VisitPointers(Object** start, Object** end) { | 5527 void VisitPointers(Object** start, Object** end) { |
5501 for (Object** p = start; p < end; p++) | 5528 for (Object** p = start; p < end; p++) |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6266 static_cast<int>(object_sizes_last_time_[index])); | 6293 static_cast<int>(object_sizes_last_time_[index])); |
6267 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6294 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6268 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6295 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6269 | 6296 |
6270 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6297 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6271 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6298 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6272 ClearObjectStats(); | 6299 ClearObjectStats(); |
6273 } | 6300 } |
6274 } | 6301 } |
6275 } // namespace v8::internal | 6302 } // namespace v8::internal |
OLD | NEW |