Commit 13f77247 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[snapshot][cleanup] Simplify Deserializer::ReadObject()

Bug: v8:8794, v8:8562
Change-Id: I199b60150437c3a475a25c49c708058cd1371a1d
Reviewed-on: https://chromium-review.googlesource.com/c/1456038
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59410}
parent ea865094
...@@ -373,12 +373,7 @@ HeapObject Deserializer::GetBackReferencedObject(int space) { ...@@ -373,12 +373,7 @@ HeapObject Deserializer::GetBackReferencedObject(int space) {
return obj; return obj;
} }
// This routine writes the new object into the pointer provided. HeapObject Deserializer::ReadObject(int space_number) {
// The reason for this strange interface is that otherwise the object is
// written very late, which means the FreeSpace map is not set up by the
// time we need to use it to mark the space at the end of a page free.
void Deserializer::ReadObject(int space_number, UnalignedSlot write_back,
HeapObjectReferenceType reference_type) {
const int size = source_.GetInt() << kObjectAlignmentBits; const int size = source_.GetInt() << kObjectAlignmentBits;
Address address = Address address =
...@@ -394,10 +389,6 @@ void Deserializer::ReadObject(int space_number, UnalignedSlot write_back, ...@@ -394,10 +389,6 @@ void Deserializer::ReadObject(int space_number, UnalignedSlot write_back,
obj = PostProcessNewObject(obj, space_number); obj = PostProcessNewObject(obj, space_number);
} }
MaybeObject write_back_obj = reference_type == HeapObjectReferenceType::STRONG
? HeapObjectReference::Strong(obj)
: HeapObjectReference::Weak(obj);
UnalignedCopy(write_back, write_back_obj);
#ifdef DEBUG #ifdef DEBUG
if (obj->IsCode()) { if (obj->IsCode()) {
DCHECK(space_number == CODE_SPACE || space_number == CODE_LO_SPACE); DCHECK(space_number == CODE_SPACE || space_number == CODE_LO_SPACE);
...@@ -405,6 +396,7 @@ void Deserializer::ReadObject(int space_number, UnalignedSlot write_back, ...@@ -405,6 +396,7 @@ void Deserializer::ReadObject(int space_number, UnalignedSlot write_back,
DCHECK(space_number != CODE_SPACE && space_number != CODE_LO_SPACE); DCHECK(space_number != CODE_SPACE && space_number != CODE_LO_SPACE);
} }
#endif // DEBUG #endif // DEBUG
return obj;
} }
UnalignedSlot Deserializer::ReadRepeatedObject(UnalignedSlot current, UnalignedSlot Deserializer::ReadRepeatedObject(UnalignedSlot current,
...@@ -836,13 +828,17 @@ UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate, ...@@ -836,13 +828,17 @@ UnalignedSlot Deserializer::ReadDataCase(Isolate* isolate,
if (allocator()->GetAndClearNextReferenceIsWeak()) { if (allocator()->GetAndClearNextReferenceIsWeak()) {
reference_type = HeapObjectReferenceType::WEAK; reference_type = HeapObjectReferenceType::WEAK;
} }
ReadObject(space_number, current, reference_type); HeapObject heap_object = ReadObject(space_number);
HeapObjectReference heap_object_ref =
reference_type == HeapObjectReferenceType::STRONG
? HeapObjectReference::Strong(heap_object)
: HeapObjectReference::Weak(heap_object);
UnalignedCopy(current, heap_object_ref);
emit_write_barrier = (space_number == NEW_SPACE); emit_write_barrier = (space_number == NEW_SPACE);
} else { } else {
Object new_object; /* May not be a real Object pointer. */ Object new_object; /* May not be a real Object pointer. */
if (where == kNewObject) { if (where == kNewObject) {
ReadObject(space_number, UnalignedSlot(&new_object), new_object = ReadObject(space_number);
HeapObjectReferenceType::STRONG);
} else if (where == kBackref) { } else if (where == kBackref) {
emit_write_barrier = (space_number == NEW_SPACE); emit_write_barrier = (space_number == NEW_SPACE);
new_object = GetBackReferencedObject(data & kSpaceMask); new_object = GetBackReferencedObject(data & kSpaceMask);
......
...@@ -136,8 +136,7 @@ class Deserializer : public SerializerDeserializer { ...@@ -136,8 +136,7 @@ class Deserializer : public SerializerDeserializer {
inline UnalignedSlot ReadExternalReferenceCase( inline UnalignedSlot ReadExternalReferenceCase(
HowToCode how, UnalignedSlot current, Address current_object_address); HowToCode how, UnalignedSlot current, Address current_object_address);
void ReadObject(int space_number, UnalignedSlot write_back, HeapObject ReadObject(int space_number);
HeapObjectReferenceType reference_type);
UnalignedSlot ReadRepeatedObject(UnalignedSlot current, int repeat_count); UnalignedSlot ReadRepeatedObject(UnalignedSlot current, int repeat_count);
......
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