v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bailout-reason.cc
Go to the documentation of this file.
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
6
7#include "src/base/logging.h"
8#include "src/sandbox/check.h"
9
10namespace v8 {
11namespace internal {
12
13#define ERROR_MESSAGES_TEXTS(C, T) T,
14
15const char* GetBailoutReason(BailoutReason reason) {
16 // Currently, the BailoutReason is read from the SharedFunctionInfo object
17 // inside the sandbox and must therefore be considered untrusted. As such, it
18 // needs to be validated here.
19 static_assert(std::is_unsigned_v<std::underlying_type_t<BailoutReason>>);
20 SBXCHECK_LT(reason, BailoutReason::kLastErrorMessage);
21 DCHECK_GE(reason, BailoutReason::kNoReason);
22 static const char* error_messages_[] = {
24 return error_messages_[static_cast<int>(reason)];
25}
26
27const char* GetAbortReason(AbortReason reason) {
28 DCHECK_LT(reason, AbortReason::kLastErrorMessage);
29 DCHECK_GE(reason, AbortReason::kNoReason);
30 static const char* error_messages_[] = {
32 return error_messages_[static_cast<int>(reason)];
33}
34
35bool IsValidAbortReason(int reason_id) {
36 return reason_id >= static_cast<int>(AbortReason::kNoReason) &&
37 reason_id < static_cast<int>(AbortReason::kLastErrorMessage);
38}
39
40#undef ERROR_MESSAGES_TEXTS
41} // namespace internal
42} // namespace v8
#define ERROR_MESSAGES_TEXTS(C, T)
#define SBXCHECK_LT(lhs, rhs)
Definition check.h:66
const char * GetAbortReason(AbortReason reason)
const char * GetBailoutReason(BailoutReason reason)
bool IsValidAbortReason(int reason_id)
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK_LT(v1, v2)
Definition logging.h:489