OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 // The following methods are used to track raw C++ pointers to externally | 1515 // The following methods are used to track raw C++ pointers to externally |
1516 // allocated memory used as backing store in live array buffers. | 1516 // allocated memory used as backing store in live array buffers. |
1517 | 1517 |
1518 // A new ArrayBuffer was created with |data| as backing store. | 1518 // A new ArrayBuffer was created with |data| as backing store. |
1519 void RegisterNewArrayBuffer(bool in_new_space, void* data, size_t length); | 1519 void RegisterNewArrayBuffer(bool in_new_space, void* data, size_t length); |
1520 | 1520 |
1521 // The backing store |data| is no longer owned by V8. | 1521 // The backing store |data| is no longer owned by V8. |
1522 void UnregisterArrayBuffer(bool in_new_space, void* data); | 1522 void UnregisterArrayBuffer(bool in_new_space, void* data); |
1523 | 1523 |
1524 // A live ArrayBuffer was discovered during marking/scavenge. | 1524 // A live ArrayBuffer was discovered during marking/scavenge. |
1525 void RegisterLiveArrayBuffer(bool in_new_space, void* data); | 1525 void RegisterLiveArrayBuffer(bool from_scavenge, void* data); |
1526 | 1526 |
1527 // Frees all backing store pointers that weren't discovered in the previous | 1527 // Frees all backing store pointers that weren't discovered in the previous |
1528 // marking or scavenge phase. | 1528 // marking or scavenge phase. |
1529 void FreeDeadArrayBuffers(bool in_new_space); | 1529 void FreeDeadArrayBuffers(bool from_scavenge); |
1530 | 1530 |
1531 // Prepare for a new scavenge phase. A new marking phase is implicitly | 1531 // Prepare for a new scavenge phase. A new marking phase is implicitly |
1532 // prepared by finishing the previous one. | 1532 // prepared by finishing the previous one. |
1533 void PrepareArrayBufferDiscoveryInNewSpace(); | 1533 void PrepareArrayBufferDiscoveryInNewSpace(); |
1534 | 1534 |
1535 // An ArrayBuffer moved from new space to old space. | 1535 // An ArrayBuffer moved from new space to old space. |
1536 void PromoteArrayBuffer(Object* buffer); | 1536 void PromoteArrayBuffer(Object* buffer); |
1537 | 1537 |
1538 protected: | 1538 protected: |
1539 // Methods made available to tests. | 1539 // Methods made available to tests. |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 MemoryChunk* chunks_queued_for_free_; | 2209 MemoryChunk* chunks_queued_for_free_; |
2210 | 2210 |
2211 base::Mutex relocation_mutex_; | 2211 base::Mutex relocation_mutex_; |
2212 | 2212 |
2213 int gc_callbacks_depth_; | 2213 int gc_callbacks_depth_; |
2214 | 2214 |
2215 bool deserialization_complete_; | 2215 bool deserialization_complete_; |
2216 | 2216 |
2217 bool concurrent_sweeping_enabled_; | 2217 bool concurrent_sweeping_enabled_; |
2218 | 2218 |
| 2219 // |live_array_buffers_| maps externally allocated memory used as backing |
| 2220 // store for ArrayBuffers to the length of the respective memory blocks. |
| 2221 // |
| 2222 // At the beginning of mark/compact, |not_yet_discovered_array_buffers_| is |
| 2223 // a copy of |live_array_buffers_| and we remove pointers as we discover live |
| 2224 // ArrayBuffer objects during marking. At the end of mark/compact, the |
| 2225 // remaining memory blocks can be freed. |
2219 std::map<void*, size_t> live_array_buffers_; | 2226 std::map<void*, size_t> live_array_buffers_; |
2220 std::map<void*, size_t> live_new_array_buffers_; | |
2221 std::map<void*, size_t> not_yet_discovered_array_buffers_; | 2227 std::map<void*, size_t> not_yet_discovered_array_buffers_; |
2222 std::map<void*, size_t> not_yet_discovered_new_array_buffers_; | 2228 |
| 2229 // To be able to free memory held by ArrayBuffers during scavenge as well, we |
| 2230 // have a separate list of allocated memory held by ArrayBuffers in new space. |
| 2231 // |
| 2232 // Since mark/compact also evacuates the new space, all pointers in the |
| 2233 // |live_array_buffers_for_scavenge_| list are also in the |
| 2234 // |live_array_buffers_| list. |
| 2235 std::map<void*, size_t> live_array_buffers_for_scavenge_; |
| 2236 std::map<void*, size_t> not_yet_discovered_array_buffers_for_scavenge_; |
2223 | 2237 |
2224 struct StrongRootsList; | 2238 struct StrongRootsList; |
2225 StrongRootsList* strong_roots_list_; | 2239 StrongRootsList* strong_roots_list_; |
2226 | 2240 |
2227 friend class AlwaysAllocateScope; | 2241 friend class AlwaysAllocateScope; |
2228 friend class Deserializer; | 2242 friend class Deserializer; |
2229 friend class Factory; | 2243 friend class Factory; |
2230 friend class GCCallbacksScope; | 2244 friend class GCCallbacksScope; |
2231 friend class GCTracer; | 2245 friend class GCTracer; |
2232 friend class HeapIterator; | 2246 friend class HeapIterator; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2692 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2679 | 2693 |
2680 private: | 2694 private: |
2681 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2695 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2682 }; | 2696 }; |
2683 #endif // DEBUG | 2697 #endif // DEBUG |
2684 } | 2698 } |
2685 } // namespace v8::internal | 2699 } // namespace v8::internal |
2686 | 2700 |
2687 #endif // V8_HEAP_HEAP_H_ | 2701 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |