diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index 9cae031877..48813f5c61 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -485,7 +485,7 @@ Vector SerializedCodeData::CodeStubKeys() const { SerializedCodeData::SerializedCodeData(ScriptData* data) : SerializedData(const_cast(data->data()), data->length()) {} -const SerializedCodeData SerializedCodeData::FromCachedData( +SerializedCodeData SerializedCodeData::FromCachedData( Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash, SanityCheckResult* rejection_result) { DisallowHeapAllocation no_gc; diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h index 52e4daaf99..38112cd926 100644 --- a/src/snapshot/code-serializer.h +++ b/src/snapshot/code-serializer.h @@ -116,9 +116,10 @@ class SerializedCodeData : public SerializedData { static const int kHeaderSize = POINTER_SIZE_ALIGN(kUnalignedHeaderSize); // Used when consuming. - static const SerializedCodeData FromCachedData( - Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash, - SanityCheckResult* rejection_result); + static SerializedCodeData FromCachedData(Isolate* isolate, + ScriptData* cached_data, + uint32_t expected_source_hash, + SanityCheckResult* rejection_result); // Used when producing. SerializedCodeData(const List* payload, const CodeSerializer* cs); diff --git a/src/snapshot/serializer-common.h b/src/snapshot/serializer-common.h index 02f97628b5..550fd38339 100644 --- a/src/snapshot/serializer-common.h +++ b/src/snapshot/serializer-common.h @@ -239,6 +239,11 @@ class SerializedData { SerializedData(byte* data, int size) : data_(data), size_(size), owns_data_(false) {} SerializedData() : data_(NULL), size_(0), owns_data_(false) {} + SerializedData(SerializedData&& other) + : data_(other.data_), size_(other.size_), owns_data_(other.owns_data_) { + // Ensure |other| will not attempt to destroy our data in destructor. + other.owns_data_ = false; + } ~SerializedData() { if (owns_data_) DeleteArray(data_); @@ -295,6 +300,9 @@ class SerializedData { byte* data_; int size_; bool owns_data_; + + private: + DISALLOW_COPY_AND_ASSIGN(SerializedData); }; } // namespace internal