Commit 3f0c8819 authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [turbofan] Collect invocation counts and compute relative call frequencies.

Port c7d7ca36

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

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com

BUG=v8:5267,v8:5372
LOG=N

Review-Url: https://codereview.chromium.org/2338413002
Cr-Commit-Position: refs/heads/master@{#39446}
parent b64565e5
......@@ -1084,6 +1084,18 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ cmp(r3, ip);
__ bne(&switch_to_different_code_kind);
// Increment invocation count for the function.
__ LoadP(r7, FieldMemOperand(r4, JSFunction::kLiteralsOffset));
__ LoadP(r7, FieldMemOperand(r7, LiteralsArray::kFeedbackVectorOffset));
__ LoadP(r8, FieldMemOperand(r7, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize));
__ AddSmiLiteral(r8, r8, Smi::FromInt(1), r0);
__ StoreP(r8, FieldMemOperand(r7, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize),
r0);
// Check function data field is actually a BytecodeArray object.
if (FLAG_debug_code) {
......
......@@ -1087,6 +1087,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ CmpP(r2, Operand(masm->CodeObject())); // Self-reference to this code.
__ bne(&switch_to_different_code_kind);
// Increment invocation count for the function.
__ LoadP(r6, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
__ LoadP(r6, FieldMemOperand(r6, LiteralsArray::kFeedbackVectorOffset));
__ LoadP(r1, FieldMemOperand(r6, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize));
__ AddSmiLiteral(r1, r1, Smi::FromInt(1), r0);
__ StoreP(r1, FieldMemOperand(r6, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize));
// Check function data field is actually a BytecodeArray object.
if (FLAG_debug_code) {
__ TestIfSmi(kInterpreterBytecodeArrayRegister);
......
......@@ -133,6 +133,22 @@ void FullCodeGenerator::Generate() {
info->set_prologue_offset(prologue_offset);
__ Prologue(info->GeneratePreagedPrologue(), ip, prologue_offset);
// Increment invocation count for the function.
{
Comment cmnt(masm_, "[ Increment invocation count");
__ LoadP(r7, FieldMemOperand(r4, JSFunction::kLiteralsOffset));
__ LoadP(r7, FieldMemOperand(r7, LiteralsArray::kFeedbackVectorOffset));
__ LoadP(r8, FieldMemOperand(r7, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize));
__ AddSmiLiteral(r8, r8, Smi::FromInt(1), r0);
__ StoreP(r8,
FieldMemOperand(
r7, TypeFeedbackVector::kInvocationCountIndex * kPointerSize +
TypeFeedbackVector::kHeaderSize),
r0);
}
{
Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
......
......@@ -133,6 +133,21 @@ void FullCodeGenerator::Generate() {
info->set_prologue_offset(prologue_offset);
__ Prologue(info->GeneratePreagedPrologue(), ip, prologue_offset);
// Increment invocation count for the function.
{
Comment cmnt(masm_, "[ Increment invocation count");
__ LoadP(r6, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
__ LoadP(r6, FieldMemOperand(r6, LiteralsArray::kFeedbackVectorOffset));
__ LoadP(r1, FieldMemOperand(r6, TypeFeedbackVector::kInvocationCountIndex *
kPointerSize +
TypeFeedbackVector::kHeaderSize));
__ AddSmiLiteral(r1, r1, Smi::FromInt(1), r0);
__ StoreP(r1,
FieldMemOperand(
r6, TypeFeedbackVector::kInvocationCountIndex * kPointerSize +
TypeFeedbackVector::kHeaderSize));
}
{
Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_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