7 #include "src/snapshot/snapshot.h" 9 #include "src/base/platform/mutex.h" 10 #include "src/snapshot/snapshot-source-sink.h" 14 #ifndef V8_USE_EXTERNAL_STARTUP_DATA 15 #error snapshot-external.cc is used only for the external snapshot build. 16 #endif // V8_USE_EXTERNAL_STARTUP_DATA 22 static base::LazyMutex external_startup_data_mutex = LAZY_MUTEX_INITIALIZER;
23 static v8::StartupData external_startup_blob = {
nullptr, 0};
25 void SetSnapshotFromFile(StartupData* snapshot_blob) {
26 base::MutexGuard lock_guard(external_startup_data_mutex.Pointer());
27 DCHECK(snapshot_blob);
28 DCHECK(snapshot_blob->data);
29 DCHECK_GT(snapshot_blob->raw_size, 0);
30 DCHECK(!external_startup_blob.data);
31 DCHECK(Snapshot::SnapshotIsValid(snapshot_blob));
32 external_startup_blob = *snapshot_blob;
36 const v8::StartupData* Snapshot::DefaultSnapshotBlob() {
37 base::MutexGuard lock_guard(external_startup_data_mutex.Pointer());
38 return &external_startup_blob;