Index: src/snapshot-external.cc |
diff --git a/src/snapshot-external.cc b/src/snapshot-external.cc |
index f26a5a1c18dba7a2b43410e352778a1bf179d4b5..a9a5df1cd7c2a04f2c40a760c79ffb89a2b3742a 100644 |
--- a/src/snapshot-external.cc |
+++ b/src/snapshot-external.cc |
@@ -6,6 +6,7 @@ |
#include "src/snapshot.h" |
+#include "src/base/platform/mutex.h" |
#include "src/serialize.h" |
#include "src/snapshot-source-sink.h" |
#include "src/v8.h" // for V8::Initialize |
@@ -19,9 +20,12 @@ |
namespace v8 { |
namespace internal { |
+static base::LazyMutex external_startup_data_mutex = LAZY_MUTEX_INITIALIZER; |
static v8::StartupData external_startup_blob = {NULL, 0}; |
void SetSnapshotFromFile(StartupData* snapshot_blob) { |
+ base::LockGuard<base::Mutex> lock_guard( |
+ external_startup_data_mutex.Pointer()); |
DCHECK(snapshot_blob); |
DCHECK(snapshot_blob->data); |
DCHECK(snapshot_blob->raw_size > 0); |
@@ -31,5 +35,9 @@ void SetSnapshotFromFile(StartupData* snapshot_blob) { |
} |
-const v8::StartupData Snapshot::SnapshotBlob() { return external_startup_blob; } |
+const v8::StartupData Snapshot::SnapshotBlob() { |
+ base::LockGuard<base::Mutex> lock_guard( |
+ external_startup_data_mutex.Pointer()); |
+ return external_startup_blob; |
+} |
} } // namespace v8::internal |