#include "src/snapshot/snapshot.h"
#include "src/api/api-inl.h"
#include "src/baseline/baseline-batch-compiler.h"
#include "src/common/assert-scope.h"
#include "src/execution/local-isolate-inl.h"
#include "src/handles/global-handles-inl.h"
#include "src/heap/local-heap-inl.h"
#include "src/heap/read-only-promotion.h"
#include "src/heap/safepoint.h"
#include "src/init/bootstrapper.h"
#include "src/logging/counters-scopes.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/js-regexp-inl.h"
#include "src/snapshot/context-deserializer.h"
#include "src/snapshot/context-serializer.h"
#include "src/snapshot/read-only-serializer.h"
#include "src/snapshot/shared-heap-serializer.h"
#include "src/snapshot/snapshot-utils.h"
#include "src/snapshot/startup-serializer.h"
#include "src/utils/memcopy.h"
#include "src/utils/version.h"
#ifdef V8_SNAPSHOT_COMPRESSION
#include "src/snapshot/snapshot-compression.h"
#endif
namespace v8 {
namespace internal {
namespace {
class SnapshotImpl : public AllStatic { … };
}
SnapshotData MaybeDecompress(Isolate* isolate,
base::Vector<const uint8_t> snapshot_data) { … }
#ifdef DEBUG
bool Snapshot::SnapshotIsValid(const v8::StartupData* snapshot_blob) { … }
#endif
bool Snapshot::HasContextSnapshot(Isolate* isolate, size_t index) { … }
bool Snapshot::VersionIsValid(const v8::StartupData* data) { … }
bool Snapshot::Initialize(Isolate* isolate) { … }
MaybeHandle<Context> Snapshot::NewContextFromSnapshot(
Isolate* isolate, Handle<JSGlobalProxy> global_proxy, size_t context_index,
DeserializeEmbedderFieldsCallback embedder_fields_deserializer) { … }
void Snapshot::ClearReconstructableDataForSerialization(
Isolate* isolate, bool clear_recompilable_data) { … }
void Snapshot::SerializeDeserializeAndVerifyForTesting(
Isolate* isolate, DirectHandle<Context> default_context) { … }
v8::StartupData Snapshot::Create(
Isolate* isolate, std::vector<Tagged<Context>>* contexts,
const std::vector<SerializeEmbedderFieldsCallback>&
embedder_fields_serializers,
const SafepointScope& safepoint_scope,
const DisallowGarbageCollection& no_gc, SerializerFlags flags) { … }
v8::StartupData SnapshotImpl::CreateSnapshotBlob(
const SnapshotData* startup_snapshot_in,
const SnapshotData* read_only_snapshot_in,
const SnapshotData* shared_heap_snapshot_in,
const std::vector<SnapshotData*>& context_snapshots_in,
bool can_be_rehashed) { … }
uint32_t SnapshotImpl::ExtractNumContexts(const v8::StartupData* data) { … }
uint32_t Snapshot::GetExpectedChecksum(const v8::StartupData* data) { … }
uint32_t Snapshot::CalculateChecksum(const v8::StartupData* data) { … }
bool Snapshot::VerifyChecksum(const v8::StartupData* data) { … }
uint32_t SnapshotImpl::ExtractContextOffset(const v8::StartupData* data,
uint32_t index) { … }
bool Snapshot::ExtractRehashability(const v8::StartupData* data) { … }
uint32_t Snapshot::ExtractReadOnlySnapshotChecksum(
const v8::StartupData* data) { … }
namespace {
base::Vector<const uint8_t> ExtractData(const v8::StartupData* snapshot,
uint32_t start_offset,
uint32_t end_offset) { … }
}
base::Vector<const uint8_t> SnapshotImpl::ExtractStartupData(
const v8::StartupData* data) { … }
base::Vector<const uint8_t> SnapshotImpl::ExtractReadOnlyData(
const v8::StartupData* data) { … }
base::Vector<const uint8_t> SnapshotImpl::ExtractSharedHeapData(
const v8::StartupData* data) { … }
base::Vector<const uint8_t> SnapshotImpl::ExtractContextData(
const v8::StartupData* data, uint32_t index) { … }
void SnapshotImpl::CheckVersion(const v8::StartupData* data) { … }
namespace {
bool RunExtraCode(v8::Isolate* isolate, v8::Local<v8::Context> context,
const char* utf8_source, const char* name) { … }
}
v8::StartupData CreateSnapshotDataBlobInternal(
v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
const char* embedded_source, SnapshotCreator& snapshot_creator,
Snapshot::SerializerFlags serializer_flags) { … }
v8::StartupData CreateSnapshotDataBlobInternal(
v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
const char* embedded_source, Snapshot::SerializerFlags serializer_flags) { … }
v8::StartupData CreateSnapshotDataBlobInternalForInspectorTest(
v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
const char* embedded_source) { … }
v8::StartupData WarmUpSnapshotDataBlobInternal(
v8::StartupData cold_snapshot_blob, const char* warmup_source) { … }
void SnapshotCreatorImpl::InitInternal(const StartupData* blob) { … }
SnapshotCreatorImpl::SnapshotCreatorImpl(
Isolate* isolate, const intptr_t* api_external_references,
const StartupData* existing_blob, bool owns_isolate)
: … { … }
SnapshotCreatorImpl::SnapshotCreatorImpl(
const v8::Isolate::CreateParams& params)
: … { … }
SnapshotCreatorImpl::SnapshotCreatorImpl(
Isolate* isolate, const v8::Isolate::CreateParams& params)
: … { … }
SnapshotCreatorImpl::~SnapshotCreatorImpl() { … }
void SnapshotCreatorImpl::SetDefaultContext(
Handle<NativeContext> context, SerializeEmbedderFieldsCallback callback) { … }
size_t SnapshotCreatorImpl::AddContext(
Handle<NativeContext> context, SerializeEmbedderFieldsCallback callback) { … }
size_t SnapshotCreatorImpl::AddData(DirectHandle<NativeContext> context,
Address object) { … }
size_t SnapshotCreatorImpl::AddData(Address object) { … }
Handle<NativeContext> SnapshotCreatorImpl::context_at(size_t i) const { … }
namespace {
void ConvertSerializedObjectsToFixedArray(Isolate* isolate) { … }
void ConvertSerializedObjectsToFixedArray(Isolate* isolate,
DirectHandle<NativeContext> context) { … }
}
StartupData SnapshotCreatorImpl::CreateBlob(
SnapshotCreator::FunctionCodeHandling function_code_handling,
Snapshot::SerializerFlags serializer_flags) { … }
SnapshotCreatorImpl* SnapshotCreatorImpl::FromSnapshotCreator(
v8::SnapshotCreator* snapshot_creator) { … }
}
}