Commit 32745df1 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Simplify control flow in Number constructor inlining.

This is a purely cosmetic change to make the Number constructor
in the JSCallReducer easier to read.

Bug: v8:7904, v8:8015
Change-Id: Id3248dcf9c4e8111bb4f0418bfa6993630df74bb
Reviewed-on: https://chromium-review.googlesource.com/1196432Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55528}
parent 2c834b1c
......@@ -7232,39 +7232,30 @@ Reduction JSCallReducer::ReduceRegExpPrototypeTest(Node* node) {
Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op());
Node* target = NodeProperties::GetValueInput(node, 0);
Node* receiver = NodeProperties::GetValueInput(node, 1);
Node* value = p.arity() < 3 ? jsgraph()->ZeroConstant()
: NodeProperties::GetValueInput(node, 2);
Node* context = NodeProperties::GetContextInput(node);
Node* frame_state = NodeProperties::GetFrameStateInput(node);
if (p.arity() <= 2) {
ReplaceWithValue(node, jsgraph()->ZeroConstant());
}
// We don't have a new.target argument, so we can convert to number,
// but must also convert BigInts.
if (p.arity() == 3) {
Node* target = NodeProperties::GetValueInput(node, 0);
Node* context = NodeProperties::GetContextInput(node);
Node* value = NodeProperties::GetValueInput(node, 2);
Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
Handle<SharedFunctionInfo> number_constructor(
handle(native_context()->number_function()->shared(), isolate()));
const std::vector<Node*> checkpoint_parameters({
jsgraph()->UndefinedConstant(), /* receiver */
});
int checkpoint_parameters_size =
static_cast<int>(checkpoint_parameters.size());
Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
jsgraph(), number_constructor,
Builtins::kGenericConstructorLazyDeoptContinuation, target, context,
checkpoint_parameters.data(), checkpoint_parameters_size,
outer_frame_state, ContinuationFrameStateMode::LAZY);
NodeProperties::ReplaceValueInputs(node, value);
NodeProperties::ChangeOp(node, javascript()->ToNumberConvertBigInt());
NodeProperties::ReplaceFrameStateInput(node, frame_state);
return Changed(node);
}
return NoChange();
// Create the artificial frame state in the middle of the Number constructor.
Handle<SharedFunctionInfo> shared_info(
handle(native_context()->number_function()->shared(), isolate()));
Node* stack_parameters[] = {receiver};
int stack_parameter_count = arraysize(stack_parameters);
Node* continuation_frame_state =
CreateJavaScriptBuiltinContinuationFrameState(
jsgraph(), shared_info,
Builtins::kGenericConstructorLazyDeoptContinuation, target, context,
stack_parameters, stack_parameter_count, frame_state,
ContinuationFrameStateMode::LAZY);
// Convert the {value} to a Number.
NodeProperties::ReplaceValueInputs(node, value);
NodeProperties::ChangeOp(node, javascript()->ToNumberConvertBigInt());
NodeProperties::ReplaceFrameStateInput(node, continuation_frame_state);
return Changed(node);
}
Graph* JSCallReducer::graph() const { return jsgraph()->graph(); }
......
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