11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/codegen/bailout-reason.h"
61cb0ef41Sopenharmony_ci#include "src/base/logging.h"
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cinamespace v8 {
91cb0ef41Sopenharmony_cinamespace internal {
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci#define ERROR_MESSAGES_TEXTS(C, T) T,
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst char* GetBailoutReason(BailoutReason reason) {
141cb0ef41Sopenharmony_ci  DCHECK_LT(reason, BailoutReason::kLastErrorMessage);
151cb0ef41Sopenharmony_ci  DCHECK_GE(reason, BailoutReason::kNoReason);
161cb0ef41Sopenharmony_ci  static const char* error_messages_[] = {
171cb0ef41Sopenharmony_ci      BAILOUT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)};
181cb0ef41Sopenharmony_ci  return error_messages_[static_cast<int>(reason)];
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciconst char* GetAbortReason(AbortReason reason) {
221cb0ef41Sopenharmony_ci  DCHECK_LT(reason, AbortReason::kLastErrorMessage);
231cb0ef41Sopenharmony_ci  DCHECK_GE(reason, AbortReason::kNoReason);
241cb0ef41Sopenharmony_ci  static const char* error_messages_[] = {
251cb0ef41Sopenharmony_ci      ABORT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)};
261cb0ef41Sopenharmony_ci  return error_messages_[static_cast<int>(reason)];
271cb0ef41Sopenharmony_ci}
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_cibool IsValidAbortReason(int reason_id) {
301cb0ef41Sopenharmony_ci  return reason_id >= static_cast<int>(AbortReason::kNoReason) &&
311cb0ef41Sopenharmony_ci         reason_id < static_cast<int>(AbortReason::kLastErrorMessage);
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci#undef ERROR_MESSAGES_TEXTS
351cb0ef41Sopenharmony_ci}  // namespace internal
361cb0ef41Sopenharmony_ci}  // namespace v8
37