Commit 60f8b7a8 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[snapshot][cleanup] Remove WhereToPoint flag from bytecodes

... as it's no longer needed.

Bug: v8:8794, v8:8562
Change-Id: Ifbc4f5f5d34f24ff4ba8f32309e8a032268c12c0
Reviewed-on: https://chromium-review.googlesource.com/c/1460457
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59461}
parent 9afefcbc
...@@ -97,8 +97,7 @@ ScriptData* CodeSerializer::SerializeSharedFunctionInfo( ...@@ -97,8 +97,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) {
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;
...@@ -116,19 +115,18 @@ bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj, ...@@ -116,19 +115,18 @@ 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)); CHECK(SerializeBackReference(obj, how_to_code));
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) { if (SerializeHotObject(obj, how_to_code)) return;
if (SerializeHotObject(obj, how_to_code, where_to_point)) return;
if (SerializeRoot(obj, how_to_code, where_to_point)) return; if (SerializeRoot(obj, how_to_code)) return;
if (SerializeBackReference(obj, how_to_code, where_to_point)) return; if (SerializeBackReference(obj, how_to_code)) return;
if (SerializeReadOnlyObject(obj, how_to_code, where_to_point)) return; if (SerializeReadOnlyObject(obj, how_to_code)) return;
if (obj->IsCode()) { if (obj->IsCode()) {
Code code_object = Code::cast(obj); Code code_object = Code::cast(obj);
...@@ -141,15 +139,14 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -141,15 +139,14 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
case Code::STUB: case Code::STUB:
case Code::BUILTIN: case Code::BUILTIN:
default: default:
return SerializeCodeObject(code_object, how_to_code, where_to_point); return SerializeCodeObject(code_object, how_to_code);
} }
UNREACHABLE(); UNREACHABLE();
} }
ReadOnlyRoots roots(isolate()); ReadOnlyRoots roots(isolate());
if (ElideObject(obj)) { if (ElideObject(obj)) {
return SerializeObject(roots.undefined_value(), how_to_code, return SerializeObject(roots.undefined_value(), how_to_code);
where_to_point);
} }
if (obj->IsScript()) { if (obj->IsScript()) {
...@@ -167,7 +164,7 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -167,7 +164,7 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
// object graph. // object graph.
FixedArray host_options = script_obj->host_defined_options(); FixedArray host_options = script_obj->host_defined_options();
script_obj->set_host_defined_options(roots.empty_fixed_array()); script_obj->set_host_defined_options(roots.empty_fixed_array());
SerializeGeneric(obj, how_to_code, where_to_point); SerializeGeneric(obj, how_to_code);
script_obj->set_host_defined_options(host_options); script_obj->set_host_defined_options(host_options);
script_obj->set_context_data(context_data); script_obj->set_context_data(context_data);
return; return;
...@@ -192,7 +189,7 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -192,7 +189,7 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
} }
DCHECK(!sfi->HasDebugInfo()); DCHECK(!sfi->HasDebugInfo());
SerializeGeneric(obj, how_to_code, where_to_point); SerializeGeneric(obj, how_to_code);
// Restore debug info // Restore debug info
if (!debug_info.is_null()) { if (!debug_info.is_null()) {
...@@ -218,15 +215,13 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -218,15 +215,13 @@ void CodeSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
// We expect no instantiated function objects or contexts. // We expect no instantiated function objects or contexts.
CHECK(!obj->IsJSFunction() && !obj->IsContext()); CHECK(!obj->IsJSFunction() && !obj->IsContext());
SerializeGeneric(obj, how_to_code, where_to_point); SerializeGeneric(obj, how_to_code);
} }
void CodeSerializer::SerializeGeneric(HeapObject heap_object, void CodeSerializer::SerializeGeneric(HeapObject heap_object,
HowToCode how_to_code, HowToCode how_to_code) {
WhereToPoint where_to_point) {
// Object has not yet been serialized. Serialize it here. // Object has not yet been serialized. Serialize it here.
ObjectSerializer serializer(this, heap_object, &sink_, how_to_code, ObjectSerializer serializer(this, heap_object, &sink_, how_to_code);
where_to_point);
serializer.Serialize(); serializer.Serialize();
} }
......
...@@ -58,21 +58,17 @@ class CodeSerializer : public Serializer { ...@@ -58,21 +58,17 @@ class CodeSerializer : public Serializer {
CodeSerializer(Isolate* isolate, uint32_t source_hash); CodeSerializer(Isolate* isolate, uint32_t source_hash);
~CodeSerializer() override { OutputStatistics("CodeSerializer"); } ~CodeSerializer() override { OutputStatistics("CodeSerializer"); }
virtual void SerializeCodeObject(Code code_object, HowToCode how_to_code, virtual void SerializeCodeObject(Code code_object, HowToCode how_to_code) {
WhereToPoint where_to_point) {
UNREACHABLE(); UNREACHABLE();
} }
virtual bool ElideObject(Object obj) { return false; } virtual bool ElideObject(Object obj) { return false; }
void SerializeGeneric(HeapObject heap_object, HowToCode how_to_code, void SerializeGeneric(HeapObject heap_object, HowToCode how_to_code);
WhereToPoint where_to_point);
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code) 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);
DISALLOW_HEAP_ALLOCATION(no_gc_); DISALLOW_HEAP_ALLOCATION(no_gc_);
uint32_t source_hash_; uint32_t source_hash_;
......
...@@ -442,15 +442,14 @@ void Deserializer::VisitRuntimeEntry(Code host, RelocInfo* rinfo) { ...@@ -442,15 +442,14 @@ void Deserializer::VisitRuntimeEntry(Code host, RelocInfo* rinfo) {
void Deserializer::VisitExternalReference(Code host, RelocInfo* rinfo) { void Deserializer::VisitExternalReference(Code host, RelocInfo* rinfo) {
byte data = source_.Get(); byte data = source_.Get();
CHECK(data == kExternalReference + kPlain + kStartOfObject || CHECK(data == kExternalReference + kPlain ||
data == kExternalReference + kFromCode + kStartOfObject); data == kExternalReference + kFromCode);
uint32_t reference_id = static_cast<uint32_t>(source_.GetInt()); uint32_t reference_id = static_cast<uint32_t>(source_.GetInt());
Address address = external_reference_table_->address(reference_id); Address address = external_reference_table_->address(reference_id);
DCHECK_EQ(rinfo->IsCodedSpecially(), DCHECK_EQ(rinfo->IsCodedSpecially(), data == kExternalReference + kFromCode);
data == kExternalReference + kFromCode + kStartOfObject); if (data == kExternalReference + kFromCode) {
if (data == kExternalReference + kFromCode + kStartOfObject) {
Address location_of_branch_data = rinfo->pc(); Address location_of_branch_data = rinfo->pc();
Assembler::deserialization_set_special_target_at(location_of_branch_data, Assembler::deserialization_set_special_target_at(location_of_branch_data,
host, address); host, address);
...@@ -537,34 +536,33 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -537,34 +536,33 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
while (current < limit) { while (current < limit) {
byte data = source_.Get(); byte data = source_.Get();
switch (data) { switch (data) {
#define CASE_STATEMENT(where, how, within, space_number) \ #define CASE_STATEMENT(where, how, space_number) \
case where + how + within + space_number: \ case where + how + space_number: \
STATIC_ASSERT((where & ~kWhereMask) == 0); \ STATIC_ASSERT((where & ~kWhereMask) == 0); \
STATIC_ASSERT((how & ~kHowToCodeMask) == 0); \ STATIC_ASSERT((how & ~kHowToCodeMask) == 0); \
STATIC_ASSERT((within & ~kWhereToPointMask) == 0); \
STATIC_ASSERT((space_number & ~kSpaceMask) == 0); STATIC_ASSERT((space_number & ~kSpaceMask) == 0);
#define CASE_BODY(where, how, within, space_number_if_any) \ #define CASE_BODY(where, how, space_number_if_any) \
current = ReadDataCase<where, how, within, space_number_if_any>( \ current = ReadDataCase<where, space_number_if_any>( \
isolate, current, current_object_address, data, write_barrier_needed); \ isolate, current, current_object_address, data, write_barrier_needed); \
break; break;
// This generates a case and a body for the new space (which has to do extra // This generates a case and a body for the new space (which has to do extra
// write barrier handling) and handles the other spaces with fall-through cases // write barrier handling) and handles the other spaces with fall-through cases
// and one body. // and one body.
#define ALL_SPACES(where, how, within) \ #define ALL_SPACES(where, how) \
CASE_STATEMENT(where, how, within, NEW_SPACE) \ CASE_STATEMENT(where, how, NEW_SPACE) \
CASE_BODY(where, how, within, NEW_SPACE) \ CASE_BODY(where, how, NEW_SPACE) \
CASE_STATEMENT(where, how, within, OLD_SPACE) \ CASE_STATEMENT(where, how, OLD_SPACE) \
V8_FALLTHROUGH; \ V8_FALLTHROUGH; \
CASE_STATEMENT(where, how, within, CODE_SPACE) \ CASE_STATEMENT(where, how, CODE_SPACE) \
V8_FALLTHROUGH; \ V8_FALLTHROUGH; \
CASE_STATEMENT(where, how, within, MAP_SPACE) \ CASE_STATEMENT(where, how, MAP_SPACE) \
V8_FALLTHROUGH; \ V8_FALLTHROUGH; \
CASE_STATEMENT(where, how, within, LO_SPACE) \ CASE_STATEMENT(where, how, LO_SPACE) \
V8_FALLTHROUGH; \ V8_FALLTHROUGH; \
CASE_STATEMENT(where, how, within, RO_SPACE) \ CASE_STATEMENT(where, how, RO_SPACE) \
CASE_BODY(where, how, within, kAnyOldSpace) CASE_BODY(where, how, kAnyOldSpace)
#define FOUR_CASES(byte_code) \ #define FOUR_CASES(byte_code) \
case byte_code: \ case byte_code: \
...@@ -578,58 +576,43 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -578,58 +576,43 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
FOUR_CASES(byte_code + 8) \ FOUR_CASES(byte_code + 8) \
FOUR_CASES(byte_code + 12) FOUR_CASES(byte_code + 12)
#define SINGLE_CASE(where, how, within, space) \ #define SINGLE_CASE(where, how, space) \
CASE_STATEMENT(where, how, within, space) \ CASE_STATEMENT(where, how, space) \
CASE_BODY(where, how, within, space) CASE_BODY(where, how, space)
// Deserialize a new object and write a pointer to it to the current // Deserialize a new object and write a pointer to it to the current
// object. // object.
ALL_SPACES(kNewObject, kPlain, kStartOfObject) ALL_SPACES(kNewObject, kPlain)
// Deserialize a new code object and write a pointer to its first // Deserialize a new code object and write a pointer to its first
// instruction to the current code object. // instruction to the current code object.
ALL_SPACES(kNewObject, kFromCode, kInnerPointer) ALL_SPACES(kNewObject, kFromCode)
// 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)
#if V8_CODE_EMBEDS_OBJECT_POINTER
// 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
// or S390 with embedded constant pool, and omitted on the other
// architectures because it is fully unrolled and would cause bloat.
ALL_SPACES(kNewObject, kFromCode, kStartOfObject)
// Find a recently deserialized code object using its offset from the
// current allocation point and write a pointer to it to the current
// object. Required only for MIPS, PPC, ARM or S390 with embedded
// constant pool.
ALL_SPACES(kBackref, kFromCode, kStartOfObject)
#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)
// 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, 0)
#if V8_CODE_EMBEDS_OBJECT_POINTER #if V8_CODE_EMBEDS_OBJECT_POINTER
// Find an object in the roots array and write a pointer to it to in code. // Find an object in the roots array and write a pointer to it to in code.
SINGLE_CASE(kRootArray, kFromCode, kStartOfObject, 0) SINGLE_CASE(kRootArray, kFromCode, 0)
#endif #endif
// Find an object in the partial snapshots cache and write a pointer to it // Find an object in the partial snapshots cache and write a pointer to it
// to the current object. // to the current object.
SINGLE_CASE(kPartialSnapshotCache, kPlain, kStartOfObject, 0) SINGLE_CASE(kPartialSnapshotCache, kPlain, 0)
SINGLE_CASE(kPartialSnapshotCache, kFromCode, kStartOfObject, 0) SINGLE_CASE(kPartialSnapshotCache, kFromCode, 0)
SINGLE_CASE(kPartialSnapshotCache, kFromCode, kInnerPointer, 0)
// Find an object in the partial snapshots cache and write a pointer to it // Find an object in the partial snapshots cache and write a pointer to it
// to the current object. // to the current object.
SINGLE_CASE(kReadOnlyObjectCache, kPlain, kStartOfObject, 0) SINGLE_CASE(kReadOnlyObjectCache, kPlain, 0)
SINGLE_CASE(kReadOnlyObjectCache, kFromCode, kStartOfObject, 0) SINGLE_CASE(kReadOnlyObjectCache, kFromCode, 0)
SINGLE_CASE(kReadOnlyObjectCache, kFromCode, kInnerPointer, 0)
// Find an object in the attached references and write a pointer to it to // Find an object in the attached references and write a pointer to it to
// the current object. // the current object.
SINGLE_CASE(kAttachedReference, kPlain, kStartOfObject, 0) SINGLE_CASE(kAttachedReference, kPlain, 0)
SINGLE_CASE(kAttachedReference, kFromCode, kStartOfObject, 0) SINGLE_CASE(kAttachedReference, kFromCode, 0)
SINGLE_CASE(kAttachedReference, kFromCode, kInnerPointer, 0)
#undef CASE_STATEMENT #undef CASE_STATEMENT
#undef CASE_BODY #undef CASE_BODY
...@@ -637,13 +620,11 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit, ...@@ -637,13 +620,11 @@ bool Deserializer::ReadData(UnalignedSlot current, UnalignedSlot limit,
// 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:
current = current =
ReadExternalReferenceCase(kPlain, current, current_object_address); ReadExternalReferenceCase(kPlain, current, current_object_address);
break; break;
// Find an external reference and write a pointer to it in the current case kExternalReference + kFromCode:
// code object.
case kExternalReference + kFromCode + kStartOfObject:
UNREACHABLE(); UNREACHABLE();
break; break;
...@@ -847,7 +828,7 @@ UnalignedSlot Deserializer::ReadExternalReferenceCase( ...@@ -847,7 +828,7 @@ UnalignedSlot Deserializer::ReadExternalReferenceCase(
return current; return current;
} }
template <int where, int how, int within, int space_number_if_any> template <SerializerDeserializer::Where where, int space_number_if_any>
UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate, UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate,
UnalignedSlot current, UnalignedSlot current,
Address current_object_address, Address current_object_address,
......
...@@ -126,7 +126,7 @@ class Deserializer : public SerializerDeserializer { ...@@ -126,7 +126,7 @@ class Deserializer : public SerializerDeserializer {
// A helper function for ReadData, templatized on the bytecode for efficiency. // A helper function for ReadData, templatized on the bytecode for efficiency.
// Returns the new value of {current}. // Returns the new value of {current}.
template <int where, int how, int within, int space_number_if_any> template <Where where, int space_number_if_any>
inline UnalignedSlot ReadDataCase(Isolate* isolate, UnalignedSlot current, inline UnalignedSlot ReadDataCase(Isolate* isolate, UnalignedSlot current,
Address current_object_address, byte data, Address current_object_address, byte data,
bool write_barrier_needed); bool write_barrier_needed);
......
...@@ -68,24 +68,23 @@ void PartialSerializer::Serialize(Context* o, bool include_global_proxy) { ...@@ -68,24 +68,23 @@ void PartialSerializer::Serialize(Context* o, bool include_global_proxy) {
Pad(); Pad();
} }
void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code) {
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)) return; if (SerializeHotObject(obj, how_to_code)) return;
if (SerializeRoot(obj, how_to_code, where_to_point)) return; if (SerializeRoot(obj, how_to_code)) return;
if (SerializeBackReference(obj, how_to_code, where_to_point)) return; if (SerializeBackReference(obj, how_to_code)) return;
if (startup_serializer_->SerializeUsingReadOnlyObjectCache( if (startup_serializer_->SerializeUsingReadOnlyObjectCache(&sink_, obj,
&sink_, obj, how_to_code, where_to_point)) { how_to_code)) {
return; return;
} }
if (ShouldBeInThePartialSnapshotCache(obj)) { if (ShouldBeInThePartialSnapshotCache(obj)) {
startup_serializer_->SerializeUsingPartialSnapshotCache( startup_serializer_->SerializeUsingPartialSnapshotCache(&sink_, obj,
&sink_, obj, how_to_code, where_to_point); how_to_code);
return; return;
} }
...@@ -104,7 +103,7 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -104,7 +103,7 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
// 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());
if (SerializeJSObjectWithEmbedderFields(obj, how_to_code, where_to_point)) { if (SerializeJSObjectWithEmbedderFields(obj, how_to_code)) {
return; return;
} }
...@@ -119,7 +118,7 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -119,7 +118,7 @@ void PartialSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
CheckRehashability(obj); CheckRehashability(obj);
// Object has not yet been serialized. Serialize it here. // Object has not yet been serialized. Serialize it here.
ObjectSerializer serializer(this, obj, &sink_, how_to_code, where_to_point); ObjectSerializer serializer(this, obj, &sink_, how_to_code);
serializer.Serialize(); serializer.Serialize();
} }
...@@ -141,7 +140,7 @@ bool DataIsEmpty(const StartupData& data) { return data.raw_size == 0; } ...@@ -141,7 +140,7 @@ bool DataIsEmpty(const StartupData& data) { return data.raw_size == 0; }
} // anonymous namespace } // anonymous namespace
bool PartialSerializer::SerializeJSObjectWithEmbedderFields( bool PartialSerializer::SerializeJSObjectWithEmbedderFields(
Object obj, HowToCode how_to_code, WhereToPoint where_to_point) { Object obj, HowToCode how_to_code) {
if (!obj->IsJSObject()) return false; if (!obj->IsJSObject()) return false;
JSObject js_obj = JSObject::cast(obj); JSObject js_obj = JSObject::cast(obj);
int embedder_fields_count = js_obj->GetEmbedderFieldCount(); int embedder_fields_count = js_obj->GetEmbedderFieldCount();
...@@ -192,8 +191,7 @@ bool PartialSerializer::SerializeJSObjectWithEmbedderFields( ...@@ -192,8 +191,7 @@ bool PartialSerializer::SerializeJSObjectWithEmbedderFields(
// 3) Serialize the object. References from embedder fields to heap objects or // 3) Serialize the object. References from embedder fields to heap objects or
// smis are serialized regularly. // smis are serialized regularly.
ObjectSerializer(this, js_obj, &sink_, how_to_code, where_to_point) ObjectSerializer(this, js_obj, &sink_, how_to_code).Serialize();
.Serialize();
// 4) Obtain back reference for the serialized object. // 4) Obtain back reference for the serialized object.
SerializerReference reference = SerializerReference reference =
......
...@@ -27,13 +27,11 @@ class PartialSerializer : public Serializer { ...@@ -27,13 +27,11 @@ class PartialSerializer : public Serializer {
bool can_be_rehashed() const { return can_be_rehashed_; } bool can_be_rehashed() const { return can_be_rehashed_; }
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code) override;
WhereToPoint where_to_point) override;
bool ShouldBeInThePartialSnapshotCache(HeapObject o); bool ShouldBeInThePartialSnapshotCache(HeapObject o);
bool SerializeJSObjectWithEmbedderFields(Object obj, HowToCode how_to_code, bool SerializeJSObjectWithEmbedderFields(Object obj, HowToCode how_to_code);
WhereToPoint where_to_point);
void CheckRehashability(HeapObject obj); void CheckRehashability(HeapObject obj);
......
...@@ -24,23 +24,21 @@ ReadOnlySerializer::~ReadOnlySerializer() { ...@@ -24,23 +24,21 @@ ReadOnlySerializer::~ReadOnlySerializer() {
OutputStatistics("ReadOnlySerializer"); OutputStatistics("ReadOnlySerializer");
} }
void ReadOnlySerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, void ReadOnlySerializer::SerializeObject(HeapObject obj,
WhereToPoint where_to_point) { HowToCode how_to_code) {
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)) return; if (SerializeHotObject(obj, how_to_code)) return;
if (IsRootAndHasBeenSerialized(obj) && if (IsRootAndHasBeenSerialized(obj) && SerializeRoot(obj, how_to_code)) {
SerializeRoot(obj, how_to_code, where_to_point)) {
return; return;
} }
if (SerializeBackReference(obj, how_to_code, where_to_point)) return; if (SerializeBackReference(obj, how_to_code)) return;
CheckRehashability(obj); CheckRehashability(obj);
// Object has not yet been serialized. Serialize it here. // Object has not yet been serialized. Serialize it here.
ObjectSerializer object_serializer(this, obj, &sink_, how_to_code, ObjectSerializer object_serializer(this, obj, &sink_, how_to_code);
where_to_point);
object_serializer.Serialize(); object_serializer.Serialize();
} }
...@@ -81,8 +79,7 @@ bool ReadOnlySerializer::MustBeDeferred(HeapObject object) { ...@@ -81,8 +79,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) {
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
...@@ -90,8 +87,7 @@ bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache( ...@@ -90,8 +87,7 @@ 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.
sink->Put(kReadOnlyObjectCache + how_to_code + where_to_point, sink->Put(kReadOnlyObjectCache + how_to_code, "ReadOnlyObjectCache");
"ReadOnlyObjectCache");
sink->PutInt(cache_index, "read_only_object_cache_index"); sink->PutInt(cache_index, "read_only_object_cache_index");
return true; return true;
......
...@@ -29,12 +29,10 @@ class ReadOnlySerializer : public RootsSerializer { ...@@ -29,12 +29,10 @@ class ReadOnlySerializer : public RootsSerializer {
// ReadOnlyObjectCache bytecode into |sink|. Returns whether this was // ReadOnlyObjectCache bytecode into |sink|. Returns whether this was
// 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);
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code) 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); SerializeObject(heap_object, kPlain);
} }
return index; return index;
} }
......
...@@ -147,8 +147,8 @@ class SerializerDeserializer : public RootVisitor { ...@@ -147,8 +147,8 @@ class SerializerDeserializer : public RootVisitor {
V(0x7b) \ V(0x7b) \
V(0x7c) V(0x7c)
// ---------- byte code range 0x00..0x7f ---------- // ---------- byte code range 0x00..0x3f ----------
// Byte codes in this range represent Where, HowToCode and WhereToPoint. // Byte codes in this range represent Where and HowToCode.
// Where the pointed-to object can be found: // Where the pointed-to object can be found:
// The static assert below will trigger when the number of preallocated spaces // The static assert below will trigger when the number of preallocated spaces
// changed. If that happens, update the bytecode ranges in the comments below. // changed. If that happens, update the bytecode ranges in the comments below.
...@@ -189,16 +189,6 @@ class SerializerDeserializer : public RootVisitor { ...@@ -189,16 +189,6 @@ class SerializerDeserializer : public RootVisitor {
static const int kHowToCodeMask = 0x20; static const int kHowToCodeMask = 0x20;
// Where to point within the object.
enum WhereToPoint {
// Points to start of object
kStartOfObject = 0,
// Points to instruction in code object or payload of cell.
kInnerPointer = 0x40
};
static const int kWhereToPointMask = 0x40;
// ---------- Misc ---------- // ---------- Misc ----------
// Do nothing, used for padding. // Do nothing, used for padding.
static const int kNop = 0x2f; static const int kNop = 0x2f;
......
...@@ -91,7 +91,7 @@ void Serializer::SerializeDeferredObjects() { ...@@ -91,7 +91,7 @@ void Serializer::SerializeDeferredObjects() {
while (!deferred_objects_.empty()) { while (!deferred_objects_.empty()) {
HeapObject obj = deferred_objects_.back(); HeapObject obj = deferred_objects_.back();
deferred_objects_.pop_back(); deferred_objects_.pop_back();
ObjectSerializer obj_serializer(this, obj, &sink_, kPlain, kStartOfObject); ObjectSerializer obj_serializer(this, obj, &sink_, kPlain);
obj_serializer.SerializeDeferred(); obj_serializer.SerializeDeferred();
} }
sink_.Put(kSynchronize, "Finished with deferred objects"); sink_.Put(kSynchronize, "Finished with deferred objects");
...@@ -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); SerializeObject(HeapObject::cast(object), kPlain);
} }
} }
...@@ -123,21 +123,19 @@ void Serializer::PrintStack() { ...@@ -123,21 +123,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) {
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); PutRoot(root_index, obj, how_to_code);
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) { if (how_to_code != kPlain) 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);
if (index == HotObjectsList::kNotFound) return false; if (index == HotObjectsList::kNotFound) return false;
...@@ -152,8 +150,7 @@ bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code, ...@@ -152,8 +150,7 @@ bool Serializer::SerializeHotObject(HeapObject obj, HowToCode how_to_code,
return true; return true;
} }
bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code) {
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;
...@@ -166,7 +163,7 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, ...@@ -166,7 +163,7 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code,
PrintF(" Encoding attached reference %d\n", PrintF(" Encoding attached reference %d\n",
reference.attached_reference_index()); reference.attached_reference_index());
} }
PutAttachedReference(reference, how_to_code, where_to_point); PutAttachedReference(reference, how_to_code);
} else { } else {
DCHECK(reference.is_back_reference()); DCHECK(reference.is_back_reference());
if (FLAG_trace_serializer) { if (FLAG_trace_serializer) {
...@@ -177,7 +174,7 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code, ...@@ -177,7 +174,7 @@ bool Serializer::SerializeBackReference(HeapObject obj, HowToCode how_to_code,
PutAlignmentPrefix(obj); PutAlignmentPrefix(obj);
AllocationSpace space = reference.space(); AllocationSpace space = reference.space();
sink_.Put(kBackref + how_to_code + where_to_point + space, "BackRef"); sink_.Put(kBackref + how_to_code + space, "BackRef");
PutBackReference(obj, reference); PutBackReference(obj, reference);
} }
return true; return true;
...@@ -189,8 +186,7 @@ bool Serializer::ObjectIsBytecodeHandler(HeapObject obj) const { ...@@ -189,8 +186,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) {
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);
...@@ -204,12 +200,11 @@ void Serializer::PutRoot(RootIndex root, HeapObject object, ...@@ -204,12 +200,11 @@ void Serializer::PutRoot(RootIndex root, HeapObject object,
kNumberOfRootArrayConstants - 1); kNumberOfRootArrayConstants - 1);
// TODO(ulan): Check that it works with young large objects. // TODO(ulan): Check that it works with young large objects.
if (how_to_code == kPlain && where_to_point == kStartOfObject && if (how_to_code == kPlain && root_index < kNumberOfRootArrayConstants &&
root_index < kNumberOfRootArrayConstants &&
!Heap::InYoungGeneration(object)) { !Heap::InYoungGeneration(object)) {
sink_.Put(kRootArrayConstants + root_index, "RootConstant"); sink_.Put(kRootArrayConstants + root_index, "RootConstant");
} else { } else {
sink_.Put(kRootArray + how_to_code + where_to_point, "RootSerialization"); sink_.Put(kRootArray + how_to_code, "RootSerialization");
sink_.PutInt(root_index, "root_index"); sink_.PutInt(root_index, "root_index");
hot_objects_.Add(object); hot_objects_.Add(object);
} }
...@@ -245,13 +240,9 @@ void Serializer::PutBackReference(HeapObject object, ...@@ -245,13 +240,9 @@ void Serializer::PutBackReference(HeapObject object,
} }
void Serializer::PutAttachedReference(SerializerReference reference, void Serializer::PutAttachedReference(SerializerReference reference,
HowToCode how_to_code, HowToCode how_to_code) {
WhereToPoint where_to_point) {
DCHECK(reference.is_attached_reference()); DCHECK(reference.is_attached_reference());
DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) || sink_.Put(kAttachedReference + how_to_code, "AttachedRef");
(how_to_code == kFromCode && where_to_point == kStartOfObject) ||
(how_to_code == kFromCode && where_to_point == kInnerPointer));
sink_.Put(kAttachedReference + how_to_code + where_to_point, "AttachedRef");
sink_.PutInt(reference.attached_reference_index(), "AttachedRefIndex"); sink_.PutInt(reference.attached_reference_index(), "AttachedRefIndex");
} }
...@@ -349,7 +340,7 @@ void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space, ...@@ -349,7 +340,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); serializer_->SerializeObject(map, kPlain);
} }
int32_t Serializer::ObjectSerializer::SerializeBackingStore( int32_t Serializer::ObjectSerializer::SerializeBackingStore(
...@@ -708,7 +699,7 @@ void Serializer::ObjectSerializer::VisitPointers(HeapObject host, ...@@ -708,7 +699,7 @@ 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); serializer_->SerializeObject(current_contents, kPlain);
} }
} }
} }
...@@ -717,8 +708,7 @@ void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host, ...@@ -717,8 +708,7 @@ void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host,
RelocInfo* rinfo) { RelocInfo* rinfo) {
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);
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
...@@ -729,7 +719,7 @@ void Serializer::ObjectSerializer::VisitExternalReference(Foreign host, ...@@ -729,7 +719,7 @@ void Serializer::ObjectSerializer::VisitExternalReference(Foreign host,
if (encoded_reference.is_from_api()) { if (encoded_reference.is_from_api()) {
sink_->Put(kApiReference, "ApiRef"); sink_->Put(kApiReference, "ApiRef");
} else { } else {
sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); sink_->Put(kExternalReference + kPlain, "ExternalRef");
} }
sink_->PutInt(encoded_reference.index(), "reference index"); sink_->PutInt(encoded_reference.index(), "reference index");
bytes_processed_so_far_ += kSystemPointerSize; bytes_processed_so_far_ += kSystemPointerSize;
...@@ -744,8 +734,7 @@ void Serializer::ObjectSerializer::VisitExternalReference(Code host, ...@@ -744,8 +734,7 @@ void Serializer::ObjectSerializer::VisitExternalReference(Code host,
sink_->Put(kApiReference, "ApiRef"); sink_->Put(kApiReference, "ApiRef");
} else { } else {
HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
sink_->Put(kExternalReference + how_to_code + kStartOfObject, sink_->Put(kExternalReference + how_to_code, "ExternalRef");
"ExternalRef");
} }
DCHECK_NE(target, kNullAddress); // Code does not reference null. DCHECK_NE(target, kNullAddress); // Code does not reference null.
sink_->PutInt(encoded_reference.index(), "reference index"); sink_->PutInt(encoded_reference.index(), "reference index");
...@@ -803,7 +792,7 @@ void Serializer::ObjectSerializer::VisitCodeTarget(Code host, ...@@ -803,7 +792,7 @@ void Serializer::ObjectSerializer::VisitCodeTarget(Code host,
DCHECK(!RelocInfo::IsRelativeCodeTarget(rinfo->rmode())); DCHECK(!RelocInfo::IsRelativeCodeTarget(rinfo->rmode()));
#endif #endif
Code object = Code::GetCodeFromTargetAddress(rinfo->target_address()); Code object = Code::GetCodeFromTargetAddress(rinfo->target_address());
serializer_->SerializeObject(object, kFromCode, kInnerPointer); serializer_->SerializeObject(object, kFromCode);
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
......
...@@ -191,8 +191,7 @@ class Serializer : public SerializerDeserializer { ...@@ -191,8 +191,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) = 0;
WhereToPoint where_to_point) = 0;
virtual bool MustBeDeferred(HeapObject object); virtual bool MustBeDeferred(HeapObject object);
...@@ -200,28 +199,24 @@ class Serializer : public SerializerDeserializer { ...@@ -200,28 +199,24 @@ class Serializer : public SerializerDeserializer {
FullObjectSlot start, FullObjectSlot end) override; FullObjectSlot start, FullObjectSlot end) override;
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);
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,
HowToCode how_to_code, WhereToPoint where_to_point); HowToCode how_to_code);
// Emit alignment prefix if necessary, return required padding space in bytes. // Emit alignment prefix if necessary, return required padding space in bytes.
int PutAlignmentPrefix(HeapObject object); int PutAlignmentPrefix(HeapObject object);
void PutNextChunk(int space); void PutNextChunk(int space);
void PutRepeat(int repeat_count); void PutRepeat(int repeat_count);
// 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);
// 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);
// 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);
// 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;
...@@ -295,12 +290,11 @@ class RelocInfoIterator; ...@@ -295,12 +290,11 @@ class RelocInfoIterator;
class Serializer::ObjectSerializer : public ObjectVisitor { class Serializer::ObjectSerializer : public ObjectVisitor {
public: public:
ObjectSerializer(Serializer* serializer, HeapObject obj, ObjectSerializer(Serializer* serializer, HeapObject obj,
SnapshotByteSink* sink, HowToCode how_to_code, SnapshotByteSink* sink, HowToCode how_to_code)
WhereToPoint where_to_point)
: serializer_(serializer), : serializer_(serializer),
object_(obj), object_(obj),
sink_(sink), sink_(sink),
reference_representation_(how_to_code + where_to_point), reference_representation_(how_to_code),
bytes_processed_so_far_(0) { bytes_processed_so_far_(0) {
#ifdef DEBUG #ifdef DEBUG
serializer_->PushStack(obj); serializer_->PushStack(obj);
......
...@@ -69,19 +69,15 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) { ...@@ -69,19 +69,15 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) {
} // namespace } // namespace
#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) {
DCHECK(!obj->IsJSFunction()); DCHECK(!obj->IsJSFunction());
DCHECK(!IsUnexpectedCodeObject(isolate(), obj)); DCHECK(!IsUnexpectedCodeObject(isolate(), obj));
if (SerializeHotObject(obj, how_to_code, where_to_point)) return; if (SerializeHotObject(obj, how_to_code)) return;
if (IsRootAndHasBeenSerialized(obj) && if (IsRootAndHasBeenSerialized(obj) && SerializeRoot(obj, how_to_code))
SerializeRoot(obj, how_to_code, where_to_point))
return; return;
if (SerializeUsingReadOnlyObjectCache(&sink_, obj, how_to_code, if (SerializeUsingReadOnlyObjectCache(&sink_, obj, how_to_code)) return;
where_to_point)) if (SerializeBackReference(obj, how_to_code)) return;
return;
if (SerializeBackReference(obj, how_to_code, where_to_point)) return;
bool use_simulator = false; bool use_simulator = false;
#ifdef USE_SIMULATOR #ifdef USE_SIMULATOR
...@@ -116,8 +112,7 @@ void StartupSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code, ...@@ -116,8 +112,7 @@ void StartupSerializer::SerializeObject(HeapObject obj, HowToCode how_to_code,
// Object has not yet been serialized. Serialize it here. // Object has not yet been serialized. Serialize it here.
DCHECK(!isolate()->heap()->read_only_space()->Contains(obj)); DCHECK(!isolate()->heap()->read_only_space()->Contains(obj));
ObjectSerializer object_serializer(this, obj, &sink_, how_to_code, ObjectSerializer object_serializer(this, obj, &sink_, how_to_code);
where_to_point);
object_serializer.Serialize(); object_serializer.Serialize();
} }
...@@ -160,18 +155,15 @@ SerializedHandleChecker::SerializedHandleChecker(Isolate* isolate, ...@@ -160,18 +155,15 @@ 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) { return read_only_serializer_->SerializeUsingReadOnlyObjectCache(sink, obj,
return read_only_serializer_->SerializeUsingReadOnlyObjectCache( how_to_code);
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 cache_index = SerializeInObjectCache(obj); int cache_index = SerializeInObjectCache(obj);
sink->Put(kPartialSnapshotCache + how_to_code + where_to_point, sink->Put(kPartialSnapshotCache + how_to_code, "PartialSnapshotCache");
"PartialSnapshotCache");
sink->PutInt(cache_index, "partial_snapshot_cache_index"); sink->PutInt(cache_index, "partial_snapshot_cache_index");
} }
......
...@@ -34,18 +34,16 @@ class StartupSerializer : public RootsSerializer { ...@@ -34,18 +34,16 @@ class StartupSerializer : public RootsSerializer {
// ReadOnlyObjectCache bytecode into |sink|. Returns whether this was // ReadOnlyObjectCache bytecode into |sink|. Returns whether this was
// 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);
// 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,
WhereToPoint where_to_point); HowToCode how_to_code);
private: private:
void SerializeObject(HeapObject o, HowToCode how_to_code, void SerializeObject(HeapObject o, HowToCode how_to_code) 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