OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 last_idle_notification_gc_count_init_(false), | 146 last_idle_notification_gc_count_init_(false), |
147 configured_(false), | 147 configured_(false), |
148 is_safe_to_read_maps_(true) { | 148 is_safe_to_read_maps_(true) { |
149 // Allow build-time customization of the max semispace size. Building | 149 // Allow build-time customization of the max semispace size. Building |
150 // V8 with snapshots and a non-default max semispace size is much | 150 // V8 with snapshots and a non-default max semispace size is much |
151 // easier if you can define it as part of the build environment. | 151 // easier if you can define it as part of the build environment. |
152 #if defined(V8_MAX_SEMISPACE_SIZE) | 152 #if defined(V8_MAX_SEMISPACE_SIZE) |
153 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 153 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
154 #endif | 154 #endif |
155 | 155 |
156 intptr_t max_virtual = OS::MaxVirtualMemory(); | |
157 | |
158 if (max_virtual > 0) { | |
159 intptr_t half = max_virtual >> 1; | |
160 intptr_t quarter = max_virtual >> 2; | |
161 // If we have limits on the amount of virtual memory we can use then we may | |
162 // be forced to lower the allocation limits. We reserve one quarter of the | |
163 // memory for young space and off-heap data. The rest is distributed as | |
164 // described below. | |
165 if (code_range_size_ > 0) { | |
166 // Reserve a quarter of the memory for the code range. The old space | |
167 // heap gets the remaining half. There is some unavoidable double | |
168 // counting going on here since the heap size is measured in committed | |
169 // virtual memory and the code range is only reserved virtual memory. | |
170 code_range_size_ = Min(code_range_size_, quarter); | |
171 max_old_generation_size_ = Min(max_old_generation_size_, half); | |
172 } else { | |
173 // Reserve three quarters of the memory for the old space heap including | |
174 // the executable code. | |
175 max_old_generation_size_ = Min(max_old_generation_size_, half + quarter); | |
176 } | |
177 } | |
178 | |
179 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 156 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
180 global_contexts_list_ = NULL; | 157 global_contexts_list_ = NULL; |
181 mark_compact_collector_.heap_ = this; | 158 mark_compact_collector_.heap_ = this; |
182 external_string_table_.heap_ = this; | 159 external_string_table_.heap_ = this; |
183 } | 160 } |
184 | 161 |
185 | 162 |
186 intptr_t Heap::Capacity() { | 163 intptr_t Heap::Capacity() { |
187 if (!HasBeenSetup()) return 0; | 164 if (!HasBeenSetup()) return 0; |
188 | 165 |
(...skipping 5775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 } | 5941 } |
5965 | 5942 |
5966 | 5943 |
5967 void ExternalStringTable::TearDown() { | 5944 void ExternalStringTable::TearDown() { |
5968 new_space_strings_.Free(); | 5945 new_space_strings_.Free(); |
5969 old_space_strings_.Free(); | 5946 old_space_strings_.Free(); |
5970 } | 5947 } |
5971 | 5948 |
5972 | 5949 |
5973 } } // namespace v8::internal | 5950 } } // namespace v8::internal |
OLD | NEW |