From cf1ebf36625ce8ffa713822768acfa59153440fc Mon Sep 17 00:00:00 2001 From: leszeks Date: Thu, 3 Nov 2016 03:21:05 -0700 Subject: [PATCH] [ignition/turbo] Remove stack check from inlined functions This removes the first stack check in inlined functions in the bytecode graph builder, to match the behaviour of the AST graph builder. I measure a ~1% statistically significant (p < 0.01) improvement on Mandreel with --ignition-staging --turbo (on my x64 machine, YMMV). Review-Url: https://codereview.chromium.org/2392333002 Cr-Commit-Position: refs/heads/master@{#40715} --- src/compiler/bytecode-graph-builder.cc | 16 +++++++++++----- src/compiler/bytecode-graph-builder.h | 4 ++-- src/compiler/js-inlining.cc | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc index b00bcec339..ab7db8079b 100644 --- a/src/compiler/bytecode-graph-builder.cc +++ b/src/compiler/bytecode-graph-builder.cc @@ -569,7 +569,7 @@ VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { return VectorSlotPair(feedback_vector(), slot); } -bool BytecodeGraphBuilder::CreateGraph() { +bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { // Set up the basic structure of the graph. Outputs for {Start} are the formal // parameters (including the receiver) plus new target, number of arguments, // context and closure. @@ -581,7 +581,7 @@ bool BytecodeGraphBuilder::CreateGraph() { GetFunctionContext()); set_environment(&env); - VisitBytecodes(); + VisitBytecodes(stack_check); // Finish the basic structure of the graph. DCHECK_NE(0u, exit_controls_.size()); @@ -641,7 +641,7 @@ void BytecodeGraphBuilder::ClearNonLiveSlotsInFrameStates() { } } -void BytecodeGraphBuilder::VisitBytecodes() { +void BytecodeGraphBuilder::VisitBytecodes(bool stack_check) { BytecodeBranchAnalysis analysis(bytecode_array(), local_zone()); BytecodeLoopAnalysis loop_analysis(bytecode_array(), &analysis, local_zone()); analysis.Analyze(); @@ -655,7 +655,7 @@ void BytecodeGraphBuilder::VisitBytecodes() { bytecode_array()->source_position_table()); BuildOSRNormalEntryPoint(); - while (!iterator.done()) { + for (; !iterator.done(); iterator.Advance()) { int current_offset = iterator.current_offset(); UpdateCurrentSourcePosition(&source_position_iterator, current_offset); EnterAndExitExceptionHandlers(current_offset); @@ -664,6 +664,13 @@ void BytecodeGraphBuilder::VisitBytecodes() { BuildLoopHeaderEnvironment(current_offset); BuildOSRLoopEntryPoint(current_offset); + // Skip the first stack check if stack_check is false + if (!stack_check && + iterator.current_bytecode() == interpreter::Bytecode::kStackCheck) { + stack_check = true; + continue; + } + switch (iterator.current_bytecode()) { #define BYTECODE_CASE(name, ...) \ case interpreter::Bytecode::k##name: \ @@ -673,7 +680,6 @@ void BytecodeGraphBuilder::VisitBytecodes() { #undef BYTECODE_CODE } } - iterator.Advance(); } set_branch_analysis(nullptr); diff --git a/src/compiler/bytecode-graph-builder.h b/src/compiler/bytecode-graph-builder.h index 65e5042d9d..d2feb93a20 100644 --- a/src/compiler/bytecode-graph-builder.h +++ b/src/compiler/bytecode-graph-builder.h @@ -33,12 +33,12 @@ class BytecodeGraphBuilder { SourcePositionTable* source_positions); // Creates a graph by visiting bytecodes. - bool CreateGraph(); + bool CreateGraph(bool stack_check = true); private: class Environment; - void VisitBytecodes(); + void VisitBytecodes(bool stack_check); // Get or create the node that represents the outer function closure. Node* GetFunctionClosure(); diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc index 1a49e2f4c6..8ab07c5fa6 100644 --- a/src/compiler/js-inlining.cc +++ b/src/compiler/js-inlining.cc @@ -531,7 +531,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle function) { Graph::SubgraphScope scope(graph()); BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(), call.frequency(), nullptr); - graph_builder.CreateGraph(); + graph_builder.CreateGraph(false); // Extract the inlinee start/end nodes. start = graph()->start();