| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_DEOPTIMIZER_H_ | 5 #ifndef V8_DEOPTIMIZER_H_ |
| 6 #define V8_DEOPTIMIZER_H_ | 6 #define V8_DEOPTIMIZER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual void EnterContext(Context* context) = 0; | 80 virtual void EnterContext(Context* context) = 0; |
| 81 | 81 |
| 82 virtual void VisitFunction(JSFunction* function) = 0; | 82 virtual void VisitFunction(JSFunction* function) = 0; |
| 83 | 83 |
| 84 // Function which is called after iteration of all optimized functions | 84 // Function which is called after iteration of all optimized functions |
| 85 // from given native context. | 85 // from given native context. |
| 86 virtual void LeaveContext(Context* context) = 0; | 86 virtual void LeaveContext(Context* context) = 0; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 | 89 |
| 90 #define DEOPT_MESSAGES_LIST(V) \ | |
| 91 V(kNoReason, "no reason") \ | |
| 92 V(kConstantGlobalVariableAssignment, "Constant global variable assignment") \ | |
| 93 V(kConversionOverflow, "conversion overflow") \ | |
| 94 V(kDivisionByZero, "division by zero") \ | |
| 95 V(kElementsKindUnhandledInKeyedLoadGenericStub, \ | |
| 96 "ElementsKind unhandled in KeyedLoadGenericStub") \ | |
| 97 V(kExpectedHeapNumber, "Expected heap number") \ | |
| 98 V(kExpectedSmi, "Expected smi") \ | |
| 99 V(kForcedDeoptToRuntime, "Forced deopt to runtime") \ | |
| 100 V(kHole, "hole") \ | |
| 101 V(kHoleyArrayDespitePackedElements_kindFeedback, \ | |
| 102 "Holey array despite packed elements_kind feedback") \ | |
| 103 V(kInstanceMigrationFailed, "instance migration failed") \ | |
| 104 V(kInsufficientTypeFeedbackForCallWithArguments, \ | |
| 105 "Insufficient type feedback for call with arguments") \ | |
| 106 V(kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation, \ | |
| 107 "Insufficient type feedback for combined type of binary operation") \ | |
| 108 V(kInsufficientTypeFeedbackForGenericNamedAccess, \ | |
| 109 "Insufficient type feedback for generic named access") \ | |
| 110 V(kInsufficientTypeFeedbackForKeyedLoad, \ | |
| 111 "Insufficient type feedback for keyed load") \ | |
| 112 V(kInsufficientTypeFeedbackForKeyedStore, \ | |
| 113 "Insufficient type feedback for keyed store") \ | |
| 114 V(kInsufficientTypeFeedbackForLHSOfBinaryOperation, \ | |
| 115 "Insufficient type feedback for LHS of binary operation") \ | |
| 116 V(kInsufficientTypeFeedbackForRHSOfBinaryOperation, \ | |
| 117 "Insufficient type feedback for RHS of binary operation") \ | |
| 118 V(kKeyIsNegative, "key is negative") \ | |
| 119 V(kLostPrecision, "lost precision") \ | |
| 120 V(kLostPrecisionOrNaN, "lost precision or NaN") \ | |
| 121 V(kMementoFound, "memento found") \ | |
| 122 V(kMinusZero, "minus zero") \ | |
| 123 V(kNaN, "NaN") \ | |
| 124 V(kNegativeKeyEncountered, "Negative key encountered") \ | |
| 125 V(kNegativeValue, "negative value") \ | |
| 126 V(kNoCache, "no cache") \ | |
| 127 V(kNonStrictElementsInKeyedLoadGenericStub, \ | |
| 128 "non-strict elements in KeyedLoadGenericStub") \ | |
| 129 V(kNotADateObject, "not a date object") \ | |
| 130 V(kNotAHeapNumber, "not a heap number") \ | |
| 131 V(kNotAHeapNumberUndefinedBoolean, "not a heap number/undefined/true/false") \ | |
| 132 V(kNotAHeapNumberUndefined, "not a heap number/undefined") \ | |
| 133 V(kNotAJavaScriptObject, "not a JavaScript object") \ | |
| 134 V(kNotASmi, "not a Smi") \ | |
| 135 V(kNotHeapNumber, "not heap number") \ | |
| 136 V(kNull, "null") \ | |
| 137 V(kOutOfBounds, "out of bounds") \ | |
| 138 V(kOutsideOfRange, "Outside of range") \ | |
| 139 V(kOverflow, "overflow") \ | |
| 140 V(kReceiverWasAGlobalObject, "receiver was a global object") \ | |
| 141 V(kSmi, "Smi") \ | |
| 142 V(kTooManyArguments, "too many arguments") \ | |
| 143 V(kTooManyUndetectableTypes, "Too many undetectable types") \ | |
| 144 V(kTracingElementsTransitions, "Tracing elements transitions") \ | |
| 145 V(kTypeMismatchBetweenFeedbackAndConstant, \ | |
| 146 "Type mismatch between feedback and constant") \ | |
| 147 V(kUndefined, "undefined") \ | |
| 148 V(kUnexpectedCellContentsInConstantGlobalStore, \ | |
| 149 "Unexpected cell contents in constant global store") \ | |
| 150 V(kUnexpectedCellContentsInGlobalStore, \ | |
| 151 "Unexpected cell contents in global store") \ | |
| 152 V(kUnexpectedObject, "unexpected object") \ | |
| 153 V(kUnexpectedRHSOfBinaryOperation, "Unexpected RHS of binary operation") \ | |
| 154 V(kUninitializedBoilerplateInFastClone, \ | |
| 155 "Uninitialized boilerplate in fast clone") \ | |
| 156 V(kUninitializedBoilerplateLiterals, "Uninitialized boilerplate literals") \ | |
| 157 V(kUnknownMapInPolymorphicAccess, "Unknown map in polymorphic access") \ | |
| 158 V(kUnknownMapInPolymorphicCall, "Unknown map in polymorphic call") \ | |
| 159 V(kUnknownMapInPolymorphicElementAccess, \ | |
| 160 "Unknown map in polymorphic element access") \ | |
| 161 V(kUnknownMap, "Unknown map") \ | |
| 162 V(kValueMismatch, "value mismatch") \ | |
| 163 V(kWrongInstanceType, "wrong instance type") \ | |
| 164 V(kWrongMap, "wrong map") | |
| 165 | |
| 166 | |
| 167 class Deoptimizer : public Malloced { | 90 class Deoptimizer : public Malloced { |
| 168 public: | 91 public: |
| 169 enum BailoutType { | 92 enum BailoutType { |
| 170 EAGER, | 93 EAGER, |
| 171 LAZY, | 94 LAZY, |
| 172 SOFT, | 95 SOFT, |
| 173 // This last bailout type is not really a bailout, but used by the | 96 // This last bailout type is not really a bailout, but used by the |
| 174 // debugger to deoptimize stack frames to allow inspection. | 97 // debugger to deoptimize stack frames to allow inspection. |
| 175 DEBUGGER, | 98 DEBUGGER, |
| 176 kBailoutTypesWithCodeEntry = SOFT + 1 | 99 kBailoutTypesWithCodeEntry = SOFT + 1 |
| 177 }; | 100 }; |
| 178 | 101 |
| 179 #define DEOPT_MESSAGES_CONSTANTS(C, T) C, | |
| 180 enum DeoptReason { | |
| 181 DEOPT_MESSAGES_LIST(DEOPT_MESSAGES_CONSTANTS) kLastDeoptReason | |
| 182 }; | |
| 183 #undef DEOPT_MESSAGES_CONSTANTS | |
| 184 | |
| 185 static const char* GetDeoptReason(DeoptReason deopt_reason); | |
| 186 | |
| 187 struct Reason { | 102 struct Reason { |
| 188 Reason(int r, const char* m, DeoptReason d) | 103 Reason(int r, const char* m, const char* d) |
| 189 : raw_position(r), mnemonic(m), deopt_reason(d) {} | 104 : raw_position(r), mnemonic(m), detail(d) {} |
| 190 | 105 |
| 191 bool operator==(const Reason& other) const { | 106 bool operator==(const Reason& other) const { |
| 192 return raw_position == other.raw_position && | 107 return raw_position == other.raw_position && |
| 193 CStringEquals(mnemonic, other.mnemonic) && | 108 CStringEquals(mnemonic, other.mnemonic) && |
| 194 deopt_reason == other.deopt_reason; | 109 CStringEquals(detail, other.detail); |
| 195 } | 110 } |
| 196 | 111 |
| 197 bool operator!=(const Reason& other) const { return !(*this == other); } | 112 bool operator!=(const Reason& other) const { return !(*this == other); } |
| 198 | 113 |
| 199 int raw_position; | 114 int raw_position; |
| 200 const char* mnemonic; | 115 const char* mnemonic; |
| 201 DeoptReason deopt_reason; | 116 const char* detail; |
| 202 }; | 117 }; |
| 203 | 118 |
| 204 struct JumpTableEntry : public ZoneObject { | 119 struct JumpTableEntry : public ZoneObject { |
| 205 inline JumpTableEntry(Address entry, const Reason& the_reason, | 120 inline JumpTableEntry(Address entry, const Reason& the_reason, |
| 206 Deoptimizer::BailoutType type, bool frame) | 121 Deoptimizer::BailoutType type, bool frame) |
| 207 : label(), | 122 : label(), |
| 208 address(entry), | 123 address(entry), |
| 209 reason(the_reason), | 124 reason(the_reason), |
| 210 bailout_type(type), | 125 bailout_type(type), |
| 211 needs_frame(frame) {} | 126 needs_frame(frame) {} |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 Object** parameters_; | 979 Object** parameters_; |
| 1065 Object** expression_stack_; | 980 Object** expression_stack_; |
| 1066 int source_position_; | 981 int source_position_; |
| 1067 | 982 |
| 1068 friend class Deoptimizer; | 983 friend class Deoptimizer; |
| 1069 }; | 984 }; |
| 1070 | 985 |
| 1071 } } // namespace v8::internal | 986 } } // namespace v8::internal |
| 1072 | 987 |
| 1073 #endif // V8_DEOPTIMIZER_H_ | 988 #endif // V8_DEOPTIMIZER_H_ |
| OLD | NEW |