Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: src/snapshot/serialize.cc

Issue 1203973002: Serializer: clear next link in weak cells. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix asan failure Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/serialize.cc
diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc
index 7410c3b393c1a931d991f7f0d1304a75e430e022..66da378617571ccb915303bb828cd01fe0e8448d 100644
--- a/src/snapshot/serialize.cc
+++ b/src/snapshot/serialize.cc
@@ -1851,6 +1851,28 @@ void Serializer::ObjectSerializer::SerializeExternalString() {
}
+// Clear and later restore the next link in the weak cell, if the object is one.
+class UnlinkWeakCellScope {
+ public:
+ explicit UnlinkWeakCellScope(HeapObject* object) : weak_cell_(NULL) {
+ if (object->IsWeakCell()) {
+ weak_cell_ = WeakCell::cast(object);
+ next_ = weak_cell_->next();
+ weak_cell_->clear_next(object->GetHeap());
+ }
+ }
+
+ ~UnlinkWeakCellScope() {
+ if (weak_cell_) weak_cell_->set_next(next_, UPDATE_WEAK_WRITE_BARRIER);
+ }
+
+ private:
+ WeakCell* weak_cell_;
+ Object* next_;
+ DisallowHeapAllocation no_gc_;
+};
+
+
void Serializer::ObjectSerializer::Serialize() {
if (FLAG_trace_serializer) {
PrintF(" Encoding heap object: ");
@@ -1910,6 +1932,8 @@ void Serializer::ObjectSerializer::Serialize() {
return;
}
+ UnlinkWeakCellScope unlink_weak_cell(object_);
+
object_->IterateBody(map->instance_type(), size, this);
OutputRawData(object_->address() + size);
}
@@ -1934,6 +1958,8 @@ void Serializer::ObjectSerializer::SerializeDeferred() {
serializer_->PutBackReference(object_, reference);
sink_->PutInt(size >> kPointerSizeLog2, "deferred object size");
+ UnlinkWeakCellScope unlink_weak_cell(object_);
+
object_->IterateBody(map->instance_type(), size, this);
OutputRawData(object_->address() + size);
}
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698