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/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return MARK_COMPACTOR; | 291 return MARK_COMPACTOR; |
292 } | 292 } |
293 | 293 |
294 // Default | 294 // Default |
295 *reason = NULL; | 295 *reason = NULL; |
296 return YoungGenerationCollector(); | 296 return YoungGenerationCollector(); |
297 } | 297 } |
298 | 298 |
299 void Heap::SetGCState(HeapState state) { | 299 void Heap::SetGCState(HeapState state) { |
300 gc_state_ = state; | 300 gc_state_ = state; |
301 store_buffer_->SetMode(gc_state_); | |
302 } | 301 } |
303 | 302 |
304 // TODO(1238405): Combine the infrastructure for --heap-stats and | 303 // TODO(1238405): Combine the infrastructure for --heap-stats and |
305 // --log-gc to avoid the complicated preprocessor and flag testing. | 304 // --log-gc to avoid the complicated preprocessor and flag testing. |
306 void Heap::ReportStatisticsBeforeGC() { | 305 void Heap::ReportStatisticsBeforeGC() { |
307 // Heap::ReportHeapStatistics will also log NewSpace statistics when | 306 // Heap::ReportHeapStatistics will also log NewSpace statistics when |
308 // compiled --log-gc is set. The following logic is used to avoid | 307 // compiled --log-gc is set. The following logic is used to avoid |
309 // double logging. | 308 // double logging. |
310 #ifdef DEBUG | 309 #ifdef DEBUG |
311 if (FLAG_heap_stats || FLAG_log_gc) new_space_->CollectStatistics(); | 310 if (FLAG_heap_stats || FLAG_log_gc) new_space_->CollectStatistics(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 ReportStatisticsBeforeGC(); | 442 ReportStatisticsBeforeGC(); |
444 #endif // DEBUG | 443 #endif // DEBUG |
445 | 444 |
446 if (new_space_->IsAtMaximumCapacity()) { | 445 if (new_space_->IsAtMaximumCapacity()) { |
447 maximum_size_scavenges_++; | 446 maximum_size_scavenges_++; |
448 } else { | 447 } else { |
449 maximum_size_scavenges_ = 0; | 448 maximum_size_scavenges_ = 0; |
450 } | 449 } |
451 CheckNewSpaceExpansionCriteria(); | 450 CheckNewSpaceExpansionCriteria(); |
452 UpdateNewSpaceAllocationCounter(); | 451 UpdateNewSpaceAllocationCounter(); |
453 store_buffer()->MoveAllEntriesToRememberedSet(); | |
454 } | 452 } |
455 | 453 |
456 size_t Heap::SizeOfObjects() { | 454 size_t Heap::SizeOfObjects() { |
457 size_t total = 0; | 455 size_t total = 0; |
458 AllSpaces spaces(this); | 456 AllSpaces spaces(this); |
459 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 457 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
460 total += space->SizeOfObjects(); | 458 total += space->SizeOfObjects(); |
461 } | 459 } |
462 return total; | 460 return total; |
463 } | 461 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 static_cast<int>(reinterpret_cast<intptr_t>(local_entry->value)); | 509 static_cast<int>(reinterpret_cast<intptr_t>(local_entry->value)); |
512 DCHECK_GT(value, 0); | 510 DCHECK_GT(value, 0); |
513 | 511 |
514 if (site->IncrementMementoFoundCount(value)) { | 512 if (site->IncrementMementoFoundCount(value)) { |
515 global_pretenuring_feedback_->LookupOrInsert(site, | 513 global_pretenuring_feedback_->LookupOrInsert(site, |
516 ObjectHash(site->address())); | 514 ObjectHash(site->address())); |
517 } | 515 } |
518 } | 516 } |
519 } | 517 } |
520 | 518 |
| 519 class Heap::SkipStoreBufferScope { |
| 520 public: |
| 521 explicit SkipStoreBufferScope(StoreBuffer* store_buffer) |
| 522 : store_buffer_(store_buffer) { |
| 523 store_buffer_->MoveAllEntriesToRememberedSet(); |
| 524 store_buffer_->SetMode(StoreBuffer::IN_GC); |
| 525 } |
| 526 |
| 527 ~SkipStoreBufferScope() { |
| 528 DCHECK(store_buffer_->Empty()); |
| 529 store_buffer_->SetMode(StoreBuffer::NOT_IN_GC); |
| 530 } |
| 531 |
| 532 private: |
| 533 StoreBuffer* store_buffer_; |
| 534 }; |
521 | 535 |
522 class Heap::PretenuringScope { | 536 class Heap::PretenuringScope { |
523 public: | 537 public: |
524 explicit PretenuringScope(Heap* heap) : heap_(heap) { | 538 explicit PretenuringScope(Heap* heap) : heap_(heap) { |
525 heap_->global_pretenuring_feedback_ = | 539 heap_->global_pretenuring_feedback_ = |
526 new base::HashMap(kInitialFeedbackCapacity); | 540 new base::HashMap(kInitialFeedbackCapacity); |
527 } | 541 } |
528 | 542 |
529 ~PretenuringScope() { | 543 ~PretenuringScope() { |
530 delete heap_->global_pretenuring_feedback_; | 544 delete heap_->global_pretenuring_feedback_; |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); | 1334 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); |
1321 } | 1335 } |
1322 } | 1336 } |
1323 | 1337 |
1324 EnsureFromSpaceIsCommitted(); | 1338 EnsureFromSpaceIsCommitted(); |
1325 | 1339 |
1326 int start_new_space_size = static_cast<int>(Heap::new_space()->Size()); | 1340 int start_new_space_size = static_cast<int>(Heap::new_space()->Size()); |
1327 | 1341 |
1328 { | 1342 { |
1329 Heap::PretenuringScope pretenuring_scope(this); | 1343 Heap::PretenuringScope pretenuring_scope(this); |
| 1344 Heap::SkipStoreBufferScope skip_store_buffer_scope(store_buffer_); |
1330 | 1345 |
1331 switch (collector) { | 1346 switch (collector) { |
1332 case MARK_COMPACTOR: | 1347 case MARK_COMPACTOR: |
1333 UpdateOldGenerationAllocationCounter(); | 1348 UpdateOldGenerationAllocationCounter(); |
1334 // Perform mark-sweep with optional compaction. | 1349 // Perform mark-sweep with optional compaction. |
1335 MarkCompact(); | 1350 MarkCompact(); |
1336 old_generation_size_configured_ = true; | 1351 old_generation_size_configured_ = true; |
1337 // This should be updated before PostGarbageCollectionProcessing, which | 1352 // This should be updated before PostGarbageCollectionProcessing, which |
1338 // can cause another GC. Take into account the objects promoted during | 1353 // can cause another GC. Take into account the objects promoted during |
1339 // GC. | 1354 // GC. |
(...skipping 5213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6553 } | 6568 } |
6554 | 6569 |
6555 | 6570 |
6556 // static | 6571 // static |
6557 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6572 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6558 return StaticVisitorBase::GetVisitorId(map); | 6573 return StaticVisitorBase::GetVisitorId(map); |
6559 } | 6574 } |
6560 | 6575 |
6561 } // namespace internal | 6576 } // namespace internal |
6562 } // namespace v8 | 6577 } // namespace v8 |
OLD | NEW |