Commit 61d653c9 authored by Mythri's avatar Mythri Committed by Commit Bot

[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/934509Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51525}
parent 0237747a
......@@ -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(
......
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