Chromium Code Reviews| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 static uint32_t NewSpaceMask() { return new_space_.mask(); } | 253 static uint32_t NewSpaceMask() { return new_space_.mask(); } |
| 254 static Address NewSpaceTop() { return new_space_.top(); } | 254 static Address NewSpaceTop() { return new_space_.top(); } |
| 255 | 255 |
| 256 static NewSpace* new_space() { return &new_space_; } | 256 static NewSpace* new_space() { return &new_space_; } |
| 257 static OldSpace* old_pointer_space() { return old_pointer_space_; } | 257 static OldSpace* old_pointer_space() { return old_pointer_space_; } |
| 258 static OldSpace* old_data_space() { return old_data_space_; } | 258 static OldSpace* old_data_space() { return old_data_space_; } |
| 259 static OldSpace* code_space() { return code_space_; } | 259 static OldSpace* code_space() { return code_space_; } |
| 260 static MapSpace* map_space() { return map_space_; } | 260 static MapSpace* map_space() { return map_space_; } |
| 261 static LargeObjectSpace* lo_space() { return lo_space_; } | 261 static LargeObjectSpace* lo_space() { return lo_space_; } |
| 262 | 262 |
| 263 static bool always_allocate() { return always_allocate_scope_depth_ != 0; } | |
|
Erik Corry
2008/10/30 09:08:43
As discussed offline the next change should have a
| |
| 264 static Address always_allocate_scope_depth_address() { | |
| 265 return reinterpret_cast<Address>(&always_allocate_scope_depth_); | |
| 266 } | |
| 267 | |
| 263 static Address* NewSpaceAllocationTopAddress() { | 268 static Address* NewSpaceAllocationTopAddress() { |
| 264 return new_space_.allocation_top_address(); | 269 return new_space_.allocation_top_address(); |
| 265 } | 270 } |
| 266 static Address* NewSpaceAllocationLimitAddress() { | 271 static Address* NewSpaceAllocationLimitAddress() { |
| 267 return new_space_.allocation_limit_address(); | 272 return new_space_.allocation_limit_address(); |
| 268 } | 273 } |
| 269 | 274 |
| 270 // Allocates and initializes a new JavaScript object based on a | 275 // Allocates and initializes a new JavaScript object based on a |
| 271 // constructor. | 276 // constructor. |
| 272 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 277 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 ExternalAsciiString::Resource* resource); | 521 ExternalAsciiString::Resource* resource); |
| 517 static Object* AllocateExternalStringFromTwoByte( | 522 static Object* AllocateExternalStringFromTwoByte( |
| 518 ExternalTwoByteString::Resource* resource); | 523 ExternalTwoByteString::Resource* resource); |
| 519 | 524 |
| 520 // Allocates an uninitialized object. The memory is non-executable if the | 525 // Allocates an uninitialized object. The memory is non-executable if the |
| 521 // hardware and OS allow. | 526 // hardware and OS allow. |
| 522 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 527 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 523 // failed. | 528 // failed. |
| 524 // Please note this function does not perform a garbage collection. | 529 // Please note this function does not perform a garbage collection. |
| 525 static inline Object* AllocateRaw(int size_in_bytes, | 530 static inline Object* AllocateRaw(int size_in_bytes, |
| 526 AllocationSpace space); | 531 AllocationSpace space, |
| 532 AllocationSpace retry_space); | |
| 527 | 533 |
| 528 // Makes a new native code object | 534 // Makes a new native code object |
| 529 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 535 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 530 // failed. | 536 // failed. |
| 531 // Please note this function does not perform a garbage collection. | 537 // Please note this function does not perform a garbage collection. |
| 532 static Object* CreateCode(const CodeDesc& desc, | 538 static Object* CreateCode(const CodeDesc& desc, |
| 533 ScopeInfo<>* sinfo, | 539 ScopeInfo<>* sinfo, |
| 534 Code::Flags flags); | 540 Code::Flags flags); |
| 535 | 541 |
| 536 static Object* CopyCode(Code* code); | 542 static Object* CopyCode(Code* code); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 static bool Contains(Address addr); | 630 static bool Contains(Address addr); |
| 625 static bool Contains(HeapObject* value); | 631 static bool Contains(HeapObject* value); |
| 626 | 632 |
| 627 // Checks whether an address/object in a space. | 633 // Checks whether an address/object in a space. |
| 628 // Currently used by tests and heap verification only. | 634 // Currently used by tests and heap verification only. |
| 629 static bool InSpace(Address addr, AllocationSpace space); | 635 static bool InSpace(Address addr, AllocationSpace space); |
| 630 static bool InSpace(HeapObject* value, AllocationSpace space); | 636 static bool InSpace(HeapObject* value, AllocationSpace space); |
| 631 | 637 |
| 632 // Finds out which space an object should get promoted to based on its type. | 638 // Finds out which space an object should get promoted to based on its type. |
| 633 static inline OldSpace* TargetSpace(HeapObject* object); | 639 static inline OldSpace* TargetSpace(HeapObject* object); |
| 640 static inline AllocationSpace TargetSpaceId(InstanceType type); | |
| 634 | 641 |
| 635 // Sets the stub_cache_ (only used when expanding the dictionary). | 642 // Sets the stub_cache_ (only used when expanding the dictionary). |
| 636 static void set_code_stubs(Dictionary* value) { code_stubs_ = value; } | 643 static void set_code_stubs(Dictionary* value) { code_stubs_ = value; } |
| 637 | 644 |
| 638 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). | 645 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). |
| 639 static void set_non_monomorphic_cache(Dictionary* value) { | 646 static void set_non_monomorphic_cache(Dictionary* value) { |
| 640 non_monomorphic_cache_ = value; | 647 non_monomorphic_cache_ = value; |
| 641 } | 648 } |
| 642 | 649 |
| 643 // Gets, sets and clears the lookup cache used for keyed access. | 650 // Gets, sets and clears the lookup cache used for keyed access. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 | 767 |
| 761 private: | 768 private: |
| 762 static int semispace_size_; | 769 static int semispace_size_; |
| 763 static int initial_semispace_size_; | 770 static int initial_semispace_size_; |
| 764 static int young_generation_size_; | 771 static int young_generation_size_; |
| 765 static int old_generation_size_; | 772 static int old_generation_size_; |
| 766 | 773 |
| 767 static int new_space_growth_limit_; | 774 static int new_space_growth_limit_; |
| 768 static int scavenge_count_; | 775 static int scavenge_count_; |
| 769 | 776 |
| 777 static int always_allocate_scope_depth_; | |
| 778 | |
| 770 static const int kMaxMapSpaceSize = 8*MB; | 779 static const int kMaxMapSpaceSize = 8*MB; |
| 771 | 780 |
| 772 static NewSpace new_space_; | 781 static NewSpace new_space_; |
| 773 static OldSpace* old_pointer_space_; | 782 static OldSpace* old_pointer_space_; |
| 774 static OldSpace* old_data_space_; | 783 static OldSpace* old_data_space_; |
| 775 static OldSpace* code_space_; | 784 static OldSpace* code_space_; |
| 776 static MapSpace* map_space_; | 785 static MapSpace* map_space_; |
| 777 static LargeObjectSpace* lo_space_; | 786 static LargeObjectSpace* lo_space_; |
| 778 static HeapState gc_state_; | 787 static HeapState gc_state_; |
| 779 | 788 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); | 927 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); |
| 919 | 928 |
| 920 // Copy memory from src to dst. | 929 // Copy memory from src to dst. |
| 921 inline static void CopyBlock(Object** dst, Object** src, int byte_size); | 930 inline static void CopyBlock(Object** dst, Object** src, int byte_size); |
| 922 | 931 |
| 923 static const int kInitialSymbolTableSize = 2048; | 932 static const int kInitialSymbolTableSize = 2048; |
| 924 static const int kInitialEvalCacheSize = 64; | 933 static const int kInitialEvalCacheSize = 64; |
| 925 | 934 |
| 926 friend class Factory; | 935 friend class Factory; |
| 927 friend class DisallowAllocationFailure; | 936 friend class DisallowAllocationFailure; |
| 937 friend class AlwaysAllocateScope; | |
| 938 }; | |
| 939 | |
| 940 | |
| 941 class AlwaysAllocateScope { | |
| 942 public: | |
| 943 AlwaysAllocateScope() { | |
| 944 // We shouldn't hit any nested scopes, because that requires | |
| 945 // non-handle code to call handle code. The code still works but | |
| 946 // performance will degrade, so we want to catch this situation | |
| 947 // in debug mode. | |
| 948 ASSERT(Heap::always_allocate_scope_depth_ == 0); | |
| 949 Heap::always_allocate_scope_depth_++; | |
| 950 } | |
| 951 | |
| 952 ~AlwaysAllocateScope() { | |
| 953 Heap::always_allocate_scope_depth_--; | |
| 954 ASSERT(Heap::always_allocate_scope_depth_ == 0); | |
| 955 } | |
| 928 }; | 956 }; |
| 929 | 957 |
| 930 | 958 |
| 931 #ifdef DEBUG | 959 #ifdef DEBUG |
| 932 // Visitor class to verify interior pointers that do not have remembered set | 960 // Visitor class to verify interior pointers that do not have remembered set |
| 933 // bits. All heap object pointers have to point into the heap to a location | 961 // bits. All heap object pointers have to point into the heap to a location |
| 934 // that has a map pointer at its first word. Caveat: Heap::Contains is an | 962 // that has a map pointer at its first word. Caveat: Heap::Contains is an |
| 935 // approximation because it can return true for objects in a heap space but | 963 // approximation because it can return true for objects in a heap space but |
| 936 // above the allocation pointer. | 964 // above the allocation pointer. |
| 937 class VerifyPointersVisitor: public ObjectVisitor { | 965 class VerifyPointersVisitor: public ObjectVisitor { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 int marked_count_; | 1247 int marked_count_; |
| 1220 | 1248 |
| 1221 // The count from the end of the previous full GC. Will be zero if there | 1249 // The count from the end of the previous full GC. Will be zero if there |
| 1222 // was no previous full GC. | 1250 // was no previous full GC. |
| 1223 int previous_marked_count_; | 1251 int previous_marked_count_; |
| 1224 }; | 1252 }; |
| 1225 | 1253 |
| 1226 } } // namespace v8::internal | 1254 } } // namespace v8::internal |
| 1227 | 1255 |
| 1228 #endif // V8_HEAP_H_ | 1256 #endif // V8_HEAP_H_ |
| OLD | NEW |