Commit b6912850 authored by vchigrin's avatar vchigrin Committed by Commit bot

Protect SerializedData from copying.

Compiler-generated copy constructor does not generate
correct code for this class, so make it move-only type.

Review-Url: https://codereview.chromium.org/2781993005
Cr-Commit-Position: refs/heads/master@{#44266}
parent d389d473
......@@ -485,7 +485,7 @@ Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const {
SerializedCodeData::SerializedCodeData(ScriptData* data)
: SerializedData(const_cast<byte*>(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;
......
......@@ -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<byte>* payload, const CodeSerializer* cs);
......
......@@ -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<byte>(data_);
......@@ -295,6 +300,9 @@ class SerializedData {
byte* data_;
int size_;
bool owns_data_;
private:
DISALLOW_COPY_AND_ASSIGN(SerializedData);
};
} // namespace internal
......
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