Chromium Code Reviews

Unified Diff: src/global-handles.cc

Issue 2498583002: [heap] Minor MC: Add marking (Closed)
Patch Set: Fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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,
« no previous file with comments | « src/global-handles.h ('k') | src/heap/gc-idle-time-handler.h » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine