Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 2330883002: [turbofan] Call frequencies for JSCallFunction and JSCallConstruct. (Closed)
Patch Set: REBASE Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index c96ef1b17c2ee40194fe6fb20d6f30dda8f41dbd..b3446c98826657bb4b33de4d3c207171a35892e5 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -2430,9 +2430,11 @@ void AstGraphBuilder::VisitCall(Call* expr) {
}
// Create node to perform the function call.
+ float const frequency = ComputeCallFrequency(expr->CallFeedbackICSlot());
VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot());
- const Operator* call = javascript()->CallFunction(
- args->length() + 2, feedback, receiver_hint, expr->tail_call_mode());
+ const Operator* call =
+ javascript()->CallFunction(args->length() + 2, frequency, feedback,
+ receiver_hint, expr->tail_call_mode());
PrepareEagerCheckpoint(possibly_eval ? expr->EvalId() : expr->CallId());
Node* value = ProcessArguments(call, args->length() + 2);
// The callee passed to the call, we just need to push something here to
@@ -2466,7 +2468,7 @@ void AstGraphBuilder::VisitCallSuper(Call* expr) {
// Create node to perform the super call.
const Operator* call =
- javascript()->CallConstruct(args->length() + 2, VectorSlotPair());
+ javascript()->CallConstruct(args->length() + 2, 0.0f, VectorSlotPair());
Node* value = ProcessArguments(call, args->length() + 2);
PrepareFrameState(value, expr->ReturnId(), OutputFrameStateCombine::Push());
ast_context()->ProduceValue(expr, value);
@@ -2484,9 +2486,10 @@ void AstGraphBuilder::VisitCallNew(CallNew* expr) {
environment()->Push(environment()->Peek(args->length()));
// Create node to perform the construct call.
+ float const frequency = ComputeCallFrequency(expr->CallNewFeedbackSlot());
VectorSlotPair feedback = CreateVectorSlotPair(expr->CallNewFeedbackSlot());
const Operator* call =
- javascript()->CallConstruct(args->length() + 2, feedback);
+ javascript()->CallConstruct(args->length() + 2, frequency, feedback);
Node* value = ProcessArguments(call, args->length() + 2);
PrepareFrameState(value, expr->ReturnId(), OutputFrameStateCombine::Push());
ast_context()->ProduceValue(expr, value);
@@ -3096,6 +3099,17 @@ uint32_t AstGraphBuilder::ComputeBitsetForDynamicContext(Variable* variable) {
return check_depths;
}
+float AstGraphBuilder::ComputeCallFrequency(FeedbackVectorSlot slot) const {
+ if (slot.IsInvalid()) return 0.0f;
+ DisallowHeapAllocation no_gc;
+ TypeFeedbackVector* const feedback_vector =
+ info()->closure()->feedback_vector();
+ FeedbackVectorSlot const slot_extra =
+ feedback_vector->ToSlot(feedback_vector->GetIndex(slot) + 1);
+ Object* const feedback_extra = feedback_vector->Get(slot_extra);
+ if (feedback_extra->IsSmi()) return Smi::cast(feedback_extra)->value();
+ return 0.0f;
+}
Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) {
DCHECK(environment()->stack_height() >= arity);

Powered by Google App Engine
This is Rietveld 408576698