[snapshot] Rename allocators
There's only one allocator kind left post-builtin-snapshot-removal, so the 'Default' prefix can be removed. Bug: v8:6666, v8:7990 Change-Id: Ib3c3eeb121792708591ca7be1e30adef77d3c111 Reviewed-on: https://chromium-review.googlesource.com/c/1309638 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#57236}
This commit is contained in:
parent
23b4892060
commit
166e74d581
8
BUILD.gn
8
BUILD.gn
@ -2477,10 +2477,8 @@ v8_source_set("v8_base") {
|
||||
"src/simulator.h",
|
||||
"src/snapshot/code-serializer.cc",
|
||||
"src/snapshot/code-serializer.h",
|
||||
"src/snapshot/default-deserializer-allocator.cc",
|
||||
"src/snapshot/default-deserializer-allocator.h",
|
||||
"src/snapshot/default-serializer-allocator.cc",
|
||||
"src/snapshot/default-serializer-allocator.h",
|
||||
"src/snapshot/deserializer-allocator.cc",
|
||||
"src/snapshot/deserializer-allocator.h",
|
||||
"src/snapshot/deserializer.cc",
|
||||
"src/snapshot/deserializer.h",
|
||||
"src/snapshot/macros.h",
|
||||
@ -2499,6 +2497,8 @@ v8_source_set("v8_base") {
|
||||
"src/snapshot/references.h",
|
||||
"src/snapshot/roots-serializer.cc",
|
||||
"src/snapshot/roots-serializer.h",
|
||||
"src/snapshot/serializer-allocator.cc",
|
||||
"src/snapshot/serializer-allocator.h",
|
||||
"src/snapshot/serializer-common.cc",
|
||||
"src/snapshot/serializer-common.h",
|
||||
"src/snapshot/serializer.cc",
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/snapshot/default-deserializer-allocator.h"
|
||||
#include "src/snapshot/deserializer-allocator.h"
|
||||
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/snapshot/deserializer.h"
|
||||
@ -11,8 +11,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
DefaultDeserializerAllocator::DefaultDeserializerAllocator(
|
||||
Deserializer* deserializer)
|
||||
DeserializerAllocator::DeserializerAllocator(Deserializer* deserializer)
|
||||
: deserializer_(deserializer) {}
|
||||
|
||||
// We know the space requirements before deserialization and can
|
||||
@ -26,8 +25,7 @@ DefaultDeserializerAllocator::DefaultDeserializerAllocator(
|
||||
// space allocation, we have to do an actual allocation when deserializing
|
||||
// each large object. Instead of tracking offset for back references, we
|
||||
// reference large objects by index.
|
||||
Address DefaultDeserializerAllocator::AllocateRaw(AllocationSpace space,
|
||||
int size) {
|
||||
Address DeserializerAllocator::AllocateRaw(AllocationSpace space, int size) {
|
||||
if (space == LO_SPACE) {
|
||||
AlwaysAllocateScope scope(isolate());
|
||||
LargeObjectSpace* lo_space = isolate()->heap()->lo_space();
|
||||
@ -57,8 +55,7 @@ Address DefaultDeserializerAllocator::AllocateRaw(AllocationSpace space,
|
||||
}
|
||||
}
|
||||
|
||||
Address DefaultDeserializerAllocator::Allocate(AllocationSpace space,
|
||||
int size) {
|
||||
Address DeserializerAllocator::Allocate(AllocationSpace space, int size) {
|
||||
Address address;
|
||||
HeapObject* obj;
|
||||
|
||||
@ -82,7 +79,7 @@ Address DefaultDeserializerAllocator::Allocate(AllocationSpace space,
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultDeserializerAllocator::MoveToNextChunk(AllocationSpace space) {
|
||||
void DeserializerAllocator::MoveToNextChunk(AllocationSpace space) {
|
||||
DCHECK_LT(space, kNumberOfPreallocatedSpaces);
|
||||
uint32_t chunk_index = current_chunk_[space];
|
||||
const Heap::Reservation& reservation = reservations_[space];
|
||||
@ -94,19 +91,19 @@ void DefaultDeserializerAllocator::MoveToNextChunk(AllocationSpace space) {
|
||||
high_water_[space] = reservation[chunk_index].start;
|
||||
}
|
||||
|
||||
HeapObject* DefaultDeserializerAllocator::GetMap(uint32_t index) {
|
||||
HeapObject* DeserializerAllocator::GetMap(uint32_t index) {
|
||||
DCHECK_LT(index, next_map_index_);
|
||||
return HeapObject::FromAddress(allocated_maps_[index]);
|
||||
}
|
||||
|
||||
HeapObject* DefaultDeserializerAllocator::GetLargeObject(uint32_t index) {
|
||||
HeapObject* DeserializerAllocator::GetLargeObject(uint32_t index) {
|
||||
DCHECK_LT(index, deserialized_large_objects_.size());
|
||||
return deserialized_large_objects_[index];
|
||||
}
|
||||
|
||||
HeapObject* DefaultDeserializerAllocator::GetObject(AllocationSpace space,
|
||||
uint32_t chunk_index,
|
||||
uint32_t chunk_offset) {
|
||||
HeapObject* DeserializerAllocator::GetObject(AllocationSpace space,
|
||||
uint32_t chunk_index,
|
||||
uint32_t chunk_offset) {
|
||||
DCHECK_LT(space, kNumberOfPreallocatedSpaces);
|
||||
DCHECK_LE(chunk_index, current_chunk_[space]);
|
||||
Address address = reservations_[space][chunk_index].start + chunk_offset;
|
||||
@ -119,7 +116,7 @@ HeapObject* DefaultDeserializerAllocator::GetObject(AllocationSpace space,
|
||||
return HeapObject::FromAddress(address);
|
||||
}
|
||||
|
||||
void DefaultDeserializerAllocator::DecodeReservation(
|
||||
void DeserializerAllocator::DecodeReservation(
|
||||
const std::vector<SerializedData::Reservation>& res) {
|
||||
DCHECK_EQ(0, reservations_[FIRST_SPACE].size());
|
||||
int current_space = FIRST_SPACE;
|
||||
@ -132,7 +129,7 @@ void DefaultDeserializerAllocator::DecodeReservation(
|
||||
for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) current_chunk_[i] = 0;
|
||||
}
|
||||
|
||||
bool DefaultDeserializerAllocator::ReserveSpace() {
|
||||
bool DeserializerAllocator::ReserveSpace() {
|
||||
#ifdef DEBUG
|
||||
for (int i = FIRST_SPACE; i < kNumberOfSpaces; ++i) {
|
||||
DCHECK_GT(reservations_[i].size(), 0);
|
||||
@ -148,7 +145,7 @@ bool DefaultDeserializerAllocator::ReserveSpace() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefaultDeserializerAllocator::ReservationsAreFullyUsed() const {
|
||||
bool DeserializerAllocator::ReservationsAreFullyUsed() const {
|
||||
for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) {
|
||||
const uint32_t chunk_index = current_chunk_[space];
|
||||
if (reservations_[space].size() != chunk_index + 1) {
|
||||
@ -161,13 +158,12 @@ bool DefaultDeserializerAllocator::ReservationsAreFullyUsed() const {
|
||||
return (allocated_maps_.size() == next_map_index_);
|
||||
}
|
||||
|
||||
void DefaultDeserializerAllocator::
|
||||
RegisterDeserializedObjectsForBlackAllocation() {
|
||||
void DeserializerAllocator::RegisterDeserializedObjectsForBlackAllocation() {
|
||||
isolate()->heap()->RegisterDeserializedObjectsForBlackAllocation(
|
||||
reservations_, deserialized_large_objects_, allocated_maps_);
|
||||
}
|
||||
|
||||
Isolate* DefaultDeserializerAllocator::isolate() const {
|
||||
Isolate* DeserializerAllocator::isolate() const {
|
||||
return deserializer_->isolate();
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_SNAPSHOT_DEFAULT_DESERIALIZER_ALLOCATOR_H_
|
||||
#define V8_SNAPSHOT_DEFAULT_DESERIALIZER_ALLOCATOR_H_
|
||||
#ifndef V8_SNAPSHOT_DESERIALIZER_ALLOCATOR_H_
|
||||
#define V8_SNAPSHOT_DESERIALIZER_ALLOCATOR_H_
|
||||
|
||||
#include "src/globals.h"
|
||||
#include "src/heap/heap.h"
|
||||
@ -15,9 +15,9 @@ namespace internal {
|
||||
class Deserializer;
|
||||
class StartupDeserializer;
|
||||
|
||||
class DefaultDeserializerAllocator final {
|
||||
class DeserializerAllocator final {
|
||||
public:
|
||||
explicit DefaultDeserializerAllocator(Deserializer* deserializer);
|
||||
explicit DeserializerAllocator(Deserializer* deserializer);
|
||||
|
||||
// ------- Allocation Methods -------
|
||||
// Methods related to memory allocation during deserialization.
|
||||
@ -99,10 +99,10 @@ class DefaultDeserializerAllocator final {
|
||||
// The current deserializer.
|
||||
Deserializer* const deserializer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DefaultDeserializerAllocator)
|
||||
DISALLOW_COPY_AND_ASSIGN(DeserializerAllocator)
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_SNAPSHOT_DEFAULT_DESERIALIZER_ALLOCATOR_H_
|
||||
#endif // V8_SNAPSHOT_DESERIALIZER_ALLOCATOR_H_
|
@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "src/objects/js-array.h"
|
||||
#include "src/snapshot/default-deserializer-allocator.h"
|
||||
#include "src/snapshot/deserializer-allocator.h"
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
#include "src/snapshot/snapshot-source-sink.h"
|
||||
|
||||
@ -88,7 +88,7 @@ class Deserializer : public SerializerDeserializer {
|
||||
return new_scripts_;
|
||||
}
|
||||
|
||||
DefaultDeserializerAllocator* allocator() { return &allocator_; }
|
||||
DeserializerAllocator* allocator() { return &allocator_; }
|
||||
bool deserializing_user_code() const { return deserializing_user_code_; }
|
||||
bool can_rehash() const { return can_rehash_; }
|
||||
|
||||
@ -148,7 +148,7 @@ class Deserializer : public SerializerDeserializer {
|
||||
std::vector<Handle<Script>> new_scripts_;
|
||||
std::vector<byte*> off_heap_backing_stores_;
|
||||
|
||||
DefaultDeserializerAllocator allocator_;
|
||||
DeserializerAllocator allocator_;
|
||||
const bool deserializing_user_code_;
|
||||
|
||||
// TODO(6593): generalize rehashing, and remove this flag.
|
||||
@ -160,7 +160,7 @@ class Deserializer : public SerializerDeserializer {
|
||||
#endif // DEBUG
|
||||
|
||||
// For source(), isolate(), and allocator().
|
||||
friend class DefaultDeserializerAllocator;
|
||||
friend class DeserializerAllocator;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Deserializer);
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/snapshot/default-serializer-allocator.h"
|
||||
#include "src/snapshot/serializer-allocator.h"
|
||||
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/snapshot/references.h"
|
||||
@ -12,14 +12,14 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
DefaultSerializerAllocator::DefaultSerializerAllocator(Serializer* serializer)
|
||||
SerializerAllocator::SerializerAllocator(Serializer* serializer)
|
||||
: serializer_(serializer) {
|
||||
for (int i = 0; i < kNumberOfPreallocatedSpaces; i++) {
|
||||
pending_chunk_[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DefaultSerializerAllocator::UseCustomChunkSize(uint32_t chunk_size) {
|
||||
void SerializerAllocator::UseCustomChunkSize(uint32_t chunk_size) {
|
||||
custom_chunk_size_ = chunk_size;
|
||||
}
|
||||
|
||||
@ -29,14 +29,14 @@ static uint32_t PageSizeOfSpace(int space) {
|
||||
static_cast<AllocationSpace>(space)));
|
||||
}
|
||||
|
||||
uint32_t DefaultSerializerAllocator::TargetChunkSize(int space) {
|
||||
uint32_t SerializerAllocator::TargetChunkSize(int space) {
|
||||
if (custom_chunk_size_ == 0) return PageSizeOfSpace(space);
|
||||
DCHECK_LE(custom_chunk_size_, PageSizeOfSpace(space));
|
||||
return custom_chunk_size_;
|
||||
}
|
||||
|
||||
SerializerReference DefaultSerializerAllocator::Allocate(AllocationSpace space,
|
||||
uint32_t size) {
|
||||
SerializerReference SerializerAllocator::Allocate(AllocationSpace space,
|
||||
uint32_t size) {
|
||||
DCHECK(space >= 0 && space < kNumberOfPreallocatedSpaces);
|
||||
DCHECK(size > 0 && size <= PageSizeOfSpace(space));
|
||||
|
||||
@ -59,27 +59,26 @@ SerializerReference DefaultSerializerAllocator::Allocate(AllocationSpace space,
|
||||
space, static_cast<uint32_t>(completed_chunks_[space].size()), offset);
|
||||
}
|
||||
|
||||
SerializerReference DefaultSerializerAllocator::AllocateMap() {
|
||||
SerializerReference SerializerAllocator::AllocateMap() {
|
||||
// Maps are allocated one-by-one when deserializing.
|
||||
return SerializerReference::MapReference(num_maps_++);
|
||||
}
|
||||
|
||||
SerializerReference DefaultSerializerAllocator::AllocateLargeObject(
|
||||
uint32_t size) {
|
||||
SerializerReference SerializerAllocator::AllocateLargeObject(uint32_t size) {
|
||||
// Large objects are allocated one-by-one when deserializing. We do not
|
||||
// have to keep track of multiple chunks.
|
||||
large_objects_total_size_ += size;
|
||||
return SerializerReference::LargeObjectReference(seen_large_objects_index_++);
|
||||
}
|
||||
|
||||
SerializerReference DefaultSerializerAllocator::AllocateOffHeapBackingStore() {
|
||||
SerializerReference SerializerAllocator::AllocateOffHeapBackingStore() {
|
||||
DCHECK_NE(0, seen_backing_stores_index_);
|
||||
return SerializerReference::OffHeapBackingStoreReference(
|
||||
seen_backing_stores_index_++);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool DefaultSerializerAllocator::BackReferenceIsAlreadyAllocated(
|
||||
bool SerializerAllocator::BackReferenceIsAlreadyAllocated(
|
||||
SerializerReference reference) const {
|
||||
DCHECK(reference.is_back_reference());
|
||||
AllocationSpace space = reference.space();
|
||||
@ -105,7 +104,7 @@ bool DefaultSerializerAllocator::BackReferenceIsAlreadyAllocated(
|
||||
#endif
|
||||
|
||||
std::vector<SerializedData::Reservation>
|
||||
DefaultSerializerAllocator::EncodeReservations() const {
|
||||
SerializerAllocator::EncodeReservations() const {
|
||||
std::vector<SerializedData::Reservation> out;
|
||||
|
||||
for (int i = FIRST_SPACE; i < kNumberOfPreallocatedSpaces; i++) {
|
||||
@ -130,7 +129,7 @@ DefaultSerializerAllocator::EncodeReservations() const {
|
||||
return out;
|
||||
}
|
||||
|
||||
void DefaultSerializerAllocator::OutputStatistics() {
|
||||
void SerializerAllocator::OutputStatistics() {
|
||||
DCHECK(FLAG_serialization_statistics);
|
||||
|
||||
PrintF(" Spaces (bytes):\n");
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_SNAPSHOT_DEFAULT_SERIALIZER_ALLOCATOR_H_
|
||||
#define V8_SNAPSHOT_DEFAULT_SERIALIZER_ALLOCATOR_H_
|
||||
#ifndef V8_SNAPSHOT_SERIALIZER_ALLOCATOR_H_
|
||||
#define V8_SNAPSHOT_SERIALIZER_ALLOCATOR_H_
|
||||
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
|
||||
@ -12,9 +12,9 @@ namespace internal {
|
||||
|
||||
class Serializer;
|
||||
|
||||
class DefaultSerializerAllocator final {
|
||||
class SerializerAllocator final {
|
||||
public:
|
||||
explicit DefaultSerializerAllocator(Serializer* serializer);
|
||||
explicit SerializerAllocator(Serializer* serializer);
|
||||
|
||||
SerializerReference Allocate(AllocationSpace space, uint32_t size);
|
||||
SerializerReference AllocateMap();
|
||||
@ -68,10 +68,10 @@ class DefaultSerializerAllocator final {
|
||||
// The current serializer.
|
||||
Serializer* const serializer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DefaultSerializerAllocator)
|
||||
DISALLOW_COPY_AND_ASSIGN(SerializerAllocator)
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_SNAPSHOT_DEFAULT_SERIALIZER_ALLOCATOR_H_
|
||||
#endif // V8_SNAPSHOT_SERIALIZER_ALLOCATOR_H_
|
@ -11,7 +11,7 @@
|
||||
#include "src/isolate.h"
|
||||
#include "src/log.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/snapshot/default-serializer-allocator.h"
|
||||
#include "src/snapshot/serializer-allocator.h"
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
#include "src/snapshot/snapshot-source-sink.h"
|
||||
|
||||
@ -265,7 +265,7 @@ class Serializer : public SerializerDeserializer {
|
||||
|
||||
SerializerReferenceMap* reference_map() { return &reference_map_; }
|
||||
const RootIndexMap* root_index_map() const { return &root_index_map_; }
|
||||
DefaultSerializerAllocator* allocator() { return &allocator_; }
|
||||
SerializerAllocator* allocator() { return &allocator_; }
|
||||
|
||||
SnapshotByteSink sink_; // Used directly by subclasses.
|
||||
|
||||
@ -278,7 +278,7 @@ class Serializer : public SerializerDeserializer {
|
||||
std::vector<byte> code_buffer_;
|
||||
std::vector<HeapObject*> deferred_objects_; // To handle stack overflow.
|
||||
int recursion_depth_ = 0;
|
||||
DefaultSerializerAllocator allocator_;
|
||||
SerializerAllocator allocator_;
|
||||
|
||||
#ifdef OBJECT_PRINT
|
||||
static const int kInstanceTypes = LAST_TYPE + 1;
|
||||
@ -290,7 +290,7 @@ class Serializer : public SerializerDeserializer {
|
||||
std::vector<HeapObject*> stack_;
|
||||
#endif // DEBUG
|
||||
|
||||
friend class DefaultSerializerAllocator;
|
||||
friend class SerializerAllocator;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Serializer);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user