[Interpreter] Use CSA::Select instead of branches

CSA::Select makes the code compact and cleaner. Use it instead of
branches.

Bug: v8:7310
Change-Id: I3694b5ab5f8085c60266a4ad02640075005f4f94
Reviewed-on: https://chromium-review.googlesource.com/934509
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51525}
This commit is contained in:
Mythri 2018-02-23 15:45:19 +00:00 committed by Commit Bot
parent 0237747a70
commit 61d653c99b

View File

@ -132,63 +132,24 @@ Node* IntrinsicsGenerator::CompareInstanceType(Node* object, int type,
}
Node* IntrinsicsGenerator::IsInstanceType(Node* input, int type) {
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
// TODO(ishell): Use Select here.
InterpreterAssembler::Label if_not_smi(assembler_), return_true(assembler_),
return_false(assembler_), end(assembler_);
__ GotoIf(__ TaggedIsSmi(input), &return_false);
Node* condition = CompareInstanceType(input, type, kInstanceTypeEqual);
__ Branch(condition, &return_true, &return_false);
__ BIND(&return_true);
{
return_value.Bind(__ TrueConstant());
__ Goto(&end);
}
__ BIND(&return_false);
{
return_value.Bind(__ FalseConstant());
__ Goto(&end);
}
__ BIND(&end);
return return_value.value();
Node* result =
__ Select(__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] {
return __ SelectBooleanConstant(
CompareInstanceType(input, type, kInstanceTypeEqual));
},
MachineRepresentation::kTagged);
return result;
}
Node* IntrinsicsGenerator::IsJSReceiver(
const InterpreterAssembler::RegListNodePair& args, Node* context) {
// TODO(ishell): Use Select here.
// TODO(ishell): Use CSA::IsJSReceiverInstanceType here.
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
InterpreterAssembler::Label return_true(assembler_), return_false(assembler_),
end(assembler_);
Node* input = __ LoadRegisterFromRegisterList(args, 0);
__ GotoIf(__ TaggedIsSmi(input), &return_false);
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
Node* condition = CompareInstanceType(input, FIRST_JS_RECEIVER_TYPE,
kInstanceTypeGreaterThanOrEqual);
__ Branch(condition, &return_true, &return_false);
__ BIND(&return_true);
{
return_value.Bind(__ TrueConstant());
__ Goto(&end);
}
__ BIND(&return_false);
{
return_value.Bind(__ FalseConstant());
__ Goto(&end);
}
__ BIND(&end);
return return_value.value();
Node* result = __ Select(
__ TaggedIsSmi(input), [=] { return __ FalseConstant(); },
[=] { return __ SelectBooleanConstant(__ IsJSReceiver(input)); },
MachineRepresentation::kTagged);
return result;
}
Node* IntrinsicsGenerator::IsArray(
@ -235,29 +196,8 @@ Node* IntrinsicsGenerator::IsJSWeakSet(
Node* IntrinsicsGenerator::IsSmi(
const InterpreterAssembler::RegListNodePair& args, Node* context) {
// TODO(ishell): Use SelectBooleanConstant here.
InterpreterAssembler::Variable return_value(assembler_,
MachineRepresentation::kTagged);
InterpreterAssembler::Label if_smi(assembler_), if_not_smi(assembler_),
end(assembler_);
Node* input = __ LoadRegisterFromRegisterList(args, 0);
__ Branch(__ TaggedIsSmi(input), &if_smi, &if_not_smi);
__ BIND(&if_smi);
{
return_value.Bind(__ TrueConstant());
__ Goto(&end);
}
__ BIND(&if_not_smi);
{
return_value.Bind(__ FalseConstant());
__ Goto(&end);
}
__ BIND(&end);
return return_value.value();
return __ SelectBooleanConstant(__ TaggedIsSmi(input));
}
Node* IntrinsicsGenerator::IntrinsicAsStubCall(