Commit 27228d2f authored by neis's avatar neis Committed by Commit bot

[turbofan] Remember source positions when creating graph from bytecode.

R=bmeurer@chromium.org
BUG=v8:5439

Review-Url: https://codereview.chromium.org/2407823002
Cr-Commit-Position: refs/heads/master@{#40263}
parent 9cb42010
......@@ -587,10 +587,9 @@ bool BytecodeGraphBuilder::Environment::StateValuesAreUpToDate(
1, output_poke_start, output_poke_end);
}
BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone,
CompilationInfo* info,
JSGraph* jsgraph,
float invocation_frequency)
BytecodeGraphBuilder::BytecodeGraphBuilder(
Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph,
float invocation_frequency, SourcePositionTable* source_positions)
: local_zone_(local_zone),
jsgraph_(jsgraph),
invocation_frequency_(invocation_frequency),
......@@ -613,8 +612,8 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone,
info->is_deoptimization_enabled()),
state_values_cache_(jsgraph),
liveness_analyzer_(
static_cast<size_t>(bytecode_array()->register_count()), local_zone) {
}
static_cast<size_t>(bytecode_array()->register_count()), local_zone),
source_positions_(source_positions) {}
Node* BytecodeGraphBuilder::GetNewTarget() {
if (!new_target_.is_set()) {
......@@ -714,11 +713,16 @@ void BytecodeGraphBuilder::VisitBytecodes() {
loop_analysis.Analyze();
set_branch_analysis(&analysis);
set_loop_analysis(&loop_analysis);
interpreter::BytecodeArrayIterator iterator(bytecode_array());
set_bytecode_iterator(&iterator);
SourcePositionTableIterator source_position_iterator(
bytecode_array()->source_position_table());
BuildOSRNormalEntryPoint();
while (!iterator.done()) {
int current_offset = iterator.current_offset();
UpdateCurrentSourcePosition(&source_position_iterator, current_offset);
EnterAndExitExceptionHandlers(current_offset);
SwitchToMergeEnvironment(current_offset);
if (environment() != nullptr) {
......@@ -736,6 +740,7 @@ void BytecodeGraphBuilder::VisitBytecodes() {
}
iterator.Advance();
}
set_branch_analysis(nullptr);
set_bytecode_iterator(nullptr);
DCHECK(exception_handlers_.empty());
......@@ -2256,6 +2261,21 @@ Node* BytecodeGraphBuilder::MergeValue(Node* value, Node* other,
return value;
}
void BytecodeGraphBuilder::UpdateCurrentSourcePosition(
SourcePositionTableIterator* it, int offset) {
// TODO(neis): Remove this once inlining supports source positions.
if (source_positions_ == nullptr) return;
if (it->done()) return;
if (it->code_offset() == offset) {
source_positions_->set_current_position(it->source_position());
it->Advance();
} else {
DCHECK_GT(it->code_offset(), offset);
}
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -9,11 +9,13 @@
#include "src/compiler/bytecode-loop-analysis.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/liveness-analyzer.h"
#include "src/compiler/source-position.h"
#include "src/compiler/state-values-utils.h"
#include "src/compiler/type-hint-analyzer.h"
#include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-flags.h"
#include "src/interpreter/bytecodes.h"
#include "src/source-position-table.h"
namespace v8 {
namespace internal {
......@@ -27,7 +29,8 @@ namespace compiler {
class BytecodeGraphBuilder {
public:
BytecodeGraphBuilder(Zone* local_zone, CompilationInfo* info,
JSGraph* jsgraph, float invocation_frequency);
JSGraph* jsgraph, float invocation_frequency,
SourcePositionTable* source_positions);
// Creates a graph by visiting bytecodes.
bool CreateGraph();
......@@ -301,6 +304,13 @@ class BytecodeGraphBuilder {
// Analyzer of register liveness.
LivenessAnalyzer liveness_analyzer_;
// The Turbofan source position table, to be populated.
SourcePositionTable* source_positions_;
// Update [source_positions_]'s current position to that of the bytecode at
// [offset], if any.
void UpdateCurrentSourcePosition(SourcePositionTableIterator* it, int offset);
static int const kBinaryOperationHintIndex = 1;
static int const kCountOperationHintIndex = 0;
static int const kBinaryOperationSmiHintIndex = 2;
......
......@@ -530,7 +530,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// Run the BytecodeGraphBuilder to create the subgraph.
Graph::SubgraphScope scope(graph());
BytecodeGraphBuilder graph_builder(&zone, &info, jsgraph(),
call.frequency());
call.frequency(), nullptr);
graph_builder.CreateGraph();
// Extract the inlinee start/end nodes.
......
......@@ -758,7 +758,8 @@ struct GraphBuilderPhase {
if (data->info()->is_optimizing_from_bytecode()) {
BytecodeGraphBuilder graph_builder(temp_zone, data->info(),
data->jsgraph(), 1.0f);
data->jsgraph(), 1.0f,
data->source_positions());
succeeded = graph_builder.CreateGraph();
} else {
AstGraphBuilderWithPositions graph_builder(
......
......@@ -72,6 +72,10 @@ class SourcePositionTable final : public ZoneObject {
SourcePosition GetSourcePosition(Node* node) const;
void SetSourcePosition(Node* node, SourcePosition position);
void set_current_position(int position) {
current_position_ = SourcePosition(position);
}
void Print(std::ostream& os) const;
private:
......
......@@ -396,10 +396,6 @@
##############################################################################
['variant == ignition_turbofan', {
# TODO(rmcilroy,4766): Requires BytecodeGraphBuilder to track source position
# on nodes (behind --turbo_source_positions flag).
'test-cpu-profiler/TickLinesOptimized': [FAIL],
# TODO(rmcilroy,4680): Related to lack of code flushing. Check failed: !function->shared()->is_compiled() || function->IsOptimized().
'test-heap/TestCodeFlushingPreAged': [FAIL],
'test-heap/TestCodeFlushingIncrementalScavenge': [FAIL],
......
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