#include "gin/v8_initializer.h"
#include <stddef.h>
#include <stdint.h>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/bits.h"
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/debug/alias.h"
#include "base/debug/crash_logging.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/memory_mapped_file.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/system/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "gin/array_buffer.h"
#include "gin/gin_features.h"
#include "partition_alloc/page_allocator.h"
#include "partition_alloc/partition_address_space.h"
#include "tools/v8_context_snapshot/buildflags.h"
#include "v8/include/v8-initialization.h"
#include "v8/include/v8-snapshot.h"
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/apk_assets.h"
#elif BUILDFLAG(IS_MAC)
#include "base/apple/foundation_util.h"
#endif
#endif
namespace gin {
namespace …
void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
const std::string js_command_line_flags,
v8::OOMErrorCallback oom_error_callback) { … }
void V8Initializer::GetV8ExternalSnapshotData(v8::StartupData* snapshot) { … }
void V8Initializer::GetV8ExternalSnapshotData(const char** snapshot_data_out,
int* snapshot_size_out) { … }
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
void V8Initializer::LoadV8Snapshot(V8SnapshotFileType snapshot_file_type) { … }
void V8Initializer::LoadV8SnapshotFromFile(
base::File snapshot_file,
base::MemoryMappedFile::Region* snapshot_file_region,
V8SnapshotFileType snapshot_file_type) { … }
#if BUILDFLAG(IS_ANDROID)
base::FilePath V8Initializer::GetSnapshotFilePath(
bool abi_32_bit,
V8SnapshotFileType snapshot_file_type) {
base::FilePath path;
const char* filename = nullptr;
switch (snapshot_file_type) {
case V8SnapshotFileType::kDefault:
filename = abi_32_bit ? kSnapshotFileName32 : kSnapshotFileName64;
break;
case V8SnapshotFileType::kWithAdditionalContext:
filename = abi_32_bit ? kV8ContextSnapshotFileName32
: kV8ContextSnapshotFileName64;
break;
}
CHECK(filename);
GetV8FilePath(filename, &path);
return path;
}
#endif
V8SnapshotFileType GetLoadedSnapshotFileType() { … }
#endif
}