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_DEOPTIMIZE_REASON_H_
6#define V8_DEOPTIMIZE_REASON_H_
7
8#include "src/globals.h"
9
10namespace v8 {
11namespace internal {
12
13#define DEOPTIMIZE_REASON_LIST(V) \
14 V(ArrayBufferWasDetached, "array buffer was detached") \
15 V(CowArrayElementsChanged, "copy-on-write array's elements changed") \
16 V(CouldNotGrowElements, "failed to grow elements store") \
17 V(DeoptimizeNow, "%_DeoptimizeNow") \
18 V(DivisionByZero, "division by zero") \
19 V(Hole, "hole") \
20 V(InstanceMigrationFailed, "instance migration failed") \
21 V(InsufficientTypeFeedbackForCall, "Insufficient type feedback for call") \
22 V(InsufficientTypeFeedbackForConstruct, \
23 "Insufficient type feedback for construct") \
24 V(InsufficientTypeFeedbackForForIn, "Insufficient type feedback for for-in") \
25 V(InsufficientTypeFeedbackForBinaryOperation, \
26 "Insufficient type feedback for binary operation") \
27 V(InsufficientTypeFeedbackForCompareOperation, \
28 "Insufficient type feedback for compare operation") \
29 V(InsufficientTypeFeedbackForGenericNamedAccess, \
30 "Insufficient type feedback for generic named access") \
31 V(InsufficientTypeFeedbackForGenericKeyedAccess, \
32 "Insufficient type feedback for generic keyed access") \
33 V(InsufficientTypeFeedbackForUnaryOperation, \
34 "Insufficient type feedback for unary operation") \
35 V(LostPrecision, "lost precision") \
36 V(LostPrecisionOrNaN, "lost precision or NaN") \
37 V(MinusZero, "minus zero") \
38 V(NaN, "NaN") \
39 V(NoCache, "no cache") \
40 V(NotAHeapNumber, "not a heap number") \
41 V(NotAJavaScriptObject, "not a JavaScript object") \
42 V(NotAJavaScriptObjectOrNullOrUndefined, \
43 "not a JavaScript object, Null or Undefined") \
44 V(NotANumberOrOddball, "not a Number or Oddball") \
45 V(NotASmi, "not a Smi") \
46 V(NotAString, "not a String") \
47 V(NotASymbol, "not a Symbol") \
48 V(OutOfBounds, "out of bounds") \
49 V(Overflow, "overflow") \
50 V(ReceiverNotAGlobalProxy, "receiver was not a global proxy") \
51 V(Smi, "Smi") \
52 V(Unknown, "(unknown)") \
53 V(ValueMismatch, "value mismatch") \
54 V(WrongCallTarget, "wrong call target") \
55 V(WrongEnumIndices, "wrong enum indices") \
56 V(WrongInstanceType, "wrong instance type") \
57 V(WrongLength, "wrong length") \
58 V(WrongMap, "wrong map") \
59 V(WrongName, "wrong name") \
60 V(WrongValue, "wrong value") \
61 V(NoInitialElement, "no initial element")
62
63enum class DeoptimizeReason : uint8_t {
64#define DEOPTIMIZE_REASON(Name, message) k##Name,
65 DEOPTIMIZE_REASON_LIST(DEOPTIMIZE_REASON)
66#undef DEOPTIMIZE_REASON
67};
68
69V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, DeoptimizeReason);
70
71size_t hash_value(DeoptimizeReason reason);
72
73V8_EXPORT_PRIVATE char const* DeoptimizeReasonToString(DeoptimizeReason reason);
74
75} // namespace internal
76} // namespace v8
77
78#endif // V8_DEOPTIMIZE_REASON_H_
79