1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_SNAPSHOT_UTILS_H_
6#define RUNTIME_BIN_SNAPSHOT_UTILS_H_
7
8#include "platform/globals.h"
9
10namespace dart {
11namespace bin {
12
13class AppSnapshot {
14 public:
15 virtual ~AppSnapshot() {}
16
17 virtual void SetBuffers(const uint8_t** vm_data_buffer,
18 const uint8_t** vm_instructions_buffer,
19 const uint8_t** isolate_data_buffer,
20 const uint8_t** isolate_instructions_buffer) = 0;
21
22 protected:
23 AppSnapshot() {}
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(AppSnapshot);
27};
28
29class Snapshot {
30 public:
31 static void GenerateKernel(const char* snapshot_filename,
32 const char* script_name,
33 const char* package_config);
34 static void GenerateAppJIT(const char* snapshot_filename);
35 static void GenerateAppAOTAsAssembly(const char* snapshot_filename);
36
37 // Returns true if snapshot_filename points to an AOT snapshot (aka,
38 // an ELF binary). May report false negatives.
39 static bool IsAOTSnapshot(const char* snapshot_filename);
40
41 static AppSnapshot* TryReadAppendedAppSnapshotElf(const char* container_path);
42 static AppSnapshot* TryReadAppSnapshot(
43 const char* script_uri,
44 bool force_load_elf_from_memory = false);
45 static void WriteAppSnapshot(const char* filename,
46 uint8_t* vm_data_buffer,
47 intptr_t vm_data_size,
48 uint8_t* vm_instructions_buffer,
49 intptr_t vm_instructions_size,
50 uint8_t* isolate_data_buffer,
51 intptr_t isolate_data_size,
52 uint8_t* isolate_instructions_buffer,
53 intptr_t isolate_instructions_size);
54
55 private:
56 DISALLOW_ALLOCATION();
57 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
58};
59
60} // namespace bin
61} // namespace dart
62
63#endif // RUNTIME_BIN_SNAPSHOT_UTILS_H_
64