Skip to content

Commit c23e8b5

Browse files
committed
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 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 41ff1bb commit c23e8b5

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
@@ -28,7 +28,7 @@
2828

2929
# Reset this number to 0 on major V8 upgrades.
3030
# Increment by one for each non-official patch applied to deps/v8.
31-
'v8_embedder_string': '-node.15',
31+
'v8_embedder_string': '-node.16',
3232

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

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

-118
Original file line numberDiff line numberDiff line change
@@ -3519,10 +3519,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
35193519
return ReduceAsyncFunctionPromiseCreate(node);
35203520
case Builtins::kAsyncFunctionPromiseRelease:
35213521
return ReduceAsyncFunctionPromiseRelease(node);
3522-
case Builtins::kPromiseCapabilityDefaultReject:
3523-
return ReducePromiseCapabilityDefaultReject(node);
3524-
case Builtins::kPromiseCapabilityDefaultResolve:
3525-
return ReducePromiseCapabilityDefaultResolve(node);
35263522
case Builtins::kPromiseInternalConstructor:
35273523
return ReducePromiseInternalConstructor(node);
35283524
case Builtins::kPromiseInternalReject:
@@ -5252,120 +5248,6 @@ Reduction JSCallReducer::ReduceAsyncFunctionPromiseRelease(Node* node) {
52525248
return Replace(value);
52535249
}
52545250

5255-
// ES section #sec-promise-reject-functions
5256-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultReject(Node* node) {
5257-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5258-
Node* target = NodeProperties::GetValueInput(node, 0);
5259-
Node* resolution = node->op()->ValueInputCount() > 2
5260-
? NodeProperties::GetValueInput(node, 2)
5261-
: jsgraph()->UndefinedConstant();
5262-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5263-
Node* effect = NodeProperties::GetEffectInput(node);
5264-
Node* control = NodeProperties::GetControlInput(node);
5265-
5266-
// We need to execute in the {target}s context.
5267-
Node* context = effect = graph()->NewNode(
5268-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5269-
effect, control);
5270-
5271-
// Grab the promise closed over by {target}.
5272-
Node* promise = effect =
5273-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5274-
PromiseBuiltinsAssembler::kPromiseSlot)),
5275-
context, effect, control);
5276-
5277-
// Check if the {promise} is still pending or already settled.
5278-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5279-
jsgraph()->UndefinedConstant());
5280-
Node* branch =
5281-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5282-
5283-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5284-
Node* etrue = effect;
5285-
5286-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5287-
Node* efalse = effect;
5288-
{
5289-
// Mark the {promise} as settled.
5290-
efalse = graph()->NewNode(
5291-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5292-
PromiseBuiltinsAssembler::kPromiseSlot)),
5293-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5294-
5295-
// Check if we should emit a debug event.
5296-
Node* debug_event = efalse =
5297-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5298-
PromiseBuiltinsAssembler::kDebugEventSlot)),
5299-
context, efalse, if_false);
5300-
5301-
// Actually reject the {promise}.
5302-
efalse =
5303-
graph()->NewNode(javascript()->RejectPromise(), promise, resolution,
5304-
debug_event, context, frame_state, efalse, if_false);
5305-
}
5306-
5307-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5308-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5309-
5310-
Node* value = jsgraph()->UndefinedConstant();
5311-
ReplaceWithValue(node, value, effect, control);
5312-
return Replace(value);
5313-
}
5314-
5315-
// ES section #sec-promise-resolve-functions
5316-
Reduction JSCallReducer::ReducePromiseCapabilityDefaultResolve(Node* node) {
5317-
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5318-
Node* target = NodeProperties::GetValueInput(node, 0);
5319-
Node* resolution = node->op()->ValueInputCount() > 2
5320-
? NodeProperties::GetValueInput(node, 2)
5321-
: jsgraph()->UndefinedConstant();
5322-
Node* frame_state = NodeProperties::GetFrameStateInput(node);
5323-
Node* effect = NodeProperties::GetEffectInput(node);
5324-
Node* control = NodeProperties::GetControlInput(node);
5325-
5326-
// We need to execute in the {target}s context.
5327-
Node* context = effect = graph()->NewNode(
5328-
simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
5329-
effect, control);
5330-
5331-
// Grab the promise closed over by {target}.
5332-
Node* promise = effect =
5333-
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
5334-
PromiseBuiltinsAssembler::kPromiseSlot)),
5335-
context, effect, control);
5336-
5337-
// Check if the {promise} is still pending or already settled.
5338-
Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
5339-
jsgraph()->UndefinedConstant());
5340-
Node* branch =
5341-
graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
5342-
5343-
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5344-
Node* etrue = effect;
5345-
5346-
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5347-
Node* efalse = effect;
5348-
{
5349-
// Mark the {promise} as settled.
5350-
efalse = graph()->NewNode(
5351-
simplified()->StoreField(AccessBuilder::ForContextSlot(
5352-
PromiseBuiltinsAssembler::kPromiseSlot)),
5353-
context, jsgraph()->UndefinedConstant(), efalse, if_false);
5354-
5355-
// Actually resolve the {promise}.
5356-
efalse =
5357-
graph()->NewNode(javascript()->ResolvePromise(), promise, resolution,
5358-
context, frame_state, efalse, if_false);
5359-
}
5360-
5361-
control = graph()->NewNode(common()->Merge(2), if_true, if_false);
5362-
effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
5363-
5364-
Node* value = jsgraph()->UndefinedConstant();
5365-
ReplaceWithValue(node, value, effect, control);
5366-
return Replace(value);
5367-
}
5368-
53695251
Node* JSCallReducer::CreateArtificialFrameState(
53705252
Node* node, Node* outer_frame_state, int parameter_count,
53715253
BailoutId bailout_id, FrameStateType frame_state_type,

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

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

131131
Reduction ReduceAsyncFunctionPromiseCreate(Node* node);
132132
Reduction ReduceAsyncFunctionPromiseRelease(Node* node);
133-
Reduction ReducePromiseCapabilityDefaultReject(Node* node);
134-
Reduction ReducePromiseCapabilityDefaultResolve(Node* node);
135133
Reduction ReducePromiseConstructor(Node* node);
136134
Reduction ReducePromiseInternalConstructor(Node* node);
137135
Reduction ReducePromiseInternalReject(Node* node);

0 commit comments

Comments
 (0)