| 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 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { | 1445 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size) { |
| 1446 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); | 1446 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); |
| 1447 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; | 1447 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; |
| 1448 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; | 1448 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 void TraceObjectStats(); | 1451 void TraceObjectStats(); |
| 1452 void TraceObjectStat(const char* name, int count, int size, double time); | 1452 void TraceObjectStat(const char* name, int count, int size, double time); |
| 1453 void CheckpointObjectStats(); | 1453 void CheckpointObjectStats(); |
| 1454 | 1454 |
| 1455 // We don't use a LockGuard here since we want to lock the heap | 1455 struct StrongRootsList { |
| 1456 // only when FLAG_concurrent_recompilation is true. | 1456 Object** start_; |
| 1457 Object** end_; |
| 1458 StrongRootsList* next_; |
| 1459 }; |
| 1460 |
| 1461 void RegisterStrongRoots(Object** start, Object** end) { |
| 1462 StrongRootsList* list = new StrongRootsList(); |
| 1463 list->next_ = strong_roots_list_; |
| 1464 list->start_ = start; |
| 1465 list->end_ = end; |
| 1466 strong_roots_list_ = list; |
| 1467 } |
| 1468 |
| 1469 void UnregisterStrongRoots(Object** start) { |
| 1470 StrongRootsList* prev = NULL; |
| 1471 for (StrongRootsList* list = strong_roots_list_; list; list = list->next_) { |
| 1472 if (list->start_ == start) { |
| 1473 if (prev) { |
| 1474 prev->next_ = list->next_; |
| 1475 } else { |
| 1476 strong_roots_list_ = list->next_; |
| 1477 } |
| 1478 delete list; |
| 1479 } |
| 1480 prev = list; |
| 1481 } |
| 1482 } |
| 1483 |
| 1484 // Taking this lock prevents the GC from entering a phase that relocates |
| 1485 // object references. |
| 1457 class RelocationLock { | 1486 class RelocationLock { |
| 1458 public: | 1487 public: |
| 1459 explicit RelocationLock(Heap* heap) : heap_(heap) { | 1488 explicit RelocationLock(Heap* heap) : heap_(heap) { |
| 1460 heap_->relocation_mutex_.Lock(); | 1489 heap_->relocation_mutex_.Lock(); |
| 1461 } | 1490 } |
| 1462 | 1491 |
| 1463 | |
| 1464 ~RelocationLock() { heap_->relocation_mutex_.Unlock(); } | 1492 ~RelocationLock() { heap_->relocation_mutex_.Unlock(); } |
| 1465 | 1493 |
| 1466 private: | 1494 private: |
| 1467 Heap* heap_; | 1495 Heap* heap_; |
| 1468 }; | 1496 }; |
| 1469 | 1497 |
| 1498 // An optional version of the above lock that can be used for some critical |
| 1499 // sections on the mutator thread; only safe since the GC currently does not |
| 1500 // do concurrent compaction. |
| 1501 class OptionalRelocationLock { |
| 1502 public: |
| 1503 explicit OptionalRelocationLock(Heap* heap, bool concurrent) |
| 1504 : heap_(heap), concurrent_(concurrent) { |
| 1505 if (concurrent_) heap_->relocation_mutex_.Lock(); |
| 1506 } |
| 1507 |
| 1508 ~OptionalRelocationLock() { |
| 1509 if (concurrent_) heap_->relocation_mutex_.Unlock(); |
| 1510 } |
| 1511 |
| 1512 private: |
| 1513 Heap* heap_; |
| 1514 bool concurrent_; |
| 1515 }; |
| 1516 |
| 1470 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj, | 1517 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj, |
| 1471 Handle<DependentCode> dep); | 1518 Handle<DependentCode> dep); |
| 1472 | 1519 |
| 1473 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj); | 1520 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj); |
| 1474 | 1521 |
| 1475 void AddRetainedMap(Handle<Map> map); | 1522 void AddRetainedMap(Handle<Map> map); |
| 1476 | 1523 |
| 1477 static void FatalProcessOutOfMemory(const char* location, | 1524 static void FatalProcessOutOfMemory(const char* location, |
| 1478 bool take_snapshot = false); | 1525 bool take_snapshot = false); |
| 1479 | 1526 |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2145 MemoryChunk* chunks_queued_for_free_; | 2192 MemoryChunk* chunks_queued_for_free_; |
| 2146 | 2193 |
| 2147 base::Mutex relocation_mutex_; | 2194 base::Mutex relocation_mutex_; |
| 2148 | 2195 |
| 2149 int gc_callbacks_depth_; | 2196 int gc_callbacks_depth_; |
| 2150 | 2197 |
| 2151 bool deserialization_complete_; | 2198 bool deserialization_complete_; |
| 2152 | 2199 |
| 2153 bool concurrent_sweeping_enabled_; | 2200 bool concurrent_sweeping_enabled_; |
| 2154 | 2201 |
| 2202 StrongRootsList* strong_roots_list_; |
| 2203 |
| 2155 friend class AlwaysAllocateScope; | 2204 friend class AlwaysAllocateScope; |
| 2156 friend class Deserializer; | 2205 friend class Deserializer; |
| 2157 friend class Factory; | 2206 friend class Factory; |
| 2158 friend class GCCallbacksScope; | 2207 friend class GCCallbacksScope; |
| 2159 friend class GCTracer; | 2208 friend class GCTracer; |
| 2160 friend class HeapIterator; | 2209 friend class HeapIterator; |
| 2161 friend class Isolate; | 2210 friend class Isolate; |
| 2162 friend class MarkCompactCollector; | 2211 friend class MarkCompactCollector; |
| 2163 friend class MarkCompactMarkingVisitor; | 2212 friend class MarkCompactMarkingVisitor; |
| 2164 friend class MapCompact; | 2213 friend class MapCompact; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2606 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2655 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2607 | 2656 |
| 2608 private: | 2657 private: |
| 2609 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2658 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2610 }; | 2659 }; |
| 2611 #endif // DEBUG | 2660 #endif // DEBUG |
| 2612 } | 2661 } |
| 2613 } // namespace v8::internal | 2662 } // namespace v8::internal |
| 2614 | 2663 |
| 2615 #endif // V8_HEAP_HEAP_H_ | 2664 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |