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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 // The following methods are used to track raw C++ pointers to externally | 1591 // The following methods are used to track raw C++ pointers to externally |
1592 // allocated memory used as backing store in live array buffers. | 1592 // allocated memory used as backing store in live array buffers. |
1593 | 1593 |
1594 // A new ArrayBuffer was created with |data| as backing store. | 1594 // A new ArrayBuffer was created with |data| as backing store. |
1595 void RegisterNewArrayBuffer(bool in_new_space, void* data, size_t length); | 1595 void RegisterNewArrayBuffer(bool in_new_space, void* data, size_t length); |
1596 | 1596 |
1597 // The backing store |data| is no longer owned by V8. | 1597 // The backing store |data| is no longer owned by V8. |
1598 void UnregisterArrayBuffer(bool in_new_space, void* data); | 1598 void UnregisterArrayBuffer(bool in_new_space, void* data); |
1599 | 1599 |
1600 // A live ArrayBuffer was discovered during marking/scavenge. | 1600 // A live ArrayBuffer was discovered during marking/scavenge. |
1601 void RegisterLiveArrayBuffer(bool in_new_space, void* data); | 1601 void RegisterLiveArrayBuffer(bool from_scavenge, void* data); |
1602 | 1602 |
1603 // Frees all backing store pointers that weren't discovered in the previous | 1603 // Frees all backing store pointers that weren't discovered in the previous |
1604 // marking or scavenge phase. | 1604 // marking or scavenge phase. |
1605 void FreeDeadArrayBuffers(bool in_new_space); | 1605 void FreeDeadArrayBuffers(bool from_scavenge); |
1606 | 1606 |
1607 // Prepare for a new scavenge phase. A new marking phase is implicitly | 1607 // Prepare for a new scavenge phase. A new marking phase is implicitly |
1608 // prepared by finishing the previous one. | 1608 // prepared by finishing the previous one. |
1609 void PrepareArrayBufferDiscoveryInNewSpace(); | 1609 void PrepareArrayBufferDiscoveryInNewSpace(); |
1610 | 1610 |
1611 // An ArrayBuffer moved from new space to old space. | 1611 // An ArrayBuffer moved from new space to old space. |
1612 void PromoteArrayBuffer(Object* buffer); | 1612 void PromoteArrayBuffer(Object* buffer); |
1613 | 1613 |
1614 protected: | 1614 protected: |
1615 // Methods made available to tests. | 1615 // Methods made available to tests. |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 MemoryChunk* chunks_queued_for_free_; | 2365 MemoryChunk* chunks_queued_for_free_; |
2366 | 2366 |
2367 base::Mutex relocation_mutex_; | 2367 base::Mutex relocation_mutex_; |
2368 | 2368 |
2369 int gc_callbacks_depth_; | 2369 int gc_callbacks_depth_; |
2370 | 2370 |
2371 bool deserialization_complete_; | 2371 bool deserialization_complete_; |
2372 | 2372 |
2373 bool concurrent_sweeping_enabled_; | 2373 bool concurrent_sweeping_enabled_; |
2374 | 2374 |
| 2375 // |live_array_buffers_| maps externally allocated memory used as backing |
| 2376 // store for ArrayBuffers to the length of the respective memory blocks. |
| 2377 // |
| 2378 // At the beginning of mark/compact, |not_yet_discovered_array_buffers_| is |
| 2379 // a copy of |live_array_buffers_| and we remove pointers as we discover live |
| 2380 // ArrayBuffer objects during marking. At the end of mark/compact, the |
| 2381 // remaining memory blocks can be freed. |
2375 std::map<void*, size_t> live_array_buffers_; | 2382 std::map<void*, size_t> live_array_buffers_; |
2376 std::map<void*, size_t> live_new_array_buffers_; | |
2377 std::map<void*, size_t> not_yet_discovered_array_buffers_; | 2383 std::map<void*, size_t> not_yet_discovered_array_buffers_; |
2378 std::map<void*, size_t> not_yet_discovered_new_array_buffers_; | 2384 |
| 2385 // To be able to free memory held by ArrayBuffers during scavenge as well, we |
| 2386 // have a separate list of allocated memory held by ArrayBuffers in new space. |
| 2387 // |
| 2388 // Since mark/compact also evacuates the new space, all pointers in the |
| 2389 // |live_array_buffers_for_scavenge_| list are also in the |
| 2390 // |live_array_buffers_| list. |
| 2391 std::map<void*, size_t> live_array_buffers_for_scavenge_; |
| 2392 std::map<void*, size_t> not_yet_discovered_array_buffers_for_scavenge_; |
2379 | 2393 |
2380 struct StrongRootsList; | 2394 struct StrongRootsList; |
2381 StrongRootsList* strong_roots_list_; | 2395 StrongRootsList* strong_roots_list_; |
2382 | 2396 |
2383 friend class AlwaysAllocateScope; | 2397 friend class AlwaysAllocateScope; |
2384 friend class Deserializer; | 2398 friend class Deserializer; |
2385 friend class Factory; | 2399 friend class Factory; |
2386 friend class GCCallbacksScope; | 2400 friend class GCCallbacksScope; |
2387 friend class GCTracer; | 2401 friend class GCTracer; |
2388 friend class HeapIterator; | 2402 friend class HeapIterator; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2850 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2837 | 2851 |
2838 private: | 2852 private: |
2839 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2853 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2840 }; | 2854 }; |
2841 #endif // DEBUG | 2855 #endif // DEBUG |
2842 } | 2856 } |
2843 } // namespace v8::internal | 2857 } // namespace v8::internal |
2844 | 2858 |
2845 #endif // V8_HEAP_HEAP_H_ | 2859 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |