1 // Copyright 2016 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_DEOPTIMIZER_DEOPTIMIZE_REASON_H_ 6 #define V8_DEOPTIMIZER_DEOPTIMIZE_REASON_H_ 7 8 #include "src/common/globals.h" 9 10 namespace v8 { 11 namespace internal { 12 13 #define DEOPTIMIZE_REASON_LIST(V) \ 14 V(ArrayBufferWasDetached, "array buffer was detached") \ 15 V(BigIntTooBig, "BigInt too big") \ 16 V(CowArrayElementsChanged, "copy-on-write array's elements changed") \ 17 V(CouldNotGrowElements, "failed to grow elements store") \ 18 V(DeoptimizeNow, "%_DeoptimizeNow") \ 19 V(DivisionByZero, "division by zero") \ 20 V(Hole, "hole") \ 21 V(InstanceMigrationFailed, "instance migration failed") \ 22 V(InsufficientTypeFeedbackForCall, "Insufficient type feedback for call") \ 23 V(InsufficientTypeFeedbackForConstruct, \ 24 "Insufficient type feedback for construct") \ 25 V(InsufficientTypeFeedbackForForIn, "Insufficient type feedback for for-in") \ 26 V(InsufficientTypeFeedbackForBinaryOperation, \ 27 "Insufficient type feedback for binary operation") \ 28 V(InsufficientTypeFeedbackForCompareOperation, \ 29 "Insufficient type feedback for compare operation") \ 30 V(InsufficientTypeFeedbackForGenericNamedAccess, \ 31 "Insufficient type feedback for generic named access") \ 32 V(InsufficientTypeFeedbackForGenericKeyedAccess, \ 33 "Insufficient type feedback for generic keyed access") \ 34 V(InsufficientTypeFeedbackForUnaryOperation, \ 35 "Insufficient type feedback for unary operation") \ 36 V(LostPrecision, "lost precision") \ 37 V(LostPrecisionOrNaN, "lost precision or NaN") \ 38 V(MinusZero, "minus zero") \ 39 V(NaN, "NaN") \ 40 V(NoCache, "no cache") \ 41 V(NotABigInt, "not a BigInt") \ 42 V(NotAHeapNumber, "not a heap number") \ 43 V(NotAJavaScriptObject, "not a JavaScript object") \ 44 V(NotAJavaScriptObjectOrNullOrUndefined, \ 45 "not a JavaScript object, Null or Undefined") \ 46 V(NotANumber, "not a Number") \ 47 V(NotANumberOrBoolean, "not a Number or Boolean") \ 48 V(NotANumberOrOddball, "not a Number or Oddball") \ 49 V(NotAnArrayIndex, "not an array index") \ 50 V(NotASmi, "not a Smi") \ 51 V(NotAString, "not a String") \ 52 V(NotASymbol, "not a Symbol") \ 53 V(NotInt32, "not int32") \ 54 V(OutOfBounds, "out of bounds") \ 55 V(Overflow, "overflow") \ 56 V(Smi, "Smi") \ 57 V(TransitionedToMonomorphicIC, "IC transitioned to monomorphic") \ 58 V(TransitionedToMegamorphicIC, "IC transitioned to megamorphic") \ 59 V(Unknown, "(unknown)") \ 60 V(ValueMismatch, "value mismatch") \ 61 V(WrongCallTarget, "wrong call target") \ 62 V(WrongEnumIndices, "wrong enum indices") \ 63 V(WrongFeedbackCell, "wrong feedback cell") \ 64 V(WrongInstanceType, "wrong instance type") \ 65 V(WrongMap, "wrong map") \ 66 V(MissingMap, "missing map") \ 67 V(DeprecatedMap, "deprecated map") \ 68 V(WrongHandler, "wrong handler") \ 69 V(WrongName, "wrong name") \ 70 V(WrongValue, "wrong value") \ 71 V(NoInitialElement, "no initial element") \ 72 V(ArrayLengthChanged, "the array length changed") 73 74 enum class DeoptimizeReason : uint8_t { 75 #define DEOPTIMIZE_REASON(Name, message) k##Name, 76 DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON) 77 #undef DEOPTIMIZE_REASON 78 }; 79 80 constexpr DeoptimizeReason kFirstDeoptimizeReason = 81 DeoptimizeReason::kArrayBufferWasDetached; 82 constexpr DeoptimizeReason kLastDeoptimizeReason = 83 DeoptimizeReason::kArrayLengthChanged; 84 STATIC_ASSERT(static_cast<int>(kFirstDeoptimizeReason) == 0); 85 constexpr int kDeoptimizeReasonCount = 86 static_cast<int>(kLastDeoptimizeReason) + 1; 87 88 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, DeoptimizeReason); 89 90 size_t hash_value(DeoptimizeReason reason); 91 92 V8_EXPORT_PRIVATE char const* DeoptimizeReasonToString(DeoptimizeReason reason); 93 94 } // namespace internal 95 } // namespace v8 96 97 #endif // V8_DEOPTIMIZER_DEOPTIMIZE_REASON_H_ 98