mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
179c96cd60
TEST=ci Change-Id: I2511dcc9234dbe29dcbc3abf3db7a8a080dc5436 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213112 Reviewed-by: Liam Appelbe <liama@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
// 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 != NULL);
|
|
const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
|
|
if (!snapshot->check_magic()) {
|
|
return NULL;
|
|
}
|
|
// 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 NULL;
|
|
}
|
|
return snapshot;
|
|
}
|
|
|
|
} // namespace dart
|