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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "api.h" | 8 #include "api.h" |
9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 store_buffer_rebuilder_(store_buffer()), | 94 store_buffer_rebuilder_(store_buffer()), |
95 hidden_string_(NULL), | 95 hidden_string_(NULL), |
96 gc_safe_size_of_old_object_(NULL), | 96 gc_safe_size_of_old_object_(NULL), |
97 total_regexp_code_generated_(0), | 97 total_regexp_code_generated_(0), |
98 tracer_(NULL), | 98 tracer_(NULL), |
99 high_survival_rate_period_length_(0), | 99 high_survival_rate_period_length_(0), |
100 promoted_objects_size_(0), | 100 promoted_objects_size_(0), |
101 promotion_rate_(0), | 101 promotion_rate_(0), |
102 semi_space_copied_object_size_(0), | 102 semi_space_copied_object_size_(0), |
103 semi_space_copied_rate_(0), | 103 semi_space_copied_rate_(0), |
| 104 maximum_size_scavenges_(0), |
104 max_gc_pause_(0.0), | 105 max_gc_pause_(0.0), |
105 total_gc_time_ms_(0.0), | 106 total_gc_time_ms_(0.0), |
106 max_alive_after_gc_(0), | 107 max_alive_after_gc_(0), |
107 min_in_mutator_(kMaxInt), | 108 min_in_mutator_(kMaxInt), |
108 alive_after_last_gc_(0), | 109 alive_after_last_gc_(0), |
109 last_gc_end_timestamp_(0.0), | 110 last_gc_end_timestamp_(0.0), |
110 marking_time_(0.0), | 111 marking_time_(0.0), |
111 sweeping_time_(0.0), | 112 sweeping_time_(0.0), |
112 mark_compact_collector_(this), | 113 mark_compact_collector_(this), |
113 store_buffer_(this), | 114 store_buffer_(this), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (FLAG_gc_verbose) Print(); | 432 if (FLAG_gc_verbose) Print(); |
432 | 433 |
433 ReportStatisticsBeforeGC(); | 434 ReportStatisticsBeforeGC(); |
434 #endif // DEBUG | 435 #endif // DEBUG |
435 | 436 |
436 store_buffer()->GCPrologue(); | 437 store_buffer()->GCPrologue(); |
437 | 438 |
438 if (isolate()->concurrent_osr_enabled()) { | 439 if (isolate()->concurrent_osr_enabled()) { |
439 isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs(); | 440 isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs(); |
440 } | 441 } |
| 442 |
| 443 if (new_space_.IsAtMaximumCapacity()) { |
| 444 maximum_size_scavenges_++; |
| 445 } else { |
| 446 maximum_size_scavenges_ = 0; |
| 447 } |
| 448 CheckNewSpaceExpansionCriteria(); |
441 } | 449 } |
442 | 450 |
443 | 451 |
444 intptr_t Heap::SizeOfObjects() { | 452 intptr_t Heap::SizeOfObjects() { |
445 intptr_t total = 0; | 453 intptr_t total = 0; |
446 AllSpaces spaces(this); | 454 AllSpaces spaces(this); |
447 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 455 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
448 total += space->SizeOfObjects(); | 456 total += space->SizeOfObjects(); |
449 } | 457 } |
450 return total; | 458 return total; |
(...skipping 27 matching lines...) Expand all Loading... |
478 void Heap::ProcessPretenuringFeedback() { | 486 void Heap::ProcessPretenuringFeedback() { |
479 if (FLAG_allocation_site_pretenuring) { | 487 if (FLAG_allocation_site_pretenuring) { |
480 int tenure_decisions = 0; | 488 int tenure_decisions = 0; |
481 int dont_tenure_decisions = 0; | 489 int dont_tenure_decisions = 0; |
482 int allocation_mementos_found = 0; | 490 int allocation_mementos_found = 0; |
483 int allocation_sites = 0; | 491 int allocation_sites = 0; |
484 int active_allocation_sites = 0; | 492 int active_allocation_sites = 0; |
485 | 493 |
486 // If the scratchpad overflowed, we have to iterate over the allocation | 494 // If the scratchpad overflowed, we have to iterate over the allocation |
487 // sites list. | 495 // sites list. |
| 496 // TODO(hpayer): We iterate over the whole list of allocation sites when |
| 497 // we grew to the maximum semi-space size to deopt maybe tenured |
| 498 // allocation sites. We could hold the maybe tenured allocation sites |
| 499 // in a seperate data structure if this is a performance problem. |
488 bool use_scratchpad = | 500 bool use_scratchpad = |
489 allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize; | 501 allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize && |
| 502 new_space_.IsAtMaximumCapacity() && |
| 503 maximum_size_scavenges_ == 0; |
490 | 504 |
491 int i = 0; | 505 int i = 0; |
492 Object* list_element = allocation_sites_list(); | 506 Object* list_element = allocation_sites_list(); |
493 bool trigger_deoptimization = false; | 507 bool trigger_deoptimization = false; |
| 508 bool maximum_size_scavenge = MaximumSizeScavenge(); |
494 while (use_scratchpad ? | 509 while (use_scratchpad ? |
495 i < allocation_sites_scratchpad_length_ : | 510 i < allocation_sites_scratchpad_length_ : |
496 list_element->IsAllocationSite()) { | 511 list_element->IsAllocationSite()) { |
497 AllocationSite* site = use_scratchpad ? | 512 AllocationSite* site = use_scratchpad ? |
498 AllocationSite::cast(allocation_sites_scratchpad()->get(i)) : | 513 AllocationSite::cast(allocation_sites_scratchpad()->get(i)) : |
499 AllocationSite::cast(list_element); | 514 AllocationSite::cast(list_element); |
500 allocation_mementos_found += site->memento_found_count(); | 515 allocation_mementos_found += site->memento_found_count(); |
501 if (site->memento_found_count() > 0) { | 516 if (site->memento_found_count() > 0) { |
502 active_allocation_sites++; | 517 active_allocation_sites++; |
| 518 if (site->DigestPretenuringFeedback(maximum_size_scavenge)) { |
| 519 trigger_deoptimization = true; |
| 520 } |
| 521 if (site->GetPretenureMode() == TENURED) { |
| 522 tenure_decisions++; |
| 523 } else { |
| 524 dont_tenure_decisions++; |
| 525 } |
| 526 allocation_sites++; |
503 } | 527 } |
504 if (site->DigestPretenuringFeedback()) trigger_deoptimization = true; | 528 |
505 if (site->GetPretenureMode() == TENURED) { | |
506 tenure_decisions++; | |
507 } else { | |
508 dont_tenure_decisions++; | |
509 } | |
510 allocation_sites++; | |
511 if (use_scratchpad) { | 529 if (use_scratchpad) { |
512 i++; | 530 i++; |
513 } else { | 531 } else { |
514 list_element = site->weak_next(); | 532 list_element = site->weak_next(); |
515 } | 533 } |
516 } | 534 } |
517 | 535 |
518 if (trigger_deoptimization) { | 536 if (trigger_deoptimization) { |
519 isolate_->stack_guard()->RequestDeoptMarkedAllocationSites(); | 537 isolate_->stack_guard()->RequestDeoptMarkedAllocationSites(); |
520 } | 538 } |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 | 1444 |
1427 // Implements Cheney's copying algorithm | 1445 // Implements Cheney's copying algorithm |
1428 LOG(isolate_, ResourceEvent("scavenge", "begin")); | 1446 LOG(isolate_, ResourceEvent("scavenge", "begin")); |
1429 | 1447 |
1430 // Clear descriptor cache. | 1448 // Clear descriptor cache. |
1431 isolate_->descriptor_lookup_cache()->Clear(); | 1449 isolate_->descriptor_lookup_cache()->Clear(); |
1432 | 1450 |
1433 // Used for updating survived_since_last_expansion_ at function end. | 1451 // Used for updating survived_since_last_expansion_ at function end. |
1434 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); | 1452 intptr_t survived_watermark = PromotedSpaceSizeOfObjects(); |
1435 | 1453 |
1436 CheckNewSpaceExpansionCriteria(); | |
1437 | |
1438 SelectScavengingVisitorsTable(); | 1454 SelectScavengingVisitorsTable(); |
1439 | 1455 |
1440 incremental_marking()->PrepareForScavenge(); | 1456 incremental_marking()->PrepareForScavenge(); |
1441 | 1457 |
1442 // Flip the semispaces. After flipping, to space is empty, from space has | 1458 // Flip the semispaces. After flipping, to space is empty, from space has |
1443 // live objects. | 1459 // live objects. |
1444 new_space_.Flip(); | 1460 new_space_.Flip(); |
1445 new_space_.ResetAllocationInfo(); | 1461 new_space_.ResetAllocationInfo(); |
1446 | 1462 |
1447 // We need to sweep newly copied objects which can be either in the | 1463 // We need to sweep newly copied objects which can be either in the |
(...skipping 4969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6417 static_cast<int>(object_sizes_last_time_[index])); | 6433 static_cast<int>(object_sizes_last_time_[index])); |
6418 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6434 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6419 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6435 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6420 | 6436 |
6421 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6437 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6422 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6438 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6423 ClearObjectStats(); | 6439 ClearObjectStats(); |
6424 } | 6440 } |
6425 | 6441 |
6426 } } // namespace v8::internal | 6442 } } // namespace v8::internal |
OLD | NEW |