OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 class GCTracer; | 221 class GCTracer; |
222 | 222 |
223 | 223 |
224 // The all static Heap captures the interface to the global object heap. | 224 // The all static Heap captures the interface to the global object heap. |
225 // All JavaScript contexts by this process share the same object heap. | 225 // All JavaScript contexts by this process share the same object heap. |
226 | 226 |
227 class Heap : public AllStatic { | 227 class Heap : public AllStatic { |
228 public: | 228 public: |
229 // Configure heap size before setup. Return false if the heap has been | 229 // Configure heap size before setup. Return false if the heap has been |
230 // setup already. | 230 // setup already. |
231 static bool ConfigureHeap(int semispace_size, int old_gen_size); | 231 static bool ConfigureHeap(int max_semispace_size, int max_old_gen_size); |
232 static bool ConfigureHeapDefault(); | 232 static bool ConfigureHeapDefault(); |
233 | 233 |
234 // Initializes the global object heap. If create_heap_objects is true, | 234 // Initializes the global object heap. If create_heap_objects is true, |
235 // also creates the basic non-mutable objects. | 235 // also creates the basic non-mutable objects. |
236 // Returns whether it succeeded. | 236 // Returns whether it succeeded. |
237 static bool Setup(bool create_heap_objects); | 237 static bool Setup(bool create_heap_objects); |
238 | 238 |
239 // Destroys all memory allocated by the heap. | 239 // Destroys all memory allocated by the heap. |
240 static void TearDown(); | 240 static void TearDown(); |
241 | 241 |
242 // Sets the stack limit in the roots_ array. Some architectures generate code | 242 // Sets the stack limit in the roots_ array. Some architectures generate code |
243 // that looks here, because it is faster than loading from the static jslimit_ | 243 // that looks here, because it is faster than loading from the static jslimit_ |
244 // variable. | 244 // variable. |
245 static void SetStackLimit(intptr_t limit); | 245 static void SetStackLimit(intptr_t limit); |
246 | 246 |
247 // Returns whether Setup has been called. | 247 // Returns whether Setup has been called. |
248 static bool HasBeenSetup(); | 248 static bool HasBeenSetup(); |
249 | 249 |
250 // Returns the maximum heap capacity. | 250 // Returns the maximum amount of memory reserved for the heap. |
251 static int MaxCapacity() { | 251 static int MaxReserved() { |
252 return young_generation_size_ + old_generation_size_; | 252 return 4 * reserved_semispace_size_ + max_old_generation_size_; |
Erik Corry
2009/10/21 13:41:49
The 4 here probably deserves a comment.
| |
253 } | 253 } |
254 static int SemiSpaceSize() { return semispace_size_; } | 254 static int MaxSemiSpaceSize() { return max_semispace_size_; } |
255 static int ReservedSemiSpaceSize() { return reserved_semispace_size_; } | |
255 static int InitialSemiSpaceSize() { return initial_semispace_size_; } | 256 static int InitialSemiSpaceSize() { return initial_semispace_size_; } |
256 static int YoungGenerationSize() { return young_generation_size_; } | 257 static int MaxOldGenerationSize() { return max_old_generation_size_; } |
257 static int OldGenerationSize() { return old_generation_size_; } | |
258 | 258 |
259 // Returns the capacity of the heap in bytes w/o growing. Heap grows when | 259 // Returns the capacity of the heap in bytes w/o growing. Heap grows when |
260 // more spaces are needed until it reaches the limit. | 260 // more spaces are needed until it reaches the limit. |
261 static int Capacity(); | 261 static int Capacity(); |
262 | 262 |
263 // Returns the amount of memory currently committed for the heap. | 263 // Returns the amount of memory currently committed for the heap. |
264 static int CommittedMemory(); | 264 static int CommittedMemory(); |
265 | 265 |
266 // Returns the available bytes in space w/o growing. | 266 // Returns the available bytes in space w/o growing. |
267 // Heap doesn't guarantee that it can allocate an object that requires | 267 // Heap doesn't guarantee that it can allocate an object that requires |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 #undef SYMBOL_DECLARATION | 878 #undef SYMBOL_DECLARATION |
879 | 879 |
880 kSymbolTableRootIndex, | 880 kSymbolTableRootIndex, |
881 kStrongRootListLength = kSymbolTableRootIndex, | 881 kStrongRootListLength = kSymbolTableRootIndex, |
882 kRootListLength | 882 kRootListLength |
883 }; | 883 }; |
884 | 884 |
885 static Object* NumberToString(Object* number); | 885 static Object* NumberToString(Object* number); |
886 | 886 |
887 private: | 887 private: |
888 static int semispace_size_; | 888 static int reserved_semispace_size_; |
889 static int max_semispace_size_; | |
889 static int initial_semispace_size_; | 890 static int initial_semispace_size_; |
890 static int young_generation_size_; | 891 static int max_old_generation_size_; |
891 static int old_generation_size_; | |
892 static size_t code_range_size_; | 892 static size_t code_range_size_; |
893 | 893 |
894 // For keeping track of how much data has survived | 894 // For keeping track of how much data has survived |
895 // scavenge since last new space expansion. | 895 // scavenge since last new space expansion. |
896 static int survived_since_last_expansion_; | 896 static int survived_since_last_expansion_; |
897 | 897 |
898 static int always_allocate_scope_depth_; | 898 static int always_allocate_scope_depth_; |
899 static bool context_disposed_pending_; | 899 static bool context_disposed_pending_; |
900 | 900 |
901 static const int kMaxMapSpaceSize = 8*MB; | 901 static const int kMaxMapSpaceSize = 8*MB; |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1592 } | 1592 } |
1593 static TranscendentalCache* caches_[kNumberOfCaches]; | 1593 static TranscendentalCache* caches_[kNumberOfCaches]; |
1594 Element elements_[kCacheSize]; | 1594 Element elements_[kCacheSize]; |
1595 Type type_; | 1595 Type type_; |
1596 }; | 1596 }; |
1597 | 1597 |
1598 | 1598 |
1599 } } // namespace v8::internal | 1599 } } // namespace v8::internal |
1600 | 1600 |
1601 #endif // V8_HEAP_H_ | 1601 #endif // V8_HEAP_H_ |
OLD | NEW |