Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
snapshot.cc
Go to the documentation of this file.
1// Copyright (c) 2012, 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#include "vm/snapshot.h"
6
7#include "platform/assert.h"
8#include "vm/dart.h"
9
10namespace dart {
11
12const char* Snapshot::KindToCString(Kind kind) {
13 switch (kind) {
14 case kFull:
15 return "full";
16 case kFullCore:
17 return "full-core";
18 case kFullJIT:
19 return "full-jit";
20 case kFullAOT:
21 return "full-aot";
22 case kNone:
23 return "none";
24 case kInvalid:
25 default:
26 return "invalid";
27 }
28}
29
30const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) {
31 ASSERT(raw_memory != nullptr);
32 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
33 if (!snapshot->check_magic()) {
34 return nullptr;
35 }
36 // If the raw length is negative or greater than what the local machine can
37 // handle, then signal an error.
38 int64_t length = snapshot->large_length();
39 if ((length < 0) || (length > kIntptrMax)) {
40 return nullptr;
41 }
42 return snapshot;
43}
44
45} // namespace dart
Kind kind() const
Definition snapshot.h:60
bool check_magic() const
Definition snapshot.h:46
static const Snapshot * SetupFromBuffer(const void *raw_memory)
Definition snapshot.cc:30
static const char * KindToCString(Kind kind)
Definition snapshot.cc:12
intptr_t length() const
Definition snapshot.h:56
int64_t large_length() const
Definition snapshot.h:53
#define ASSERT(E)
constexpr intptr_t kIntptrMax
Definition globals.h:557