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/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/deoptimize-reason.h" |
9 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
10 | 11 |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 class FrameDescription; | 16 class FrameDescription; |
16 class TranslationIterator; | 17 class TranslationIterator; |
17 class DeoptimizedFrameInfo; | 18 class DeoptimizedFrameInfo; |
18 class TranslatedState; | 19 class TranslatedState; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // from given native context. | 316 // from given native context. |
316 virtual void EnterContext(Context* context) = 0; | 317 virtual void EnterContext(Context* context) = 0; |
317 | 318 |
318 virtual void VisitFunction(JSFunction* function) = 0; | 319 virtual void VisitFunction(JSFunction* function) = 0; |
319 | 320 |
320 // Function which is called after iteration of all optimized functions | 321 // Function which is called after iteration of all optimized functions |
321 // from given native context. | 322 // from given native context. |
322 virtual void LeaveContext(Context* context) = 0; | 323 virtual void LeaveContext(Context* context) = 0; |
323 }; | 324 }; |
324 | 325 |
325 #define DEOPT_MESSAGES_LIST(V) \ | |
326 V(kAccessCheck, "Access check needed") \ | |
327 V(kNoReason, "no reason") \ | |
328 V(kConstantGlobalVariableAssignment, "Constant global variable assignment") \ | |
329 V(kConversionOverflow, "conversion overflow") \ | |
330 V(kDivisionByZero, "division by zero") \ | |
331 V(kElementsKindUnhandledInKeyedLoadGenericStub, \ | |
332 "ElementsKind unhandled in KeyedLoadGenericStub") \ | |
333 V(kExpectedHeapNumber, "Expected heap number") \ | |
334 V(kExpectedSmi, "Expected smi") \ | |
335 V(kForcedDeoptToRuntime, "Forced deopt to runtime") \ | |
336 V(kHole, "hole") \ | |
337 V(kHoleyArrayDespitePackedElements_kindFeedback, \ | |
338 "Holey array despite packed elements_kind feedback") \ | |
339 V(kInstanceMigrationFailed, "instance migration failed") \ | |
340 V(kInsufficientTypeFeedbackForCallWithArguments, \ | |
341 "Insufficient type feedback for call with arguments") \ | |
342 V(kFastPathFailed, "Falling off the fast path") \ | |
343 V(kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation, \ | |
344 "Insufficient type feedback for combined type of binary operation") \ | |
345 V(kInsufficientTypeFeedbackForGenericNamedAccess, \ | |
346 "Insufficient type feedback for generic named access") \ | |
347 V(kInsufficientTypeFeedbackForKeyedLoad, \ | |
348 "Insufficient type feedback for keyed load") \ | |
349 V(kInsufficientTypeFeedbackForKeyedStore, \ | |
350 "Insufficient type feedback for keyed store") \ | |
351 V(kInsufficientTypeFeedbackForLHSOfBinaryOperation, \ | |
352 "Insufficient type feedback for LHS of binary operation") \ | |
353 V(kInsufficientTypeFeedbackForRHSOfBinaryOperation, \ | |
354 "Insufficient type feedback for RHS of binary operation") \ | |
355 V(kKeyIsNegative, "key is negative") \ | |
356 V(kLiteralsWereDisposed, "literals have been disposed") \ | |
357 V(kLostPrecision, "lost precision") \ | |
358 V(kLostPrecisionOrNaN, "lost precision or NaN") \ | |
359 V(kMementoFound, "memento found") \ | |
360 V(kMinusZero, "minus zero") \ | |
361 V(kNaN, "NaN") \ | |
362 V(kNegativeKeyEncountered, "Negative key encountered") \ | |
363 V(kNegativeValue, "negative value") \ | |
364 V(kNoCache, "no cache") \ | |
365 V(kNonStrictElementsInKeyedLoadGenericStub, \ | |
366 "non-strict elements in KeyedLoadGenericStub") \ | |
367 V(kNotADateObject, "not a date object") \ | |
368 V(kNotAHeapNumber, "not a heap number") \ | |
369 V(kNotAHeapNumberUndefinedBoolean, "not a heap number/undefined/true/false") \ | |
370 V(kNotAHeapNumberUndefined, "not a heap number/undefined") \ | |
371 V(kNotAJavaScriptObject, "not a JavaScript object") \ | |
372 V(kNotASmi, "not a Smi") \ | |
373 V(kNull, "null") \ | |
374 V(kOutOfBounds, "out of bounds") \ | |
375 V(kOutsideOfRange, "Outside of range") \ | |
376 V(kOverflow, "overflow") \ | |
377 V(kProxy, "proxy") \ | |
378 V(kReceiverWasAGlobalObject, "receiver was a global object") \ | |
379 V(kSmi, "Smi") \ | |
380 V(kTooManyArguments, "too many arguments") \ | |
381 V(kTooManyUndetectableTypes, "Too many undetectable types") \ | |
382 V(kTracingElementsTransitions, "Tracing elements transitions") \ | |
383 V(kTypeMismatchBetweenFeedbackAndConstant, \ | |
384 "Type mismatch between feedback and constant") \ | |
385 V(kUndefined, "undefined") \ | |
386 V(kUnexpectedCellContentsInConstantGlobalStore, \ | |
387 "Unexpected cell contents in constant global store") \ | |
388 V(kUnexpectedCellContentsInGlobalStore, \ | |
389 "Unexpected cell contents in global store") \ | |
390 V(kUnexpectedObject, "unexpected object") \ | |
391 V(kUnexpectedRHSOfBinaryOperation, "Unexpected RHS of binary operation") \ | |
392 V(kUninitializedBoilerplateInFastClone, \ | |
393 "Uninitialized boilerplate in fast clone") \ | |
394 V(kUninitializedBoilerplateLiterals, "Uninitialized boilerplate literals") \ | |
395 V(kUnknownMapInPolymorphicAccess, "Unknown map in polymorphic access") \ | |
396 V(kUnknownMapInPolymorphicCall, "Unknown map in polymorphic call") \ | |
397 V(kUnknownMapInPolymorphicElementAccess, \ | |
398 "Unknown map in polymorphic element access") \ | |
399 V(kUnknownMap, "Unknown map") \ | |
400 V(kValueMismatch, "value mismatch") \ | |
401 V(kWrongInstanceType, "wrong instance type") \ | |
402 V(kWrongMap, "wrong map") \ | |
403 V(kUndefinedOrNullInForIn, "null or undefined in for-in") \ | |
404 V(kUndefinedOrNullInToObject, "null or undefined in ToObject") | |
405 | |
406 class Deoptimizer : public Malloced { | 326 class Deoptimizer : public Malloced { |
407 public: | 327 public: |
408 enum BailoutType { EAGER, LAZY, SOFT, kLastBailoutType = SOFT }; | 328 enum BailoutType { EAGER, LAZY, SOFT, kLastBailoutType = SOFT }; |
409 | 329 |
410 enum class BailoutState { | 330 enum class BailoutState { |
411 NO_REGISTERS, | 331 NO_REGISTERS, |
412 TOS_REGISTER, | 332 TOS_REGISTER, |
413 }; | 333 }; |
414 | 334 |
415 static const char* BailoutStateToString(BailoutState state) { | 335 static const char* BailoutStateToString(BailoutState state) { |
416 switch (state) { | 336 switch (state) { |
417 case BailoutState::NO_REGISTERS: | 337 case BailoutState::NO_REGISTERS: |
418 return "NO_REGISTERS"; | 338 return "NO_REGISTERS"; |
419 case BailoutState::TOS_REGISTER: | 339 case BailoutState::TOS_REGISTER: |
420 return "TOS_REGISTER"; | 340 return "TOS_REGISTER"; |
421 } | 341 } |
422 UNREACHABLE(); | 342 UNREACHABLE(); |
423 return nullptr; | 343 return nullptr; |
424 } | 344 } |
425 | 345 |
426 #define DEOPT_MESSAGES_CONSTANTS(C, T) C, | |
427 enum DeoptReason { | |
428 DEOPT_MESSAGES_LIST(DEOPT_MESSAGES_CONSTANTS) kLastDeoptReason | |
429 }; | |
430 #undef DEOPT_MESSAGES_CONSTANTS | |
431 static const char* GetDeoptReason(DeoptReason deopt_reason); | |
432 | |
433 struct DeoptInfo { | 346 struct DeoptInfo { |
434 DeoptInfo(SourcePosition position, DeoptReason deopt_reason, int deopt_id) | 347 DeoptInfo(SourcePosition position, DeoptimizeReason deopt_reason, |
| 348 int deopt_id) |
435 : position(position), deopt_reason(deopt_reason), deopt_id(deopt_id) {} | 349 : position(position), deopt_reason(deopt_reason), deopt_id(deopt_id) {} |
436 | 350 |
437 SourcePosition position; | 351 SourcePosition position; |
438 DeoptReason deopt_reason; | 352 DeoptimizeReason deopt_reason; |
439 int deopt_id; | 353 int deopt_id; |
440 | 354 |
441 static const int kNoDeoptId = -1; | 355 static const int kNoDeoptId = -1; |
442 }; | 356 }; |
443 | 357 |
444 static DeoptInfo GetDeoptInfo(Code* code, byte* from); | 358 static DeoptInfo GetDeoptInfo(Code* code, byte* from); |
445 | 359 |
446 static int ComputeSourcePosition(SharedFunctionInfo* shared, | 360 static int ComputeSourcePosition(SharedFunctionInfo* shared, |
447 BailoutId node_id); | 361 BailoutId node_id); |
448 | 362 |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 std::vector<Handle<Object> > expression_stack_; | 1066 std::vector<Handle<Object> > expression_stack_; |
1153 int source_position_; | 1067 int source_position_; |
1154 | 1068 |
1155 friend class Deoptimizer; | 1069 friend class Deoptimizer; |
1156 }; | 1070 }; |
1157 | 1071 |
1158 } // namespace internal | 1072 } // namespace internal |
1159 } // namespace v8 | 1073 } // namespace v8 |
1160 | 1074 |
1161 #endif // V8_DEOPTIMIZER_H_ | 1075 #endif // V8_DEOPTIMIZER_H_ |
OLD | NEW |