OLD | NEW |
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 Loading... |
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 |
247 uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); } | 252 uint32_t GetMagicNumber() const { return GetHeaderValue(kMagicNumberOffset); } |
248 uint32_t GetExtraReferences() const { | 253 uint32_t GetExtraReferences() const { |
249 return GetHeaderValue(kExtraExternalReferencesOffset); | 254 return GetHeaderValue(kExtraExternalReferencesOffset); |
250 } | 255 } |
251 | 256 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 293 } |
289 | 294 |
290 void SetMagicNumber(Isolate* isolate) { | 295 void SetMagicNumber(Isolate* isolate) { |
291 SetHeaderValue(kMagicNumberOffset, ComputeMagicNumber(isolate)); | 296 SetHeaderValue(kMagicNumberOffset, ComputeMagicNumber(isolate)); |
292 SetHeaderValue(kExtraExternalReferencesOffset, GetExtraReferences(isolate)); | 297 SetHeaderValue(kExtraExternalReferencesOffset, GetExtraReferences(isolate)); |
293 } | 298 } |
294 | 299 |
295 byte* data_; | 300 byte* data_; |
296 int size_; | 301 int size_; |
297 bool owns_data_; | 302 bool owns_data_; |
| 303 |
| 304 private: |
| 305 DISALLOW_COPY_AND_ASSIGN(SerializedData); |
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_ |
OLD | NEW |