Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: src/snapshot/serializer-common.h

Issue 2781993005: Protect SerializedData from copying. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/code-serializer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_ 5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_
6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ 6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_
7 7
8 #include "src/address-map.h" 8 #include "src/address-map.h"
9 #include "src/external-reference-table.h" 9 #include "src/external-reference-table.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 void mark_as_last() { reservation_ |= IsLastChunkBits::encode(true); } 233 void mark_as_last() { reservation_ |= IsLastChunkBits::encode(true); }
234 234
235 private: 235 private:
236 uint32_t reservation_; 236 uint32_t reservation_;
237 }; 237 };
238 238
239 SerializedData(byte* data, int size) 239 SerializedData(byte* data, int size)
240 : data_(data), size_(size), owns_data_(false) {} 240 : data_(data), size_(size), owns_data_(false) {}
241 SerializedData() : data_(NULL), size_(0), owns_data_(false) {} 241 SerializedData() : data_(NULL), size_(0), owns_data_(false) {}
242 SerializedData(SerializedData&& other)
243 : data_(other.data_), size_(other.size_), owns_data_(other.owns_data_) {
244 // Ensure |other| will not attempt to destroy our data in destructor.
245 other.owns_data_ = false;
246 }
242 247
243 ~SerializedData() { 248 ~SerializedData() {
244 if (owns_data_) DeleteArray<byte>(data_); 249 if (owns_data_) DeleteArray<byte>(data_);
245 } 250 }
246 251
252 SerializedData(const SerializedData&) = delete;
253 const SerializedData& operator=(const SerializedData&) = delete;
254
Yang 2017/03/29 17:06:59 We have a macro called DISALLOW_COPY_AND_ASSIGN or
Slava Chigrin 2017/03/30 09:40:06 Done. Thanks - didn't notice that V8 also have thi
247 uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); } 255 uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); }
248 uint32_t GetExtraReferences() const { 256 uint32_t GetExtraReferences() const {
249 return GetHeaderValue(kExtraExternalReferencesOffset); 257 return GetHeaderValue(kExtraExternalReferencesOffset);
250 } 258 }
251 259
252 class ChunkSizeBits : public BitField<uint32_t, 0, 31> {}; 260 class ChunkSizeBits : public BitField<uint32_t, 0, 31> {};
253 class IsLastChunkBits : public BitField<bool, 31, 1> {}; 261 class IsLastChunkBits : public BitField<bool, 31, 1> {};
254 262
255 static uint32_t ComputeMagicNumber(ExternalReferenceTable* table) { 263 static uint32_t ComputeMagicNumber(ExternalReferenceTable* table) {
256 uint32_t external_refs = table->size() - table->num_api_references(); 264 uint32_t external_refs = table->size() - table->num_api_references();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 302
295 byte* data_; 303 byte* data_;
296 int size_; 304 int size_;
297 bool owns_data_; 305 bool owns_data_;
298 }; 306 };
299 307
300 } // namespace internal 308 } // namespace internal
301 } // namespace v8 309 } // namespace v8
302 310
303 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ 311 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_
OLDNEW
« no previous file with comments | « src/snapshot/code-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698