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#ifndef V8_BAILOUT_REASON_H_
6#define V8_BAILOUT_REASON_H_
7
8#include <cstdint>
9
10namespace v8 {
11namespace internal {
12
13#define ABORT_MESSAGES_LIST(V) \
14 V(kNoReason, "no reason") \
15 \
16 V(k32BitValueInRegisterIsNotZeroExtended, \
17 "32 bit value in register is not zero-extended") \
18 V(kAPICallReturnedInvalidObject, "API call returned invalid object") \
19 V(kAllocatingNonEmptyPackedArray, "Allocating non-empty packed array") \
20 V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned") \
21 V(kExpectedOptimizationSentinel, \
22 "Expected optimized code cell or optimization sentinel") \
23 V(kExpectedUndefinedOrCell, "Expected undefined or cell in register") \
24 V(kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, \
25 "The function_data field should be a BytecodeArray on interpreter entry") \
26 V(kInputStringTooLong, "Input string too long") \
27 V(kInvalidBytecode, "Invalid bytecode") \
28 V(kInvalidBytecodeAdvance, "Cannot advance current bytecode, ") \
29 V(kInvalidElementsKindForInternalPackedArray, \
30 "Invalid ElementsKind for InternalPackedArray") \
31 V(kInvalidHandleScopeLevel, "Invalid HandleScope level") \
32 V(kInvalidJumpTableIndex, "Invalid jump table index") \
33 V(kInvalidParametersAndRegistersInGenerator, \
34 "invalid parameters and registers in generator") \
35 V(kMissingBytecodeArray, "Missing bytecode array from function") \
36 V(kObjectNotTagged, "The object is not tagged") \
37 V(kObjectTagged, "The object is tagged") \
38 V(kOffsetOutOfRange, "Offset out of range") \
39 V(kOperandIsASmi, "Operand is a smi") \
40 V(kOperandIsASmiAndNotABoundFunction, \
41 "Operand is a smi and not a bound function") \
42 V(kOperandIsASmiAndNotAConstructor, \
43 "Operand is a smi and not a constructor") \
44 V(kOperandIsASmiAndNotAFunction, "Operand is a smi and not a function") \
45 V(kOperandIsASmiAndNotAGeneratorObject, \
46 "Operand is a smi and not a generator object") \
47 V(kOperandIsNotABoundFunction, "Operand is not a bound function") \
48 V(kOperandIsNotAConstructor, "Operand is not a constructor") \
49 V(kOperandIsNotAFixedArray, "Operand is not a fixed array") \
50 V(kOperandIsNotAFunction, "Operand is not a function") \
51 V(kOperandIsNotAGeneratorObject, "Operand is not a generator object") \
52 V(kOperandIsNotASmi, "Operand is not a smi") \
53 V(kPromiseAlreadySettled, "Promise already settled") \
54 V(kReceivedInvalidReturnAddress, "Received invalid return address") \
55 V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root") \
56 V(kRegisterWasClobbered, "Register was clobbered") \
57 V(kReturnAddressNotFoundInFrame, "Return address not found in frame") \
58 V(kShouldNotDirectlyEnterOsrFunction, \
59 "Should not directly enter OSR-compiled function") \
60 V(kStackAccessBelowStackPointer, "Stack access below stack pointer") \
61 V(kStackFrameTypesMustMatch, "Stack frame types must match") \
62 V(kUnalignedCellInWriteBarrier, "Unaligned cell in write barrier") \
63 V(kUnexpectedElementsKindInArrayConstructor, \
64 "Unexpected ElementsKind in array constructor") \
65 V(kUnexpectedFPCRMode, "Unexpected FPCR mode.") \
66 V(kUnexpectedFunctionIDForInvokeIntrinsic, \
67 "Unexpected runtime function id for the InvokeIntrinsic bytecode") \
68 V(kUnexpectedInitialMapForArrayFunction, \
69 "Unexpected initial map for Array function") \
70 V(kUnexpectedInitialMapForInternalArrayFunction, \
71 "Unexpected initial map for InternalArray function") \
72 V(kUnexpectedLevelAfterReturnFromApiCall, \
73 "Unexpected level after return from api call") \
74 V(kUnexpectedNegativeValue, "Unexpected negative value") \
75 V(kUnexpectedReturnFromFrameDropper, \
76 "Unexpectedly returned from dropping frames") \
77 V(kUnexpectedReturnFromThrow, "Unexpectedly returned from a throw") \
78 V(kUnexpectedReturnFromWasmTrap, \
79 "Should not return after throwing a wasm trap") \
80 V(kUnexpectedStackPointer, "The stack pointer is not the expected value") \
81 V(kUnexpectedValue, "Unexpected value") \
82 V(kUnsupportedModuleOperation, "Unsupported module operation") \
83 V(kUnsupportedNonPrimitiveCompare, "Unsupported non-primitive compare") \
84 V(kWrongAddressOrValuePassedToRecordWrite, \
85 "Wrong address or value passed to RecordWrite") \
86 V(kWrongArgumentCountForInvokeIntrinsic, \
87 "Wrong number of arguments for intrinsic") \
88 V(kWrongFunctionCodeStart, "Wrong value in code start register passed") \
89 V(kWrongFunctionContext, "Wrong context passed to function") \
90 V(kWrongNumberOfArgumentsForInternalPackedArray, \
91 "Wrong number of arguments for InternalPackedArray") \
92 V(kUnexpectedThreadInWasmSet, "thread_in_wasm flag was already set") \
93 V(kUnexpectedThreadInWasmUnset, "thread_in_wasm flag was not set")
94
95#define BAILOUT_MESSAGES_LIST(V) \
96 V(kNoReason, "no reason") \
97 \
98 V(kBailedOutDueToDependencyChange, "Bailed out due to dependency change") \
99 V(kCodeGenerationFailed, "Code generation failed") \
100 V(kCyclicObjectStateDetectedInEscapeAnalysis, \
101 "Cyclic object state detected by escape analysis") \
102 V(kFunctionBeingDebugged, "Function is being debugged") \
103 V(kGraphBuildingFailed, "Optimized graph construction failed") \
104 V(kFunctionTooBig, "Function is too big to be optimized") \
105 V(kLiveEdit, "LiveEdit") \
106 V(kNativeFunctionLiteral, "Native function literal") \
107 V(kNotEnoughVirtualRegistersRegalloc, \
108 "Not enough virtual registers (regalloc)") \
109 V(kOptimizationDisabled, "Optimization disabled") \
110 V(kNeverOptimize, "Optimization is always disabled")
111
112#define ERROR_MESSAGES_CONSTANTS(C, T) C,
113enum class BailoutReason : uint8_t {
114 BAILOUT_MESSAGES_LIST(ERROR_MESSAGES_CONSTANTS) kLastErrorMessage
115};
116
117enum class AbortReason : uint8_t {
118 ABORT_MESSAGES_LIST(ERROR_MESSAGES_CONSTANTS) kLastErrorMessage
119};
120#undef ERROR_MESSAGES_CONSTANTS
121
122const char* GetBailoutReason(BailoutReason reason);
123const char* GetAbortReason(AbortReason reason);
124bool IsValidAbortReason(int reason_id);
125
126} // namespace internal
127} // namespace v8
128
129#endif // V8_BAILOUT_REASON_H_
130