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