-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsnapshot.cc
45 lines (39 loc) · 1.13 KB
/
snapshot.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/snapshot.h"
#include "platform/assert.h"
#include "vm/dart.h"
namespace dart {
const char* Snapshot::KindToCString(Kind kind) {
switch (kind) {
case kFull:
return "full";
case kFullCore:
return "full-core";
case kFullJIT:
return "full-jit";
case kFullAOT:
return "full-aot";
case kNone:
return "none";
case kInvalid:
default:
return "invalid";
}
}
const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) {
ASSERT(raw_memory != nullptr);
const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
if (!snapshot->check_magic()) {
return nullptr;
}
// If the raw length is negative or greater than what the local machine can
// handle, then signal an error.
int64_t length = snapshot->large_length();
if ((length < 0) || (length > kIntptrMax)) {
return nullptr;
}
return snapshot;
}
} // namespace dart