Commit 721e74d9 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Collect NumberOrOddball feedback in CompareOps.

Collect feedback for oddballs in the interpreter compare operations handlers.
This is important to ensure that we don't consider oddball comparisons as
generic, which prevents optimization.

BUG=chromium:660947

Review-Url: https://codereview.chromium.org/2506283003
Cr-Commit-Position: refs/heads/master@{#41081}
parent 541c36c0
......@@ -1244,8 +1244,8 @@ class BinaryOperationFeedback {
// Type feedback is encoded in such a way that, we can combine the feedback
// at different points by performing an 'OR' operation. Type feedback moves
// to a more generic type when we combine feedback.
// kSignedSmall -> kNumber -> kAny
// kString -> kAny
// kSignedSmall -> kNumber -> kNumberOrOddball -> kAny
// kString -> kAny
// TODO(epertoso): consider unifying this with BinaryOperationFeedback.
class CompareOperationFeedback {
public:
......@@ -1253,8 +1253,9 @@ class CompareOperationFeedback {
kNone = 0x00,
kSignedSmall = 0x01,
kNumber = 0x3,
kString = 0x4,
kAny = 0xf
kNumberOrOddball = 0x7,
kString = 0x8,
kAny = 0x1F
};
};
......
......@@ -1008,8 +1008,8 @@ void Interpreter::DoCompareOpWithFeedback(Token::Value compare_op,
{
Variable var_type_feedback(assembler, MachineRepresentation::kWord32);
Label lhs_is_not_smi(assembler), lhs_is_not_number(assembler),
lhs_is_not_string(assembler), gather_rhs_type(assembler),
update_feedback(assembler);
lhs_is_not_oddball(assembler), lhs_is_not_string(assembler),
gather_rhs_type(assembler), update_feedback(assembler);
__ GotoUnless(__ TaggedIsSmi(lhs), &lhs_is_not_smi);
......@@ -1030,19 +1030,31 @@ void Interpreter::DoCompareOpWithFeedback(Token::Value compare_op,
__ Bind(&lhs_is_not_number);
{
Node* lhs_instance_type = __ LoadInstanceType(lhs);
Node* lhs_type =
__ Select(__ IsStringInstanceType(lhs_instance_type),
__ Int32Constant(CompareOperationFeedback::kString),
__ Int32Constant(CompareOperationFeedback::kAny));
Node* lhs_is_oddball =
__ Word32Equal(lhs_instance_type, __ Int32Constant(ODDBALL_TYPE));
__ GotoUnless(lhs_is_oddball, &lhs_is_not_oddball);
var_type_feedback.Bind(lhs_type);
var_type_feedback.Bind(
__ Int32Constant(CompareOperationFeedback::kNumberOrOddball));
__ Goto(&gather_rhs_type);
__ Bind(&lhs_is_not_oddball);
{
Node* lhs_type =
__ Select(__ IsStringInstanceType(lhs_instance_type),
__ Int32Constant(CompareOperationFeedback::kString),
__ Int32Constant(CompareOperationFeedback::kAny));
var_type_feedback.Bind(lhs_type);
__ Goto(&gather_rhs_type);
}
}
}
__ Bind(&gather_rhs_type);
{
Label rhs_is_not_smi(assembler), rhs_is_not_number(assembler);
Label rhs_is_not_smi(assembler), rhs_is_not_number(assembler),
rhs_is_not_oddball(assembler);
__ GotoUnless(__ TaggedIsSmi(rhs), &rhs_is_not_smi);
......@@ -1065,13 +1077,24 @@ void Interpreter::DoCompareOpWithFeedback(Token::Value compare_op,
__ Bind(&rhs_is_not_number);
{
Node* rhs_instance_type = __ LoadInstanceType(rhs);
Node* rhs_type =
__ Select(__ IsStringInstanceType(rhs_instance_type),
__ Int32Constant(CompareOperationFeedback::kString),
__ Int32Constant(CompareOperationFeedback::kAny));
Node* rhs_is_oddball =
__ Word32Equal(rhs_instance_type, __ Int32Constant(ODDBALL_TYPE));
__ GotoUnless(rhs_is_oddball, &rhs_is_not_oddball);
var_type_feedback.Bind(
__ Word32Or(var_type_feedback.value(), rhs_type));
__ Goto(&update_feedback);
__ Int32Constant(CompareOperationFeedback::kNumberOrOddball));
__ Goto(&do_compare);
__ Bind(&rhs_is_not_oddball);
{
Node* rhs_type =
__ Select(__ IsStringInstanceType(rhs_instance_type),
__ Int32Constant(CompareOperationFeedback::kString),
__ Int32Constant(CompareOperationFeedback::kAny));
var_type_feedback.Bind(
__ Word32Or(var_type_feedback.value(), rhs_type));
__ Goto(&update_feedback);
}
}
}
}
......
......@@ -149,6 +149,8 @@ CompareOperationHint CompareOperationHintFromFeedback(int type_feedback) {
return CompareOperationHint::kSignedSmall;
case CompareOperationFeedback::kNumber:
return CompareOperationHint::kNumber;
case CompareOperationFeedback::kNumberOrOddball:
return CompareOperationHint::kNumberOrOddball;
case CompareOperationFeedback::kString:
return CompareOperationHint::kString;
default:
......
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