Commit c9a9d825 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[snapshot][cleanup] Remove skipping bytecodes

... as they are no longer needed.

Bug: v8:8794, v8:8562
Change-Id: Ib5d87fce9834839410b0dffce95b4a8ae4f946cc
Reviewed-on: https://chromium-review.googlesource.com/c/1460456Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59457}
parent 1f386f4f
...@@ -98,8 +98,7 @@ ScriptData* CodeSerializer::SerializeSharedFunctionInfo( ...@@ -98,8 +98,7 @@ ScriptData* CodeSerializer::SerializeSharedFunctionInfo(
bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj, bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj,
HowToCode how_to_code, HowToCode how_to_code,
WhereToPoint where_to_point, WhereToPoint where_to_point) {
int skip) {
PagedSpace* read_only_space = isolate()->heap()->read_only_space(); PagedSpace* read_only_space = isolate()->heap()->read_only_space();
if (!read_only_space->Contains(obj)) return false; if (!read_only_space->Contains(obj)) return false;
...@@ -117,21 +116,19 @@ bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj, ...@@ -117,21 +116,19 @@ bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj,
SerializerReference back_reference = SerializerReference back_reference =
SerializerReference::BackReference(RO_SPACE, chunk_index, chunk_offset); SerializerReference::BackReference(RO_SPACE, chunk_index, chunk_offset);
reference_map()->Add(reinterpret_cast<void*>(obj->ptr()), back_reference); reference_map()->Add(reinterpret_cast<void*>(obj->ptr()), back_reference);
CHECK(SerializeBackReference(obj, how_to_code, where_to_point, skip)); CHECK(SerializeBackReference(obj, how_to_code, where_to_point));
return true; return true;
} }
void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return; if (SerializeHotObject(obj, how_to_code, where_to_point)) return;
if (SerializeRoot(obj, how_to_code, where_to_point, skip)) return; if (SerializeRoot(obj, how_to_code, where_to_point)) return;
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return; if (SerializeBackReference(obj, how_to_code, where_to_point)) return;
if (SerializeReadOnlyObject(obj, how_to_code, where_to_point, skip)) return; if (SerializeReadOnlyObject(obj, how_to_code, where_to_point)) return;
FlushSkip(skip);
if (obj->IsCode()) { if (obj->IsCode()) {
Code code_object = Code::cast(obj); Code code_object = Code::cast(obj);
...@@ -151,8 +148,8 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -151,8 +148,8 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
ReadOnlyRoots roots(isolate()); ReadOnlyRoots roots(isolate());
if (ElideObject(obj)) { if (ElideObject(obj)) {
return SerializeObject(roots.undefined_value(), how_to_code, where_to_point, return SerializeObject(roots.undefined_value(), how_to_code,
skip); where_to_point);
} }
if (obj->IsScript()) { if (obj->IsScript()) {
......
...@@ -69,10 +69,10 @@ class CodeSerializer : public Serializer { ...@@ -69,10 +69,10 @@ class CodeSerializer : public Serializer {
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) override; WhereToPoint where_to_point) override;
bool SerializeReadOnlyObject(HeapObject obj, HowToCode how_to_code, bool SerializeReadOnlyObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
DISALLOW_HEAP_ALLOCATION(no_gc_); DISALLOW_HEAP_ALLOCATION(no_gc_);
uint32_t source_hash_; uint32_t source_hash_;
......
...@@ -591,7 +591,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -591,7 +591,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
// Find a recently deserialized object using its offset from the current // Find a recently deserialized object using its offset from the current
// allocation point and write a pointer to it to the current object. // allocation point and write a pointer to it to the current object.
ALL_SPACES(kBackref, kPlain, kStartOfObject) ALL_SPACES(kBackref, kPlain, kStartOfObject)
ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject)
#if V8_CODE_EMBEDS_OBJECT_POINTER #if V8_CODE_EMBEDS_OBJECT_POINTER
// Deserialize a new object from pointer found in code and write // Deserialize a new object from pointer found in code and write
// a pointer to it to the current object. Required only for MIPS, PPC, ARM // a pointer to it to the current object. Required only for MIPS, PPC, ARM
...@@ -603,14 +602,12 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -603,14 +602,12 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
// object. Required only for MIPS, PPC, ARM or S390 with embedded // object. Required only for MIPS, PPC, ARM or S390 with embedded
// constant pool. // constant pool.
ALL_SPACES(kBackref, kFromCode, kStartOfObject) ALL_SPACES(kBackref, kFromCode, kStartOfObject)
ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject)
#endif #endif
// Find a recently deserialized code object using its offset from the // Find a recently deserialized code object using its offset from the
// current allocation point and write a pointer to its first instruction // current allocation point and write a pointer to its first instruction
// to the current code object or the instruction pointer in a function // to the current code object or the instruction pointer in a function
// object. // object.
ALL_SPACES(kBackref, kFromCode, kInnerPointer) ALL_SPACES(kBackref, kFromCode, kInnerPointer)
ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer)
// Find an object in the roots array and write a pointer to it to the // Find an object in the roots array and write a pointer to it to the
// current object. // current object.
SINGLE_CASE(kRootArray, kPlain, kStartOfObject, 0) SINGLE_CASE(kRootArray, kPlain, kStartOfObject, 0)
...@@ -638,12 +635,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -638,12 +635,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
#undef CASE_BODY #undef CASE_BODY
#undef ALL_SPACES #undef ALL_SPACES
case kSkip: {
int size = source_.GetInt();
current.Advance(size);
break;
}
// Find an external reference and write a pointer to it to the current // Find an external reference and write a pointer to it to the current
// object. // object.
case kExternalReference + kPlain + kStartOfObject: case kExternalReference + kPlain + kStartOfObject:
...@@ -777,13 +768,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -777,13 +768,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
STATIC_ASSERT(kNumberOfRootArrayConstants <= STATIC_ASSERT(kNumberOfRootArrayConstants <=
static_cast<int>(RootIndex::kLastImmortalImmovableRoot)); static_cast<int>(RootIndex::kLastImmortalImmovableRoot));
STATIC_ASSERT(kNumberOfRootArrayConstants == 32); STATIC_ASSERT(kNumberOfRootArrayConstants == 32);
SIXTEEN_CASES(kRootArrayConstantsWithSkip)
SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) {
int skip = source_.GetInt();
current.Advance(skip);
V8_FALLTHROUGH;
}
SIXTEEN_CASES(kRootArrayConstants) SIXTEEN_CASES(kRootArrayConstants)
SIXTEEN_CASES(kRootArrayConstants + 16) { SIXTEEN_CASES(kRootArrayConstants + 16) {
int id = data & kRootArrayConstantsMask; int id = data & kRootArrayConstantsMask;
...@@ -796,13 +780,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -796,13 +780,6 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
} }
STATIC_ASSERT(kNumberOfHotObjects == 8); STATIC_ASSERT(kNumberOfHotObjects == 8);
FOUR_CASES(kHotObjectWithSkip)
FOUR_CASES(kHotObjectWithSkip + 4) {
int skip = source_.GetInt();
current.Advance(skip);
V8_FALLTHROUGH;
}
FOUR_CASES(kHotObject) FOUR_CASES(kHotObject)
FOUR_CASES(kHotObject + 4) { FOUR_CASES(kHotObject + 4) {
int index = data & kHotObjectMask; int index = data & kHotObjectMask;
...@@ -890,11 +867,6 @@ UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate, ...@@ -890,11 +867,6 @@ UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate,
} else if (where == kBackref) { } else if (where == kBackref) {
emit_write_barrier = (space_number == NEW_SPACE); emit_write_barrier = (space_number == NEW_SPACE);
heap_object = GetBackReferencedObject(data & kSpaceMask); heap_object = GetBackReferencedObject(data & kSpaceMask);
} else if (where == kBackrefWithSkip) {
int skip = source_.GetInt();
current.Advance(skip);
emit_write_barrier = (space_number == NEW_SPACE);
heap_object = GetBackReferencedObject(data & kSpaceMask);
} else if (where == kRootArray) { } else if (where == kRootArray) {
int id = source_.GetInt(); int id = source_.GetInt();
RootIndex root_index = static_cast<RootIndex>(id); RootIndex root_index = static_cast<RootIndex>(id);
......
...@@ -69,23 +69,23 @@ void PartialSerializer::Serialize(Context* o, bool include_global_proxy) { ...@@ -69,23 +69,23 @@ void PartialSerializer::Serialize(Context* o, bool include_global_proxy) {
} }
void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
DCHECK(!ObjectIsBytecodeHandler(obj)); // Only referenced in dispatch table. DCHECK(!ObjectIsBytecodeHandler(obj)); // Only referenced in dispatch table.
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return; if (SerializeHotObject(obj, how_to_code, where_to_point)) return;
if (SerializeRoot(obj, how_to_code, where_to_point, skip)) return; if (SerializeRoot(obj, how_to_code, where_to_point)) return;
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return; if (SerializeBackReference(obj, how_to_code, where_to_point)) return;
if (startup_serializer_->SerializeUsingReadOnlyObjectCache( if (startup_serializer_->SerializeUsingReadOnlyObjectCache(
&sink_, obj, how_to_code, where_to_point, skip)) { &sink_, obj, how_to_code, where_to_point)) {
return; return;
} }
if (ShouldBeInThePartialSnapshotCache(obj)) { if (ShouldBeInThePartialSnapshotCache(obj)) {
startup_serializer_->SerializeUsingPartialSnapshotCache( startup_serializer_->SerializeUsingPartialSnapshotCache(
&sink_, obj, how_to_code, where_to_point, skip); &sink_, obj, how_to_code, where_to_point);
return; return;
} }
...@@ -101,8 +101,6 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -101,8 +101,6 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
// We should not end up at another native context. // We should not end up at another native context.
DCHECK_IMPLIES(obj != context_, !obj->IsNativeContext()); DCHECK_IMPLIES(obj != context_, !obj->IsNativeContext());
FlushSkip(skip);
// Clear literal boilerplates and feedback. // Clear literal boilerplates and feedback.
if (obj->IsFeedbackVector()) FeedbackVector::cast(obj)->ClearSlots(isolate()); if (obj->IsFeedbackVector()) FeedbackVector::cast(obj)->ClearSlots(isolate());
......
...@@ -28,7 +28,7 @@ class PartialSerializer : public Serializer { ...@@ -28,7 +28,7 @@ class PartialSerializer : public Serializer {
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) override; WhereToPoint where_to_point) override;
bool ShouldBeInThePartialSnapshotCache(HeapObject o); bool ShouldBeInThePartialSnapshotCache(HeapObject o);
......
...@@ -25,19 +25,16 @@ ReadOnlySerializer::~ReadOnlySerializer() { ...@@ -25,19 +25,16 @@ ReadOnlySerializer::~ReadOnlySerializer() {
} }
void ReadOnlySerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void ReadOnlySerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, WhereToPoint where_to_point) {
int skip) {
CHECK(isolate()->heap()->read_only_space()->Contains(obj)); CHECK(isolate()->heap()->read_only_space()->Contains(obj));
CHECK_IMPLIES(obj->IsString(), obj->IsInternalizedString()); CHECK_IMPLIES(obj->IsString(), obj->IsInternalizedString());
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return; if (SerializeHotObject(obj, how_to_code, where_to_point)) return;
if (IsRootAndHasBeenSerialized(obj) && if (IsRootAndHasBeenSerialized(obj) &&
SerializeRoot(obj, how_to_code, where_to_point, skip)) { SerializeRoot(obj, how_to_code, where_to_point)) {
return; return;
} }
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return; if (SerializeBackReference(obj, how_to_code, where_to_point)) return;
FlushSkip(skip);
CheckRehashability(obj); CheckRehashability(obj);
...@@ -85,7 +82,7 @@ bool ReadOnlySerializer::MustBeDeferred(HeapObject object) { ...@@ -85,7 +82,7 @@ bool ReadOnlySerializer::MustBeDeferred(HeapObject object) {
bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache( bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache(
SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code, SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
if (!isolate()->heap()->read_only_space()->Contains(obj)) return false; if (!isolate()->heap()->read_only_space()->Contains(obj)) return false;
// Get the cache index and serialize it into the read-only snapshot if // Get the cache index and serialize it into the read-only snapshot if
...@@ -93,7 +90,6 @@ bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache( ...@@ -93,7 +90,6 @@ bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache(
int cache_index = SerializeInObjectCache(obj); int cache_index = SerializeInObjectCache(obj);
// Writing out the cache entry into the calling serializer's sink. // Writing out the cache entry into the calling serializer's sink.
FlushSkip(sink, skip);
sink->Put(kReadOnlyObjectCache + how_to_code + where_to_point, sink->Put(kReadOnlyObjectCache + how_to_code + where_to_point,
"ReadOnlyObjectCache"); "ReadOnlyObjectCache");
sink->PutInt(cache_index, "read_only_object_cache_index"); sink->PutInt(cache_index, "read_only_object_cache_index");
......
...@@ -30,11 +30,11 @@ class ReadOnlySerializer : public RootsSerializer { ...@@ -30,11 +30,11 @@ class ReadOnlySerializer : public RootsSerializer {
// successful. // successful.
bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink, HeapObject obj, bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink, HeapObject obj,
HowToCode how_to_code, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) override; WhereToPoint where_to_point) override;
bool MustBeDeferred(HeapObject object) override; bool MustBeDeferred(HeapObject object) override;
DISALLOW_COPY_AND_ASSIGN(ReadOnlySerializer); DISALLOW_COPY_AND_ASSIGN(ReadOnlySerializer);
......
...@@ -28,7 +28,7 @@ int RootsSerializer::SerializeInObjectCache(HeapObject heap_object) { ...@@ -28,7 +28,7 @@ int RootsSerializer::SerializeInObjectCache(HeapObject heap_object) {
if (!object_cache_index_map_.LookupOrInsert(heap_object, &index)) { if (!object_cache_index_map_.LookupOrInsert(heap_object, &index)) {
// This object is not part of the object cache yet. Add it to the cache so // This object is not part of the object cache yet. Add it to the cache so
// we can refer to it via cache index from the delegating snapshot. // we can refer to it via cache index from the delegating snapshot.
SerializeObject(heap_object, kPlain, kStartOfObject, 0); SerializeObject(heap_object, kPlain, kStartOfObject);
} }
return index; return index;
} }
......
...@@ -123,6 +123,8 @@ class SerializerDeserializer : public RootVisitor { ...@@ -123,6 +123,8 @@ class SerializerDeserializer : public RootVisitor {
void RestoreExternalReferenceRedirectors( void RestoreExternalReferenceRedirectors(
const std::vector<CallHandlerInfo>& call_handler_infos); const std::vector<CallHandlerInfo>& call_handler_infos);
// TODO(ishell): reassign bytecodes and update this list
// once HowToCode and WhereToPoint are gone.
#define UNUSED_SERIALIZER_BYTE_CODES(V) \ #define UNUSED_SERIALIZER_BYTE_CODES(V) \
V(0x0e) \ V(0x0e) \
V(0x2e) \ V(0x2e) \
...@@ -156,8 +158,6 @@ class SerializerDeserializer : public RootVisitor { ...@@ -156,8 +158,6 @@ class SerializerDeserializer : public RootVisitor {
kNewObject = 0x00, kNewObject = 0x00,
// 0x08..0x0d Reference to previous object from space. // 0x08..0x0d Reference to previous object from space.
kBackref = 0x08, kBackref = 0x08,
// 0x10..0x15 Reference to previous object from space after skip.
kBackrefWithSkip = 0x10,
// 0x06 Object in the partial snapshot cache. // 0x06 Object in the partial snapshot cache.
kPartialSnapshotCache = 0x06, kPartialSnapshotCache = 0x06,
...@@ -200,8 +200,6 @@ class SerializerDeserializer : public RootVisitor { ...@@ -200,8 +200,6 @@ class SerializerDeserializer : public RootVisitor {
static const int kWhereToPointMask = 0x40; static const int kWhereToPointMask = 0x40;
// ---------- Misc ---------- // ---------- Misc ----------
// Skip.
static const int kSkip = 0x0f;
// Do nothing, used for padding. // Do nothing, used for padding.
static const int kNop = 0x2f; static const int kNop = 0x2f;
// Move to next reserved chunk. // Move to next reserved chunk.
...@@ -247,8 +245,6 @@ class SerializerDeserializer : public RootVisitor { ...@@ -247,8 +245,6 @@ class SerializerDeserializer : public RootVisitor {
static const int kNumberOfRootArrayConstants = 0x20; static const int kNumberOfRootArrayConstants = 0x20;
// 0x80..0x9f // 0x80..0x9f
static const int kRootArrayConstants = 0x80; static const int kRootArrayConstants = 0x80;
// 0xa0..0xbf
static const int kRootArrayConstantsWithSkip = 0xa0;
static const int kRootArrayConstantsMask = 0x1f; static const int kRootArrayConstantsMask = 0x1f;
// 32 common raw data lengths. // 32 common raw data lengths.
...@@ -268,8 +264,6 @@ class SerializerDeserializer : public RootVisitor { ...@@ -268,8 +264,6 @@ class SerializerDeserializer : public RootVisitor {
STATIC_ASSERT(kNumberOfHotObjects == HotObjectsList::kSize); STATIC_ASSERT(kNumberOfHotObjects == HotObjectsList::kSize);
// 0xf0..0xf7 // 0xf0..0xf7
static const int kHotObject = 0xf0; static const int kHotObject = 0xf0;
// 0xf8..0xff
static const int kHotObjectWithSkip = 0xf8;
static const int kHotObjectMask = 0x07; static const int kHotObjectMask = 0x07;
// ---------- special values ---------- // ---------- special values ----------
......
...@@ -110,7 +110,7 @@ void Serializer::SerializeRootObject(Object object) { ...@@ -110,7 +110,7 @@ void Serializer::SerializeRootObject(Object object) {
if (object->IsSmi()) { if (object->IsSmi()) {
PutSmi(Smi::cast(object)); PutSmi(Smi::cast(object));
} else { } else {
SerializeObject(HeapObject::cast(object), kPlain, kStartOfObject, 0); SerializeObject(HeapObject::cast(object), kPlain, kStartOfObject);
} }
} }
...@@ -124,19 +124,19 @@ void Serializer::PrintStack() { ...@@ -124,19 +124,19 @@ void Serializer::PrintStack() {
#endif // DEBUG #endif // DEBUG
bool Serializer::SerializeRoot(HeapObject obj, HowToCode how_to_code, bool Serializer::SerializeRoot(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
RootIndex root_index; RootIndex root_index;
// Derived serializers are responsible for determining if the root has // Derived serializers are responsible for determining if the root has
// actually been serialized before calling this. // actually been serialized before calling this.
if (root_index_map()->Lookup(obj, &root_index)) { if (root_index_map()->Lookup(obj, &root_index)) {
PutRoot(root_index, obj, how_to_code, where_to_point, skip); PutRoot(root_index, obj, how_to_code, where_to_point);
return true; return true;
} }
return false; return false;
} }
bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code, bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
if (how_to_code != kPlain || where_to_point != kStartOfObject) return false; if (how_to_code != kPlain || where_to_point != kStartOfObject) return false;
// Encode a reference to a hot object by its index in the working set. // Encode a reference to a hot object by its index in the working set.
int index = hot_objects_.Find(obj); int index = hot_objects_.Find(obj);
...@@ -153,7 +153,7 @@ bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code, ...@@ -153,7 +153,7 @@ bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code,
} }
bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
SerializerReference reference = SerializerReference reference =
reference_map_.LookupReference(reinterpret_cast<void*>(obj.ptr())); reference_map_.LookupReference(reinterpret_cast<void*>(obj.ptr()));
if (!reference.is_valid()) return false; if (!reference.is_valid()) return false;
...@@ -162,7 +162,6 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, ...@@ -162,7 +162,6 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code,
// offset fromthe start of the deserialized objects or as an offset // offset fromthe start of the deserialized objects or as an offset
// backwards from thecurrent allocation pointer. // backwards from thecurrent allocation pointer.
if (reference.is_attached_reference()) { if (reference.is_attached_reference()) {
FlushSkip(skip);
if (FLAG_trace_serializer) { if (FLAG_trace_serializer) {
PrintF(" Encoding attached reference %d\n", PrintF(" Encoding attached reference %d\n",
reference.attached_reference_index()); reference.attached_reference_index());
...@@ -178,7 +177,6 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, ...@@ -178,7 +177,6 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code,
PutAlignmentPrefix(obj); PutAlignmentPrefix(obj);
AllocationSpace space = reference.space(); AllocationSpace space = reference.space();
// TODO(ishell): remove kBackrefWithSkip
sink_.Put(kBackref + how_to_code + where_to_point + space, "BackRef"); sink_.Put(kBackref + how_to_code + where_to_point + space, "BackRef");
PutBackReference(obj, reference); PutBackReference(obj, reference);
} }
...@@ -192,8 +190,7 @@ bool Serializer::ObjectIsBytecodeHandler(HeapObject obj) const { ...@@ -192,8 +190,7 @@ bool Serializer::ObjectIsBytecodeHandler(HeapObject obj) const {
void Serializer::PutRoot(RootIndex root, HeapObject object, void Serializer::PutRoot(RootIndex root, HeapObject object,
SerializerDeserializer::HowToCode how_to_code, SerializerDeserializer::HowToCode how_to_code,
SerializerDeserializer::WhereToPoint where_to_point, SerializerDeserializer::WhereToPoint where_to_point) {
int skip) {
int root_index = static_cast<int>(root); int root_index = static_cast<int>(root);
if (FLAG_trace_serializer) { if (FLAG_trace_serializer) {
PrintF(" Encoding root %d:", root_index); PrintF(" Encoding root %d:", root_index);
...@@ -210,10 +207,8 @@ void Serializer::PutRoot(RootIndex root, HeapObject object, ...@@ -210,10 +207,8 @@ void Serializer::PutRoot(RootIndex root, HeapObject object,
if (how_to_code == kPlain && where_to_point == kStartOfObject && if (how_to_code == kPlain && where_to_point == kStartOfObject &&
root_index < kNumberOfRootArrayConstants && root_index < kNumberOfRootArrayConstants &&
!Heap::InYoungGeneration(object)) { !Heap::InYoungGeneration(object)) {
// TODO(ishell): remove kRootArrayConstantsWithSkip
sink_.Put(kRootArrayConstants + root_index, "RootConstant"); sink_.Put(kRootArrayConstants + root_index, "RootConstant");
} else { } else {
FlushSkip(skip);
sink_.Put(kRootArray + how_to_code + where_to_point, "RootSerialization"); sink_.Put(kRootArray + how_to_code + where_to_point, "RootSerialization");
sink_.PutInt(root_index, "root_index"); sink_.PutInt(root_index, "root_index");
hot_objects_.Add(object); hot_objects_.Add(object);
...@@ -354,7 +349,7 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space, ...@@ -354,7 +349,7 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space,
back_reference); back_reference);
// Serialize the map (first word of the object). // Serialize the map (first word of the object).
serializer_->SerializeObject(map, kPlain, kStartOfObject, 0); serializer_->SerializeObject(map, kPlain, kStartOfObject);
} }
int32_t Serializer::ObjectSerializer::SerializeBackingStore( int32_t Serializer::ObjectSerializer::SerializeBackingStore(
...@@ -650,8 +645,6 @@ void Serializer::ObjectSerializer::SerializeContent(Map map, int size) { ...@@ -650,8 +645,6 @@ void Serializer::ObjectSerializer::SerializeContent(Map map, int size) {
OutputCode(size); OutputCode(size);
// Then iterate references via reloc info. // Then iterate references via reloc info.
object_->IterateBody(map, size, this); object_->IterateBody(map, size, this);
// Finally skip to the end.
serializer_->FlushSkip(SkipTo(object_->address() + size));
} else { } else {
// For other objects, iterate references first. // For other objects, iterate references first.
object_->IterateBody(map, size, this); object_->IterateBody(map, size, this);
...@@ -715,30 +708,22 @@ void Serializer::ObjectSerializer::VisitPointers(HeapObject host, ...@@ -715,30 +708,22 @@ void Serializer::ObjectSerializer::VisitPointers(HeapObject host,
if (reference_type == HeapObjectReferenceType::WEAK) { if (reference_type == HeapObjectReferenceType::WEAK) {
sink_->Put(kWeakPrefix, "WeakReference"); sink_->Put(kWeakPrefix, "WeakReference");
} }
serializer_->SerializeObject(current_contents, kPlain, kStartOfObject, 0); serializer_->SerializeObject(current_contents, kPlain, kStartOfObject);
} }
} }
} }
void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host, void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host,
RelocInfo* rinfo) { RelocInfo* rinfo) {
// TODO(ishell): remove skip parameter from bytecode.
int skip = 0;
HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
Object object = rinfo->target_object(); Object object = rinfo->target_object();
serializer_->SerializeObject(HeapObject::cast(object), how_to_code, serializer_->SerializeObject(HeapObject::cast(object), how_to_code,
kStartOfObject, skip); kStartOfObject);
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
void Serializer::ObjectSerializer::VisitExternalReference(Foreign host, void Serializer::ObjectSerializer::VisitExternalReference(Foreign host,
Address* p) { Address* p) {
// TODO(ishell): handle gap between map field and payload field
// once we shrink kTaggedSize.
STATIC_ASSERT(static_cast<int>(Foreign::kForeignAddressOffset) ==
static_cast<int>(HeapObject::kHeaderSize));
DCHECK_EQ(0, SkipTo(reinterpret_cast<Address>(p)));
Address target = *p; Address target = *p;
auto encoded_reference = serializer_->EncodeExternalReference(target); auto encoded_reference = serializer_->EncodeExternalReference(target);
if (encoded_reference.is_from_api()) { if (encoded_reference.is_from_api()) {
...@@ -817,10 +802,8 @@ void Serializer::ObjectSerializer::VisitCodeTarget(Code host, ...@@ -817,10 +802,8 @@ void Serializer::ObjectSerializer::VisitCodeTarget(Code host,
#ifdef V8_TARGET_ARCH_ARM #ifdef V8_TARGET_ARCH_ARM
DCHECK(!RelocInfo::IsRelativeCodeTarget(rinfo->rmode())); DCHECK(!RelocInfo::IsRelativeCodeTarget(rinfo->rmode()));
#endif #endif
// TODO(ishell): remove skip parameter from bytecode.
int skip = 0;
Code object = Code::GetCodeFromTargetAddress(rinfo->target_address()); Code object = Code::GetCodeFromTargetAddress(rinfo->target_address());
serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); serializer_->SerializeObject(object, kFromCode, kInnerPointer);
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
...@@ -870,18 +853,6 @@ void Serializer::ObjectSerializer::OutputRawData(Address up_to) { ...@@ -870,18 +853,6 @@ void Serializer::ObjectSerializer::OutputRawData(Address up_to) {
} }
} }
int Serializer::ObjectSerializer::SkipTo(Address to) {
Address object_start = object_->address();
int up_to_offset = static_cast<int>(to - object_start);
int to_skip = up_to_offset - bytes_processed_so_far_;
bytes_processed_so_far_ += to_skip;
// This assert will fail if the reloc info gives us the target_address_address
// locations in a non-ascending order. We make sure this doesn't happen by
// sorting the relocation info.
DCHECK_GE(to_skip, 0);
return to_skip;
}
void Serializer::ObjectSerializer::OutputCode(int size) { void Serializer::ObjectSerializer::OutputCode(int size) {
DCHECK_EQ(kTaggedSize, bytes_processed_so_far_); DCHECK_EQ(kTaggedSize, bytes_processed_so_far_);
Code on_heap_code = Code::cast(object_); Code on_heap_code = Code::cast(object_);
......
...@@ -192,7 +192,7 @@ class Serializer : public SerializerDeserializer { ...@@ -192,7 +192,7 @@ class Serializer : public SerializerDeserializer {
void SerializeDeferredObjects(); void SerializeDeferredObjects();
virtual void SerializeObject(HeapObject o, HowToCode how_to_code, virtual void SerializeObject(HeapObject o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) = 0; WhereToPoint where_to_point) = 0;
virtual bool MustBeDeferred(HeapObject object); virtual bool MustBeDeferred(HeapObject object);
...@@ -201,7 +201,7 @@ class Serializer : public SerializerDeserializer { ...@@ -201,7 +201,7 @@ class Serializer : public SerializerDeserializer {
void SerializeRootObject(Object object); void SerializeRootObject(Object object);
void PutRoot(RootIndex root_index, HeapObject object, HowToCode how, void PutRoot(RootIndex root_index, HeapObject object, HowToCode how,
WhereToPoint where, int skip); WhereToPoint where);
void PutSmi(Smi smi); void PutSmi(Smi smi);
void PutBackReference(HeapObject object, SerializerReference reference); void PutBackReference(HeapObject object, SerializerReference reference);
void PutAttachedReference(SerializerReference reference, void PutAttachedReference(SerializerReference reference,
...@@ -213,25 +213,19 @@ class Serializer : public SerializerDeserializer { ...@@ -213,25 +213,19 @@ class Serializer : public SerializerDeserializer {
// Returns true if the object was successfully serialized as a root. // Returns true if the object was successfully serialized as a root.
bool SerializeRoot(HeapObject obj, HowToCode how_to_code, bool SerializeRoot(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
// Returns true if the object was successfully serialized as hot object. // Returns true if the object was successfully serialized as hot object.
bool SerializeHotObject(HeapObject obj, HowToCode how_to_code, bool SerializeHotObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
// Returns true if the object was successfully serialized as back reference. // Returns true if the object was successfully serialized as back reference.
bool SerializeBackReference(HeapObject obj, HowToCode how_to_code, bool SerializeBackReference(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
// Returns true if the given heap object is a bytecode handler code object. // Returns true if the given heap object is a bytecode handler code object.
bool ObjectIsBytecodeHandler(HeapObject obj) const; bool ObjectIsBytecodeHandler(HeapObject obj) const;
static inline void FlushSkip(SnapshotByteSink* sink, int skip) {
// TODO(ishell): remove kSkip and friends as they are no longer needed.
}
inline void FlushSkip(int skip) { FlushSkip(&sink_, skip); }
ExternalReferenceEncoder::Value EncodeExternalReference(Address addr) { ExternalReferenceEncoder::Value EncodeExternalReference(Address addr) {
return external_reference_encoder_.Encode(addr); return external_reference_encoder_.Encode(addr);
} }
...@@ -341,7 +335,6 @@ class Serializer::ObjectSerializer : public ObjectVisitor { ...@@ -341,7 +335,6 @@ class Serializer::ObjectSerializer : public ObjectVisitor {
void SerializeContent(Map map, int size); void SerializeContent(Map map, int size);
void OutputRawData(Address up_to); void OutputRawData(Address up_to);
void OutputCode(int size); void OutputCode(int size);
int SkipTo(Address to);
int32_t SerializeBackingStore(void* backing_store, int32_t byte_length); int32_t SerializeBackingStore(void* backing_store, int32_t byte_length);
void SerializeJSTypedArray(); void SerializeJSTypedArray();
void SerializeJSArrayBuffer(); void SerializeJSArrayBuffer();
......
...@@ -70,20 +70,19 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) { ...@@ -70,20 +70,19 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) {
#endif // DEBUG #endif // DEBUG
void StartupSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void StartupSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
DCHECK(!obj->IsJSFunction()); DCHECK(!obj->IsJSFunction());
DCHECK(!IsUnexpectedCodeObject(isolate(), obj)); DCHECK(!IsUnexpectedCodeObject(isolate(), obj));
if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return; if (SerializeHotObject(obj, how_to_code, where_to_point)) return;
if (IsRootAndHasBeenSerialized(obj) && if (IsRootAndHasBeenSerialized(obj) &&
SerializeRoot(obj, how_to_code, where_to_point, skip)) SerializeRoot(obj, how_to_code, where_to_point))
return; return;
if (SerializeUsingReadOnlyObjectCache(&sink_, obj, how_to_code, if (SerializeUsingReadOnlyObjectCache(&sink_, obj, how_to_code,
where_to_point, skip)) where_to_point))
return; return;
if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return; if (SerializeBackReference(obj, how_to_code, where_to_point)) return;
FlushSkip(skip);
bool use_simulator = false; bool use_simulator = false;
#ifdef USE_SIMULATOR #ifdef USE_SIMULATOR
use_simulator = true; use_simulator = true;
...@@ -162,16 +161,14 @@ SerializedHandleChecker::SerializedHandleChecker(Isolate* isolate, ...@@ -162,16 +161,14 @@ SerializedHandleChecker::SerializedHandleChecker(Isolate* isolate,
bool StartupSerializer::SerializeUsingReadOnlyObjectCache( bool StartupSerializer::SerializeUsingReadOnlyObjectCache(
SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code, SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
return read_only_serializer_->SerializeUsingReadOnlyObjectCache( return read_only_serializer_->SerializeUsingReadOnlyObjectCache(
sink, obj, how_to_code, where_to_point, skip); sink, obj, how_to_code, where_to_point);
} }
void StartupSerializer::SerializeUsingPartialSnapshotCache( void StartupSerializer::SerializeUsingPartialSnapshotCache(
SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code, SnapshotByteSink* sink, HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point) {
FlushSkip(sink, skip);
int cache_index = SerializeInObjectCache(obj); int cache_index = SerializeInObjectCache(obj);
sink->Put(kPartialSnapshotCache + how_to_code + where_to_point, sink->Put(kPartialSnapshotCache + how_to_code + where_to_point,
"PartialSnapshotCache"); "PartialSnapshotCache");
......
...@@ -35,18 +35,17 @@ class StartupSerializer : public RootsSerializer { ...@@ -35,18 +35,17 @@ class StartupSerializer : public RootsSerializer {
// successful. // successful.
bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink, HeapObject obj, bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink, HeapObject obj,
HowToCode how_to_code, HowToCode how_to_code,
WhereToPoint where_to_point, int skip); WhereToPoint where_to_point);
// Adds |obj| to the partial snapshot object cache if not already present and // Adds |obj| to the partial snapshot object cache if not already present and
// emits a PartialSnapshotCache bytecode into |sink|. // emits a PartialSnapshotCache bytecode into |sink|.
void SerializeUsingPartialSnapshotCache(SnapshotByteSink* sink, void SerializeUsingPartialSnapshotCache(SnapshotByteSink* sink,
HeapObject obj, HowToCode how_to_code, HeapObject obj, HowToCode how_to_code,
WhereToPoint where_to_point, WhereToPoint where_to_point);
int skip);
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) override; WhereToPoint where_to_point) override;
ReadOnlySerializer* read_only_serializer_; ReadOnlySerializer* read_only_serializer_;
std::vector<AccessorInfo> accessor_infos_; std::vector<AccessorInfo> accessor_infos_;
......
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