1 // Copyright 2014 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/bailout-reason.h" 6 #include "src/base/logging.h" 7 8 namespace v8 { 9 namespace internal { 10 11 #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 BAILOUT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)}; 18 return error_messages_[static_cast<int>(reason)]; 19 } 20 21 const char* GetAbortReason(AbortReason reason) { 22 DCHECK_LT(reason, AbortReason::kLastErrorMessage); 23 DCHECK_GE(reason, AbortReason::kNoReason); 24 static const char* error_messages_[] = { 25 ABORT_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)}; 26 return error_messages_[static_cast<int>(reason)]; 27 } 28 29 bool IsValidAbortReason(int reason_id) { 30 return reason_id >= static_cast<int>(AbortReason::kNoReason) && 31 reason_id < static_cast<int>(AbortReason::kLastErrorMessage); 32 } 33 34 #undef ERROR_MESSAGES_TEXTS 35 } // namespace internal 36 } // namespace v8 37