v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
snapshot-external.cc
Go to the documentation of this file.
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
3// found in the LICENSE file.
4
5// Used for building with external snapshots.
6
8#include "src/flags/flags.h"
9#include "src/init/v8.h" // for V8::Initialize
12
13#ifndef V8_USE_EXTERNAL_STARTUP_DATA
14#error snapshot-external.cc is used only for the external snapshot build.
15#endif // V8_USE_EXTERNAL_STARTUP_DATA
16
17
18namespace v8 {
19namespace internal {
20
23#ifdef V8_TARGET_OS_ANDROID
24static bool external_startup_checksum_verified = false;
25#endif
26
27void SetSnapshotFromFile(StartupData* snapshot_blob) {
29 DCHECK(snapshot_blob);
30 DCHECK(snapshot_blob->data);
31 DCHECK_GT(snapshot_blob->raw_size, 0);
33 DCHECK(Snapshot::SnapshotIsValid(snapshot_blob));
34 external_startup_blob = *snapshot_blob;
35#ifdef V8_TARGET_OS_ANDROID
36 external_startup_checksum_verified = false;
37#endif
38}
39
41#ifdef V8_TARGET_OS_ANDROID
43 if (data != &external_startup_blob) {
44 return v8_flags.verify_snapshot_checksum;
45 }
46 // Verify the external snapshot maximally once per process due to the
47 // additional overhead.
48 if (external_startup_checksum_verified) return false;
49 external_startup_checksum_verified = true;
50 return true;
51#else
52 return v8_flags.verify_snapshot_checksum;
53#endif
54}
55
59}
60} // namespace internal
61} // namespace v8
const char * data
Definition v8-snapshot.h:35
static const v8::StartupData * DefaultSnapshotBlob()
static bool ShouldVerifyChecksum(const v8::StartupData *data)
#define LAZY_MUTEX_INITIALIZER
Definition mutex.h:105
LockGuard< Mutex > MutexGuard
Definition mutex.h:219
static v8::StartupData external_startup_blob
V8_EXPORT_PRIVATE FlagValues v8_flags
static base::LazyMutex external_startup_data_mutex
void SetSnapshotFromFile(StartupData *snapshot_blob)
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_GT(v1, v2)
Definition logging.h:487