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