Commit 8d8f8756 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Clean up deoptimization reasons.

- Remove unused deoptimization reasons.
- Replace most uses of kNoReason with an actual reason (some are new).
- Rename kNoReason to kUnknown.

Bug: 
Change-Id: Ia8df54fca0f0f4885ef0c3523ce8f67b557a635d
Reviewed-on: https://chromium-review.googlesource.com/839421Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50440}
parent 0c138bae
...@@ -413,7 +413,6 @@ ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) { ...@@ -413,7 +413,6 @@ ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) {
#define CACHED_DEOPTIMIZE_LIST(V) \ #define CACHED_DEOPTIMIZE_LIST(V) \
V(Eager, MinusZero) \ V(Eager, MinusZero) \
V(Eager, NoReason) \
V(Eager, WrongMap) \ V(Eager, WrongMap) \
V(Soft, InsufficientTypeFeedbackForGenericKeyedAccess) \ V(Soft, InsufficientTypeFeedbackForGenericKeyedAccess) \
V(Soft, InsufficientTypeFeedbackForGenericNamedAccess) V(Soft, InsufficientTypeFeedbackForGenericNamedAccess)
...@@ -428,7 +427,6 @@ ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) { ...@@ -428,7 +427,6 @@ ZoneVector<MachineType> const* MachineTypesOf(Operator const* op) {
#define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \ #define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \
V(Eager, LostPrecision) \ V(Eager, LostPrecision) \
V(Eager, LostPrecisionOrNaN) \ V(Eager, LostPrecisionOrNaN) \
V(Eager, NoReason) \
V(Eager, NotAHeapNumber) \ V(Eager, NotAHeapNumber) \
V(Eager, NotANumberOrOddball) \ V(Eager, NotANumberOrOddball) \
V(Eager, NotASmi) \ V(Eager, NotASmi) \
......
...@@ -3282,9 +3282,7 @@ Node* EffectControlLinearizer::LowerMaybeGrowFastElements(Node* node, ...@@ -3282,9 +3282,7 @@ Node* EffectControlLinearizer::LowerMaybeGrowFastElements(Node* node,
ChangeInt32ToSmi(index), __ NoContextConstant()); ChangeInt32ToSmi(index), __ NoContextConstant());
// Ensure that we were able to grow the {elements}. // Ensure that we were able to grow the {elements}.
// TODO(turbofan): We use kSmi as reason here similar to Crankshaft, __ DeoptimizeIf(DeoptimizeReason::kCouldNotGrowElements, params.feedback(),
// but maybe we should just introduce a reason that makes sense.
__ DeoptimizeIf(DeoptimizeReason::kSmi, params.feedback(),
ObjectIsSmi(new_elements), frame_state); ObjectIsSmi(new_elements), frame_state);
__ Goto(&done, new_elements); __ Goto(&done, new_elements);
......
...@@ -815,7 +815,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, ...@@ -815,7 +815,7 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
int const state_id = sequence()->AddDeoptimizationEntry( int const state_id = sequence()->AddDeoptimizationEntry(
buffer->frame_state_descriptor, DeoptimizeKind::kLazy, buffer->frame_state_descriptor, DeoptimizeKind::kLazy,
DeoptimizeReason::kNoReason, VectorSlotPair()); DeoptimizeReason::kUnknown, VectorSlotPair());
buffer->instruction_args.push_back(g.TempImmediate(state_id)); buffer->instruction_args.push_back(g.TempImmediate(state_id));
StateObjectDeduplicator deduplicator(instruction_zone()); StateObjectDeduplicator deduplicator(instruction_zone());
......
...@@ -1331,7 +1331,7 @@ class DeoptimizationEntry final { ...@@ -1331,7 +1331,7 @@ class DeoptimizationEntry final {
private: private:
FrameStateDescriptor* descriptor_ = nullptr; FrameStateDescriptor* descriptor_ = nullptr;
DeoptimizeKind kind_ = DeoptimizeKind::kEager; DeoptimizeKind kind_ = DeoptimizeKind::kEager;
DeoptimizeReason reason_ = DeoptimizeReason::kNoReason; DeoptimizeReason reason_ = DeoptimizeReason::kUnknown;
VectorSlotPair feedback_ = VectorSlotPair(); VectorSlotPair feedback_ = VectorSlotPair();
}; };
......
...@@ -537,7 +537,7 @@ Reduction JSCallReducer::ReduceObjectPrototypeHasOwnProperty(Node* node) { ...@@ -537,7 +537,7 @@ Reduction JSCallReducer::ReduceObjectPrototypeHasOwnProperty(Node* node) {
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
receiver_map, cache_type); receiver_map, cache_type);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->CheckIf(DeoptimizeReason::kNoReason), check, effect, simplified()->CheckIf(DeoptimizeReason::kWrongMap), check, effect,
control); control);
} }
Node* value = jsgraph()->TrueConstant(); Node* value = jsgraph()->TrueConstant();
...@@ -3227,9 +3227,9 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) { ...@@ -3227,9 +3227,9 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
// Check that the {target} is still the {target_function}. // Check that the {target} is still the {target_function}.
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target,
target_function); target_function);
effect = effect = graph()->NewNode(
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), simplified()->CheckIf(DeoptimizeReason::kWrongCallTarget), check,
check, effect, control); effect, control);
// Specialize the JSCall node to the {target_function}. // Specialize the JSCall node to the {target_function}.
NodeProperties::ReplaceValueInput(node, target_function, 0); NodeProperties::ReplaceValueInput(node, target_function, 0);
...@@ -3300,9 +3300,9 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) { ...@@ -3300,9 +3300,9 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
// Check that the {target} is still the {array_function}. // Check that the {target} is still the {array_function}.
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target, Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target,
array_function); array_function);
effect = effect = graph()->NewNode(
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), simplified()->CheckIf(DeoptimizeReason::kWrongCallTarget), check,
check, effect, control); effect, control);
// Turn the {node} into a {JSCreateArray} call. // Turn the {node} into a {JSCreateArray} call.
NodeProperties::ReplaceEffectInput(node, effect); NodeProperties::ReplaceEffectInput(node, effect);
...@@ -3323,9 +3323,9 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) { ...@@ -3323,9 +3323,9 @@ Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
// Check that the {new_target} is still the {new_target_feedback}. // Check that the {new_target} is still the {new_target_feedback}.
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
new_target, new_target_feedback); new_target, new_target_feedback);
effect = effect = graph()->NewNode(
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), simplified()->CheckIf(DeoptimizeReason::kWrongCallTarget), check,
check, effect, control); effect, control);
// Specialize the JSConstruct node to the {new_target_feedback}. // Specialize the JSConstruct node to the {new_target_feedback}.
NodeProperties::ReplaceValueInput(node, new_target_feedback, arity + 1); NodeProperties::ReplaceValueInput(node, new_target_feedback, arity + 1);
......
...@@ -135,8 +135,8 @@ Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { ...@@ -135,8 +135,8 @@ Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
// TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer.
Node* deoptimize = graph()->NewNode( Node* deoptimize = graph()->NewNode(
common()->Deoptimize(DeoptimizeKind::kEager, DeoptimizeReason::kNoReason, common()->Deoptimize(DeoptimizeKind::kEager,
VectorSlotPair()), DeoptimizeReason::kDeoptimizeNow, VectorSlotPair()),
frame_state, effect, control); frame_state, effect, control);
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
Revisit(graph()->end()); Revisit(graph()->end());
......
...@@ -1503,7 +1503,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) { ...@@ -1503,7 +1503,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) {
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
receiver_map, enumerator); receiver_map, enumerator);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->CheckIf(DeoptimizeReason::kNoReason), check, effect, simplified()->CheckIf(DeoptimizeReason::kWrongMap), check, effect,
control); control);
} }
...@@ -1524,9 +1524,9 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) { ...@@ -1524,9 +1524,9 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) {
simplified()->BooleanNot(), simplified()->BooleanNot(),
graph()->NewNode(simplified()->ReferenceEqual(), enum_indices, graph()->NewNode(simplified()->ReferenceEqual(), enum_indices,
jsgraph()->EmptyFixedArrayConstant())); jsgraph()->EmptyFixedArrayConstant()));
effect = effect = graph()->NewNode(
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), simplified()->CheckIf(DeoptimizeReason::kWrongEnumIndices), check,
check, effect, control); effect, control);
// Determine the index from the {enum_indices}. // Determine the index from the {enum_indices}.
index = effect = graph()->NewNode( index = effect = graph()->NewNode(
...@@ -1774,7 +1774,7 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -1774,7 +1774,7 @@ JSNativeContextSpecialization::BuildPropertyStore(
Node* check = Node* check =
graph()->NewNode(simplified()->ReferenceEqual(), value, constant_value); graph()->NewNode(simplified()->ReferenceEqual(), value, constant_value);
effect = effect =
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kWrongValue),
check, effect, control); check, effect, control);
value = constant_value; value = constant_value;
} else if (access_info.IsAccessorConstant()) { } else if (access_info.IsAccessorConstant()) {
...@@ -1852,8 +1852,8 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -1852,8 +1852,8 @@ JSNativeContextSpecialization::BuildPropertyStore(
Node* check = graph()->NewNode(simplified()->NumberEqual(), Node* check = graph()->NewNode(simplified()->NumberEqual(),
current_value, value); current_value, value);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->CheckIf(DeoptimizeReason::kNoReason), check, effect, simplified()->CheckIf(DeoptimizeReason::kWrongValue), check,
control); effect, control);
return ValueEffectControl(value, effect, control); return ValueEffectControl(value, effect, control);
} }
break; break;
...@@ -1871,8 +1871,8 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -1871,8 +1871,8 @@ JSNativeContextSpecialization::BuildPropertyStore(
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
current_value, value); current_value, value);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->CheckIf(DeoptimizeReason::kNoReason), check, effect, simplified()->CheckIf(DeoptimizeReason::kWrongValue), check,
control); effect, control);
return ValueEffectControl(value, effect, control); return ValueEffectControl(value, effect, control);
} }
...@@ -2007,7 +2007,7 @@ Reduction JSNativeContextSpecialization::ReduceJSStoreDataPropertyInLiteral( ...@@ -2007,7 +2007,7 @@ Reduction JSNativeContextSpecialization::ReduceJSStoreDataPropertyInLiteral(
Node* name = NodeProperties::GetValueInput(node, 1); Node* name = NodeProperties::GetValueInput(node, 1);
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), name, Node* check = graph()->NewNode(simplified()->ReferenceEqual(), name,
jsgraph()->HeapConstant(cached_name)); jsgraph()->HeapConstant(cached_name));
effect = graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), effect = graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kWrongName),
check, effect, control); check, effect, control);
Node* value = NodeProperties::GetValueInput(node, 2); Node* value = NodeProperties::GetValueInput(node, 2);
......
...@@ -1773,7 +1773,7 @@ Reduction JSTypedLowering::ReduceJSForInNext(Node* node) { ...@@ -1773,7 +1773,7 @@ Reduction JSTypedLowering::ReduceJSForInNext(Node* node) {
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
receiver_map, cache_type); receiver_map, cache_type);
effect = effect =
graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kWrongMap),
check, effect, control); check, effect, control);
// Since the change to LoadElement() below is effectful, we connect // Since the change to LoadElement() below is effectful, we connect
......
...@@ -177,8 +177,9 @@ Node* PropertyAccessBuilder::BuildCheckValue(Node* receiver, Node** effect, ...@@ -177,8 +177,9 @@ Node* PropertyAccessBuilder::BuildCheckValue(Node* receiver, Node** effect,
Node* expected = jsgraph()->HeapConstant(value); Node* expected = jsgraph()->HeapConstant(value);
Node* check = Node* check =
graph()->NewNode(simplified()->ReferenceEqual(), receiver, expected); graph()->NewNode(simplified()->ReferenceEqual(), receiver, expected);
*effect = graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kNoReason), *effect =
check, *effect, control); graph()->NewNode(simplified()->CheckIf(DeoptimizeReason::kWrongValue),
check, *effect, control);
return expected; return expected;
} }
......
...@@ -11,24 +11,16 @@ namespace v8 { ...@@ -11,24 +11,16 @@ namespace v8 {
namespace internal { namespace internal {
#define DEOPTIMIZE_REASON_LIST(V) \ #define DEOPTIMIZE_REASON_LIST(V) \
V(AccessCheck, "Access check needed") \
V(NoReason, "no reason") \
V(ArrayBufferWasNeutered, "array buffer was neutered") \ V(ArrayBufferWasNeutered, "array buffer was neutered") \
V(ConstantGlobalVariableAssignment, "Constant global variable assignment") \
V(ConversionOverflow, "conversion overflow") \
V(CowArrayElementsChanged, "copy-on-write array's elements changed") \ V(CowArrayElementsChanged, "copy-on-write array's elements changed") \
V(CouldNotGrowElements, "failed to grow elements store") \
V(DeoptimizeNow, "%_DeoptimizeNow") \
V(DivisionByZero, "division by zero") \ V(DivisionByZero, "division by zero") \
V(ExpectedHeapNumber, "Expected heap number") \
V(ExpectedSmi, "Expected smi") \
V(ForcedDeoptToRuntime, "Forced deopt to runtime") \
V(Hole, "hole") \ V(Hole, "hole") \
V(InstanceMigrationFailed, "instance migration failed") \ V(InstanceMigrationFailed, "instance migration failed") \
V(InsufficientTypeFeedbackForCall, "Insufficient type feedback for call") \ V(InsufficientTypeFeedbackForCall, "Insufficient type feedback for call") \
V(InsufficientTypeFeedbackForCallWithArguments, \
"Insufficient type feedback for call with arguments") \
V(InsufficientTypeFeedbackForConstruct, \ V(InsufficientTypeFeedbackForConstruct, \
"Insufficient type feedback for construct") \ "Insufficient type feedback for construct") \
V(FastPathFailed, "Falling off the fast path") \
V(InsufficientTypeFeedbackForForIn, "Insufficient type feedback for for-in") \ V(InsufficientTypeFeedbackForForIn, "Insufficient type feedback for for-in") \
V(InsufficientTypeFeedbackForBinaryOperation, \ V(InsufficientTypeFeedbackForBinaryOperation, \
"Insufficient type feedback for binary operation") \ "Insufficient type feedback for binary operation") \
...@@ -40,48 +32,28 @@ namespace internal { ...@@ -40,48 +32,28 @@ namespace internal {
"Insufficient type feedback for generic keyed access") \ "Insufficient type feedback for generic keyed access") \
V(InsufficientTypeFeedbackForUnaryOperation, \ V(InsufficientTypeFeedbackForUnaryOperation, \
"Insufficient type feedback for unary operation") \ "Insufficient type feedback for unary operation") \
V(KeyIsNegative, "key is negative") \
V(LostPrecision, "lost precision") \ V(LostPrecision, "lost precision") \
V(LostPrecisionOrNaN, "lost precision or NaN") \ V(LostPrecisionOrNaN, "lost precision or NaN") \
V(MementoFound, "memento found") \
V(MinusZero, "minus zero") \ V(MinusZero, "minus zero") \
V(NaN, "NaN") \ V(NaN, "NaN") \
V(NegativeKeyEncountered, "Negative key encountered") \
V(NegativeValue, "negative value") \
V(NoCache, "no cache") \ V(NoCache, "no cache") \
V(NotAHeapNumber, "not a heap number") \ V(NotAHeapNumber, "not a heap number") \
V(NotAHeapNumberUndefined, "not a heap number/undefined") \
V(NotAJavaScriptObject, "not a JavaScript object") \ V(NotAJavaScriptObject, "not a JavaScript object") \
V(NotANumberOrOddball, "not a Number or Oddball") \ V(NotANumberOrOddball, "not a Number or Oddball") \
V(NotASmi, "not a Smi") \ V(NotASmi, "not a Smi") \
V(NotASymbol, "not a Symbol") \ V(NotASymbol, "not a Symbol") \
V(OutOfBounds, "out of bounds") \ V(OutOfBounds, "out of bounds") \
V(OutsideOfRange, "Outside of range") \
V(Overflow, "overflow") \ V(Overflow, "overflow") \
V(Proxy, "proxy") \
V(ReceiverNotAGlobalProxy, "receiver was not a global proxy") \ V(ReceiverNotAGlobalProxy, "receiver was not a global proxy") \
V(ReceiverWasAGlobalObject, "receiver was a global object") \
V(Smi, "Smi") \ V(Smi, "Smi") \
V(TooManyArguments, "too many arguments") \ V(Unknown, "(unknown)") \
V(TracingElementsTransitions, "Tracing elements transitions") \
V(TypeMismatchBetweenFeedbackAndConstant, \
"Type mismatch between feedback and constant") \
V(UnexpectedCellContentsInConstantGlobalStore, \
"Unexpected cell contents in constant global store") \
V(UnexpectedCellContentsInGlobalStore, \
"Unexpected cell contents in global store") \
V(UnexpectedObject, "unexpected object") \
V(UnknownMapInPolymorphicAccess, "Unknown map in polymorphic access") \
V(UnknownMapInPolymorphicCall, "Unknown map in polymorphic call") \
V(UnknownMapInPolymorphicElementAccess, \
"Unknown map in polymorphic element access") \
V(UnknownMap, "Unknown map") \
V(ValueMismatch, "value mismatch") \ V(ValueMismatch, "value mismatch") \
V(WrongCallTarget, "wrong call target") \
V(WrongEnumIndices, "wrong enum indices") \
V(WrongInstanceType, "wrong instance type") \ V(WrongInstanceType, "wrong instance type") \
V(WrongMap, "wrong map") \ V(WrongMap, "wrong map") \
V(WrongName, "wrong name") \ V(WrongName, "wrong name") \
V(UndefinedOrNullInForIn, "null or undefined in for-in") \ V(WrongValue, "wrong value")
V(UndefinedOrNullInToObject, "null or undefined in ToObject")
enum class DeoptimizeReason : uint8_t { enum class DeoptimizeReason : uint8_t {
#define DEOPTIMIZE_REASON(Name, message) k##Name, #define DEOPTIMIZE_REASON(Name, message) k##Name,
......
...@@ -2283,7 +2283,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state, ...@@ -2283,7 +2283,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state,
Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) {
CHECK(code->instruction_start() <= pc && pc <= code->instruction_end()); CHECK(code->instruction_start() <= pc && pc <= code->instruction_end());
SourcePosition last_position = SourcePosition::Unknown(); SourcePosition last_position = SourcePosition::Unknown();
DeoptimizeReason last_reason = DeoptimizeReason::kNoReason; DeoptimizeReason last_reason = DeoptimizeReason::kUnknown;
int last_deopt_id = kNoDeoptimizationId; int last_deopt_id = kNoDeoptimizationId;
int mask = RelocInfo::ModeMask(RelocInfo::DEOPT_REASON) | int mask = RelocInfo::ModeMask(RelocInfo::DEOPT_REASON) |
RelocInfo::ModeMask(RelocInfo::DEOPT_ID) | RelocInfo::ModeMask(RelocInfo::DEOPT_ID) |
......
...@@ -14131,7 +14131,7 @@ void JSFunction::ClearTypeFeedbackInfo() { ...@@ -14131,7 +14131,7 @@ void JSFunction::ClearTypeFeedbackInfo() {
void Code::PrintDeoptLocation(FILE* out, Address pc) { void Code::PrintDeoptLocation(FILE* out, Address pc) {
Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(this, pc); Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(this, pc);
class SourcePosition pos = info.position; class SourcePosition pos = info.position;
if (info.deopt_reason != DeoptimizeReason::kNoReason || pos.IsKnown()) { if (info.deopt_reason != DeoptimizeReason::kUnknown || pos.IsKnown()) {
PrintF(out, " ;;; deoptimize at "); PrintF(out, " ;;; deoptimize at ");
OFStream outstr(out); OFStream outstr(out);
pos.Print(outstr, this); pos.Print(outstr, this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment