1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "src/deoptimize-reason.h"
6
7namespace v8 {
8namespace internal {
9
10std::ostream& operator<<(std::ostream& os, DeoptimizeReason reason) {
11  switch (reason) {
12#define DEOPTIMIZE_REASON(Name, message) \
13  case DeoptimizeReason::k##Name:        \
14    return os << #Name;
15    DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON)
16#undef DEOPTIMIZE_REASON
17  }
18  UNREACHABLE();
19  return os;
20}
21
22size_t hash_value(DeoptimizeReason reason) {
23  return static_cast<uint8_t>(reason);
24}
25
26char const* DeoptimizeReasonToString(DeoptimizeReason reason) {
27  static char const* kDeoptimizeReasonStrings[] = {
28#define DEOPTIMIZE_REASON(Name, message) message,
29      DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON)
30#undef DEOPTIMIZE_REASON
31  };
32  size_t const index = static_cast<size_t>(reason);
33  DCHECK_LT(index, arraysize(kDeoptimizeReasonStrings));
34  return kDeoptimizeReasonStrings[index];
35}
36
37}  // namespace internal
38}  // namespace v8
39