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-external.cc

Issue 918213002: Protect access to the external_snapshot_blob global with a lock. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // Used for building with external snapshots. 5 // Used for building with external snapshots.
6 6
7 #include "src/snapshot.h" 7 #include "src/snapshot.h"
8 8
9 #include "src/base/platform/mutex.h"
9 #include "src/serialize.h" 10 #include "src/serialize.h"
10 #include "src/snapshot-source-sink.h" 11 #include "src/snapshot-source-sink.h"
11 #include "src/v8.h" // for V8::Initialize 12 #include "src/v8.h" // for V8::Initialize
12 13
13 14
14 #ifndef V8_USE_EXTERNAL_STARTUP_DATA 15 #ifndef V8_USE_EXTERNAL_STARTUP_DATA
15 #error snapshot-external.cc is used only for the external snapshot build. 16 #error snapshot-external.cc is used only for the external snapshot build.
16 #endif // V8_USE_EXTERNAL_STARTUP_DATA 17 #endif // V8_USE_EXTERNAL_STARTUP_DATA
17 18
18 19
19 namespace v8 { 20 namespace v8 {
20 namespace internal { 21 namespace internal {
21 22
23 static base::LazyMutex external_startup_data_mutex = LAZY_MUTEX_INITIALIZER;
22 static v8::StartupData external_startup_blob = {NULL, 0}; 24 static v8::StartupData external_startup_blob = {NULL, 0};
23 25
24 void SetSnapshotFromFile(StartupData* snapshot_blob) { 26 void SetSnapshotFromFile(StartupData* snapshot_blob) {
27 base::LockGuard<base::Mutex> lock_guard(
28 external_startup_data_mutex.Pointer());
25 DCHECK(snapshot_blob); 29 DCHECK(snapshot_blob);
26 DCHECK(snapshot_blob->data); 30 DCHECK(snapshot_blob->data);
27 DCHECK(snapshot_blob->raw_size > 0); 31 DCHECK(snapshot_blob->raw_size > 0);
28 DCHECK(!external_startup_blob.data); 32 DCHECK(!external_startup_blob.data);
29 DCHECK(Snapshot::SnapshotIsValid(snapshot_blob)); 33 DCHECK(Snapshot::SnapshotIsValid(snapshot_blob));
30 external_startup_blob = *snapshot_blob; 34 external_startup_blob = *snapshot_blob;
31 } 35 }
32 36
33 37
34 const v8::StartupData Snapshot::SnapshotBlob() { return external_startup_blob; } 38 const v8::StartupData Snapshot::SnapshotBlob() {
39 base::LockGuard<base::Mutex> lock_guard(
40 external_startup_data_mutex.Pointer());
41 return external_startup_blob;
42 }
35 } } // namespace v8::internal 43 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698