Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 last_idle_notification_gc_count_init_(false), | 143 last_idle_notification_gc_count_init_(false), |
| 144 mark_sweeps_since_idle_round_started_(0), | 144 mark_sweeps_since_idle_round_started_(0), |
| 145 gc_count_at_last_idle_gc_(0), | 145 gc_count_at_last_idle_gc_(0), |
| 146 scavenges_since_last_idle_round_(kIdleScavengeThreshold), | 146 scavenges_since_last_idle_round_(kIdleScavengeThreshold), |
| 147 full_codegen_bytes_generated_(0), | 147 full_codegen_bytes_generated_(0), |
| 148 crankshaft_codegen_bytes_generated_(0), | 148 crankshaft_codegen_bytes_generated_(0), |
| 149 gcs_since_last_deopt_(0), | 149 gcs_since_last_deopt_(0), |
| 150 #ifdef VERIFY_HEAP | 150 #ifdef VERIFY_HEAP |
| 151 no_weak_object_verification_scope_depth_(0), | 151 no_weak_object_verification_scope_depth_(0), |
| 152 #endif | 152 #endif |
| 153 allocation_sites_scratchpad_length(0), | 153 allocation_sites_scratchpad_length_(0), |
| 154 promotion_queue_(this), | 154 promotion_queue_(this), |
| 155 configured_(false), | 155 configured_(false), |
| 156 external_string_table_(this), | 156 external_string_table_(this), |
| 157 chunks_queued_for_free_(NULL), | 157 chunks_queued_for_free_(NULL), |
| 158 relocation_mutex_(NULL) { | 158 relocation_mutex_(NULL) { |
| 159 // Allow build-time customization of the max semispace size. Building | 159 // Allow build-time customization of the max semispace size. Building |
| 160 // V8 with snapshots and a non-default max semispace size is much | 160 // V8 with snapshots and a non-default max semispace size is much |
| 161 // easier if you can define it as part of the build environment. | 161 // easier if you can define it as part of the build environment. |
| 162 #if defined(V8_MAX_SEMISPACE_SIZE) | 162 #if defined(V8_MAX_SEMISPACE_SIZE) |
| 163 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 163 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 if (FLAG_allocation_site_pretenuring) { | 509 if (FLAG_allocation_site_pretenuring) { |
| 510 int tenure_decisions = 0; | 510 int tenure_decisions = 0; |
| 511 int dont_tenure_decisions = 0; | 511 int dont_tenure_decisions = 0; |
| 512 int allocation_mementos_found = 0; | 512 int allocation_mementos_found = 0; |
| 513 int allocation_sites = 0; | 513 int allocation_sites = 0; |
| 514 int active_allocation_sites = 0; | 514 int active_allocation_sites = 0; |
| 515 | 515 |
| 516 // If the scratchpad overflowed, we have to iterate over the allocation | 516 // If the scratchpad overflowed, we have to iterate over the allocation |
| 517 // sites list. | 517 // sites list. |
| 518 bool use_scratchpad = | 518 bool use_scratchpad = |
| 519 allocation_sites_scratchpad_length < kAllocationSiteScratchpadSize; | 519 allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize; |
| 520 | 520 |
| 521 int i = 0; | 521 int i = 0; |
| 522 Object* list_element = allocation_sites_list(); | 522 Object* list_element = allocation_sites_list(); |
| 523 bool trigger_deoptimization = false; | 523 bool trigger_deoptimization = false; |
| 524 while (use_scratchpad ? | 524 while (use_scratchpad ? |
| 525 i < allocation_sites_scratchpad_length : | 525 i < allocation_sites_scratchpad_length_ : |
| 526 list_element->IsAllocationSite()) { | 526 list_element->IsAllocationSite()) { |
| 527 AllocationSite* site = use_scratchpad ? | 527 AllocationSite* site = use_scratchpad ? |
| 528 allocation_sites_scratchpad[i] : AllocationSite::cast(list_element); | 528 AllocationSite::cast(allocation_sites_scratchpad()->get(i)) : |
| 529 AllocationSite::cast(list_element); | |
| 529 allocation_mementos_found += site->memento_found_count(); | 530 allocation_mementos_found += site->memento_found_count(); |
| 530 if (site->memento_found_count() > 0) { | 531 if (site->memento_found_count() > 0) { |
| 531 active_allocation_sites++; | 532 active_allocation_sites++; |
| 532 } | 533 } |
| 533 if (site->DigestPretenuringFeedback()) trigger_deoptimization = true; | 534 if (site->DigestPretenuringFeedback()) trigger_deoptimization = true; |
| 534 if (site->GetPretenureMode() == TENURED) { | 535 if (site->GetPretenureMode() == TENURED) { |
| 535 tenure_decisions++; | 536 tenure_decisions++; |
| 536 } else { | 537 } else { |
| 537 dont_tenure_decisions++; | 538 dont_tenure_decisions++; |
| 538 } | 539 } |
| 539 allocation_sites++; | 540 allocation_sites++; |
| 540 if (use_scratchpad) { | 541 if (use_scratchpad) { |
| 541 i++; | 542 i++; |
| 542 } else { | 543 } else { |
| 543 list_element = site->weak_next(); | 544 list_element = site->weak_next(); |
| 544 } | 545 } |
| 545 } | 546 } |
| 546 | 547 |
| 547 if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode(); | 548 if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode(); |
| 548 | 549 |
| 549 allocation_sites_scratchpad_length = 0; | 550 FlushAllocationSitesScratchpad(); |
| 550 | 551 |
| 551 if (FLAG_trace_pretenuring_statistics && | 552 if (FLAG_trace_pretenuring_statistics && |
| 552 (allocation_mementos_found > 0 || | 553 (allocation_mementos_found > 0 || |
| 553 tenure_decisions > 0 || | 554 tenure_decisions > 0 || |
| 554 dont_tenure_decisions > 0)) { | 555 dont_tenure_decisions > 0)) { |
| 555 PrintF("GC: (mode, #visited allocation sites, #active allocation sites, " | 556 PrintF("GC: (mode, #visited allocation sites, #active allocation sites, " |
| 556 "#mementos, #tenure decisions, #donttenure decisions) " | 557 "#mementos, #tenure decisions, #donttenure decisions) " |
| 557 "(%s, %d, %d, %d, %d, %d)\n", | 558 "(%s, %d, %d, %d, %d, %d)\n", |
| 558 use_scratchpad ? "use scratchpad" : "use list", | 559 use_scratchpad ? "use scratchpad" : "use list", |
| 559 allocation_sites, | 560 allocation_sites, |
| (...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3293 set_observed_symbol(Symbol::cast(obj)); | 3294 set_observed_symbol(Symbol::cast(obj)); |
| 3294 | 3295 |
| 3295 { MaybeObject* maybe_obj = AllocateFixedArray(0, TENURED); | 3296 { MaybeObject* maybe_obj = AllocateFixedArray(0, TENURED); |
| 3296 if (!maybe_obj->ToObject(&obj)) return false; | 3297 if (!maybe_obj->ToObject(&obj)) return false; |
| 3297 } | 3298 } |
| 3298 set_materialized_objects(FixedArray::cast(obj)); | 3299 set_materialized_objects(FixedArray::cast(obj)); |
| 3299 | 3300 |
| 3300 // Handling of script id generation is in Factory::NewScript. | 3301 // Handling of script id generation is in Factory::NewScript. |
| 3301 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId)); | 3302 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId)); |
| 3302 | 3303 |
| 3304 { MaybeObject* maybe_obj = AllocateAllocationSitesScratchpad(); | |
| 3305 if (!maybe_obj->ToObject(&obj)) return false; | |
| 3306 } | |
| 3307 set_allocation_sites_scratchpad(FixedArray::cast(obj)); | |
| 3308 InitializeAllocationSitesScratchpad(); | |
| 3309 | |
| 3303 // Initialize keyed lookup cache. | 3310 // Initialize keyed lookup cache. |
| 3304 isolate_->keyed_lookup_cache()->Clear(); | 3311 isolate_->keyed_lookup_cache()->Clear(); |
| 3305 | 3312 |
| 3306 // Initialize context slot cache. | 3313 // Initialize context slot cache. |
| 3307 isolate_->context_slot_cache()->Clear(); | 3314 isolate_->context_slot_cache()->Clear(); |
| 3308 | 3315 |
| 3309 // Initialize descriptor cache. | 3316 // Initialize descriptor cache. |
| 3310 isolate_->descriptor_lookup_cache()->Clear(); | 3317 isolate_->descriptor_lookup_cache()->Clear(); |
| 3311 | 3318 |
| 3312 // Initialize compilation cache. | 3319 // Initialize compilation cache. |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3582 | 3589 |
| 3583 MaybeObject* Heap::Uint32ToString(uint32_t value, | 3590 MaybeObject* Heap::Uint32ToString(uint32_t value, |
| 3584 bool check_number_string_cache) { | 3591 bool check_number_string_cache) { |
| 3585 Object* number; | 3592 Object* number; |
| 3586 MaybeObject* maybe = NumberFromUint32(value); | 3593 MaybeObject* maybe = NumberFromUint32(value); |
| 3587 if (!maybe->To<Object>(&number)) return maybe; | 3594 if (!maybe->To<Object>(&number)) return maybe; |
| 3588 return NumberToString(number, check_number_string_cache); | 3595 return NumberToString(number, check_number_string_cache); |
| 3589 } | 3596 } |
| 3590 | 3597 |
| 3591 | 3598 |
| 3599 MaybeObject* Heap::AllocateAllocationSitesScratchpad() { | |
| 3600 MaybeObject* maybe_obj = | |
| 3601 AllocateFixedArray(kAllocationSiteScratchpadSize, TENURED); | |
| 3602 return maybe_obj; | |
| 3603 } | |
| 3604 | |
| 3605 | |
| 3606 void Heap::FlushAllocationSitesScratchpad() { | |
| 3607 for (int i = 0; i < allocation_sites_scratchpad_length_; i++) { | |
| 3608 allocation_sites_scratchpad()->set_undefined(i); | |
| 3609 } | |
| 3610 allocation_sites_scratchpad_length_ = 0; | |
| 3611 } | |
| 3612 | |
| 3613 | |
| 3614 void Heap::InitializeAllocationSitesScratchpad() { | |
| 3615 ASSERT(allocation_sites_scratchpad()->length() == | |
| 3616 kAllocationSiteScratchpadSize); | |
| 3617 for (int i = 0; i < kAllocationSiteScratchpadSize; i++) { | |
| 3618 allocation_sites_scratchpad()->set_undefined(i); | |
| 3619 } | |
| 3620 } | |
| 3621 | |
| 3622 | |
| 3623 void Heap::AddAllocationSiteToScratchpad(AllocationSite* site) { | |
| 3624 if (allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize) { | |
| 3625 allocation_sites_scratchpad()->set( | |
| 3626 allocation_sites_scratchpad_length_, site); | |
|
mvstanton
2014/02/06 13:46:37
So both the scratchpad and the AllocationSite are
Hannes Payer (out of office)
2014/02/06 13:51:24
The allocation site may be on an evacuation candid
| |
| 3627 allocation_sites_scratchpad_length_++; | |
| 3628 } | |
| 3629 } | |
| 3630 | |
| 3631 | |
| 3592 Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { | 3632 Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { |
| 3593 return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]); | 3633 return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]); |
| 3594 } | 3634 } |
| 3595 | 3635 |
| 3596 | 3636 |
| 3597 Heap::RootListIndex Heap::RootIndexForExternalArrayType( | 3637 Heap::RootListIndex Heap::RootIndexForExternalArrayType( |
| 3598 ExternalArrayType array_type) { | 3638 ExternalArrayType array_type) { |
| 3599 switch (array_type) { | 3639 switch (array_type) { |
| 3600 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ | 3640 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
| 3601 case kExternal##Type##Array: \ | 3641 case kExternal##Type##Array: \ |
| (...skipping 4060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7662 static_cast<int>(object_sizes_last_time_[index])); | 7702 static_cast<int>(object_sizes_last_time_[index])); |
| 7663 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7703 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7664 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7704 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7665 | 7705 |
| 7666 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7706 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7667 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7707 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7668 ClearObjectStats(); | 7708 ClearObjectStats(); |
| 7669 } | 7709 } |
| 7670 | 7710 |
| 7671 } } // namespace v8::internal | 7711 } } // namespace v8::internal |
| OLD | NEW |