chromium/v8/src/snapshot/snapshot.h

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_SNAPSHOT_SNAPSHOT_H_
#define V8_SNAPSHOT_SNAPSHOT_H_

#include <vector>

#include "include/v8-array-buffer.h"  // For ArrayBuffer::Allocator.
#include "include/v8-snapshot.h"  // For StartupData.
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/snapshot/serializer-deserializer.h"

namespace v8 {
namespace internal {

class Context;
class Isolate;
class JSGlobalProxy;
class SafepointScope;
class SnapshotData;

class Snapshot : public AllStatic {};

// Convenience wrapper around snapshot data blob creation used e.g. by tests.
V8_EXPORT_PRIVATE v8::StartupData CreateSnapshotDataBlobInternal(
    v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
    const char* embedded_source = nullptr,
    Snapshot::SerializerFlags serializer_flags =
        Snapshot::kDefaultSerializerFlags);
// Convenience wrapper around snapshot data blob creation used e.g. by
// mksnapshot.
V8_EXPORT_PRIVATE v8::StartupData CreateSnapshotDataBlobInternal(
    v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
    const char* embedded_source, v8::SnapshotCreator& snapshot_creator,
    Snapshot::SerializerFlags serializer_flags =
        Snapshot::kDefaultSerializerFlags);
// .. and for inspector-test.cc which needs an extern declaration due to
// restrictive include rules:
V8_EXPORT_PRIVATE v8::StartupData
CreateSnapshotDataBlobInternalForInspectorTest(
    v8::SnapshotCreator::FunctionCodeHandling function_code_handling,
    const char* embedded_source);

// Convenience wrapper around snapshot data blob warmup used e.g. by tests and
// mksnapshot.
V8_EXPORT_PRIVATE v8::StartupData WarmUpSnapshotDataBlobInternal(
    v8::StartupData cold_snapshot_blob, const char* warmup_source);

#ifdef V8_USE_EXTERNAL_STARTUP_DATA
void SetSnapshotFromFile(StartupData* snapshot_blob);
#endif

// The implementation of the API-exposed class SnapshotCreator.
class SnapshotCreatorImpl final {};

}  // namespace internal
}  // namespace v8

#endif  // V8_SNAPSHOT_SNAPSHOT_H_