v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
deoptimize-reason.h
Go to the documentation of this file.
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
9
10namespace v8 {
11namespace internal {
12
13#define DEOPTIMIZE_REASON_LIST(V) \
14 V(ArrayBufferWasDetached, "array buffer was detached") \
15 V(ArrayLengthChanged, "the array length changed") \
16 V(BigIntTooBig, "BigInt too big") \
17 V(ConstTrackingLet, "const tracking let constness invalidated") \
18 V(CouldNotGrowElements, "failed to grow elements store") \
19 V(CowArrayElementsChanged, "copy-on-write array's elements changed") \
20 V(DeoptimizeNow, "%_DeoptimizeNow") \
21 V(DeprecatedMap, "deprecated map") \
22 V(DivisionByZero, "division by zero") \
23 V(Float16NotYetSupported, "float16 is not supported as machine operation") \
24 V(GreaterThanMaxFastElementArray, \
25 "length is greater than the maximum for fast elements array") \
26 V(Hole, "hole") \
27 V(InstanceMigrationFailed, "instance migration failed") \
28 V(InsufficientTypeFeedbackForArrayLiteral, \
29 "Insufficient type feedback for array literal") \
30 V(InsufficientTypeFeedbackForBinaryOperation, \
31 "Insufficient type feedback for binary operation") \
32 V(InsufficientTypeFeedbackForCall, "Insufficient type feedback for call") \
33 V(InsufficientTypeFeedbackForCompareOperation, \
34 "Insufficient type feedback for compare operation") \
35 V(InsufficientTypeFeedbackForConstruct, \
36 "Insufficient type feedback for construct") \
37 V(InsufficientTypeFeedbackForForIn, "Insufficient type feedback for for-in") \
38 V(InsufficientTypeFeedbackForGenericGlobalAccess, \
39 "Insufficient type feedback for generic global access") \
40 V(InsufficientTypeFeedbackForGenericKeyedAccess, \
41 "Insufficient type feedback for generic keyed access") \
42 V(InsufficientTypeFeedbackForGenericNamedAccess, \
43 "Insufficient type feedback for generic named access") \
44 V(InsufficientTypeFeedbackForInstanceOf, \
45 "Insufficient type feedback for instanceof") \
46 V(InsufficientTypeFeedbackForObjectLiteral, \
47 "Insufficient type feedback for object literal") \
48 V(InsufficientTypeFeedbackForTypeOf, \
49 "Insufficient type feedback for typeof") \
50 V(InsufficientTypeFeedbackForUnaryOperation, \
51 "Insufficient type feedback for unary operation") \
52 V(KeyedAccessChanged, "unexpected name in keyed access") \
53 V(LostPrecision, "lost precision") \
54 V(LostPrecisionOrNaN, "lost precision or NaN") \
55 V(MinusZero, "minus zero") \
56 V(NaN, "NaN") \
57 V(NoCache, "no cache") \
58 V(NoInitialElement, "no initial element") \
59 V(NotABigInt, "not a BigInt") \
60 V(NotABigInt64, "not a BigInt64") \
61 V(NotAHeapNumber, "not a heap number") \
62 V(NotAJavaScriptObject, "not a JavaScript object") \
63 V(NotAJavaScriptObjectOrNullOrUndefined, \
64 "not a JavaScript object, Null or Undefined") \
65 V(NotANumber, "not a Number") \
66 V(NotANumberOrBoolean, "not a Number or Boolean") \
67 V(NotANumberOrOddball, "not a Number or Oddball") \
68 V(NotASmi, "not a Smi") \
69 V(NotAString, "not a String") \
70 V(NotAStringOrStringWrapper, "not a String or a string wrapper") \
71 V(NotAStringWrapper, "not a string wrapper") \
72 V(NotASymbol, "not a Symbol") \
73 V(NotAdditiveSafeInteger, "not AdditiveSafeInteger") \
74 V(NotAnArrayIndex, "not an array index") \
75 V(NotDetectableReceiver, "not a detectable receiver") \
76 V(NotInt32, "not int32") \
77 V(NotUint32, "not unsigned int32") \
78 V(OSREarlyExit, "exit from OSR'd inner loop") \
79 V(OutOfBounds, "out of bounds") \
80 V(Overflow, "overflow") \
81 V(PrepareForOnStackReplacement, "prepare for on stack replacement (OSR)") \
82 V(Smi, "Smi") \
83 V(StoreToConstant, "Storing to a constant field") \
84 V(StringTooLarge, "Result string larger than String::kMaxLength") \
85 V(SuspendGeneratorIsDead, "SuspendGenerator is in a dead branch") \
86 V(UnexpectedContextExtension, "unexpected context extension") \
87 V(Unknown, "(unknown)") \
88 V(UnoptimizedCatch, "First use of catch block") \
89 V(ValueMismatch, "value mismatch") \
90 V(WrongCallTarget, "wrong call target") \
91 V(WrongConstructor, "wrong call target constructor") \
92 V(WrongEnumIndices, "wrong enum indices") \
93 V(WrongFeedbackCell, "wrong feedback cell") \
94 V(WrongInstanceType, "wrong instance type") \
95 V(WrongMap, "wrong map") \
96 V(WrongMapDynamic, "map changed during operation") \
97 V(WrongName, "wrong name") \
98 V(WrongValue, "wrong value")
99
100enum class DeoptimizeReason : uint8_t {
101#define DEOPTIMIZE_REASON(Name, message) k##Name,
103#undef DEOPTIMIZE_REASON
104};
105
106#define LAZY_DEOPTIMIZE_REASON_LIST(V) \
107 V(MapDeprecated, "dependent map was deprecated") \
108 V(PrototypeChange, "dependent prototype chain changed") \
109 V(PropertyCellChange, "dependent property cell changed") \
110 V(FieldTypeConstChange, "dependent field type constness changed") \
111 V(FieldTypeChange, "dependent field type changed") \
112 V(FieldRepresentationChange, "dependent field representation changed") \
113 V(InitialMapChange, "dependent initial map changed") \
114 V(AllocationSiteTenuringChange, \
115 "dependent allocation site tenuring changed") \
116 V(AllocationSiteTransitionChange, \
117 "dependent allocation site transition changed") \
118 V(ScriptContextSlotPropertyChange, \
119 "dependent script context slot property changed") \
120 V(EmptyContextExtensionChange, "dependent empty context extension changed") \
121 V(WeakObjects, "embedded weak objects cleared") \
122 V(Debugger, "JS debugger attached") \
123 V(Testing, "for testing") \
124 V(ExceptionCaught, "exception with omitted catch handler") \
125 V(EagerDeopt, "marked due to eager deopt") \
126 V(FrameValueMaterialized, "value in stack frame was materialized")
127
128enum class LazyDeoptimizeReason : uint8_t {
129#define LAZY_DEOPTIMIZE_REASON(Name, message) k##Name,
131#undef LAZY_DEOPTIMIZE_REASON
132};
133
135 static_cast<DeoptimizeReason>(0);
136#define SUM(_1, _2) +1
138#undef SUM
141
142V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, DeoptimizeReason);
143
144size_t hash_value(DeoptimizeReason reason);
145
148 LazyDeoptimizeReason reason);
149
151 DeoptimizeReason reason) {
152 // Maglev OSRs into Turbofan by first deoptimizing in order to restore the
153 // unoptimized frame layout. Since no actual assumptions in the Maglev code
154 // object are violated, it (and any associated cached optimized code) should
155 // not be invalidated s.t. we may reenter it in the future.
156 return reason == DeoptimizeReason::kPrepareForOnStackReplacement ||
157 reason == DeoptimizeReason::kOSREarlyExit;
158}
159
160} // namespace internal
161} // namespace v8
162
163#endif // V8_DEOPTIMIZER_DEOPTIMIZE_REASON_H_
#define LAZY_DEOPTIMIZE_REASON_LIST(V)
#define SUM(_1, _2)
#define DEOPTIMIZE_REASON_LIST(V)
size_t hash_value(AtomicMemoryOrder order)
char const * DeoptimizeReasonToString(DeoptimizeReason reason)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
constexpr DeoptimizeReason kLastDeoptimizeReason
constexpr DeoptimizeReason kFirstDeoptimizeReason
constexpr bool IsDeoptimizationWithoutCodeInvalidation(DeoptimizeReason reason)
constexpr int kDeoptimizeReasonCount
#define V8_EXPORT_PRIVATE
Definition macros.h:460