Commit aeb921c9 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[serializer] Remove unneeded destructor

... by replacing manual memory management with unique_ptrs.

Bug: v8:10416
Change-Id: Id3acb38192a5203bcb8c0f7eee774eacb934ef49
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2159492
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67334}
parent 5c61eb67
......@@ -27,29 +27,9 @@ Serializer::Serializer(Isolate* isolate)
#ifdef OBJECT_PRINT
if (FLAG_serialization_statistics) {
for (int space = 0; space < kNumberOfSpaces; ++space) {
instance_type_count_[space] = NewArray<int>(kInstanceTypes);
instance_type_size_[space] = NewArray<size_t>(kInstanceTypes);
for (int i = 0; i < kInstanceTypes; i++) {
instance_type_count_[space][i] = 0;
instance_type_size_[space][i] = 0;
}
}
} else {
for (int space = 0; space < kNumberOfSpaces; ++space) {
instance_type_count_[space] = nullptr;
instance_type_size_[space] = nullptr;
}
}
#endif // OBJECT_PRINT
}
Serializer::~Serializer() {
if (code_address_map_ != nullptr) delete code_address_map_;
#ifdef OBJECT_PRINT
for (int space = 0; space < kNumberOfSpaces; ++space) {
if (instance_type_count_[space] != nullptr) {
DeleteArray(instance_type_count_[space]);
DeleteArray(instance_type_size_[space]);
// Value-initialized to 0.
instance_type_count_[space] = std::make_unique<int[]>(kInstanceTypes);
instance_type_size_[space] = std::make_unique<size_t[]>(kInstanceTypes);
}
}
#endif // OBJECT_PRINT
......@@ -293,7 +273,7 @@ void Serializer::Pad(int padding_offset) {
void Serializer::InitializeCodeAddressMap() {
isolate_->InitializeLoggingAndCounters();
code_address_map_ = new CodeAddressMap(isolate_);
code_address_map_ = std::make_unique<CodeAddressMap>(isolate_);
}
Code Serializer::CopyCode(Code code) {
......
......@@ -159,7 +159,6 @@ class ObjectCacheIndexMap {
class Serializer : public SerializerDeserializer {
public:
explicit Serializer(Isolate* isolate);
~Serializer() override;
std::vector<SerializedData::Reservation> EncodeReservations() const {
return allocator_.EncodeReservations();
......@@ -266,16 +265,16 @@ class Serializer : public SerializerDeserializer {
SerializerReferenceMap reference_map_;
ExternalReferenceEncoder external_reference_encoder_;
RootIndexMap root_index_map_;
CodeAddressMap* code_address_map_ = nullptr;
std::unique_ptr<CodeAddressMap> code_address_map_;
std::vector<byte> code_buffer_;
std::vector<HeapObject> deferred_objects_; // To handle stack overflow.
int recursion_depth_ = 0;
SerializerAllocator allocator_;
#ifdef OBJECT_PRINT
static const int kInstanceTypes = LAST_TYPE + 1;
int* instance_type_count_[kNumberOfSpaces];
size_t* instance_type_size_[kNumberOfSpaces];
static constexpr int kInstanceTypes = LAST_TYPE + 1;
std::unique_ptr<int[]> instance_type_count_[kNumberOfSpaces];
std::unique_ptr<size_t[]> instance_type_size_[kNumberOfSpaces];
#endif // OBJECT_PRINT
#ifdef DEBUG
......
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