Commit b6acda3a authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Collect invocation counts and compute relative call frequencies.

  port c7d7ca36(r39410)

  original commit message:
  Add a notion of "invocation count" to the baseline compilers, which
  increment a special slot in the TypeFeedbackVector for each invocation
  of a given function (the optimized code doesn't currently collect this
  information).

  Use this invocation count to relativize the call counts on the call
  sites within the function, so that the inlining heuristic has a view
  of relative importance of a call site rather than some absolute numbers
  with unclear meaning for the current function. Also apply the call site
  frequency as a factor to all frequencies in the inlinee by passing this
  to the graph builders so that the importance of a call site in an
  inlinee is relative to the topmost optimized function.

  Note that all functions that neither have literals nor need type
  feedback slots will share a single invocation count cell in the
  canonical empty type feedback vector, so their invocation count is
  meaningless, but that doesn't matter since we only use the invocation
  count to relativize call counts within the function, which we only have
  if we have at least one type feedback vector (the CallIC slot).

  See the design document for additional details on this change:
  https://docs.google.com/document/d/1VoYBhpDhJC4VlqMXCKvae-8IGuheBGxy32EOgC2LnT8

BUG=

Review-Url: https://codereview.chromium.org/2352493002
Cr-Commit-Position: refs/heads/master@{#39490}
parent 3761a9e1
......@@ -591,6 +591,13 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ cmp(ecx, FieldOperand(eax, SharedFunctionInfo::kCodeOffset));
__ j(not_equal, &switch_to_different_code_kind);
// Increment invocation count for the function.
__ EmitLoadTypeFeedbackVector(ecx);
__ add(FieldOperand(ecx,
TypeFeedbackVector::kInvocationCountIndex * kPointerSize +
TypeFeedbackVector::kHeaderSize),
Immediate(Smi::FromInt(1)));
// Check function data field is actually a BytecodeArray object.
if (FLAG_debug_code) {
__ AssertNotSmi(kInterpreterBytecodeArrayRegister);
......
......@@ -117,6 +117,17 @@ void FullCodeGenerator::Generate() {
info->set_prologue_offset(masm_->pc_offset());
__ Prologue(info->GeneratePreagedPrologue());
// Increment invocation count for the function.
{
Comment cmnt(masm_, "[ Increment invocation count");
__ mov(ecx, FieldOperand(edi, JSFunction::kLiteralsOffset));
__ mov(ecx, FieldOperand(ecx, LiteralsArray::kFeedbackVectorOffset));
__ add(FieldOperand(
ecx, TypeFeedbackVector::kInvocationCountIndex * kPointerSize +
TypeFeedbackVector::kHeaderSize),
Immediate(Smi::FromInt(1)));
}
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
......
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