Skip to content

Commit 2075910

Browse files
bmeurerCommit Bot
authored andcommitted
[turbofan] Remove optimization of default Promise capability functions.
The JSCallReducer could in theory inline the default resolve and reject functions passed to the executor in the Promise constructor. But that inlining is almost never triggered because we don't have SFI based feedback in the CallIC. Also the use of the Promise constructor is discouraged, so we shouldn't really need to squeeze the last bit of performance out of this even in the future. Getting rid of this optimization will make significantly easier to implement the Swallowed Rejection Hook, as there's less churn on the TurboFan side then. Bug: v8:7919 Change-Id: If0c54f1c6c7ce95686cd74232be6b8693ac688c9 Reviewed-on: https://chromium-review.googlesource.com/1125926 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Jaroslav Sevcik <[email protected]> Cr-Commit-Position: refs/heads/master@{#54210}
1 parent 7416d4f commit 2075910

File tree

2 files changed

+0
-120
lines changed

2 files changed

+0
-120
lines changed

src/compiler/js-call-reducer.cc

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,10 +3579,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
35793579
return ReduceAsyncFunctionPromiseCreate(node);
35803580
case Builtins::kAsyncFunctionPromiseRelease:
35813581
return ReduceAsyncFunctionPromiseRelease(node);
3582-
case Builtins::kPromiseCapabilityDefaultReject:
3583-
return ReducePromiseCapabilityDefaultReject(node);
3584-
case Builtins::kPromiseCapabilityDefaultResolve:
3585-
return ReducePromiseCapabilityDefaultResolve(node);
35863582
case Builtins::kPromiseInternalConstructor:
35873583
return ReducePromiseInternalConstructor(node);
35883584
case Builtins::kPromiseInternalReject:
@@ -5343,120 +5339,6 @@ Reduction JSCallReducer::ReduceAsyncFunctionPromiseRelease(Node* node) {
53435339
return Replace(value);
53445340
}
53455341

5346-
// ES section #sec-promise-reject-functions
5347-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultReject(Node* node) {
5348-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5349-
Node* target = NodeProperties::GetValueInput(node, 0);
5350-
Node* resolution = node->op()->ValueInputCount() > 2
5351-
? NodeProperties::GetValueInput(node, 2)
5352-
: jsgraph()->UndefinedConstant();
5353-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5354-
Node* effect = NodeProperties::GetEffectInput(node);
5355-
Node* control = NodeProperties::GetControlInput(node);
5356-
5357-
// We need to execute in the {target}s context.
5358-
Node* context = effect = graph()->NewNode(
5359-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5360-
effect, control);
5361-
5362-
// Grab the promise closed over by {target}.
5363-
Node* promise = effect =
5364-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5365-
PromiseBuiltinsAssembler::kPromiseSlot)),
5366-
context, effect, control);
5367-
5368-
// Check if the {promise} is still pending or already settled.
5369-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5370-
jsgraph()->UndefinedConstant());
5371-
Node* branch =
5372-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5373-
5374-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5375-
Node* etrue = effect;
5376-
5377-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5378-
Node* efalse = effect;
5379-
{
5380-
// Mark the {promise} as settled.
5381-
efalse = graph()->NewNode(
5382-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5383-
PromiseBuiltinsAssembler::kPromiseSlot)),
5384-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5385-
5386-
// Check if we should emit a debug event.
5387-
Node* debug_event = efalse =
5388-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5389-
PromiseBuiltinsAssembler::kDebugEventSlot)),
5390-
context, efalse, if_false);
5391-
5392-
// Actually reject the {promise}.
5393-
efalse =
5394-
graph()->NewNode(javascript()->RejectPromise(), promise, resolution,
5395-
debug_event, context, frame_state, efalse, if_false);
5396-
}
5397-
5398-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5399-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5400-
5401-
Node* value = jsgraph()->UndefinedConstant();
5402-
ReplaceWithValue(node, value, effect, control);
5403-
return Replace(value);
5404-
}
5405-
5406-
// ES section #sec-promise-resolve-functions
5407-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultResolve(Node* node) {
5408-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5409-
Node* target = NodeProperties::GetValueInput(node, 0);
5410-
Node* resolution = node->op()->ValueInputCount() > 2
5411-
? NodeProperties::GetValueInput(node, 2)
5412-
: jsgraph()->UndefinedConstant();
5413-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5414-
Node* effect = NodeProperties::GetEffectInput(node);
5415-
Node* control = NodeProperties::GetControlInput(node);
5416-
5417-
// We need to execute in the {target}s context.
5418-
Node* context = effect = graph()->NewNode(
5419-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5420-
effect, control);
5421-
5422-
// Grab the promise closed over by {target}.
5423-
Node* promise = effect =
5424-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5425-
PromiseBuiltinsAssembler::kPromiseSlot)),
5426-
context, effect, control);
5427-
5428-
// Check if the {promise} is still pending or already settled.
5429-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5430-
jsgraph()->UndefinedConstant());
5431-
Node* branch =
5432-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5433-
5434-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5435-
Node* etrue = effect;
5436-
5437-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5438-
Node* efalse = effect;
5439-
{
5440-
// Mark the {promise} as settled.
5441-
efalse = graph()->NewNode(
5442-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5443-
PromiseBuiltinsAssembler::kPromiseSlot)),
5444-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5445-
5446-
// Actually resolve the {promise}.
5447-
efalse =
5448-
graph()->NewNode(javascript()->ResolvePromise(), promise, resolution,
5449-
context, frame_state, efalse, if_false);
5450-
}
5451-
5452-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5453-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5454-
5455-
Node* value = jsgraph()->UndefinedConstant();
5456-
ReplaceWithValue(node, value, effect, control);
5457-
return Replace(value);
5458-
}
5459-
54605342
Node* JSCallReducer::CreateArtificialFrameState(
54615343
Node* node, Node* outer_frame_state, int parameter_count,
54625344
BailoutId bailout_id, FrameStateType frame_state_type,

src/compiler/js-call-reducer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
135135

136136
Reduction ReduceAsyncFunctionPromiseCreate(Node* node);
137137
Reduction ReduceAsyncFunctionPromiseRelease(Node* node);
138-
Reduction ReducePromiseCapabilityDefaultReject(Node* node);
139-
Reduction ReducePromiseCapabilityDefaultResolve(Node* node);
140138
Reduction ReducePromiseConstructor(Node* node);
141139
Reduction ReducePromiseInternalConstructor(Node* node);
142140
Reduction ReducePromiseInternalReject(Node* node);

0 commit comments

Comments
 (0)