| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 uintptr_t NewSpaceMask() { return new_space_.mask(); } | 501 uintptr_t NewSpaceMask() { return new_space_.mask(); } |
| 502 Address NewSpaceTop() { return new_space_.top(); } | 502 Address NewSpaceTop() { return new_space_.top(); } |
| 503 | 503 |
| 504 NewSpace* new_space() { return &new_space_; } | 504 NewSpace* new_space() { return &new_space_; } |
| 505 OldSpace* old_pointer_space() { return old_pointer_space_; } | 505 OldSpace* old_pointer_space() { return old_pointer_space_; } |
| 506 OldSpace* old_data_space() { return old_data_space_; } | 506 OldSpace* old_data_space() { return old_data_space_; } |
| 507 OldSpace* code_space() { return code_space_; } | 507 OldSpace* code_space() { return code_space_; } |
| 508 MapSpace* map_space() { return map_space_; } | 508 MapSpace* map_space() { return map_space_; } |
| 509 CellSpace* cell_space() { return cell_space_; } | 509 CellSpace* cell_space() { return cell_space_; } |
| 510 LargeObjectSpace* lo_space() { return lo_space_; } | 510 LargeObjectSpace* lo_space() { return lo_space_; } |
| 511 PagedSpace* paged_space(int idx) { |
| 512 switch (idx) { |
| 513 case OLD_POINTER_SPACE: |
| 514 return old_pointer_space(); |
| 515 case OLD_DATA_SPACE: |
| 516 return old_data_space(); |
| 517 case MAP_SPACE: |
| 518 return map_space(); |
| 519 case CELL_SPACE: |
| 520 return cell_space(); |
| 521 case CODE_SPACE: |
| 522 return code_space(); |
| 523 case NEW_SPACE: |
| 524 case LO_SPACE: |
| 525 UNREACHABLE(); |
| 526 } |
| 527 return NULL; |
| 528 } |
| 511 | 529 |
| 512 bool always_allocate() { return always_allocate_scope_depth_ != 0; } | 530 bool always_allocate() { return always_allocate_scope_depth_ != 0; } |
| 513 Address always_allocate_scope_depth_address() { | 531 Address always_allocate_scope_depth_address() { |
| 514 return reinterpret_cast<Address>(&always_allocate_scope_depth_); | 532 return reinterpret_cast<Address>(&always_allocate_scope_depth_); |
| 515 } | 533 } |
| 516 bool linear_allocation() { | 534 bool linear_allocation() { |
| 517 return linear_allocation_scope_depth_ != 0; | 535 return linear_allocation_scope_depth_ != 0; |
| 518 } | 536 } |
| 519 | 537 |
| 520 Address* NewSpaceAllocationTopAddress() { | 538 Address* NewSpaceAllocationTopAddress() { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 668 |
| 651 // Allocates an empty TypeFeedbackInfo. | 669 // Allocates an empty TypeFeedbackInfo. |
| 652 MUST_USE_RESULT MaybeObject* AllocateTypeFeedbackInfo(); | 670 MUST_USE_RESULT MaybeObject* AllocateTypeFeedbackInfo(); |
| 653 | 671 |
| 654 // Allocates an AliasedArgumentsEntry. | 672 // Allocates an AliasedArgumentsEntry. |
| 655 MUST_USE_RESULT MaybeObject* AllocateAliasedArgumentsEntry(int slot); | 673 MUST_USE_RESULT MaybeObject* AllocateAliasedArgumentsEntry(int slot); |
| 656 | 674 |
| 657 // Clear the Instanceof cache (used when a prototype changes). | 675 // Clear the Instanceof cache (used when a prototype changes). |
| 658 inline void ClearInstanceofCache(); | 676 inline void ClearInstanceofCache(); |
| 659 | 677 |
| 678 // For use during bootup. |
| 679 void RepairFreeListsAfterBoot(); |
| 680 |
| 660 // Allocates and fully initializes a String. There are two String | 681 // Allocates and fully initializes a String. There are two String |
| 661 // encodings: ASCII and two byte. One should choose between the three string | 682 // encodings: ASCII and two byte. One should choose between the three string |
| 662 // allocation functions based on the encoding of the string buffer used to | 683 // allocation functions based on the encoding of the string buffer used to |
| 663 // initialized the string. | 684 // initialized the string. |
| 664 // - ...FromAscii initializes the string from a buffer that is ASCII | 685 // - ...FromAscii initializes the string from a buffer that is ASCII |
| 665 // encoded (it does not check that the buffer is ASCII encoded) and the | 686 // encoded (it does not check that the buffer is ASCII encoded) and the |
| 666 // result will be ASCII encoded. | 687 // result will be ASCII encoded. |
| 667 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 | 688 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 |
| 668 // encoded. If the characters are all single-byte characters, the | 689 // encoded. If the characters are all single-byte characters, the |
| 669 // result will be ASCII encoded, otherwise it will converted to two | 690 // result will be ASCII encoded, otherwise it will converted to two |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 // Callback function passed to Heap::Iterate etc. Copies an object if | 1323 // Callback function passed to Heap::Iterate etc. Copies an object if |
| 1303 // necessary, the object might be promoted to an old space. The caller must | 1324 // necessary, the object might be promoted to an old space. The caller must |
| 1304 // ensure the precondition that the object is (a) a heap object and (b) in | 1325 // ensure the precondition that the object is (a) a heap object and (b) in |
| 1305 // the heap's from space. | 1326 // the heap's from space. |
| 1306 static inline void ScavengePointer(HeapObject** p); | 1327 static inline void ScavengePointer(HeapObject** p); |
| 1307 static inline void ScavengeObject(HeapObject** p, HeapObject* object); | 1328 static inline void ScavengeObject(HeapObject** p, HeapObject* object); |
| 1308 | 1329 |
| 1309 // Commits from space if it is uncommitted. | 1330 // Commits from space if it is uncommitted. |
| 1310 void EnsureFromSpaceIsCommitted(); | 1331 void EnsureFromSpaceIsCommitted(); |
| 1311 | 1332 |
| 1312 // Support for partial snapshots. After calling this we can allocate a | 1333 // Support for partial snapshots. After calling this we have a linear |
| 1313 // certain number of bytes using only linear allocation (with a | 1334 // space to write objects in each space. |
| 1314 // LinearAllocationScope and an AlwaysAllocateScope) without using freelists | 1335 void ReserveSpace(intptr_t *sizes, Address* addresses); |
| 1315 // or causing a GC. It returns true of space was reserved or false if a GC is | |
| 1316 // needed. For paged spaces the space requested must include the space wasted | |
| 1317 // at the end of each page when allocating linearly. | |
| 1318 void ReserveSpace( | |
| 1319 int new_space_size, | |
| 1320 int pointer_space_size, | |
| 1321 int data_space_size, | |
| 1322 int code_space_size, | |
| 1323 int map_space_size, | |
| 1324 int cell_space_size, | |
| 1325 int large_object_size); | |
| 1326 | 1336 |
| 1327 // | 1337 // |
| 1328 // Support for the API. | 1338 // Support for the API. |
| 1329 // | 1339 // |
| 1330 | 1340 |
| 1331 bool CreateApiObjects(); | 1341 bool CreateApiObjects(); |
| 1332 | 1342 |
| 1333 // Attempt to find the number in a small cache. If we finds it, return | 1343 // Attempt to find the number in a small cache. If we finds it, return |
| 1334 // the string representation of the number. Otherwise return undefined. | 1344 // the string representation of the number. Otherwise return undefined. |
| 1335 Object* GetNumberStringCache(Object* number); | 1345 Object* GetNumberStringCache(Object* number); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; | 2134 VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
| 2125 | 2135 |
| 2126 MemoryChunk* chunks_queued_for_free_; | 2136 MemoryChunk* chunks_queued_for_free_; |
| 2127 | 2137 |
| 2128 Mutex* relocation_mutex_; | 2138 Mutex* relocation_mutex_; |
| 2129 | 2139 |
| 2130 friend class Factory; | 2140 friend class Factory; |
| 2131 friend class GCTracer; | 2141 friend class GCTracer; |
| 2132 friend class DisallowAllocationFailure; | 2142 friend class DisallowAllocationFailure; |
| 2133 friend class AlwaysAllocateScope; | 2143 friend class AlwaysAllocateScope; |
| 2134 friend class LinearAllocationScope; | |
| 2135 friend class Page; | 2144 friend class Page; |
| 2136 friend class Isolate; | 2145 friend class Isolate; |
| 2137 friend class MarkCompactCollector; | 2146 friend class MarkCompactCollector; |
| 2138 friend class MarkCompactMarkingVisitor; | 2147 friend class MarkCompactMarkingVisitor; |
| 2139 friend class MapCompact; | 2148 friend class MapCompact; |
| 2140 | 2149 |
| 2141 DISALLOW_COPY_AND_ASSIGN(Heap); | 2150 DISALLOW_COPY_AND_ASSIGN(Heap); |
| 2142 }; | 2151 }; |
| 2143 | 2152 |
| 2144 | 2153 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 public: | 2200 public: |
| 2192 inline AlwaysAllocateScope(); | 2201 inline AlwaysAllocateScope(); |
| 2193 inline ~AlwaysAllocateScope(); | 2202 inline ~AlwaysAllocateScope(); |
| 2194 | 2203 |
| 2195 private: | 2204 private: |
| 2196 // Implicitly disable artificial allocation failures. | 2205 // Implicitly disable artificial allocation failures. |
| 2197 DisallowAllocationFailure disallow_allocation_failure_; | 2206 DisallowAllocationFailure disallow_allocation_failure_; |
| 2198 }; | 2207 }; |
| 2199 | 2208 |
| 2200 | 2209 |
| 2201 class LinearAllocationScope { | |
| 2202 public: | |
| 2203 inline LinearAllocationScope(); | |
| 2204 inline ~LinearAllocationScope(); | |
| 2205 }; | |
| 2206 | |
| 2207 | |
| 2208 #ifdef DEBUG | 2210 #ifdef DEBUG |
| 2209 // Visitor class to verify interior pointers in spaces that do not contain | 2211 // Visitor class to verify interior pointers in spaces that do not contain |
| 2210 // or care about intergenerational references. All heap object pointers have to | 2212 // or care about intergenerational references. All heap object pointers have to |
| 2211 // point into the heap to a location that has a map pointer at its first word. | 2213 // point into the heap to a location that has a map pointer at its first word. |
| 2212 // Caveat: Heap::Contains is an approximation because it can return true for | 2214 // Caveat: Heap::Contains is an approximation because it can return true for |
| 2213 // objects in a heap space but above the allocation pointer. | 2215 // objects in a heap space but above the allocation pointer. |
| 2214 class VerifyPointersVisitor: public ObjectVisitor { | 2216 class VerifyPointersVisitor: public ObjectVisitor { |
| 2215 public: | 2217 public: |
| 2216 inline void VisitPointers(Object** start, Object** end); | 2218 inline void VisitPointers(Object** start, Object** end); |
| 2217 }; | 2219 }; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2798 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 2800 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
| 2799 | 2801 |
| 2800 private: | 2802 private: |
| 2801 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2803 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2802 }; | 2804 }; |
| 2803 #endif // DEBUG || LIVE_OBJECT_LIST | 2805 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2804 | 2806 |
| 2805 } } // namespace v8::internal | 2807 } } // namespace v8::internal |
| 2806 | 2808 |
| 2807 #endif // V8_HEAP_H_ | 2809 #endif // V8_HEAP_H_ |
| OLD | NEW |