Chromium Code Reviews| Index: src/heap/heap.h |
| diff --git a/src/heap/heap.h b/src/heap/heap.h |
| index dcf7bdea0ac812972304bd382d52b0a1f4c5eff2..75efd3a59f09724a1d52c88ccf35f61fb222151f 100644 |
| --- a/src/heap/heap.h |
| +++ b/src/heap/heap.h |
| @@ -1452,15 +1452,57 @@ class Heap { |
| void TraceObjectStat(const char* name, int count, int size, double time); |
| void CheckpointObjectStats(); |
| - // We don't use a LockGuard here since we want to lock the heap |
| - // only when FLAG_concurrent_recompilation is true. |
| + struct StrongRootsList { |
| + Object** start_; |
| + Object** end_; |
| + StrongRootsList* next_; |
| + }; |
| + |
| + void RegisterStrongRoots(Object** start, Object** end) { |
| + StrongRootsList* list = new StrongRootsList(); |
| + list->next_ = strong_roots_list_; |
| + list->start_ = start; |
| + list->end_ = end; |
| + strong_roots_list_ = list; |
| + } |
| + |
| + void UnregisterStrongRoots(Object** start) { |
| + StrongRootsList* prev = NULL; |
| + for (StrongRootsList* list = strong_roots_list_; list; list = list->next_) { |
| + if (list->start_ == start) { |
| + if (prev) { |
| + prev->next_ = list->next_; |
| + } else { |
| + strong_roots_list_ = list->next_; |
| + } |
| + delete list; |
|
Erik Corry
2015/04/27 15:39:13
Might we not just as well return here?
titzer
2015/04/27 16:36:48
Doesn't really matter. As written, the code will b
|
| + } |
| + prev = list; |
| + } |
|
Erik Corry
2015/04/27 15:39:13
unreachable?
titzer
2015/04/27 16:36:48
Don't need it if we just allow the above.
|
| + } |
| + |
| + class OptionalRelocationLock { |
|
Erik Corry
2015/04/27 15:39:13
Perhaps you could spend a couple of lines of comme
titzer
2015/04/27 16:36:48
Done.
|
| + public: |
| + explicit OptionalRelocationLock(Heap* heap, bool concurrent) |
| + : heap_(heap), concurrent_(concurrent) { |
| + if (concurrent_) heap_->relocation_mutex_.Lock(); |
| + } |
| + |
| + ~OptionalRelocationLock() { |
| + if (concurrent_) heap_->relocation_mutex_.Unlock(); |
| + } |
| + |
| + private: |
| + Heap* heap_; |
| + bool concurrent_; |
| + }; |
| + |
| class RelocationLock { |
| public: |
| explicit RelocationLock(Heap* heap) : heap_(heap) { |
| heap_->relocation_mutex_.Lock(); |
| } |
| - |
| ~RelocationLock() { heap_->relocation_mutex_.Unlock(); } |
| private: |
| @@ -2152,6 +2194,8 @@ class Heap { |
| bool concurrent_sweeping_enabled_; |
| + StrongRootsList* strong_roots_list_; |
| + |
| friend class AlwaysAllocateScope; |
| friend class Deserializer; |
| friend class Factory; |