Commit 724d8111 authored by Alexander Timokhin's avatar Alexander Timokhin Committed by Commit Bot

[serializer] Add support for AllocationSites without weak_next field

After https://chromium-review.googlesource.com/c/v8/v8/+/1101323 some
AllocationSites can have dropped weak_next field, but this doesn't suported in
serializer/deserializer.

This CL adds support for such AllocationSites.

Change-Id: Ibf495ae4effdf4e127892d906967d8e30eebfc87
Reviewed-on: https://chromium-review.googlesource.com/1183238
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55579}
parent b50fa92a
...@@ -179,18 +179,11 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj, ...@@ -179,18 +179,11 @@ HeapObject* Deserializer<AllocatorT>::PostProcessNewObject(HeapObject* obj,
} }
if (obj->IsAllocationSite()) { if (obj->IsAllocationSite()) {
// Allocation sites are present in the snapshot, and must be linked into // We should link new allocation sites, but we can't do this immediately
// a list at deserialization time. // because |AllocationSite::HasWeakNext()| internally accesses
AllocationSite* site = AllocationSite::cast(obj); // |Heap::roots_| that may not have been initialized yet. So defer this to
// TODO(mvstanton): consider treating the heap()->allocation_sites_list() // |ObjectDeserializer::CommitPostProcessedObjects()|.
// as a (weak) root. If this root is relocated correctly, this becomes new_allocation_sites_.push_back(AllocationSite::cast(obj));
// unnecessary.
if (isolate_->heap()->allocation_sites_list() == Smi::kZero) {
site->set_weak_next(ReadOnlyRoots(isolate_).undefined_value());
} else {
site->set_weak_next(isolate_->heap()->allocation_sites_list());
}
isolate_->heap()->set_allocation_sites_list(site);
} else if (obj->IsCode()) { } else if (obj->IsCode()) {
// We flush all code pages after deserializing the startup snapshot. In that // We flush all code pages after deserializing the startup snapshot. In that
// case, we only need to remember code objects in the large object space. // case, we only need to remember code objects in the large object space.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class AllocationSite;
class HeapObject; class HeapObject;
class Object; class Object;
...@@ -71,6 +72,9 @@ class Deserializer : public SerializerDeserializer { ...@@ -71,6 +72,9 @@ class Deserializer : public SerializerDeserializer {
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
SnapshotByteSource* source() { return &source_; } SnapshotByteSource* source() { return &source_; }
const std::vector<AllocationSite*>& new_allocation_sites() const {
return new_allocation_sites_;
}
const std::vector<Code*>& new_code_objects() const { const std::vector<Code*>& new_code_objects() const {
return new_code_objects_; return new_code_objects_;
} }
...@@ -148,6 +152,7 @@ class Deserializer : public SerializerDeserializer { ...@@ -148,6 +152,7 @@ class Deserializer : public SerializerDeserializer {
ExternalReferenceTable* external_reference_table_; ExternalReferenceTable* external_reference_table_;
std::vector<AllocationSite*> new_allocation_sites_;
std::vector<Code*> new_code_objects_; std::vector<Code*> new_code_objects_;
std::vector<AccessorInfo*> accessor_infos_; std::vector<AccessorInfo*> accessor_infos_;
std::vector<CallHandlerInfo*> call_handler_infos_; std::vector<CallHandlerInfo*> call_handler_infos_;
......
...@@ -90,6 +90,21 @@ void ObjectDeserializer::CommitPostProcessedObjects() { ...@@ -90,6 +90,21 @@ void ObjectDeserializer::CommitPostProcessedObjects() {
MaybeObjectHandle::Weak(script)); MaybeObjectHandle::Weak(script));
heap->SetRootScriptList(*list); heap->SetRootScriptList(*list);
} }
// Allocation sites are present in the snapshot, and must be linked into
// a list at deserialization time.
for (AllocationSite* site : new_allocation_sites()) {
if (!site->HasWeakNext()) continue;
// TODO(mvstanton): consider treating the heap()->allocation_sites_list()
// as a (weak) root. If this root is relocated correctly, this becomes
// unnecessary.
if (heap->allocation_sites_list() == Smi::kZero) {
site->set_weak_next(ReadOnlyRoots(heap).undefined_value());
} else {
site->set_weak_next(heap->allocation_sites_list());
}
heap->set_allocation_sites_list(site);
}
} }
} // namespace internal } // namespace internal
......
...@@ -581,7 +581,8 @@ class UnlinkWeakNextScope { ...@@ -581,7 +581,8 @@ class UnlinkWeakNextScope {
public: public:
explicit UnlinkWeakNextScope(Heap* heap, HeapObject* object) explicit UnlinkWeakNextScope(Heap* heap, HeapObject* object)
: object_(nullptr) { : object_(nullptr) {
if (object->IsAllocationSite()) { if (object->IsAllocationSite() &&
AllocationSite::cast(object)->HasWeakNext()) {
object_ = object; object_ = object;
next_ = AllocationSite::cast(object)->weak_next(); next_ = AllocationSite::cast(object)->weak_next();
AllocationSite::cast(object)->set_weak_next( AllocationSite::cast(object)->set_weak_next(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment