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 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { | 1439 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { |
1440 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); | 1440 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); |
1441 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; | 1441 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; |
1442 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; | 1442 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; |
1443 } | 1443 } |
1444 | 1444 |
1445 void TraceObjectStats(); | 1445 void TraceObjectStats(); |
1446 void TraceObjectStat(const char* name, int count, int size, double time); | 1446 void TraceObjectStat(const char* name, int count, int size, double time); |
1447 void CheckpointObjectStats(); | 1447 void CheckpointObjectStats(); |
1448 | 1448 |
1449 // We don't use a LockGuard here since we want to lock the heap | 1449 void RegisterStrongRoots(Object** start, Object** end); |
1450 // only when FLAG_concurrent_recompilation is true. | 1450 void UnregisterStrongRoots(Object** start); |
| 1451 |
| 1452 // Taking this lock prevents the GC from entering a phase that relocates |
| 1453 // object references. |
1451 class RelocationLock { | 1454 class RelocationLock { |
1452 public: | 1455 public: |
1453 explicit RelocationLock(Heap* heap) : heap_(heap) { | 1456 explicit RelocationLock(Heap* heap) : heap_(heap) { |
1454 heap_->relocation_mutex_.Lock(); | 1457 heap_->relocation_mutex_.Lock(); |
1455 } | 1458 } |
1456 | 1459 |
1457 | |
1458 ~RelocationLock() { heap_->relocation_mutex_.Unlock(); } | 1460 ~RelocationLock() { heap_->relocation_mutex_.Unlock(); } |
1459 | 1461 |
1460 private: | 1462 private: |
1461 Heap* heap_; | 1463 Heap* heap_; |
1462 }; | 1464 }; |
1463 | 1465 |
| 1466 // An optional version of the above lock that can be used for some critical |
| 1467 // sections on the mutator thread; only safe since the GC currently does not |
| 1468 // do concurrent compaction. |
| 1469 class OptionalRelocationLock { |
| 1470 public: |
| 1471 OptionalRelocationLock(Heap* heap, bool concurrent) |
| 1472 : heap_(heap), concurrent_(concurrent) { |
| 1473 if (concurrent_) heap_->relocation_mutex_.Lock(); |
| 1474 } |
| 1475 |
| 1476 ~OptionalRelocationLock() { |
| 1477 if (concurrent_) heap_->relocation_mutex_.Unlock(); |
| 1478 } |
| 1479 |
| 1480 private: |
| 1481 Heap* heap_; |
| 1482 bool concurrent_; |
| 1483 }; |
| 1484 |
1464 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj, | 1485 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj, |
1465 Handle<DependentCode> dep); | 1486 Handle<DependentCode> dep); |
1466 | 1487 |
1467 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj); | 1488 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj); |
1468 | 1489 |
1469 void AddRetainedMap(Handle<Map> map); | 1490 void AddRetainedMap(Handle<Map> map); |
1470 | 1491 |
1471 static void FatalProcessOutOfMemory(const char* location, | 1492 static void FatalProcessOutOfMemory(const char* location, |
1472 bool take_snapshot = false); | 1493 bool take_snapshot = false); |
1473 | 1494 |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2147 | 2168 |
2148 int gc_callbacks_depth_; | 2169 int gc_callbacks_depth_; |
2149 | 2170 |
2150 bool deserialization_complete_; | 2171 bool deserialization_complete_; |
2151 | 2172 |
2152 bool concurrent_sweeping_enabled_; | 2173 bool concurrent_sweeping_enabled_; |
2153 | 2174 |
2154 std::map<void*, size_t> live_array_buffers_; | 2175 std::map<void*, size_t> live_array_buffers_; |
2155 std::map<void*, size_t> not_yet_discovered_array_buffers_; | 2176 std::map<void*, size_t> not_yet_discovered_array_buffers_; |
2156 | 2177 |
| 2178 struct StrongRootsList; |
| 2179 StrongRootsList* strong_roots_list_; |
| 2180 |
2157 friend class AlwaysAllocateScope; | 2181 friend class AlwaysAllocateScope; |
2158 friend class Deserializer; | 2182 friend class Deserializer; |
2159 friend class Factory; | 2183 friend class Factory; |
2160 friend class GCCallbacksScope; | 2184 friend class GCCallbacksScope; |
2161 friend class GCTracer; | 2185 friend class GCTracer; |
2162 friend class HeapIterator; | 2186 friend class HeapIterator; |
2163 friend class Isolate; | 2187 friend class Isolate; |
2164 friend class MarkCompactCollector; | 2188 friend class MarkCompactCollector; |
2165 friend class MarkCompactMarkingVisitor; | 2189 friend class MarkCompactMarkingVisitor; |
2166 friend class MapCompact; | 2190 friend class MapCompact; |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2632 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2609 | 2633 |
2610 private: | 2634 private: |
2611 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2635 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2612 }; | 2636 }; |
2613 #endif // DEBUG | 2637 #endif // DEBUG |
2614 } | 2638 } |
2615 } // namespace v8::internal | 2639 } // namespace v8::internal |
2616 | 2640 |
2617 #endif // V8_HEAP_HEAP_H_ | 2641 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |