Skip to content

Commit afacfd2

Browse files
targosrvagg
authored andcommitted
deps: cherry-pick 2075910 from upstream V8
Original commit message: [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} Refs: v8/v8@2075910 Backport-PR-URL: #21668 PR-URL: #21838 Refs: nodejs/promises-debugging#8 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]> Reviewed-By: Benedikt Meurer <[email protected]>
1 parent 4f24256 commit afacfd2

File tree

3 files changed

+1
-121
lines changed

3 files changed

+1
-121
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Reset this number to 0 on major V8 upgrades.
3131
# Increment by one for each non-official patch applied to deps/v8.
32-
'v8_embedder_string': '-node.8',
32+
'v8_embedder_string': '-node.9',
3333

3434
# Enable disassembler for `--print-code` v8 options
3535
'v8_enable_disassembler': 1,

deps/v8/src/compiler/js-call-reducer.cc

-118
Original file line numberDiff line numberDiff line change
@@ -3551,10 +3551,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
35513551
return ReduceAsyncFunctionPromiseCreate(node);
35523552
case Builtins::kAsyncFunctionPromiseRelease:
35533553
return ReduceAsyncFunctionPromiseRelease(node);
3554-
case Builtins::kPromiseCapabilityDefaultReject:
3555-
return ReducePromiseCapabilityDefaultReject(node);
3556-
case Builtins::kPromiseCapabilityDefaultResolve:
3557-
return ReducePromiseCapabilityDefaultResolve(node);
35583554
case Builtins::kPromiseInternalConstructor:
35593555
return ReducePromiseInternalConstructor(node);
35603556
case Builtins::kPromiseInternalReject:
@@ -5310,120 +5306,6 @@ Reduction JSCallReducer::ReduceAsyncFunctionPromiseRelease(Node* node) {
53105306
return Replace(value);
53115307
}
53125308

5313-
// ES section #sec-promise-reject-functions
5314-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultReject(Node* node) {
5315-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5316-
Node* target = NodeProperties::GetValueInput(node, 0);
5317-
Node* resolution = node->op()->ValueInputCount() > 2
5318-
? NodeProperties::GetValueInput(node, 2)
5319-
: jsgraph()->UndefinedConstant();
5320-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5321-
Node* effect = NodeProperties::GetEffectInput(node);
5322-
Node* control = NodeProperties::GetControlInput(node);
5323-
5324-
// We need to execute in the {target}s context.
5325-
Node* context = effect = graph()->NewNode(
5326-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5327-
effect, control);
5328-
5329-
// Grab the promise closed over by {target}.
5330-
Node* promise = effect =
5331-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5332-
PromiseBuiltinsAssembler::kPromiseSlot)),
5333-
context, effect, control);
5334-
5335-
// Check if the {promise} is still pending or already settled.
5336-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5337-
jsgraph()->UndefinedConstant());
5338-
Node* branch =
5339-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5340-
5341-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5342-
Node* etrue = effect;
5343-
5344-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5345-
Node* efalse = effect;
5346-
{
5347-
// Mark the {promise} as settled.
5348-
efalse = graph()->NewNode(
5349-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5350-
PromiseBuiltinsAssembler::kPromiseSlot)),
5351-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5352-
5353-
// Check if we should emit a debug event.
5354-
Node* debug_event = efalse =
5355-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5356-
PromiseBuiltinsAssembler::kDebugEventSlot)),
5357-
context, efalse, if_false);
5358-
5359-
// Actually reject the {promise}.
5360-
efalse =
5361-
graph()->NewNode(javascript()->RejectPromise(), promise, resolution,
5362-
debug_event, context, frame_state, efalse, if_false);
5363-
}
5364-
5365-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5366-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5367-
5368-
Node* value = jsgraph()->UndefinedConstant();
5369-
ReplaceWithValue(node, value, effect, control);
5370-
return Replace(value);
5371-
}
5372-
5373-
// ES section #sec-promise-resolve-functions
5374-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultResolve(Node* node) {
5375-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5376-
Node* target = NodeProperties::GetValueInput(node, 0);
5377-
Node* resolution = node->op()->ValueInputCount() > 2
5378-
? NodeProperties::GetValueInput(node, 2)
5379-
: jsgraph()->UndefinedConstant();
5380-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5381-
Node* effect = NodeProperties::GetEffectInput(node);
5382-
Node* control = NodeProperties::GetControlInput(node);
5383-
5384-
// We need to execute in the {target}s context.
5385-
Node* context = effect = graph()->NewNode(
5386-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5387-
effect, control);
5388-
5389-
// Grab the promise closed over by {target}.
5390-
Node* promise = effect =
5391-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5392-
PromiseBuiltinsAssembler::kPromiseSlot)),
5393-
context, effect, control);
5394-
5395-
// Check if the {promise} is still pending or already settled.
5396-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5397-
jsgraph()->UndefinedConstant());
5398-
Node* branch =
5399-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5400-
5401-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5402-
Node* etrue = effect;
5403-
5404-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5405-
Node* efalse = effect;
5406-
{
5407-
// Mark the {promise} as settled.
5408-
efalse = graph()->NewNode(
5409-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5410-
PromiseBuiltinsAssembler::kPromiseSlot)),
5411-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5412-
5413-
// Actually resolve the {promise}.
5414-
efalse =
5415-
graph()->NewNode(javascript()->ResolvePromise(), promise, resolution,
5416-
context, frame_state, efalse, if_false);
5417-
}
5418-
5419-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5420-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5421-
5422-
Node* value = jsgraph()->UndefinedConstant();
5423-
ReplaceWithValue(node, value, effect, control);
5424-
return Replace(value);
5425-
}
5426-
54275309
Node* JSCallReducer::CreateArtificialFrameState(
54285310
Node* node, Node* outer_frame_state, int parameter_count,
54295311
BailoutId bailout_id, FrameStateType frame_state_type,

deps/v8/src/compiler/js-call-reducer.h

-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
132132

133133
Reduction ReduceAsyncFunctionPromiseCreate(Node* node);
134134
Reduction ReduceAsyncFunctionPromiseRelease(Node* node);
135-
Reduction ReducePromiseCapabilityDefaultReject(Node* node);
136-
Reduction ReducePromiseCapabilityDefaultResolve(Node* node);
137135
Reduction ReducePromiseConstructor(Node* node);
138136
Reduction ReducePromiseInternalConstructor(Node* node);
139137
Reduction ReducePromiseInternalReject(Node* node);

0 commit comments

Comments
 (0)