Commit 8a80c3b7 authored by mythria's avatar mythria Committed by Commit bot

[Interpreter] Collect feedback about Oddballs in Bitwise, Inc, Dec operations.

Add support to collect feedback about oddballs for Bitwise binary operations and
Increment and decrement operations. For the case of Oddballs the code to convert
them to numbers is inlined into the handlers instead of calling the
NonNumberToNumber Stub.

BUG=v8:4280, v8:5400

Review-Url: https://chromiumcodereview.appspot.com/2407103003
Cr-Commit-Position: refs/heads/master@{#40468}
parent f36713b5
......@@ -1750,6 +1750,31 @@ compiler::Node* IncStub::Generate(CodeStubAssembler* assembler,
}
assembler->Bind(&if_valuenotnumber);
{
// We do not require an Or with earlier feedback here because once we
// convert the value to a number, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
assembler->Assert(assembler->Word32Equal(
var_type_feedback.value(),
assembler->Int32Constant(BinaryOperationFeedback::kNone)));
Label if_valueisoddball(assembler), if_valuenotoddball(assembler);
Node* instance_type = assembler->LoadMapInstanceType(value_map);
Node* is_oddball = assembler->Word32Equal(
instance_type, assembler->Int32Constant(ODDBALL_TYPE));
assembler->Branch(is_oddball, &if_valueisoddball, &if_valuenotoddball);
assembler->Bind(&if_valueisoddball);
{
// Convert Oddball to Number and check again.
value_var.Bind(
assembler->LoadObjectField(value, Oddball::kToNumberOffset));
var_type_feedback.Bind(assembler->Int32Constant(
BinaryOperationFeedback::kNumberOrOddball));
assembler->Goto(&start);
}
assembler->Bind(&if_valuenotoddball);
{
// Convert to a Number first and try again.
Callable callable =
......@@ -1761,6 +1786,7 @@ compiler::Node* IncStub::Generate(CodeStubAssembler* assembler,
}
}
}
}
assembler->Bind(&do_finc);
{
......@@ -1863,6 +1889,31 @@ compiler::Node* DecStub::Generate(CodeStubAssembler* assembler,
}
assembler->Bind(&if_valuenotnumber);
{
// We do not require an Or with earlier feedback here because once we
// convert the value to a number, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
assembler->Assert(assembler->Word32Equal(
var_type_feedback.value(),
assembler->Int32Constant(BinaryOperationFeedback::kNone)));
Label if_valueisoddball(assembler), if_valuenotoddball(assembler);
Node* instance_type = assembler->LoadMapInstanceType(value_map);
Node* is_oddball = assembler->Word32Equal(
instance_type, assembler->Int32Constant(ODDBALL_TYPE));
assembler->Branch(is_oddball, &if_valueisoddball, &if_valuenotoddball);
assembler->Bind(&if_valueisoddball);
{
// Convert Oddball to Number and check again.
value_var.Bind(
assembler->LoadObjectField(value, Oddball::kToNumberOffset));
var_type_feedback.Bind(assembler->Int32Constant(
BinaryOperationFeedback::kNumberOrOddball));
assembler->Goto(&start);
}
assembler->Bind(&if_valuenotoddball);
{
// Convert to a Number first and try again.
Callable callable =
......@@ -1874,6 +1925,7 @@ compiler::Node* DecStub::Generate(CodeStubAssembler* assembler,
}
}
}
}
assembler->Bind(&do_fdec);
{
......
......@@ -1160,7 +1160,8 @@ Node* InterpreterAssembler::TruncateTaggedToWord32WithFeedback(
// Check if {value} is a HeapNumber.
Label if_valueisheapnumber(this),
if_valueisnotheapnumber(this, Label::kDeferred);
Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
Node* value_map = LoadMap(value);
Branch(WordEqual(value_map, HeapNumberMapConstant()),
&if_valueisheapnumber, &if_valueisnotheapnumber);
Bind(&if_valueisheapnumber);
......@@ -1174,6 +1175,29 @@ Node* InterpreterAssembler::TruncateTaggedToWord32WithFeedback(
}
Bind(&if_valueisnotheapnumber);
{
// We do not require an Or with earlier feedback here because once we
// convert the value to a number, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
Assert(Word32Equal(var_type_feedback->value(),
Int32Constant(BinaryOperationFeedback::kNone)));
Label if_valueisoddball(this),
if_valueisnotoddball(this, Label::kDeferred);
Node* is_oddball = Word32Equal(LoadMapInstanceType(value_map),
Int32Constant(ODDBALL_TYPE));
Branch(is_oddball, &if_valueisoddball, &if_valueisnotoddball);
Bind(&if_valueisoddball);
{
// Convert Oddball to a Number and perform checks again.
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset));
var_type_feedback->Bind(
Int32Constant(BinaryOperationFeedback::kNumberOrOddball));
Goto(&loop);
}
Bind(&if_valueisnotoddball);
{
// Convert the {value} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(isolate());
......@@ -1183,6 +1207,7 @@ Node* InterpreterAssembler::TruncateTaggedToWord32WithFeedback(
}
}
}
}
Bind(&done_loop);
return var_result.value();
}
......
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