Commit 10c69473 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Merge CanInlineFunction into SharedFunctionInfo::IsInlineable

Change-Id: I1bdb803a66a004f1a6dfdee149f459b0d0210f2f
Reviewed-on: https://chromium-review.googlesource.com/c/1414922
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58882}
parent 1a1f4e1e
...@@ -60,27 +60,6 @@ int CollectFunctions(Node* node, Handle<JSFunction>* functions, ...@@ -60,27 +60,6 @@ int CollectFunctions(Node* node, Handle<JSFunction>* functions,
return 0; return 0;
} }
bool CanInlineFunction(Handle<SharedFunctionInfo> shared,
Handle<BytecodeArray> bytecode) {
// Built-in functions are handled by the JSCallReducer.
if (shared->HasBuiltinFunctionId()) return false;
// Only choose user code for inlining.
if (!shared->IsUserJavaScript()) return false;
// If there is no bytecode array, it is either not compiled or it is compiled
// with WebAssembly for the asm.js pipeline. In either case we don't want to
// inline.
if (bytecode.is_null()) return false;
// Quick check on the size of the bytecode to avoid inlining large functions.
if (bytecode->length() > FLAG_max_inlined_bytecode_size) {
return false;
}
return true;
}
bool IsSmallInlineFunction(Handle<BytecodeArray> bytecode) { bool IsSmallInlineFunction(Handle<BytecodeArray> bytecode) {
// Forcibly inline small functions. // Forcibly inline small functions.
// Don't forcibly inline functions that weren't compiled yet. // Don't forcibly inline functions that weren't compiled yet.
...@@ -127,8 +106,7 @@ Reduction JSInliningHeuristic::Reduce(Node* node) { ...@@ -127,8 +106,7 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
candidate.functions[i].is_null() candidate.functions[i].is_null()
? candidate.shared_info ? candidate.shared_info
: handle(candidate.functions[i]->shared(), isolate()); : handle(candidate.functions[i]->shared(), isolate());
Handle<BytecodeArray> bytecode = candidate.bytecode[i]; candidate.can_inline_function[i] = shared->IsInlineable();
candidate.can_inline_function[i] = CanInlineFunction(shared, bytecode);
// Do not allow direct recursion i.e. f() -> f(). We still allow indirect // Do not allow direct recursion i.e. f() -> f(). We still allow indirect
// recurion like f() -> g() -> f(). The indirect recursion is helpful in // recurion like f() -> g() -> f(). The indirect recursion is helpful in
// cases where f() is a small dispatch function that calls the appropriate // cases where f() is a small dispatch function that calls the appropriate
...@@ -144,6 +122,7 @@ Reduction JSInliningHeuristic::Reduce(Node* node) { ...@@ -144,6 +122,7 @@ Reduction JSInliningHeuristic::Reduce(Node* node) {
node->id(), node->op()->mnemonic()); node->id(), node->op()->mnemonic());
candidate.can_inline_function[i] = false; candidate.can_inline_function[i] = false;
} }
Handle<BytecodeArray> bytecode = candidate.bytecode[i];
if (candidate.can_inline_function[i]) { if (candidate.can_inline_function[i]) {
can_inline = true; can_inline = true;
candidate.total_size += bytecode->length(); candidate.total_size += bytecode->length();
......
...@@ -393,13 +393,7 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -393,13 +393,7 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
// Determine the call target. // Determine the call target.
if (!DetermineCallTarget(node, shared_info)) return NoChange(); if (!DetermineCallTarget(node, shared_info)) return NoChange();
// Function must be inlineable. DCHECK(shared_info->IsInlineable());
if (!shared_info->IsInlineable()) {
TRACE("Not inlining %s into %s because callee is not inlineable\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
return NoChange();
}
// Constructor must be constructable. // Constructor must be constructable.
if (node->opcode() == IrOpcode::kJSConstruct && if (node->opcode() == IrOpcode::kJSConstruct &&
......
...@@ -14258,12 +14258,32 @@ Handle<Object> SharedFunctionInfo::GetSourceCodeHarmony( ...@@ -14258,12 +14258,32 @@ Handle<Object> SharedFunctionInfo::GetSourceCodeHarmony(
bool SharedFunctionInfo::IsInlineable() { bool SharedFunctionInfo::IsInlineable() {
// Check that the function has a script associated with it. // Check that the function has a script associated with it.
if (!script()->IsScript()) return false; if (!script()->IsScript()) return false;
if (GetIsolate()->is_precise_binary_code_coverage() && if (GetIsolate()->is_precise_binary_code_coverage() &&
!has_reported_binary_coverage()) { !has_reported_binary_coverage()) {
// We may miss invocations if this function is inlined. // We may miss invocations if this function is inlined.
return false; return false;
} }
return !optimization_disabled();
if (optimization_disabled()) return false;
// Built-in functions are handled by the JSCallReducer.
if (HasBuiltinFunctionId()) return false;
// Only choose user code for inlining.
if (!IsUserJavaScript()) return false;
// If there is no bytecode array, it is either not compiled or it is compiled
// with WebAssembly for the asm.js pipeline. In either case we don't want to
// inline.
if (!HasBytecodeArray()) return false;
// Quick check on the size of the bytecode to avoid inlining large functions.
if (GetBytecodeArray()->length() > FLAG_max_inlined_bytecode_size) {
return false;
}
return true;
} }
int SharedFunctionInfo::SourceSize() { return EndPosition() - StartPosition(); } int SharedFunctionInfo::SourceSize() { return EndPosition() - StartPosition(); }
......
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