Index: src/global-handles.cc |
diff --git a/src/global-handles.cc b/src/global-handles.cc |
index 9ff16affe4f948114ee18d1558dfe259da6dc079..09ed4e7a8fe21ee6c3596f63266b715f6aac4c56 100644 |
--- a/src/global-handles.cc |
+++ b/src/global-handles.cc |
@@ -380,6 +380,13 @@ class GlobalHandles::Node { |
Node* next_free; |
} parameter_or_next_free_; |
+#ifdef VERIFY_HEAP |
+ friend std::vector<std::pair<void*, uint8_t>> |
+ GlobalHandles::GetNewSpaceNodeStates(); |
+ friend void GlobalHandles::RestoreNewSpaceNodeStates( |
+ const std::vector<std::pair<void*, uint8_t>>& states); |
+#endif // VERIFY_HEAP |
+ |
DISALLOW_COPY_AND_ASSIGN(Node); |
}; |
@@ -719,7 +726,7 @@ void GlobalHandles::MarkNewSpaceWeakUnmodifiedObjectsPending( |
} |
} |
- |
+template <GlobalHandles::IterationMode mode> |
void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v) { |
for (int i = 0; i < new_space_nodes_.length(); ++i) { |
Node* node = new_space_nodes_[i]; |
@@ -728,11 +735,15 @@ void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v) { |
node->IsWeakRetainer()) { |
// Pending weak phantom handles die immediately. Everything else survives. |
if (node->IsPendingPhantomResetHandle()) { |
- node->ResetPhantomHandle(); |
- ++number_of_phantom_handle_resets_; |
+ if (mode == IterationMode::HANDLE_PHANTOM_NODES) { |
+ node->ResetPhantomHandle(); |
+ ++number_of_phantom_handle_resets_; |
+ } |
} else if (node->IsPendingPhantomCallback()) { |
- node->CollectPhantomCallbackData(isolate(), |
- &pending_phantom_callbacks_); |
+ if (mode == IterationMode::HANDLE_PHANTOM_NODES) { |
+ node->CollectPhantomCallbackData(isolate(), |
+ &pending_phantom_callbacks_); |
+ } |
} else { |
v->VisitPointer(node->location()); |
} |
@@ -740,6 +751,32 @@ void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v) { |
} |
} |
+template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< |
+ GlobalHandles::HANDLE_PHANTOM_NODES>(ObjectVisitor* v); |
+ |
+template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< |
+ GlobalHandles::DONT_HANDLE_PHANTOM_NODES>(ObjectVisitor* v); |
+ |
+#ifdef VERIFY_HEAP |
+ |
+std::vector<std::pair<void*, uint8_t>> GlobalHandles::GetNewSpaceNodeStates() { |
+ std::vector<std::pair<void*, uint8_t>> states; |
+ for (int i = 0; i < new_space_nodes_.length(); ++i) { |
+ Node* node = new_space_nodes_[i]; |
+ DCHECK(node->is_in_new_space_list()); |
+ states.push_back(std::make_pair(static_cast<void*>(node), node->flags_)); |
+ } |
+ return states; |
+} |
+ |
+void GlobalHandles::RestoreNewSpaceNodeStates( |
+ const std::vector<std::pair<void*, uint8_t>>& states) { |
+ for (auto pair : states) { |
+ static_cast<Node*>(pair.first)->flags_ = pair.second; |
+ } |
+} |
+ |
+#endif // VERIFY_HEAP |
DISABLE_CFI_PERF |
bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, |