[snapshot] Clean up builtin serializer allocater

Recent changes in SerializerReferences (see https://crrev.com/c/1113930)
opened up these minor improvements to the builtin serializer allocator,
since we now have dedicated BuiltinReferences.

R=yangguo@chromium.org

Bug: v8:7887
Change-Id: Ie76a52a88ef4075c63c5eb2eaa81382c52325688
Reviewed-on: https://chromium-review.googlesource.com/1125844
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54207}
This commit is contained in:
jgruber 2018-07-04 12:56:27 +02:00 committed by Commit Bot
parent a5332b493c
commit 8956128a1a
3 changed files with 9 additions and 10 deletions

View File

@ -18,10 +18,11 @@ SerializerReference BuiltinSerializerAllocator::Allocate(AllocationSpace space,
// system. Instead of worrying about chunk indices and offsets, we simply
// need to generate unique offsets here.
const auto ref = SerializerReference::BuiltinReference(virtual_chunk_offset_);
const auto ref =
SerializerReference::BuiltinReference(next_builtin_reference_index_);
virtual_chunk_size_ += size;
virtual_chunk_offset_ += kObjectAlignment; // Needs to be aligned.
allocated_bytes_ += size;
next_builtin_reference_index_++;
return ref;
}
@ -30,7 +31,7 @@ SerializerReference BuiltinSerializerAllocator::Allocate(AllocationSpace space,
bool BuiltinSerializerAllocator::BackReferenceIsAlreadyAllocated(
SerializerReference reference) const {
DCHECK(reference.is_builtin_reference());
return reference.builtin_offset() < virtual_chunk_offset_;
return reference.builtin_index() < next_builtin_reference_index_;
}
#endif // DEBUG
@ -50,7 +51,7 @@ void BuiltinSerializerAllocator::OutputStatistics() {
PrintF("\n");
for (int space = FIRST_SPACE; space < kNumberOfSpaces; space++) {
uint32_t space_size = (space == CODE_SPACE) ? virtual_chunk_size_ : 0;
uint32_t space_size = (space == CODE_SPACE) ? allocated_bytes_ : 0;
PrintF("%16d", space_size);
}
PrintF("\n");

View File

@ -38,10 +38,8 @@ class BuiltinSerializerAllocator final {
static constexpr int kNumberOfSpaces =
SerializerDeserializer::kNumberOfSpaces;
// We need to track a faked offset to create back-references. The size is
// kept simply to display statistics.
uint32_t virtual_chunk_size_ = 0;
uint32_t virtual_chunk_offset_ = 0;
uint32_t allocated_bytes_ = 0;
uint32_t next_builtin_reference_index_ = 0;
DISALLOW_COPY_AND_ASSIGN(BuiltinSerializerAllocator)
};

View File

@ -131,7 +131,7 @@ class SerializerReference {
SpecialValueTypeBits::decode(bitfield_) == kBuiltinReference;
}
uint32_t builtin_offset() const {
uint32_t builtin_index() const {
DCHECK(is_builtin_reference());
return value_;
}