diff --git a/src/compiler/js-call-reducer.cc b/src/compiler/js-call-reducer.cc index 097aed3f40..172716d82d 100644 --- a/src/compiler/js-call-reducer.cc +++ b/src/compiler/js-call-reducer.cc @@ -6064,6 +6064,19 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) { result = effect = graph()->NewNode( javascript()->PerformPromiseThen(), receiver, on_fulfilled, on_rejected, 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 result_map(native_context()->promise_function()->initial_map(), + isolate()); + effect = + graph()->NewNode(simplified()->MapGuard(ZoneHandleSet(result_map)), + result, effect, control); + ReplaceWithValue(node, result, effect, control); return Replace(result); } diff --git a/src/compiler/node-properties.cc b/src/compiler/node-properties.cc index 755937db00..236cd63a03 100644 --- a/src/compiler/node-properties.cc +++ b/src/compiler/node-properties.cc @@ -428,6 +428,16 @@ NodeProperties::InferReceiverMapsResult NodeProperties::InferReceiverMaps( } break; } + case IrOpcode::kJSCreatePromise: { + if (IsSame(receiver, effect)) { + *maps_return = ZoneHandleSet(broker->native_context() + .promise_function() + .initial_map() + .object()); + return result; + } + break; + } case IrOpcode::kStoreField: { // We only care about StoreField of maps. Node* const object = GetValueInput(effect, 0);