| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 698 |
| 699 Counters::objs_since_last_full.Set(0); | 699 Counters::objs_since_last_full.Set(0); |
| 700 | 700 |
| 701 contexts_disposed_ = 0; | 701 contexts_disposed_ = 0; |
| 702 } | 702 } |
| 703 | 703 |
| 704 | 704 |
| 705 void Heap::MarkCompactPrologue(bool is_compacting) { | 705 void Heap::MarkCompactPrologue(bool is_compacting) { |
| 706 // At any old GC clear the keyed lookup cache to enable collection of unused | 706 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 707 // maps. | 707 // maps. |
| 708 KeyedLookupCache::Clear(); | 708 isolate_->keyed_lookup_cache()->Clear(); |
| 709 ContextSlotCache::Clear(); | 709 isolate_->context_slot_cache()->Clear(); |
| 710 DescriptorLookupCache::Clear(); | 710 isolate_->descriptor_lookup_cache()->Clear(); |
| 711 | 711 |
| 712 CompilationCache::MarkCompactPrologue(); | 712 CompilationCache::MarkCompactPrologue(); |
| 713 | 713 |
| 714 Top::MarkCompactPrologue(is_compacting); | 714 Top::MarkCompactPrologue(is_compacting); |
| 715 ThreadManager::MarkCompactPrologue(is_compacting); | 715 ThreadManager::MarkCompactPrologue(is_compacting); |
| 716 | 716 |
| 717 CompletelyClearInstanceofCache(); | 717 CompletelyClearInstanceofCache(); |
| 718 | 718 |
| 719 if (is_compacting) THIS->FlushNumberStringCache(); | 719 if (is_compacting) THIS->FlushNumberStringCache(); |
| 720 } | 720 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 // we have to manually cache the watermark and mark the top page as having an | 853 // we have to manually cache the watermark and mark the top page as having an |
| 854 // invalid watermark. This guarantees that dirty regions iteration will use a | 854 // invalid watermark. This guarantees that dirty regions iteration will use a |
| 855 // correct watermark even if a linear allocation happens. | 855 // correct watermark even if a linear allocation happens. |
| 856 old_pointer_space_->FlushTopPageWatermark(); | 856 old_pointer_space_->FlushTopPageWatermark(); |
| 857 map_space_->FlushTopPageWatermark(); | 857 map_space_->FlushTopPageWatermark(); |
| 858 | 858 |
| 859 // Implements Cheney's copying algorithm | 859 // Implements Cheney's copying algorithm |
| 860 LOG(ResourceEvent("scavenge", "begin")); | 860 LOG(ResourceEvent("scavenge", "begin")); |
| 861 | 861 |
| 862 // Clear descriptor cache. | 862 // Clear descriptor cache. |
| 863 DescriptorLookupCache::Clear(); | 863 isolate_->descriptor_lookup_cache()->Clear(); |
| 864 | 864 |
| 865 // Used for updating survived_since_last_expansion_ at function end. | 865 // Used for updating survived_since_last_expansion_ at function end. |
| 866 int survived_watermark = PromotedSpaceSize(); | 866 int survived_watermark = PromotedSpaceSize(); |
| 867 | 867 |
| 868 CheckNewSpaceExpansionCriteria(); | 868 CheckNewSpaceExpansionCriteria(); |
| 869 | 869 |
| 870 // Flip the semispaces. After flipping, to space is empty, from space has | 870 // Flip the semispaces. After flipping, to space is empty, from space has |
| 871 // live objects. | 871 // live objects. |
| 872 new_space_.Flip(); | 872 new_space_.Flip(); |
| 873 new_space_.ResetAllocationInfo(); | 873 new_space_.ResetAllocationInfo(); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 | 1663 |
| 1664 // Allocate cache for external strings pointing to native source code. | 1664 // Allocate cache for external strings pointing to native source code. |
| 1665 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); | 1665 obj = AllocateFixedArray(Natives::GetBuiltinsCount()); |
| 1666 if (obj->IsFailure()) return false; | 1666 if (obj->IsFailure()) return false; |
| 1667 set_natives_source_cache(FixedArray::cast(obj)); | 1667 set_natives_source_cache(FixedArray::cast(obj)); |
| 1668 | 1668 |
| 1669 // Handling of script id generation is in Factory::NewScript. | 1669 // Handling of script id generation is in Factory::NewScript. |
| 1670 set_last_script_id(undefined_value()); | 1670 set_last_script_id(undefined_value()); |
| 1671 | 1671 |
| 1672 // Initialize keyed lookup cache. | 1672 // Initialize keyed lookup cache. |
| 1673 KeyedLookupCache::Clear(); | 1673 isolate_->keyed_lookup_cache()->Clear(); |
| 1674 | 1674 |
| 1675 // Initialize context slot cache. | 1675 // Initialize context slot cache. |
| 1676 ContextSlotCache::Clear(); | 1676 isolate_->context_slot_cache()->Clear(); |
| 1677 | 1677 |
| 1678 // Initialize descriptor cache. | 1678 // Initialize descriptor cache. |
| 1679 DescriptorLookupCache::Clear(); | 1679 isolate_->descriptor_lookup_cache()->Clear(); |
| 1680 | 1680 |
| 1681 // Initialize compilation cache. | 1681 // Initialize compilation cache. |
| 1682 CompilationCache::Clear(); | 1682 CompilationCache::Clear(); |
| 1683 | 1683 |
| 1684 return true; | 1684 return true; |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 | 1687 |
| 1688 Object* Heap::InitializeNumberStringCache() { | 1688 Object* Heap::InitializeNumberStringCache() { |
| 1689 // Compute the size of the number string cache based on the max heap size. | 1689 // Compute the size of the number string cache based on the max heap size. |
| (...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4665 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); | 4665 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); |
| 4666 } | 4666 } |
| 4667 | 4667 |
| 4668 | 4668 |
| 4669 int KeyedLookupCache::Lookup(Map* map, String* name) { | 4669 int KeyedLookupCache::Lookup(Map* map, String* name) { |
| 4670 int index = Hash(map, name); | 4670 int index = Hash(map, name); |
| 4671 Key& key = keys_[index]; | 4671 Key& key = keys_[index]; |
| 4672 if ((key.map == map) && key.name->Equals(name)) { | 4672 if ((key.map == map) && key.name->Equals(name)) { |
| 4673 return field_offsets_[index]; | 4673 return field_offsets_[index]; |
| 4674 } | 4674 } |
| 4675 return -1; | 4675 return kNotFound; |
| 4676 } | 4676 } |
| 4677 | 4677 |
| 4678 | 4678 |
| 4679 void KeyedLookupCache::Update(Map* map, String* name, int field_offset) { | 4679 void KeyedLookupCache::Update(Map* map, String* name, int field_offset) { |
| 4680 String* symbol; | 4680 String* symbol; |
| 4681 if (HEAP->LookupSymbolIfExists(name, &symbol)) { | 4681 if (HEAP->LookupSymbolIfExists(name, &symbol)) { |
| 4682 int index = Hash(map, symbol); | 4682 int index = Hash(map, symbol); |
| 4683 Key& key = keys_[index]; | 4683 Key& key = keys_[index]; |
| 4684 key.map = map; | 4684 key.map = map; |
| 4685 key.name = symbol; | 4685 key.name = symbol; |
| 4686 field_offsets_[index] = field_offset; | 4686 field_offsets_[index] = field_offset; |
| 4687 } | 4687 } |
| 4688 } | 4688 } |
| 4689 | 4689 |
| 4690 | 4690 |
| 4691 void KeyedLookupCache::Clear() { | 4691 void KeyedLookupCache::Clear() { |
| 4692 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; | 4692 for (int index = 0; index < kLength; index++) keys_[index].map = NULL; |
| 4693 } | 4693 } |
| 4694 | 4694 |
| 4695 | 4695 |
| 4696 KeyedLookupCache::Key KeyedLookupCache::keys_[KeyedLookupCache::kLength]; | |
| 4697 | |
| 4698 | |
| 4699 int KeyedLookupCache::field_offsets_[KeyedLookupCache::kLength]; | |
| 4700 | |
| 4701 | |
| 4702 void DescriptorLookupCache::Clear() { | 4696 void DescriptorLookupCache::Clear() { |
| 4703 for (int index = 0; index < kLength; index++) keys_[index].array = NULL; | 4697 for (int index = 0; index < kLength; index++) keys_[index].array = NULL; |
| 4704 } | 4698 } |
| 4705 | 4699 |
| 4706 | 4700 |
| 4707 DescriptorLookupCache::Key | |
| 4708 DescriptorLookupCache::keys_[DescriptorLookupCache::kLength]; | |
| 4709 | |
| 4710 int DescriptorLookupCache::results_[DescriptorLookupCache::kLength]; | |
| 4711 | |
| 4712 | |
| 4713 #ifdef DEBUG | 4701 #ifdef DEBUG |
| 4714 bool Heap::GarbageCollectionGreedyCheck() { | 4702 bool Heap::GarbageCollectionGreedyCheck() { |
| 4715 ASSERT(FLAG_gc_greedy); | 4703 ASSERT(FLAG_gc_greedy); |
| 4716 if (Bootstrapper::IsActive()) return true; | 4704 if (Bootstrapper::IsActive()) return true; |
| 4717 if (disallow_allocation_failure()) return true; | 4705 if (disallow_allocation_failure()) return true; |
| 4718 return CollectGarbage(0, NEW_SPACE); | 4706 return CollectGarbage(0, NEW_SPACE); |
| 4719 } | 4707 } |
| 4720 #endif | 4708 #endif |
| 4721 | 4709 |
| 4722 | 4710 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 void ExternalStringTable::TearDown() { | 4756 void ExternalStringTable::TearDown() { |
| 4769 new_space_strings_.Free(); | 4757 new_space_strings_.Free(); |
| 4770 old_space_strings_.Free(); | 4758 old_space_strings_.Free(); |
| 4771 } | 4759 } |
| 4772 | 4760 |
| 4773 | 4761 |
| 4774 List<Object*> ExternalStringTable::new_space_strings_; | 4762 List<Object*> ExternalStringTable::new_space_strings_; |
| 4775 List<Object*> ExternalStringTable::old_space_strings_; | 4763 List<Object*> ExternalStringTable::old_space_strings_; |
| 4776 | 4764 |
| 4777 } } // namespace v8::internal | 4765 } } // namespace v8::internal |
| OLD | NEW |