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