Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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_;
38 DISALLOW_COPY_AND_ASSIGN(AppSnapshot);
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* isolate_data_buffer,
63 intptr_t isolate_data_size,
64 uint8_t* isolate_instructions_buffer,
65 intptr_t isolate_instructions_size);
66
67 private:
68#if defined(DART_TARGET_OS_MACOS)
69 static AppSnapshot* TryReadAppendedAppSnapshotElfFromMachO(
70 const char* container_path);
71#endif
72#if defined(DART_TARGET_OS_WINDOWS)
73 static AppSnapshot* TryReadAppendedAppSnapshotElfFromPE(
74 const char* container_path);
75#endif
76
77 DISALLOW_ALLOCATION();
78 DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
79};
80
81} // namespace bin
82} // namespace dart
83
84#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
bool IsKernelList() const
static bool IsAotMagicNumber(MagicNumber number)
Definition: dartutils.h:275
static void WriteAppSnapshot(const char *filename, uint8_t *isolate_data_buffer, intptr_t isolate_data_size, uint8_t *isolate_instructions_buffer, intptr_t isolate_instructions_size)
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)
Definition: dart_vm.cc:33