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

Side by Side Diff: src/snapshot/code-serializer.cc

Issue 2781993005: Protect SerializedData from copying. (Closed)
Patch Set: Use DISALLOW_COPY_AND_ASSIGN macro. 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.h ('k') | src/snapshot/serializer-common.h » ('j') | 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 #include "src/snapshot/code-serializer.h" 5 #include "src/snapshot/code-serializer.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const { 478 Vector<const uint32_t> SerializedCodeData::CodeStubKeys() const {
479 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size; 479 int reservations_size = GetHeaderValue(kNumReservationsOffset) * kInt32Size;
480 const byte* start = data_ + kHeaderSize + reservations_size; 480 const byte* start = data_ + kHeaderSize + reservations_size;
481 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start), 481 return Vector<const uint32_t>(reinterpret_cast<const uint32_t*>(start),
482 GetHeaderValue(kNumCodeStubKeysOffset)); 482 GetHeaderValue(kNumCodeStubKeysOffset));
483 } 483 }
484 484
485 SerializedCodeData::SerializedCodeData(ScriptData* data) 485 SerializedCodeData::SerializedCodeData(ScriptData* data)
486 : SerializedData(const_cast<byte*>(data->data()), data->length()) {} 486 : SerializedData(const_cast<byte*>(data->data()), data->length()) {}
487 487
488 const SerializedCodeData SerializedCodeData::FromCachedData( 488 SerializedCodeData SerializedCodeData::FromCachedData(
489 Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash, 489 Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash,
490 SanityCheckResult* rejection_result) { 490 SanityCheckResult* rejection_result) {
491 DisallowHeapAllocation no_gc; 491 DisallowHeapAllocation no_gc;
492 SerializedCodeData scd(cached_data); 492 SerializedCodeData scd(cached_data);
493 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); 493 *rejection_result = scd.SanityCheck(isolate, expected_source_hash);
494 if (*rejection_result != CHECK_SUCCESS) { 494 if (*rejection_result != CHECK_SUCCESS) {
495 cached_data->Reject(); 495 cached_data->Reject();
496 return SerializedCodeData(nullptr, 0); 496 return SerializedCodeData(nullptr, 0);
497 } 497 }
498 return scd; 498 return scd;
499 } 499 }
500 500
501 } // namespace internal 501 } // namespace internal
502 } // namespace v8 502 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | src/snapshot/serializer-common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698