Commit 5b38c7fc authored by Mythri's avatar Mythri Committed by Commit Bot

[TurboFan] Remove a check on nesting levels inlining heuristics

We have a check on maximum number of levels that can be inlined. This
in some cases causes performance cliffs, when we cannot inline a small
function because it has exceeded the number of levels. This cl removes
that check. The intuition is that, having gone down several levels in
a particular line stopping inlining that chain and exploring a new
call site may not be beneficial. This cl also introduces a absolute
limit on the number of nodes that can be inlined (including the small
functions).

Bug: v8:6871, chromium:779509
Change-Id: Id29639ff2fd85b84d8746da3fb78a82d4e9852e8
Reviewed-on: https://chromium-review.googlesource.com/743727Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49050}
parent 6dc35ab4
......@@ -139,24 +139,6 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
}
if (!can_inline) return NoChange();
// Stop inlining once the maximum allowed level is reached.
int level = 0;
for (Node* frame_state = NodeProperties::GetFrameStateInput(node);
frame_state->opcode() == IrOpcode::kFrameState;
frame_state = NodeProperties::GetFrameStateInput(frame_state)) {
FrameStateInfo const& frame_info = OpParameter<FrameStateInfo>(frame_state);
if (FrameStateFunctionInfo::IsJSFunctionType(frame_info.type())) {
if (++level > FLAG_max_inlining_levels) {
TRACE(
"Not considering call site #%d:%s, because inlining depth "
"%d exceeds maximum allowed level %d\n",
node->id(), node->op()->mnemonic(), level,
FLAG_max_inlining_levels);
return NoChange();
}
}
}
// Gather feedback on how often this call site has been hit before.
if (node->opcode() == IrOpcode::kJSCall) {
CallParameters const p = CallParametersOf(node->op());
......@@ -188,7 +170,8 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
// Forcibly inline small functions here. In the case of polymorphic inlining
// small_inline is set only when all functions are small.
if (small_inline) {
if (small_inline &&
cumulative_count_ < FLAG_max_inlined_bytecode_size_absolute) {
TRACE("Inlining small function(s) at call site #%d:%s\n", node->id(),
node->op()->mnemonic());
return InlineCandidate(candidate, true);
......
......@@ -236,7 +236,6 @@ int DebugFrameHelper::FindIndexedNonNativeFrame(StackTraceFrameIterator* it,
int count = -1;
for (; !it->done(); it->Advance()) {
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
it->frame()->Summarize(&frames);
for (size_t i = frames.size(); i != 0; i--) {
// Omit functions from native and extension scripts.
......
......@@ -29,7 +29,6 @@ DebugStackTraceIterator::DebugStackTraceIterator(Isolate* isolate, int index)
is_top_frame_(true) {
if (iterator_.done()) return;
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
iterator_.frame()->Summarize(&frames);
inlined_frame_index_ = static_cast<int>(frames.size());
Advance();
......@@ -61,7 +60,6 @@ void DebugStackTraceIterator::Advance() {
iterator_.Advance();
if (iterator_.done()) break;
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
iterator_.frame()->Summarize(&frames);
inlined_frame_index_ = static_cast<int>(frames.size());
}
......
......@@ -414,11 +414,12 @@ DEFINE_BOOL(turbo_splitting, true, "split nodes during scheduling in TurboFan")
DEFINE_BOOL(function_context_specialization, false,
"enable function context specialization in TurboFan")
DEFINE_BOOL(turbo_inlining, true, "enable inlining in TurboFan")
DEFINE_INT(max_inlining_levels, 5, "maximum number of inlining levels")
DEFINE_INT(max_inlined_bytecode_size, 500,
"maximum size of bytecode for a single inlining")
DEFINE_INT(max_inlined_bytecode_size_cumulative, 1000,
"maximum cumulative size of bytecode considered for inlining")
DEFINE_INT(max_inlined_bytecode_size_absolute, 5000,
"maximum cumulative size of bytecode considered for inlining")
DEFINE_FLOAT(reserve_inline_budget_scale_factor, 1.2,
"maximum cumulative size of bytecode considered for inlining")
DEFINE_INT(max_inlined_bytecode_size_small, 30,
......@@ -427,10 +428,11 @@ DEFINE_FLOAT(min_inlining_frequency, 0.15, "minimum frequency for inlining")
DEFINE_BOOL(polymorphic_inlining, true, "polymorphic inlining")
DEFINE_BOOL(stress_inline, false,
"set high thresholds for inlining to inline as much as possible")
DEFINE_VALUE_IMPLICATION(stress_inline, max_inlining_levels, 999999)
DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size, 999999)
DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size_cumulative,
999999)
DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size_absolute,
999999)
DEFINE_VALUE_IMPLICATION(stress_inline, min_inlining_frequency, 0)
DEFINE_VALUE_IMPLICATION(stress_inline, polymorphic_inlining, true)
DEFINE_BOOL(trace_turbo_inlining, false, "trace TurboFan inlining")
......
......@@ -1268,7 +1268,6 @@ FrameSummary::~FrameSummary() {
FrameSummary FrameSummary::GetTop(const StandardFrame* frame) {
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
DCHECK_LT(0, frames.size());
return frames.back();
......@@ -1288,7 +1287,6 @@ FrameSummary FrameSummary::GetSingle(const StandardFrame* frame) {
FrameSummary FrameSummary::Get(const StandardFrame* frame, int index) {
DCHECK_LE(0, index);
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
DCHECK_GT(frames.size(), index);
return frames[index];
......
......@@ -390,7 +390,6 @@ class FrameArrayBuilder {
void AppendStandardFrame(StandardFrame* frame) {
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
// A standard frame may include many summarized frames (due to inlining).
for (size_t i = frames.size(); i != 0 && !full(); i--) {
......@@ -802,7 +801,6 @@ Handle<FixedArray> Isolate::CaptureCurrentStackTrace(
// Set initial size to the maximum inlining level + 1 for the outermost
// function.
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
for (size_t i = frames.size(); i != 0 && frames_seen < limit; i--) {
FrameSummary& frame = frames[i - 1];
......@@ -1601,7 +1599,6 @@ bool Isolate::ComputeLocation(MessageLocation* target) {
// baseline code. For optimized code this will use the deoptimization
// information to get canonical location information.
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
frame->Summarize(&frames);
FrameSummary& summary = frames.back();
int pos = summary.SourcePosition();
......
......@@ -434,7 +434,6 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
}
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) {
frames.clear();
it.frame()->Summarize(&frames);
......
......@@ -370,7 +370,6 @@ bool ComputeLocation(Isolate* isolate, MessageLocation* target) {
// baseline code. For optimized code this will use the deoptimization
// information to get canonical location information.
std::vector<FrameSummary> frames;
frames.reserve(FLAG_max_inlining_levels + 1);
it.frame()->Summarize(&frames);
auto& summary = frames.back().AsJavaScript();
Handle<SharedFunctionInfo> shared(summary.function()->shared());
......
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