[turbofan] Allow inlining into BytecodeGraphBuilder graph.

This is a first implementation of inlining into graphs that have been
created using the {BytecodeGraphBuilder}. Note that inlining sticks to
graphs of the same kind, we only ever inline AstGraph into AstGraph or
BytecodeGraph into BytecodeGraph, no mixed inlining.

R=bmeurer@chromium.org,rmcilroy@chromium.org
TEST=cctest/test-run-inlining
BUG=v8:5251

Review-Url: https://codereview.chromium.org/2262033003
Cr-Commit-Position: refs/heads/master@{#39439}
This commit is contained in:
mstarzinger 2016-09-15 01:53:00 -07:00 committed by Commit bot
parent 62e02829e1
commit a400590761
3 changed files with 28 additions and 56 deletions

View File

@ -11,6 +11,7 @@
#include "src/compiler/all-nodes.h"
#include "src/compiler/ast-graph-builder.h"
#include "src/compiler/ast-loop-assignment-analyzer.h"
#include "src/compiler/bytecode-graph-builder.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-operator.h"
@ -475,8 +476,18 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
CompilationInfo info(&parse_info, function);
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
if (info_->is_type_feedback_enabled()) info.MarkAsTypeFeedbackEnabled();
if (info_->is_optimizing_from_bytecode()) info.MarkAsOptimizeFromBytecode();
if (!Compiler::ParseAndAnalyze(info.parse_info())) {
if (info.is_optimizing_from_bytecode() && !Compiler::EnsureBytecode(&info)) {
TRACE("Not inlining %s into %s because bytecode generation failed\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
DCHECK(!info_->isolate()->has_pending_exception());
return NoChange();
}
if (!info.is_optimizing_from_bytecode() &&
!Compiler::ParseAndAnalyze(info.parse_info())) {
TRACE("Not inlining %s into %s because parsing failed\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
@ -486,7 +497,8 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
return NoChange();
}
if (!Compiler::EnsureDeoptimizationSupport(&info)) {
if (!info.is_optimizing_from_bytecode() &&
!Compiler::EnsureDeoptimizationSupport(&info)) {
TRACE("Not inlining %s into %s because deoptimization support failed\n",
shared_info->DebugName()->ToCString().get(),
info_->shared_info()->DebugName()->ToCString().get());
@ -512,7 +524,17 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// Create the subgraph for the inlinee.
Node* start;
Node* end;
{
if (info.is_optimizing_from_bytecode()) {
// Run the BytecodeGraphBuilder to create the subgraph.
Graph::SubgraphScope scope(graph());
BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(),
call.frequency());
graph_builder.CreateGraph();
// Extract the inlinee start/end nodes.
start = graph()->start();
end = graph()->end();
} else {
// Run the loop assignment analyzer on the inlinee.
AstLoopAssignmentAnalyzer loop_assignment_analyzer(&zone, &info);
LoopAssignmentAnalysis* loop_assignment =
@ -616,7 +638,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// in that frame state tho, as the conversion of the receiver can be repeated
// any number of times, it's not observable.
if (node->opcode() == IrOpcode::kJSCallFunction &&
is_sloppy(parse_info.language_mode()) && !shared_info->native()) {
is_sloppy(shared_info->language_mode()) && !shared_info->native()) {
Node* effect = NodeProperties::GetEffectInput(node);
if (NeedsConvertReceiver(call.receiver(), effect)) {
const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
@ -647,7 +669,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// count (i.e. value outputs of start node minus target, receiver, new target,
// arguments count and context) have to match the number of arguments passed
// to the call.
int parameter_count = info.literal()->parameter_count();
int parameter_count = shared_info->internal_formal_parameter_count();
DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5);
if (call.formal_arguments() != parameter_count) {
frame_state = CreateArtificialFrameState(

View File

@ -844,9 +844,7 @@ struct InliningPhase {
AddReducer(data, &graph_reducer, &context_specialization);
AddReducer(data, &graph_reducer, &intrinsic_lowering);
AddReducer(data, &graph_reducer, &call_reducer);
if (!data->info()->is_optimizing_from_bytecode()) {
AddReducer(data, &graph_reducer, &inlining);
}
AddReducer(data, &graph_reducer, &inlining);
graph_reducer.ReduceGraph();
}
};

View File

@ -395,29 +395,6 @@
'test-heap/TestCodeFlushingIncremental': [FAIL],
'test-heap/TestCodeFlushingIncrementalScavenge': [FAIL],
'test-heap/TestCodeFlushingPreAged': [FAIL],
'test-run-inlining/InlineBuiltin': [FAIL],
'test-run-inlining/InlineLoopGuardedEmpty': [FAIL],
'test-run-inlining/InlineLoopGuardedOnce': [FAIL],
'test-run-inlining/InlineLoopGuardedTwice': [FAIL],
'test-run-inlining/InlineLoopUnguardedEmpty': [FAIL],
'test-run-inlining/InlineLoopUnguardedOnce': [FAIL],
'test-run-inlining/InlineLoopUnguardedTwice': [FAIL],
'test-run-inlining/InlineMutuallyRecursive': [FAIL],
'test-run-inlining/InlineNestedBuiltin': [FAIL],
'test-run-inlining/InlineOmitArgumentsDeopt': [FAIL],
'test-run-inlining/InlineOmitArguments': [FAIL],
'test-run-inlining/InlineOmitArgumentsObject': [FAIL],
'test-run-inlining/InlineSurplusArgumentsDeopt': [FAIL],
'test-run-inlining/InlineSurplusArguments': [FAIL],
'test-run-inlining/InlineSurplusArgumentsObject': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamondDifferent': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamond': [FAIL],
'test-run-inlining/InlineTwiceDependent': [FAIL],
'test-run-inlining/InlineTwice': [FAIL],
'test-run-inlining/InlineWithArguments': [FAIL],
'test-run-inlining/SimpleInliningContextDeopt': [FAIL],
'test-run-inlining/SimpleInliningContext': [FAIL],
'test-run-inlining/SimpleInlining': [FAIL],
# BUG(5193): Flaky.
'test-cpu-profiler/FunctionApplySample': [PASS, ['system == windows', SKIP]],
@ -425,31 +402,6 @@
##############################################################################
['variant == ignition_turbofan', {
# TODO(5251): Inlining is currently disabled for the BytecodeGraphBuilder.
'test-run-inlining/InlineLoopGuardedTwice': [FAIL],
'test-run-inlining/InlineSurplusArgumentsDeopt': [FAIL],
'test-run-inlining/InlineTwice': [FAIL],
'test-run-inlining/InlineSurplusArgumentsObject': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamond': [FAIL],
'test-run-inlining/InlineWithArguments': [FAIL],
'test-run-inlining/InlineLoopUnguardedTwice': [FAIL],
'test-run-inlining/InlineOmitArgumentsObject': [FAIL],
'test-run-inlining/InlineLoopUnguardedOnce': [FAIL],
'test-run-inlining/InlineOmitArgumentsDeopt': [FAIL],
'test-run-inlining/InlineTwiceDependentDiamondDifferent': [FAIL],
'test-run-inlining/SimpleInliningContext': [FAIL],
'test-run-inlining/InlineMutuallyRecursive': [FAIL],
'test-run-inlining/InlineLoopGuardedEmpty': [FAIL],
'test-run-inlining/InlineLoopGuardedOnce': [FAIL],
'test-run-inlining/InlineOmitArguments': [FAIL],
'test-run-inlining/SimpleInlining': [FAIL],
'test-run-inlining/InlineLoopUnguardedEmpty': [FAIL],
'test-run-inlining/InlineNestedBuiltin': [FAIL],
'test-run-inlining/InlineSurplusArguments': [FAIL],
'test-run-inlining/InlineBuiltin': [FAIL],
'test-run-inlining/InlineTwiceDependent': [FAIL],
'test-run-inlining/SimpleInliningContextDeopt': [FAIL],
# TODO(rmcilroy,4766): Requires BytecodeGraphBuilder to track source position
# on nodes (behind --turbo_source_positions flag).
'test-cpu-profiler/TickLinesOptimized': [FAIL],