Commit d5ee4622 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Infer maps of JSPerformPromiseThen and JSCreatePromise.

Teach TurboFan about the maps produced by JSPerformPromiseThen and
JSCreatePromise, which yields a ~1-2% improvement on the doxbee
promises benchmark by removing the redundant checks from the optimized
code with promise chaining.

Bug: v8:7253
Change-Id: If0edce8ba15917c1b7e76b9d06490cfffe911650
Reviewed-on: https://chromium-review.googlesource.com/c/1288639Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56778}
parent 7c65ac3c
...@@ -6064,6 +6064,19 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) { ...@@ -6064,6 +6064,19 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) {
result = effect = graph()->NewNode( result = effect = graph()->NewNode(
javascript()->PerformPromiseThen(), receiver, on_fulfilled, on_rejected, javascript()->PerformPromiseThen(), receiver, on_fulfilled, on_rejected,
result, context, frame_state, effect, control); result, context, frame_state, effect, control);
// At this point we know that {result} is going to have the
// initial Promise map, since even if {PerformPromiseThen}
// above called into the host rejection tracker, the {result}
// doesn't escape to user JavaScript. So bake this information
// into the graph such that subsequent passes can use the
// information for further optimizations.
Handle<Map> result_map(native_context()->promise_function()->initial_map(),
isolate());
effect =
graph()->NewNode(simplified()->MapGuard(ZoneHandleSet<Map>(result_map)),
result, effect, control);
ReplaceWithValue(node, result, effect, control); ReplaceWithValue(node, result, effect, control);
return Replace(result); return Replace(result);
} }
......
...@@ -428,6 +428,16 @@ NodeProperties::InferReceiverMapsResult NodeProperties::InferReceiverMaps( ...@@ -428,6 +428,16 @@ NodeProperties::InferReceiverMapsResult NodeProperties::InferReceiverMaps(
} }
break; break;
} }
case IrOpcode::kJSCreatePromise: {
if (IsSame(receiver, effect)) {
*maps_return = ZoneHandleSet<Map>(broker->native_context()
.promise_function()
.initial_map()
.object());
return result;
}
break;
}
case IrOpcode::kStoreField: { case IrOpcode::kStoreField: {
// We only care about StoreField of maps. // We only care about StoreField of maps.
Node* const object = GetValueInput(effect, 0); Node* const object = GetValueInput(effect, 0);
......
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