Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
snapshot_utils.h
Go to the documentation of this file.
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 "bin/dartutils.h"
9#include "platform/globals.h"
10
11namespace dart {
12namespace bin {
13
15 public:
16 virtual ~AppSnapshot() {}
17
18 virtual void SetBuffers(const uint8_t** vm_data_buffer,
19 const uint8_t** vm_instructions_buffer,
20 const uint8_t** isolate_data_buffer,
21 const uint8_t** isolate_instructions_buffer) = 0;
22
23 bool IsJIT() const { return magic_number_ == DartUtils::kAppJITMagicNumber; }
24 bool IsAOT() const { return DartUtils::IsAotMagicNumber(magic_number_); }
25 bool IsJITorAOT() const { return IsJIT() || IsAOT(); }
26 bool IsKernel() const {
27 return magic_number_ == DartUtils::kKernelMagicNumber;
28 }
29 bool IsKernelList() const {
30 return magic_number_ == DartUtils::kKernelListMagicNumber;
31 }
32
33 protected:
34 explicit AppSnapshot(DartUtils::MagicNumber num) : magic_number_(num) {}
35
36 private:
37 DartUtils::MagicNumber magic_number_;
39};
40
41class Snapshot {
42 public:
43 static void GenerateKernel(const char* snapshot_filename,
44 const char* script_name,
45 const char* package_config);
46 static void GenerateAppJIT(const char* snapshot_filename);
47 static void GenerateAppAOTAsAssembly(const char* snapshot_filename);
48
49#if defined(DART_TARGET_OS_MACOS)
50 static bool IsMachOFormattedBinary(const char* container_path);
51#endif
52#if defined(DART_TARGET_OS_WINDOWS)
53 static bool IsPEFormattedBinary(const char* container_path);
54#endif
55
56 static AppSnapshot* TryReadAppendedAppSnapshotElf(const char* container_path);
58 const char* script_uri,
59 bool force_load_elf_from_memory = false,
60 bool decode_uri = true);
61 static void WriteAppSnapshot(const char* filename,
62 uint8_t* vm_data_buffer,
63 intptr_t vm_data_size,
64 uint8_t* vm_instructions_buffer,
65 intptr_t vm_instructions_size,
66 uint8_t* isolate_data_buffer,
67 intptr_t isolate_data_size,
68 uint8_t* isolate_instructions_buffer,
69 intptr_t isolate_instructions_size);
70
71 private:
72#if defined(DART_TARGET_OS_MACOS)
73 static AppSnapshot* TryReadAppendedAppSnapshotElfFromMachO(
74 const char* container_path);
75#endif
76#if defined(DART_TARGET_OS_WINDOWS)
77 static AppSnapshot* TryReadAppendedAppSnapshotElfFromPE(
78 const char* container_path);
79#endif
80
81 DISALLOW_ALLOCATION();
83};
84
85} // namespace bin
86} // namespace dart
87
88#endif // RUNTIME_BIN_SNAPSHOT_UTILS_H_
AppSnapshot(DartUtils::MagicNumber num)
virtual void SetBuffers(const uint8_t **vm_data_buffer, const uint8_t **vm_instructions_buffer, const uint8_t **isolate_data_buffer, const uint8_t **isolate_instructions_buffer)=0
static bool IsAotMagicNumber(MagicNumber number)
Definition dartutils.h:275
static void GenerateAppAOTAsAssembly(const char *snapshot_filename)
static AppSnapshot * TryReadAppSnapshot(const char *script_uri, bool force_load_elf_from_memory=false, bool decode_uri=true)
static AppSnapshot * TryReadAppendedAppSnapshotElf(const char *container_path)
static void GenerateKernel(const char *snapshot_filename, const char *script_name, const char *package_config)
static void GenerateAppJIT(const char *snapshot_filename)
static void WriteAppSnapshot(const char *filename, uint8_t *vm_data_buffer, intptr_t vm_data_size, uint8_t *vm_instructions_buffer, intptr_t vm_instructions_size, uint8_t *isolate_data_buffer, intptr_t isolate_data_size, uint8_t *isolate_instructions_buffer, intptr_t isolate_instructions_size)
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition globals.h:593
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581