Commit d38e270c authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Brokerize Function.prototype.call and .apply reductions

Bug: v8:7790
Change-Id: If6b58ed24786e0143cb72796d16d9c56b3f76914
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1706468
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62771}
parent 4a416dbb
......@@ -368,6 +368,8 @@ Reduction JSCallReducer::ReduceObjectConstructor(Node* node) {
// ES6 section 19.2.3.1 Function.prototype.apply ( thisArg, argArray )
Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op());
size_t arity = p.arity();
......@@ -475,9 +477,17 @@ Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
}
}
// Change {node} to the new {JSCall} operator.
// TODO(mslekova): Since this introduces a Call that will get optimized by
// the JSCallReducer, we basically might have to do all the serialization
// that we do for that here as well. The only difference is that here we
// disable speculation (cf. the empty VectorSlotPair above), causing the
// JSCallReducer to do much less work. We should revisit this later.
NodeProperties::ChangeOp(
node,
javascript()->Call(arity, p.frequency(), VectorSlotPair(), convert_mode));
// TODO(mslekova): Remove once ReduceJSCall is brokerized.
AllowHandleDereference allow_handle_dereference;
AllowHandleAllocation allow_handle_allocation;
// Try to further reduce the JSCall {node}.
Reduction const reduction = ReduceJSCall(node);
return reduction.Changed() ? reduction : Changed(node);
......@@ -590,6 +600,8 @@ Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
// ES6 section 19.2.3.3 Function.prototype.call (thisArg, ...args)
Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op());
Node* target = NodeProperties::GetValueInput(node, 0);
......@@ -602,6 +614,10 @@ Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
HeapObjectMatcher m(target);
if (m.HasValue()) {
JSFunctionRef function = m.Ref(broker()).AsJSFunction();
if (FLAG_concurrent_inlining && !function.serialized()) {
TRACE_BROKER_MISSING(broker(), "Serialize call on function " << function);
return NoChange();
}
context = jsgraph()->Constant(function.context());
} else {
context = effect = graph()->NewNode(
......@@ -631,6 +647,9 @@ Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
NodeProperties::ChangeOp(
node,
javascript()->Call(arity, p.frequency(), VectorSlotPair(), convert_mode));
// TODO(mslekova): Remove once ReduceJSCall is brokerized.
AllowHandleDereference allow_handle_dereference;
AllowHandleAllocation allow_handle_allocation;
// Try to further reduce the JSCall {node}.
Reduction const reduction = ReduceJSCall(node);
return reduction.Changed() ? reduction : Changed(node);
......@@ -3774,6 +3793,10 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
}
Reduction JSCallReducer::ReduceJSCallWithArrayLike(Node* node) {
// TODO(mslekova): Remove once ReduceJSCallWithArrayLike is brokerized.
AllowHandleDereference allow_handle_dereference;
AllowHandleAllocation allow_handle_allocation;
DCHECK_EQ(IrOpcode::kJSCallWithArrayLike, node->opcode());
CallFrequency frequency = CallFrequencyOf(node->op());
VectorSlotPair feedback;
......
......@@ -1082,6 +1082,8 @@ void SerializerForBackgroundCompilation::ProcessCallOrConstruct(
if (!hint->IsJSFunction()) continue;
Handle<JSFunction> function = Handle<JSFunction>::cast(hint);
JSFunctionRef(broker(), function).Serialize();
Handle<SharedFunctionInfo> shared(function->shared(), broker()->isolate());
if (shared->IsApiFunction()) {
......@@ -1239,6 +1241,12 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
}
break;
}
case Builtins::kFunctionPrototypeCall:
if (arguments.size() >= 1) {
Hints const& target_hints = arguments[0];
ProcessHintsForFunctionCall(target_hints);
}
break;
default:
break;
}
......@@ -1314,6 +1322,15 @@ void SerializerForBackgroundCompilation::ProcessHintsForRegExpTest(
}
}
void SerializerForBackgroundCompilation::ProcessHintsForFunctionCall(
Hints const& target_hints) {
for (auto constant : target_hints.constants()) {
if (!constant->IsJSFunction()) continue;
JSFunctionRef func(broker(), constant);
func.Serialize();
}
}
void SerializerForBackgroundCompilation::ContributeToJumpTargetEnvironment(
int target_offset) {
auto it = jump_target_environments_.find(target_offset);
......
......@@ -389,6 +389,7 @@ class SerializerForBackgroundCompilation {
void ProcessHintsForPromiseResolve(Hints const& resolution_hints);
void ProcessHintsForRegExpTest(Hints const& regexp_hints);
PropertyAccessInfo ProcessMapForRegExpTest(MapRef map);
void ProcessHintsForFunctionCall(Hints const& target_hints);
GlobalAccessFeedback const* ProcessFeedbackForGlobalAccess(FeedbackSlot slot);
NamedAccessFeedback const* ProcessFeedbackMapsForNamedAccess(
......
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