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