Commit 74aea87a authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Revert "[snapshot] Factor out root serialization code"

This reverts commit 22b56f47.

Reason for revert: Speculatively reverting because it increases Android binary size unexpectedly, see https://ci.chromium.org/p/chromium/builders/luci.chromium.try/android-binary-size/72572

Original change's description:
> [snapshot] Factor out root serialization code
> 
> Factors out a new method Serializer::SerializeRoot which attempts to
> serialize a given object as a Root if it is one and the Serializer's
> policy allows that root to be serialized (implemented as a new virtual
> method RootCanBeSerialized)..
> 
> This is in preparation for adding a ReadOnlySerializer which change the
> way read-only roots are serialized.
> 
> Bug: v8:8191
> Change-Id: I7fbb4e9520fba8b836a0b6bf95ca39abc3ded79e
> Reviewed-on: https://chromium-review.googlesource.com/c/1264698
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Dan Elphick <delphick@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#56494}

TBR=jgruber@chromium.org,delphick@chromium.org,ygg@google.com

Change-Id: I7012abec0f33f655efc64dc44f7fa461d7e4b7e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8191
Reviewed-on: https://chromium-review.googlesource.com/c/1273098Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56509}
parent 007c6744
......@@ -57,7 +57,7 @@ class RootIndexMap {
explicit RootIndexMap(Isolate* isolate);
// Returns true on successful lookup and sets *|out_root_list|.
bool Lookup(HeapObject* obj, RootIndex* out_root_list) const {
bool Lookup(HeapObject* obj, RootIndex* out_root_list) {
Maybe<uint32_t> maybe_index = map_->Get(obj);
if (maybe_index.IsJust()) {
*out_root_list = static_cast<RootIndex>(maybe_index.FromJust());
......
......@@ -70,7 +70,12 @@ void BuiltinSerializer::SerializeObject(HeapObject* o, HowToCode how_to_code,
DCHECK(!o->IsSmi());
// Roots can simply be serialized as root references.
if (SerializeRoot(o, how_to_code, where_to_point, skip)) return;
RootIndex root_index;
if (root_index_map()->Lookup(o, &root_index)) {
DCHECK(startup_serializer_->root_has_been_serialized(root_index));
PutRoot(root_index, o, how_to_code, where_to_point, skip);
return;
}
// Builtins are serialized using a dedicated bytecode. We only reach this
// point if encountering a Builtin e.g. while iterating the body of another
......
......@@ -124,7 +124,11 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) {
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return;
if (SerializeRoot(obj, how_to_code, where_to_point, skip)) return;
RootIndex root_index;
if (root_index_map()->Lookup(obj, &root_index)) {
PutRoot(root_index, obj, how_to_code, where_to_point, skip);
return;
}
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
......
......@@ -59,7 +59,11 @@ void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
}
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return;
if (SerializeRoot(obj, how_to_code, where_to_point, skip)) return;
RootIndex root_index;
if (root_index_map()->Lookup(obj, &root_index)) {
PutRoot(root_index, obj, how_to_code, where_to_point, skip);
return;
}
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
......
......@@ -138,21 +138,6 @@ void Serializer<AllocatorT>::PrintStack() {
}
#endif // DEBUG
template <class AllocatorT>
bool Serializer<AllocatorT>::SerializeRoot(HeapObject* obj,
HowToCode how_to_code,
WhereToPoint where_to_point,
int skip) {
RootIndex root_index;
// Derived serializers are responsible for determining if the root has
// actually been serialized before calling this.
if (root_index_map()->Lookup(obj, &root_index)) {
PutRoot(root_index, obj, how_to_code, where_to_point, skip);
return true;
}
return false;
}
template <class AllocatorT>
bool Serializer<AllocatorT>::SerializeHotObject(HeapObject* obj,
HowToCode how_to_code,
......
......@@ -182,10 +182,6 @@ class Serializer : public SerializerDeserializer {
int PutAlignmentPrefix(HeapObject* object);
void PutNextChunk(int space);
// Returns true if the object was successfully serialized as a root.
bool SerializeRoot(HeapObject* obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip);
// Returns true if the object was successfully serialized as hot object.
bool SerializeHotObject(HeapObject* obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip);
......@@ -241,7 +237,7 @@ class Serializer : public SerializerDeserializer {
#endif // DEBUG
SerializerReferenceMap* reference_map() { return &reference_map_; }
const RootIndexMap* root_index_map() const { return &root_index_map_; }
RootIndexMap* root_index_map() { return &root_index_map_; }
AllocatorT* allocator() { return &allocator_; }
SnapshotByteSink sink_; // Used directly by subclasses.
......
......@@ -33,9 +33,17 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
return;
}
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return;
if (IsRootAndHasBeenSerialized(obj) &&
SerializeRoot(obj, how_to_code, where_to_point, skip))
return;
RootIndex root_index;
// We can only encode roots as such if it has already been serialized.
// That applies to root indices below the wave front.
if (root_index_map()->Lookup(obj, &root_index)) {
if (root_has_been_serialized(root_index)) {
PutRoot(root_index, obj, how_to_code, where_to_point, skip);
return;
}
}
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
FlushSkip(skip);
......
......@@ -32,12 +32,6 @@ class StartupSerializer : public Serializer<> {
return root_has_been_serialized_.test(static_cast<size_t>(root_index));
}
bool IsRootAndHasBeenSerialized(HeapObject* obj) const {
RootIndex root_index;
return root_index_map()->Lookup(obj, &root_index) &&
root_has_been_serialized(root_index);
}
private:
class PartialCacheIndexMap {
public:
......
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