summaryrefslogtreecommitdiff
path: root/deps/v8/src/deoptimize-reason.cc
blob: 733fdfd8833cac1c8a1e16dadcc5fc8d7b721da5 (plain)
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
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/deoptimize-reason.h"

namespace v8 {
namespace internal {

std::ostream& operator<<(std::ostream& os, DeoptimizeReason reason) {
  switch (reason) {
#define DEOPTIMIZE_REASON(Name, message) \
  case DeoptimizeReason::k##Name:        \
    return os << #Name;
    DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON)
#undef DEOPTIMIZE_REASON
  }
  UNREACHABLE();
}

size_t hash_value(DeoptimizeReason reason) {
  return static_cast<uint8_t>(reason);
}

char const* DeoptimizeReasonToString(DeoptimizeReason reason) {
  static char const* kDeoptimizeReasonStrings[] = {
#define DEOPTIMIZE_REASON(Name, message) message,
      DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON)
#undef DEOPTIMIZE_REASON
  };
  size_t const index = static_cast<size_t>(reason);
  DCHECK_LT(index, arraysize(kDeoptimizeReasonStrings));
  return kDeoptimizeReasonStrings[index];
}

}  // namespace internal
}  // namespace v8