Commit 10f392ac authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[csa] Clean up handling of type feedback variable.

This makes the code dealing with type feedback more concise and uniform
(at the cost of a few redundant comparisons).

Bug: 
Change-Id: If6b98bd1f0dddd392d7b00d65b600127bd30ff7e
Reviewed-on: https://chromium-review.googlesource.com/818984
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50035}
parent e1f23233
...@@ -3510,8 +3510,8 @@ Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) { ...@@ -3510,8 +3510,8 @@ Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) {
Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) { Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) {
VARIABLE(var_result, MachineRepresentation::kWord32); VARIABLE(var_result, MachineRepresentation::kWord32);
Label done(this); Label done(this);
TaggedToWord32OrBigIntImpl<Feedback::kNone, Object::Conversion::kToNumber>( TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumber>(context, value,
context, value, &done, &var_result); &done, &var_result);
BIND(&done); BIND(&done);
return var_result.value(); return var_result.value();
} }
...@@ -3523,7 +3523,7 @@ void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value, ...@@ -3523,7 +3523,7 @@ void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value,
Variable* var_word32, Variable* var_word32,
Label* if_bigint, Label* if_bigint,
Variable* var_bigint) { Variable* var_bigint) {
TaggedToWord32OrBigIntImpl<Feedback::kNone, Object::Conversion::kToNumeric>( TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>(
context, value, if_number, var_word32, if_bigint, var_bigint); context, value, if_number, var_word32, if_bigint, var_bigint);
} }
...@@ -3533,13 +3533,12 @@ void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value, ...@@ -3533,13 +3533,12 @@ void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value,
void CodeStubAssembler::TaggedToWord32OrBigIntWithFeedback( void CodeStubAssembler::TaggedToWord32OrBigIntWithFeedback(
Node* context, Node* value, Label* if_number, Variable* var_word32, Node* context, Node* value, Label* if_number, Variable* var_word32,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) { Label* if_bigint, Variable* var_bigint, Variable* var_feedback) {
TaggedToWord32OrBigIntImpl<Feedback::kCollect, TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>(
Object::Conversion::kToNumeric>(
context, value, if_number, var_word32, if_bigint, var_bigint, context, value, if_number, var_word32, if_bigint, var_bigint,
var_feedback); var_feedback);
} }
template <CodeStubAssembler::Feedback feedback, Object::Conversion conversion> template <Object::Conversion conversion>
void CodeStubAssembler::TaggedToWord32OrBigIntImpl( void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
Node* context, Node* value, Label* if_number, Variable* var_word32, Node* context, Node* value, Label* if_number, Variable* var_word32,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) { Label* if_bigint, Variable* var_bigint, Variable* var_feedback) {
...@@ -3551,14 +3550,10 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -3551,14 +3550,10 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
// We might need to loop after conversion. // We might need to loop after conversion.
VARIABLE(var_value, MachineRepresentation::kTagged, value); VARIABLE(var_value, MachineRepresentation::kTagged, value);
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNone);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kNone));
} else {
DCHECK(var_feedback == nullptr);
}
Variable* loop_vars[] = {&var_value, var_feedback}; Variable* loop_vars[] = {&var_value, var_feedback};
int num_vars = feedback == Feedback::kCollect ? arraysize(loop_vars) int num_vars =
: arraysize(loop_vars) - 1; var_feedback != nullptr ? arraysize(loop_vars) : arraysize(loop_vars) - 1;
Label loop(this, num_vars, loop_vars); Label loop(this, num_vars, loop_vars);
Goto(&loop); Goto(&loop);
BIND(&loop); BIND(&loop);
...@@ -3570,11 +3565,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -3570,11 +3565,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
// {value} is a Smi. // {value} is a Smi.
var_word32->Bind(SmiToWord32(value)); var_word32->Bind(SmiToWord32(value));
if (feedback == Feedback::kCollect) { CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
var_feedback->Bind(
SmiOr(var_feedback->value(),
SmiConstant(BinaryOperationFeedback::kSignedSmall)));
}
Goto(if_number); Goto(if_number);
BIND(&not_smi); BIND(&not_smi);
...@@ -3587,7 +3578,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -3587,7 +3578,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
// Not HeapNumber (or BigInt if conversion == kToNumeric). // Not HeapNumber (or BigInt if conversion == kToNumeric).
{ {
if (feedback == Feedback::kCollect) { if (var_feedback != nullptr) {
// We do not require an Or with earlier feedback here because once we // We do not require an Or with earlier feedback here because once we
// convert the value to a Numeric, we cannot reach this path. We can // convert the value to a Numeric, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone. // only reach this path on the first pass when the feedback is kNone.
...@@ -3600,36 +3591,25 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -3600,36 +3591,25 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
? Builtins::kNonNumberToNumeric ? Builtins::kNonNumberToNumeric
: Builtins::kNonNumberToNumber; : Builtins::kNonNumberToNumber;
var_value.Bind(CallBuiltin(builtin, context, value)); var_value.Bind(CallBuiltin(builtin, context, value));
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kAny));
}
Goto(&loop); Goto(&loop);
BIND(&is_oddball); BIND(&is_oddball);
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset)); var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset));
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback,
var_feedback->Bind( BinaryOperationFeedback::kNumberOrOddball);
SmiConstant(BinaryOperationFeedback::kNumberOrOddball));
}
Goto(&loop); Goto(&loop);
} }
BIND(&is_heap_number); BIND(&is_heap_number);
var_word32->Bind(TruncateHeapNumberValueToWord32(value)); var_word32->Bind(TruncateHeapNumberValueToWord32(value));
if (feedback == Feedback::kCollect) { CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber);
var_feedback->Bind(SmiOr(var_feedback->value(),
SmiConstant(BinaryOperationFeedback::kNumber)));
}
Goto(if_number); Goto(if_number);
if (conversion == Object::Conversion::kToNumeric) { if (conversion == Object::Conversion::kToNumeric) {
BIND(&is_bigint); BIND(&is_bigint);
var_bigint->Bind(value); var_bigint->Bind(value);
if (feedback == Feedback::kCollect) { CombineFeedback(var_feedback, BinaryOperationFeedback::kBigInt);
var_feedback->Bind(
SmiOr(var_feedback->value(),
SmiConstant(BinaryOperationFeedback::kBigInt)));
}
Goto(if_bigint); Goto(if_bigint);
} }
} }
...@@ -5528,18 +5508,17 @@ TNode<Number> CodeStubAssembler::ToNumber(SloppyTNode<Context> context, ...@@ -5528,18 +5508,17 @@ TNode<Number> CodeStubAssembler::ToNumber(SloppyTNode<Context> context,
void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done, void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
Variable* var_numeric) { Variable* var_numeric) {
TaggedToNumeric<Feedback::kNone>(context, value, done, var_numeric); TaggedToNumeric(context, value, done, var_numeric, nullptr);
} }
void CodeStubAssembler::TaggedToNumericWithFeedback(Node* context, Node* value, void CodeStubAssembler::TaggedToNumericWithFeedback(Node* context, Node* value,
Label* done, Label* done,
Variable* var_numeric, Variable* var_numeric,
Variable* var_feedback) { Variable* var_feedback) {
TaggedToNumeric<Feedback::kCollect>(context, value, done, var_numeric, DCHECK_NOT_NULL(var_feedback);
var_feedback); TaggedToNumeric(context, value, done, var_numeric, var_feedback);
} }
template <CodeStubAssembler::Feedback feedback>
void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done, void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
Variable* var_numeric, Variable* var_numeric,
Variable* var_feedback) { Variable* var_feedback) {
...@@ -5554,34 +5533,24 @@ void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done, ...@@ -5554,34 +5533,24 @@ void CodeStubAssembler::TaggedToNumeric(Node* context, Node* value, Label* done,
// {value} is not a Numeric yet. // {value} is not a Numeric yet.
GotoIf(Word32Equal(instance_type, Int32Constant(ODDBALL_TYPE)), &if_oddball); GotoIf(Word32Equal(instance_type, Int32Constant(ODDBALL_TYPE)), &if_oddball);
var_numeric->Bind(CallBuiltin(Builtins::kNonNumberToNumeric, context, value)); var_numeric->Bind(CallBuiltin(Builtins::kNonNumberToNumeric, context, value));
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kAny));
}
Goto(done); Goto(done);
BIND(&if_smi); BIND(&if_smi);
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kSignedSmall));
}
Goto(done); Goto(done);
BIND(&if_heapnumber); BIND(&if_heapnumber);
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNumber);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kNumber));
}
Goto(done); Goto(done);
BIND(&if_bigint); BIND(&if_bigint);
if (feedback == Feedback::kCollect) { OverwriteFeedback(var_feedback, BinaryOperationFeedback::kBigInt);
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kBigInt));
}
Goto(done); Goto(done);
BIND(&if_oddball); BIND(&if_oddball);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNumberOrOddball);
var_numeric->Bind(LoadObjectField(value, Oddball::kToNumberOffset)); var_numeric->Bind(LoadObjectField(value, Oddball::kToNumberOffset));
if (feedback == Feedback::kCollect) {
var_feedback->Bind(SmiConstant(BinaryOperationFeedback::kNumberOrOddball));
}
Goto(done); Goto(done);
} }
...@@ -7380,8 +7349,22 @@ void CodeStubAssembler::ReportFeedbackUpdate( ...@@ -7380,8 +7349,22 @@ void CodeStubAssembler::ReportFeedbackUpdate(
#endif // V8_TRACE_FEEDBACK_UPDATES #endif // V8_TRACE_FEEDBACK_UPDATES
} }
void CodeStubAssembler::OverwriteFeedback(Variable* existing_feedback,
int new_feedback) {
if (existing_feedback == nullptr) return;
existing_feedback->Bind(SmiConstant(new_feedback));
}
void CodeStubAssembler::CombineFeedback(Variable* existing_feedback,
int feedback) {
if (existing_feedback == nullptr) return;
existing_feedback->Bind(
SmiOr(existing_feedback->value(), SmiConstant(feedback)));
}
void CodeStubAssembler::CombineFeedback(Variable* existing_feedback, void CodeStubAssembler::CombineFeedback(Variable* existing_feedback,
Node* feedback) { Node* feedback) {
if (existing_feedback == nullptr) return;
existing_feedback->Bind(SmiOr(existing_feedback->value(), feedback)); existing_feedback->Bind(SmiOr(existing_feedback->value(), feedback));
} }
...@@ -8323,10 +8306,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8323,10 +8306,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsissmi); BIND(&if_rhsissmi);
{ {
// Both {lhs} and {rhs} are Smi, so just perform a fast Smi comparison. // Both {lhs} and {rhs} are Smi, so just perform a fast Smi comparison.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, CompareOperationFeedback::kSignedSmall);
SmiConstant(CompareOperationFeedback::kSignedSmall));
}
switch (op) { switch (op) {
case Operation::kLessThan: case Operation::kLessThan:
BranchIfSmiLessThan(lhs, rhs, &return_true, &return_false); BranchIfSmiLessThan(lhs, rhs, &return_true, &return_false);
...@@ -8349,10 +8330,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8349,10 +8330,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
{ {
// Convert the {lhs} and {rhs} to floating point values, and // Convert the {lhs} and {rhs} to floating point values, and
// perform a floating point comparison. // perform a floating point comparison.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kNumber));
}
var_fcmp_lhs.Bind(SmiToFloat64(lhs)); var_fcmp_lhs.Bind(SmiToFloat64(lhs));
var_fcmp_rhs.Bind(LoadHeapNumberValue(rhs)); var_fcmp_rhs.Bind(LoadHeapNumberValue(rhs));
Goto(&do_fcmp); Goto(&do_fcmp);
...@@ -8361,9 +8339,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8361,9 +8339,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisbigint); BIND(&if_rhsisbigint);
{ {
// The {lhs} is a Smi and {rhs} is a BigInt. // The {lhs} is a Smi and {rhs} is a BigInt.
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback, CompareOperationFeedback::kAny);
var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kAny));
}
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber, result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
NoContextConstant(), SmiConstant(Reverse(op)), NoContextConstant(), SmiConstant(Reverse(op)),
rhs, lhs)); rhs, lhs));
...@@ -8373,9 +8349,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8373,9 +8349,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisnotnumeric); BIND(&if_rhsisnotnumeric);
{ {
// The {lhs} is a Smi and {rhs} is not a Numeric. // The {lhs} is a Smi and {rhs} is not a Numeric.
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback, CompareOperationFeedback::kAny);
var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kAny));
}
// Convert the {rhs} to a Numeric; we don't need to perform the // Convert the {rhs} to a Numeric; we don't need to perform the
// dedicated ToPrimitive(rhs, hint Number) operation, as the // dedicated ToPrimitive(rhs, hint Number) operation, as the
// ToNumeric(rhs) will by itself already invoke ToPrimitive with // ToNumeric(rhs) will by itself already invoke ToPrimitive with
...@@ -8406,10 +8380,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8406,10 +8380,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
{ {
// Convert the {lhs} and {rhs} to floating point values, and // Convert the {lhs} and {rhs} to floating point values, and
// perform a floating point comparison. // perform a floating point comparison.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kNumber));
}
var_fcmp_lhs.Bind(LoadHeapNumberValue(lhs)); var_fcmp_lhs.Bind(LoadHeapNumberValue(lhs));
var_fcmp_rhs.Bind(SmiToFloat64(rhs)); var_fcmp_rhs.Bind(SmiToFloat64(rhs));
Goto(&do_fcmp); Goto(&do_fcmp);
...@@ -8417,10 +8388,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8417,10 +8388,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_lhsisbigint); BIND(&if_lhsisbigint);
{ {
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback, CompareOperationFeedback::kAny);
var_type_feedback->Bind(
SmiConstant(CompareOperationFeedback::kAny));
}
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber, result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
NoContextConstant(), SmiConstant(op), lhs, NoContextConstant(), SmiConstant(op), lhs,
rhs)); rhs));
...@@ -8430,10 +8398,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8430,10 +8398,7 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_lhsisnotnumeric); BIND(&if_lhsisnotnumeric);
{ {
// The {lhs} is not a Numeric and {rhs} is an Smi. // The {lhs} is not a Numeric and {rhs} is an Smi.
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback, CompareOperationFeedback::kAny);
var_type_feedback->Bind(
SmiConstant(CompareOperationFeedback::kAny));
}
// Convert the {lhs} to a Numeric; we don't need to perform the // Convert the {lhs} to a Numeric; we don't need to perform the
// dedicated ToPrimitive(lhs, hint Number) operation, as the // dedicated ToPrimitive(lhs, hint Number) operation, as the
// ToNumeric(lhs) will by itself already invoke ToPrimitive with // ToNumeric(lhs) will by itself already invoke ToPrimitive with
...@@ -8473,10 +8438,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8473,10 +8438,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
{ {
// Convert the {lhs} and {rhs} to floating point values, and // Convert the {lhs} and {rhs} to floating point values, and
// perform a floating point comparison. // perform a floating point comparison.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
SmiConstant(CompareOperationFeedback::kNumber));
}
var_fcmp_lhs.Bind(LoadHeapNumberValue(lhs)); var_fcmp_lhs.Bind(LoadHeapNumberValue(lhs));
var_fcmp_rhs.Bind(LoadHeapNumberValue(rhs)); var_fcmp_rhs.Bind(LoadHeapNumberValue(rhs));
Goto(&do_fcmp); Goto(&do_fcmp);
...@@ -8484,10 +8447,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8484,10 +8447,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisbigint); BIND(&if_rhsisbigint);
{ {
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback,
var_type_feedback->Bind( CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
}
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber, result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
NoContextConstant(), NoContextConstant(),
SmiConstant(Reverse(op)), rhs, lhs)); SmiConstant(Reverse(op)), rhs, lhs));
...@@ -8497,10 +8458,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8497,10 +8458,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisnotnumeric); BIND(&if_rhsisnotnumeric);
{ {
// The {lhs} is a HeapNumber and {rhs} is not a Numeric. // The {lhs} is a HeapNumber and {rhs} is not a Numeric.
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback,
var_type_feedback->Bind( CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
}
// Convert the {rhs} to a Numeric; we don't need to perform // Convert the {rhs} to a Numeric; we don't need to perform
// dedicated ToPrimitive(rhs, hint Number) operation, as the // dedicated ToPrimitive(rhs, hint Number) operation, as the
// ToNumeric(rhs) will by itself already invoke ToPrimitive with // ToNumeric(rhs) will by itself already invoke ToPrimitive with
...@@ -8522,10 +8481,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8522,10 +8481,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisheapnumber); BIND(&if_rhsisheapnumber);
{ {
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback,
var_type_feedback->Bind( CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
}
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber, result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
NoContextConstant(), SmiConstant(op), lhs, NoContextConstant(), SmiConstant(op), lhs,
rhs)); rhs));
...@@ -8534,10 +8491,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8534,10 +8491,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisbigint); BIND(&if_rhsisbigint);
{ {
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, CompareOperationFeedback::kBigInt);
SmiConstant(CompareOperationFeedback::kBigInt));
}
result.Bind(CallRuntime(Runtime::kBigIntCompareToBigInt, result.Bind(CallRuntime(Runtime::kBigIntCompareToBigInt,
NoContextConstant(), SmiConstant(op), lhs, NoContextConstant(), SmiConstant(op), lhs,
rhs)); rhs));
...@@ -8546,10 +8501,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8546,10 +8501,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisnotnumeric); BIND(&if_rhsisnotnumeric);
{ {
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback,
var_type_feedback->Bind( CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
}
// Convert the {rhs} to a Numeric; we don't need to perform // Convert the {rhs} to a Numeric; we don't need to perform
// dedicated ToPrimitive(rhs, hint Number) operation, as the // dedicated ToPrimitive(rhs, hint Number) operation, as the
// ToNumeric(rhs) will by itself already invoke ToPrimitive with // ToNumeric(rhs) will by itself already invoke ToPrimitive with
...@@ -8574,10 +8527,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8574,10 +8527,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisstring); BIND(&if_rhsisstring);
{ {
// Both {lhs} and {rhs} are strings. // Both {lhs} and {rhs} are strings.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, CompareOperationFeedback::kString);
SmiConstant(CompareOperationFeedback::kString));
}
switch (op) { switch (op) {
case Operation::kLessThan: case Operation::kLessThan:
result.Bind( result.Bind(
...@@ -8607,10 +8558,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8607,10 +8558,8 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&if_rhsisnotstring); BIND(&if_rhsisnotstring);
{ {
// The {lhs} is a String and {rhs} is not a String. // The {lhs} is a String and {rhs} is not a String.
if (var_type_feedback != nullptr) { OverwriteFeedback(var_type_feedback,
var_type_feedback->Bind( CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
}
// The {lhs} is a String, while {rhs} isn't. So we call // The {lhs} is a String, while {rhs} isn't. So we call
// ToPrimitive(rhs, hint Number) if {rhs} is a receiver, or // ToPrimitive(rhs, hint Number) if {rhs} is a receiver, or
// ToNumeric(lhs) and then ToNumeric(rhs) in the other cases. // ToNumeric(lhs) and then ToNumeric(rhs) in the other cases.
...@@ -8661,16 +8610,15 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs, ...@@ -8661,16 +8610,15 @@ Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
BIND(&collect_oddball_feedback); BIND(&collect_oddball_feedback);
{ {
CombineFeedback( CombineFeedback(var_type_feedback,
var_type_feedback, CompareOperationFeedback::kNumberOrOddball);
SmiConstant(CompareOperationFeedback::kNumberOrOddball));
Goto(&collect_feedback_done); Goto(&collect_feedback_done);
} }
BIND(&collect_any_feedback); BIND(&collect_any_feedback);
{ {
var_type_feedback->Bind( OverwriteFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kAny)); CompareOperationFeedback::kAny);
Goto(&collect_feedback_done); Goto(&collect_feedback_done);
} }
...@@ -8790,29 +8738,25 @@ void CodeStubAssembler::GenerateEqual_Same(Node* value, Label* if_equal, ...@@ -8790,29 +8738,25 @@ void CodeStubAssembler::GenerateEqual_Same(Node* value, Label* if_equal,
BIND(&if_symbol); BIND(&if_symbol);
{ {
CombineFeedback(var_type_feedback, CombineFeedback(var_type_feedback, CompareOperationFeedback::kSymbol);
SmiConstant(CompareOperationFeedback::kSymbol));
Goto(if_equal); Goto(if_equal);
} }
BIND(&if_receiver); BIND(&if_receiver);
{ {
CombineFeedback(var_type_feedback, CombineFeedback(var_type_feedback, CompareOperationFeedback::kReceiver);
SmiConstant(CompareOperationFeedback::kReceiver));
Goto(if_equal); Goto(if_equal);
} }
BIND(&if_bigint); BIND(&if_bigint);
{ {
CombineFeedback(var_type_feedback, CombineFeedback(var_type_feedback, CompareOperationFeedback::kBigInt);
SmiConstant(CompareOperationFeedback::kBigInt));
Goto(if_equal); Goto(if_equal);
} }
BIND(&if_other); BIND(&if_other);
{ {
CombineFeedback(var_type_feedback, CombineFeedback(var_type_feedback, CompareOperationFeedback::kAny);
SmiConstant(CompareOperationFeedback::kAny));
Goto(if_equal); Goto(if_equal);
} }
} else { } else {
...@@ -8821,20 +8765,14 @@ void CodeStubAssembler::GenerateEqual_Same(Node* value, Label* if_equal, ...@@ -8821,20 +8765,14 @@ void CodeStubAssembler::GenerateEqual_Same(Node* value, Label* if_equal,
BIND(&if_heapnumber); BIND(&if_heapnumber);
{ {
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kNumber));
}
Node* number_value = LoadHeapNumberValue(value); Node* number_value = LoadHeapNumberValue(value);
BranchIfFloat64IsNaN(number_value, if_notequal, if_equal); BranchIfFloat64IsNaN(number_value, if_notequal, if_equal);
} }
BIND(&if_smi); BIND(&if_smi);
{ {
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kSignedSmall);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kSignedSmall));
}
Goto(if_equal); Goto(if_equal);
} }
} }
...@@ -8862,9 +8800,9 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8862,9 +8800,9 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
VARIABLE(var_right, MachineRepresentation::kTagged, right); VARIABLE(var_right, MachineRepresentation::kTagged, right);
VariableList loop_variable_list({&var_left, &var_right}, zone()); VariableList loop_variable_list({&var_left, &var_right}, zone());
if (var_type_feedback != nullptr) { if (var_type_feedback != nullptr) {
// Initialize the type feedback to None. The current feedback is combined // Initialize the type feedback to None. The current feedback will be
// with the previous feedback. // combined with the previous feedback.
var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kNone)); OverwriteFeedback(var_type_feedback, CompareOperationFeedback::kNone);
loop_variable_list.push_back(var_type_feedback); loop_variable_list.push_back(var_type_feedback);
} }
Label loop(this, loop_variable_list); Label loop(this, loop_variable_list);
...@@ -8895,10 +8833,8 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8895,10 +8833,8 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
{ {
// We have already checked for {left} and {right} being the same value, // We have already checked for {left} and {right} being the same value,
// so when we get here they must be different Smis. // so when we get here they must be different Smis.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, CompareOperationFeedback::kSignedSmall);
SmiConstant(CompareOperationFeedback::kSignedSmall));
}
Goto(&if_notequal); Goto(&if_notequal);
} }
...@@ -8923,10 +8859,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8923,10 +8859,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
{ {
var_left_float = SmiToFloat64(left); var_left_float = SmiToFloat64(left);
var_right_float = LoadHeapNumberValue(right); var_right_float = LoadHeapNumberValue(right);
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kNumber));
}
Goto(&do_float_comparison); Goto(&do_float_comparison);
} }
...@@ -8976,11 +8909,9 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8976,11 +8909,9 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
{ {
GotoIfNot(IsStringInstanceType(right_type), &use_symmetry); GotoIfNot(IsStringInstanceType(right_type), &use_symmetry);
result.Bind(CallBuiltin(Builtins::kStringEqual, context, left, right)); result.Bind(CallBuiltin(Builtins::kStringEqual, context, left, right));
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback,
CombineFeedback(var_type_feedback, SmiOr(CollectFeedbackForString(left_type),
SmiOr(CollectFeedbackForString(left_type), CollectFeedbackForString(right_type)));
CollectFeedbackForString(right_type)));
}
Goto(&end); Goto(&end);
} }
...@@ -8991,10 +8922,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8991,10 +8922,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
var_left_float = LoadHeapNumberValue(left); var_left_float = LoadHeapNumberValue(left);
var_right_float = LoadHeapNumberValue(right); var_right_float = LoadHeapNumberValue(right);
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kNumber);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kNumber));
}
Goto(&do_float_comparison); Goto(&do_float_comparison);
BIND(&if_right_not_number); BIND(&if_right_not_number);
...@@ -9042,10 +8970,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -9042,10 +8970,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
BIND(&if_right_bigint); BIND(&if_right_bigint);
{ {
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kBigInt);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kBigInt));
}
result.Bind(CallRuntime(Runtime::kBigIntEqualToBigInt, result.Bind(CallRuntime(Runtime::kBigIntEqualToBigInt,
NoContextConstant(), left, right)); NoContextConstant(), left, right));
Goto(&end); Goto(&end);
...@@ -9110,7 +9035,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -9110,7 +9035,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
BIND(&if_right_symbol); BIND(&if_right_symbol);
{ {
CombineFeedback(var_type_feedback, CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kSymbol)); CompareOperationFeedback::kSymbol);
Goto(&if_notequal); Goto(&if_notequal);
} }
} else { } else {
...@@ -9136,10 +9061,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -9136,10 +9061,7 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
GotoIfNot(IsJSReceiverInstanceType(right_type), &if_right_not_receiver); GotoIfNot(IsJSReceiverInstanceType(right_type), &if_right_not_receiver);
// {left} and {right} are different JSReceiver references. // {left} and {right} are different JSReceiver references.
if (var_type_feedback != nullptr) { CombineFeedback(var_type_feedback, CompareOperationFeedback::kReceiver);
CombineFeedback(var_type_feedback,
SmiConstant(CompareOperationFeedback::kReceiver));
}
Goto(&if_notequal); Goto(&if_notequal);
BIND(&if_right_not_receiver); BIND(&if_right_not_receiver);
......
...@@ -1634,9 +1634,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1634,9 +1634,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
void ReportFeedbackUpdate(SloppyTNode<FeedbackVector> feedback_vector, void ReportFeedbackUpdate(SloppyTNode<FeedbackVector> feedback_vector,
SloppyTNode<IntPtrT> slot_id, const char* reason); SloppyTNode<IntPtrT> slot_id, const char* reason);
// Combine the new feedback with the existing_feedback. // Combine the new feedback with the existing_feedback. Do nothing if
// existing_feedback is nullptr.
void CombineFeedback(Variable* existing_feedback, int feedback);
void CombineFeedback(Variable* existing_feedback, Node* feedback); void CombineFeedback(Variable* existing_feedback, Node* feedback);
// Overwrite the existing feedback with new_feedback. Do nothing if
// existing_feedback is nullptr.
void OverwriteFeedback(Variable* existing_feedback, int new_feedback);
// Check if a property name might require protector invalidation when it is // Check if a property name might require protector invalidation when it is
// used for a property store or deletion. // used for a property store or deletion.
void CheckForAssociatedProtector(Node* name, Label* if_protector); void CheckForAssociatedProtector(Node* name, Label* if_protector);
...@@ -1931,12 +1937,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1931,12 +1937,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* context, Node* input, Object::Conversion mode, Node* context, Node* input, Object::Conversion mode,
BigIntHandling bigint_handling = BigIntHandling::kThrow); BigIntHandling bigint_handling = BigIntHandling::kThrow);
enum class Feedback { kCollect, kNone };
template <Feedback feedback>
void TaggedToNumeric(Node* context, Node* value, Label* done, void TaggedToNumeric(Node* context, Node* value, Label* done,
Variable* var_numeric, Variable* var_feedback = nullptr); Variable* var_numeric, Variable* var_feedback);
template <Feedback feedback, Object::Conversion conversion> template <Object::Conversion conversion>
void TaggedToWord32OrBigIntImpl(Node* context, Node* value, Label* if_number, void TaggedToWord32OrBigIntImpl(Node* context, Node* value, Label* if_number,
Variable* var_word32, Variable* var_word32,
Label* if_bigint = nullptr, Label* if_bigint = nullptr,
......
...@@ -1301,8 +1301,8 @@ class CompareOperationFeedback { ...@@ -1301,8 +1301,8 @@ class CompareOperationFeedback {
kInternalizedString = 0x8, kInternalizedString = 0x8,
kString = 0x18, kString = 0x18,
kSymbol = 0x20, kSymbol = 0x20,
kBigInt = 0x30,
kReceiver = 0x40, kReceiver = 0x40,
kBigInt = 0x80,
kAny = 0xff kAny = 0xff
}; };
}; };
......
...@@ -1245,8 +1245,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler { ...@@ -1245,8 +1245,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler {
BIND(&if_bigint); BIND(&if_bigint);
{ {
var_result.Bind(BigIntOp(value)); var_result.Bind(BigIntOp(value));
CombineFeedback(&var_feedback, CombineFeedback(&var_feedback, BinaryOperationFeedback::kBigInt);
SmiConstant(BinaryOperationFeedback::kBigInt));
Goto(&end); Goto(&end);
} }
...@@ -1257,8 +1256,8 @@ class UnaryNumericOpAssembler : public InterpreterAssembler { ...@@ -1257,8 +1256,8 @@ class UnaryNumericOpAssembler : public InterpreterAssembler {
// only reach this path on the first pass when the feedback is kNone. // only reach this path on the first pass when the feedback is kNone.
CSA_ASSERT(this, SmiEqual(var_feedback.value(), CSA_ASSERT(this, SmiEqual(var_feedback.value(),
SmiConstant(BinaryOperationFeedback::kNone))); SmiConstant(BinaryOperationFeedback::kNone)));
var_feedback.Bind( OverwriteFeedback(&var_feedback,
SmiConstant(BinaryOperationFeedback::kNumberOrOddball)); BinaryOperationFeedback::kNumberOrOddball);
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset)); var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset));
Goto(&start); Goto(&start);
} }
...@@ -1270,7 +1269,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler { ...@@ -1270,7 +1269,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler {
// only reach this path on the first pass when the feedback is kNone. // only reach this path on the first pass when the feedback is kNone.
CSA_ASSERT(this, SmiEqual(var_feedback.value(), CSA_ASSERT(this, SmiEqual(var_feedback.value(),
SmiConstant(BinaryOperationFeedback::kNone))); SmiConstant(BinaryOperationFeedback::kNone)));
var_feedback.Bind(SmiConstant(BinaryOperationFeedback::kAny)); OverwriteFeedback(&var_feedback, BinaryOperationFeedback::kAny);
var_value.Bind( var_value.Bind(
CallBuiltin(Builtins::kNonNumberToNumeric, GetContext(), value)); CallBuiltin(Builtins::kNonNumberToNumeric, GetContext(), value));
Goto(&start); Goto(&start);
...@@ -1279,8 +1278,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler { ...@@ -1279,8 +1278,7 @@ class UnaryNumericOpAssembler : public InterpreterAssembler {
BIND(&do_float_op); BIND(&do_float_op);
{ {
CombineFeedback(&var_feedback, CombineFeedback(&var_feedback, BinaryOperationFeedback::kNumber);
SmiConstant(BinaryOperationFeedback::kNumber));
var_result.Bind( var_result.Bind(
AllocateHeapNumberWithValue(FloatOp(var_float_value.value()))); AllocateHeapNumberWithValue(FloatOp(var_float_value.value())));
Goto(&end); Goto(&end);
...@@ -1310,14 +1308,12 @@ class NegateAssemblerImpl : public UnaryNumericOpAssembler { ...@@ -1310,14 +1308,12 @@ class NegateAssemblerImpl : public UnaryNumericOpAssembler {
GotoIf(SmiEqual(smi_value, SmiConstant(Smi::kMinValue)), &if_min_smi); GotoIf(SmiEqual(smi_value, SmiConstant(Smi::kMinValue)), &if_min_smi);
// Else simply subtract operand from 0. // Else simply subtract operand from 0.
CombineFeedback(var_feedback, CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
SmiConstant(BinaryOperationFeedback::kSignedSmall));
var_result.Bind(SmiSub(SmiConstant(0), smi_value)); var_result.Bind(SmiSub(SmiConstant(0), smi_value));
Goto(&end); Goto(&end);
BIND(&if_zero); BIND(&if_zero);
CombineFeedback(var_feedback, CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber);
SmiConstant(BinaryOperationFeedback::kNumber));
var_result.Bind(MinusZeroConstant()); var_result.Bind(MinusZeroConstant());
Goto(&end); Goto(&end);
...@@ -1412,8 +1408,7 @@ class IncDecAssembler : public UnaryNumericOpAssembler { ...@@ -1412,8 +1408,7 @@ class IncDecAssembler : public UnaryNumericOpAssembler {
} }
BIND(&if_notoverflow); BIND(&if_notoverflow);
CombineFeedback(var_feedback, CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
SmiConstant(BinaryOperationFeedback::kSignedSmall));
return BitcastWordToTaggedSigned(Projection(0, pair)); return BitcastWordToTaggedSigned(Projection(0, pair));
} }
......
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