bailout-reason.cc 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// Copyright 2014 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/bailout-reason.h"
#include "src/base/logging.h"

namespace v8 {
namespace internal {

#define ERROR_MESSAGES_TEXTS(C, T) T,
12 13

const char* GetBailoutReason(BailoutReason reason) {
14
  DCHECK_LT(reason, BailoutReason::kLastErrorMessage);
15
  DCHECK_GE(reason, BailoutReason::kNoReason);
16
  static const char* error_messages_[] = {
17 18
      BAILOUT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)};
  return error_messages_[static_cast<int>(reason)];
19
}
20 21

const char* GetAbortReason(AbortReason reason) {
22
  DCHECK_LT(reason, AbortReason::kLastErrorMessage);
23 24 25 26 27 28
  DCHECK_GE(reason, AbortReason::kNoReason);
  static const char* error_messages_[] = {
      ABORT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)};
  return error_messages_[static_cast<int>(reason)];
}

29 30 31 32 33
bool IsValidAbortReason(int reason_id) {
  return reason_id >= static_cast<int>(AbortReason::kNoReason) &&
         reason_id < static_cast<int>(AbortReason::kLastErrorMessage);
}

34
#undef ERROR_MESSAGES_TEXTS
35 36
}  // namespace internal
}  // namespace v8