| 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 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 static const int kThreshold = 20; | 1062 static const int kThreshold = 20; |
| 1063 while (gc_performed && counter++ < kThreshold) { | 1063 while (gc_performed && counter++ < kThreshold) { |
| 1064 gc_performed = false; | 1064 gc_performed = false; |
| 1065 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) { | 1065 for (int space = NEW_SPACE; space < Serializer::kNumberOfSpaces; space++) { |
| 1066 Reservation* reservation = &reservations[space]; | 1066 Reservation* reservation = &reservations[space]; |
| 1067 DCHECK_LE(1, reservation->length()); | 1067 DCHECK_LE(1, reservation->length()); |
| 1068 if (reservation->at(0).size == 0) continue; | 1068 if (reservation->at(0).size == 0) continue; |
| 1069 bool perform_gc = false; | 1069 bool perform_gc = false; |
| 1070 if (space == LO_SPACE) { | 1070 if (space == LO_SPACE) { |
| 1071 DCHECK_EQ(1, reservation->length()); | 1071 DCHECK_EQ(1, reservation->length()); |
| 1072 perform_gc = !lo_space()->CanAllocateSize(reservation->at(0).size); | 1072 perform_gc = !CanExpandOldGeneration(reservation->at(0).size); |
| 1073 } else { | 1073 } else { |
| 1074 for (auto& chunk : *reservation) { | 1074 for (auto& chunk : *reservation) { |
| 1075 AllocationResult allocation; | 1075 AllocationResult allocation; |
| 1076 int size = chunk.size; | 1076 int size = chunk.size; |
| 1077 DCHECK_LE(size, MemoryAllocator::PageAreaSize( | 1077 DCHECK_LE(size, MemoryAllocator::PageAreaSize( |
| 1078 static_cast<AllocationSpace>(space))); | 1078 static_cast<AllocationSpace>(space))); |
| 1079 if (space == NEW_SPACE) { | 1079 if (space == NEW_SPACE) { |
| 1080 allocation = new_space()->AllocateRawUnaligned(size); | 1080 allocation = new_space()->AllocateRawUnaligned(size); |
| 1081 } else { | 1081 } else { |
| 1082 allocation = paged_space(space)->AllocateRawUnaligned(size); | 1082 allocation = paged_space(space)->AllocateRawUnaligned(size); |
| (...skipping 4673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5756 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) | 5756 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) |
| 5757 return false; | 5757 return false; |
| 5758 | 5758 |
| 5759 // Set up new space. | 5759 // Set up new space. |
| 5760 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { | 5760 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { |
| 5761 return false; | 5761 return false; |
| 5762 } | 5762 } |
| 5763 new_space_top_after_last_gc_ = new_space()->top(); | 5763 new_space_top_after_last_gc_ = new_space()->top(); |
| 5764 | 5764 |
| 5765 // Initialize old space. | 5765 // Initialize old space. |
| 5766 old_space_ = | 5766 old_space_ = new OldSpace(this, OLD_SPACE, NOT_EXECUTABLE); |
| 5767 new OldSpace(this, max_old_generation_size_, OLD_SPACE, NOT_EXECUTABLE); | |
| 5768 if (old_space_ == NULL) return false; | 5767 if (old_space_ == NULL) return false; |
| 5769 if (!old_space_->SetUp()) return false; | 5768 if (!old_space_->SetUp()) return false; |
| 5770 | 5769 |
| 5771 if (!isolate_->code_range()->SetUp(code_range_size_)) return false; | 5770 if (!isolate_->code_range()->SetUp(code_range_size_)) return false; |
| 5772 | 5771 |
| 5773 // Initialize the code space, set its maximum capacity to the old | 5772 // Initialize the code space, set its maximum capacity to the old |
| 5774 // generation size. It needs executable memory. | 5773 // generation size. It needs executable memory. |
| 5775 code_space_ = | 5774 code_space_ = new OldSpace(this, CODE_SPACE, EXECUTABLE); |
| 5776 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | |
| 5777 if (code_space_ == NULL) return false; | 5775 if (code_space_ == NULL) return false; |
| 5778 if (!code_space_->SetUp()) return false; | 5776 if (!code_space_->SetUp()) return false; |
| 5779 | 5777 |
| 5780 // Initialize map space. | 5778 // Initialize map space. |
| 5781 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); | 5779 map_space_ = new MapSpace(this, MAP_SPACE); |
| 5782 if (map_space_ == NULL) return false; | 5780 if (map_space_ == NULL) return false; |
| 5783 if (!map_space_->SetUp()) return false; | 5781 if (!map_space_->SetUp()) return false; |
| 5784 | 5782 |
| 5785 // The large object code space may contain code or data. We set the memory | 5783 // The large object code space may contain code or data. We set the memory |
| 5786 // to be non-executable here for safety, but this means we need to enable it | 5784 // to be non-executable here for safety, but this means we need to enable it |
| 5787 // explicitly when allocating large code objects. | 5785 // explicitly when allocating large code objects. |
| 5788 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); | 5786 lo_space_ = new LargeObjectSpace(this, LO_SPACE); |
| 5789 if (lo_space_ == NULL) return false; | 5787 if (lo_space_ == NULL) return false; |
| 5790 if (!lo_space_->SetUp()) return false; | 5788 if (!lo_space_->SetUp()) return false; |
| 5791 | 5789 |
| 5792 // Set up the seed that is used to randomize the string hash function. | 5790 // Set up the seed that is used to randomize the string hash function. |
| 5793 DCHECK(hash_seed() == 0); | 5791 DCHECK(hash_seed() == 0); |
| 5794 if (FLAG_randomize_hashes) { | 5792 if (FLAG_randomize_hashes) { |
| 5795 if (FLAG_hash_seed == 0) { | 5793 if (FLAG_hash_seed == 0) { |
| 5796 int rnd = isolate()->random_number_generator()->NextInt(); | 5794 int rnd = isolate()->random_number_generator()->NextInt(); |
| 5797 set_hash_seed(Smi::FromInt(rnd & Name::kHashBitMask)); | 5795 set_hash_seed(Smi::FromInt(rnd & Name::kHashBitMask)); |
| 5798 } else { | 5796 } else { |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6902 *object_type = "CODE_TYPE"; \ | 6900 *object_type = "CODE_TYPE"; \ |
| 6903 *object_sub_type = "CODE_AGE/" #name; \ | 6901 *object_sub_type = "CODE_AGE/" #name; \ |
| 6904 return true; | 6902 return true; |
| 6905 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6903 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6906 #undef COMPARE_AND_RETURN_NAME | 6904 #undef COMPARE_AND_RETURN_NAME |
| 6907 } | 6905 } |
| 6908 return false; | 6906 return false; |
| 6909 } | 6907 } |
| 6910 } // namespace internal | 6908 } // namespace internal |
| 6911 } // namespace v8 | 6909 } // namespace v8 |
| OLD | NEW |