Commit 8cc7e700 authored by titzer's avatar titzer Committed by Commit bot

[turbofan] Treat uninitialized source positions as unknown.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1109763002

Cr-Commit-Position: refs/heads/master@{#28399}
parent 6c96d656
...@@ -38,7 +38,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, ...@@ -38,7 +38,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
info_(info), info_(info),
labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), labels_(zone()->NewArray<Label>(code->InstructionBlockCount())),
current_block_(RpoNumber::Invalid()), current_block_(RpoNumber::Invalid()),
current_source_position_(SourcePosition::Invalid()), current_source_position_(SourcePosition::Unknown()),
masm_(info->isolate(), NULL, 0), masm_(info->isolate(), NULL, 0),
resolver_(this), resolver_(this),
safepoints_(code->zone()), safepoints_(code->zone()),
...@@ -256,11 +256,10 @@ void CodeGenerator::AssembleSourcePosition(Instruction* instr) { ...@@ -256,11 +256,10 @@ void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
SourcePosition source_position; SourcePosition source_position;
if (!code()->GetSourcePosition(instr, &source_position)) return; if (!code()->GetSourcePosition(instr, &source_position)) return;
if (source_position == current_source_position_) return; if (source_position == current_source_position_) return;
DCHECK(!source_position.IsInvalid());
current_source_position_ = source_position; current_source_position_ = source_position;
if (source_position.IsUnknown()) return; if (source_position.IsUnknown()) return;
int code_pos = source_position.raw(); int code_pos = source_position.raw();
masm()->positions_recorder()->RecordPosition(source_position.raw()); masm()->positions_recorder()->RecordPosition(code_pos);
masm()->positions_recorder()->WriteRecordedPositions(); masm()->positions_recorder()->WriteRecordedPositions();
if (FLAG_code_comments) { if (FLAG_code_comments) {
Vector<char> buffer = Vector<char>::New(256); Vector<char> buffer = Vector<char>::New(256);
......
...@@ -122,8 +122,7 @@ class JSONGraphNodeWriter { ...@@ -122,8 +122,7 @@ class JSONGraphNodeWriter {
os_ << ",\"rankInputs\":[0]"; os_ << ",\"rankInputs\":[0]";
} }
SourcePosition position = positions_->GetSourcePosition(node); SourcePosition position = positions_->GetSourcePosition(node);
if (!position.IsUnknown()) { if (position.IsKnown()) {
DCHECK(!position.IsInvalid());
os_ << ",\"pos\":" << position.raw(); os_ << ",\"pos\":" << position.raw();
} }
os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\""; os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\"";
...@@ -650,8 +649,7 @@ void GraphC1Visualizer::PrintSchedule(const char* phase, ...@@ -650,8 +649,7 @@ void GraphC1Visualizer::PrintSchedule(const char* phase,
} }
if (positions != NULL) { if (positions != NULL) {
SourcePosition position = positions->GetSourcePosition(node); SourcePosition position = positions->GetSourcePosition(node);
if (!position.IsUnknown()) { if (position.IsKnown()) {
DCHECK(!position.IsInvalid());
os_ << " pos:" << position.raw(); os_ << " pos:" << position.raw();
} }
} }
......
...@@ -423,10 +423,9 @@ void InstructionSelector::VisitBlock(BasicBlock* block) { ...@@ -423,10 +423,9 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
if (instructions_.size() == current_node_end) continue; if (instructions_.size() == current_node_end) continue;
// Mark source position on first instruction emitted. // Mark source position on first instruction emitted.
SourcePosition source_position = source_positions_->GetSourcePosition(node); SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsUnknown()) continue; if (source_position.IsKnown() &&
DCHECK(!source_position.IsInvalid()); (source_position_mode_ == kAllSourcePositions ||
if (source_position_mode_ == kAllSourcePositions || node->opcode() == IrOpcode::kCall)) {
node->opcode() == IrOpcode::kCall) {
sequence()->SetSourcePosition(instructions_[current_node_end], sequence()->SetSourcePosition(instructions_[current_node_end],
source_position); source_position);
} }
......
...@@ -657,8 +657,6 @@ bool InstructionSequence::GetSourcePosition(const Instruction* instr, ...@@ -657,8 +657,6 @@ bool InstructionSequence::GetSourcePosition(const Instruction* instr,
void InstructionSequence::SetSourcePosition(const Instruction* instr, void InstructionSequence::SetSourcePosition(const Instruction* instr,
SourcePosition value) { SourcePosition value) {
DCHECK(!value.IsInvalid());
DCHECK(!value.IsUnknown());
source_positions_.insert(std::make_pair(instr, value)); source_positions_.insert(std::make_pair(instr, value));
} }
......
...@@ -488,8 +488,6 @@ struct ContextSpecializerPhase { ...@@ -488,8 +488,6 @@ struct ContextSpecializerPhase {
static const char* phase_name() { return "context specializing"; } static const char* phase_name() { return "context specializing"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
JSContextSpecializer spec(data->jsgraph()); JSContextSpecializer spec(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone); GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &spec); AddReducer(data, &graph_reducer, &spec);
...@@ -502,8 +500,6 @@ struct InliningPhase { ...@@ -502,8 +500,6 @@ struct InliningPhase {
static const char* phase_name() { return "inlining"; } static const char* phase_name() { return "inlining"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
GraphReducer graph_reducer(data->graph(), temp_zone); GraphReducer graph_reducer(data->graph(), temp_zone);
JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled()
? JSInliner::kGeneralInlining ? JSInliner::kGeneralInlining
...@@ -526,8 +522,6 @@ struct OsrDeconstructionPhase { ...@@ -526,8 +522,6 @@ struct OsrDeconstructionPhase {
static const char* phase_name() { return "OSR deconstruction"; } static const char* phase_name() { return "OSR deconstruction"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
OsrHelper osr_helper(data->info()); OsrHelper osr_helper(data->info());
osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone); osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone);
} }
...@@ -538,8 +532,6 @@ struct JSTypeFeedbackPhase { ...@@ -538,8 +532,6 @@ struct JSTypeFeedbackPhase {
static const char* phase_name() { return "type feedback specializing"; } static const char* phase_name() { return "type feedback specializing"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
Handle<Context> native_context(data->info()->context()->native_context()); Handle<Context> native_context(data->info()->context()->native_context());
TypeFeedbackOracle oracle(data->isolate(), temp_zone, TypeFeedbackOracle oracle(data->isolate(), temp_zone,
data->info()->unoptimized_code(), data->info()->unoptimized_code(),
...@@ -565,8 +557,6 @@ struct TypedLoweringPhase { ...@@ -565,8 +557,6 @@ struct TypedLoweringPhase {
static const char* phase_name() { return "typed lowering"; } static const char* phase_name() { return "typed lowering"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
LoadElimination load_elimination; LoadElimination load_elimination;
JSBuiltinReducer builtin_reducer(data->jsgraph()); JSBuiltinReducer builtin_reducer(data->jsgraph());
JSTypedLowering typed_lowering(data->jsgraph(), temp_zone); JSTypedLowering typed_lowering(data->jsgraph(), temp_zone);
...@@ -589,8 +579,6 @@ struct SimplifiedLoweringPhase { ...@@ -589,8 +579,6 @@ struct SimplifiedLoweringPhase {
static const char* phase_name() { return "simplified lowering"; } static const char* phase_name() { return "simplified lowering"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
SimplifiedLowering lowering(data->jsgraph(), temp_zone, SimplifiedLowering lowering(data->jsgraph(), temp_zone,
data->source_positions()); data->source_positions());
lowering.LowerAllNodes(); lowering.LowerAllNodes();
...@@ -612,8 +600,6 @@ struct ControlFlowOptimizationPhase { ...@@ -612,8 +600,6 @@ struct ControlFlowOptimizationPhase {
static const char* phase_name() { return "control flow optimization"; } static const char* phase_name() { return "control flow optimization"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlFlowOptimizer optimizer(data->jsgraph(), temp_zone); ControlFlowOptimizer optimizer(data->jsgraph(), temp_zone);
optimizer.Optimize(); optimizer.Optimize();
} }
...@@ -624,8 +610,6 @@ struct ChangeLoweringPhase { ...@@ -624,8 +610,6 @@ struct ChangeLoweringPhase {
static const char* phase_name() { return "change lowering"; } static const char* phase_name() { return "change lowering"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ValueNumberingReducer vn_reducer(temp_zone); ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph()); SimplifiedOperatorReducer simple_reducer(data->jsgraph());
ChangeLowering lowering(data->jsgraph()); ChangeLowering lowering(data->jsgraph());
...@@ -645,8 +629,6 @@ struct ChangeLoweringPhase { ...@@ -645,8 +629,6 @@ struct ChangeLoweringPhase {
struct EarlyControlReductionPhase { struct EarlyControlReductionPhase {
static const char* phase_name() { return "early control reduction"; } static const char* phase_name() { return "early control reduction"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0); ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0);
} }
}; };
...@@ -655,8 +637,6 @@ struct EarlyControlReductionPhase { ...@@ -655,8 +637,6 @@ struct EarlyControlReductionPhase {
struct LateControlReductionPhase { struct LateControlReductionPhase {
static const char* phase_name() { return "late control reduction"; } static const char* phase_name() { return "late control reduction"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0); ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0);
} }
}; };
...@@ -666,8 +646,6 @@ struct StressLoopPeelingPhase { ...@@ -666,8 +646,6 @@ struct StressLoopPeelingPhase {
static const char* phase_name() { return "stress loop peeling"; } static const char* phase_name() { return "stress loop peeling"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
// Peel the first outer loop for testing. // Peel the first outer loop for testing.
// TODO(titzer): peel all loops? the N'th loop? Innermost loops? // TODO(titzer): peel all loops? the N'th loop? Innermost loops?
LoopTree* loop_tree = LoopFinder::BuildLoopTree(data->graph(), temp_zone); LoopTree* loop_tree = LoopFinder::BuildLoopTree(data->graph(), temp_zone);
...@@ -683,8 +661,6 @@ struct GenericLoweringPhase { ...@@ -683,8 +661,6 @@ struct GenericLoweringPhase {
static const char* phase_name() { return "generic lowering"; } static const char* phase_name() { return "generic lowering"; }
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
JSGenericLowering generic(data->info()->is_typing_enabled(), JSGenericLowering generic(data->info()->is_typing_enabled(),
data->jsgraph()); data->jsgraph());
SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());
......
...@@ -16,7 +16,6 @@ class SourcePositionTable::Decorator final : public GraphDecorator { ...@@ -16,7 +16,6 @@ class SourcePositionTable::Decorator final : public GraphDecorator {
: source_positions_(source_positions) {} : source_positions_(source_positions) {}
void Decorate(Node* node, bool incomplete) final { void Decorate(Node* node, bool incomplete) final {
DCHECK(!source_positions_->current_position_.IsInvalid());
source_positions_->table_.Set(node, source_positions_->current_position_); source_positions_->table_.Set(node, source_positions_->current_position_);
} }
...@@ -28,7 +27,7 @@ class SourcePositionTable::Decorator final : public GraphDecorator { ...@@ -28,7 +27,7 @@ class SourcePositionTable::Decorator final : public GraphDecorator {
SourcePositionTable::SourcePositionTable(Graph* graph) SourcePositionTable::SourcePositionTable(Graph* graph)
: graph_(graph), : graph_(graph),
decorator_(nullptr), decorator_(nullptr),
current_position_(SourcePosition::Invalid()), current_position_(SourcePosition::Unknown()),
table_(graph->zone()) {} table_(graph->zone()) {}
...@@ -56,7 +55,7 @@ void SourcePositionTable::Print(std::ostream& os) const { ...@@ -56,7 +55,7 @@ void SourcePositionTable::Print(std::ostream& os) const {
bool needs_comma = false; bool needs_comma = false;
for (auto i : table_) { for (auto i : table_) {
SourcePosition pos = i.second; SourcePosition pos = i.second;
if (!pos.IsUnknown()) { if (pos.IsKnown()) {
if (needs_comma) { if (needs_comma) {
os << ","; os << ",";
} }
......
...@@ -20,16 +20,12 @@ class SourcePosition final { ...@@ -20,16 +20,12 @@ class SourcePosition final {
static SourcePosition Unknown() { return SourcePosition(kUnknownPosition); } static SourcePosition Unknown() { return SourcePosition(kUnknownPosition); }
bool IsUnknown() const { return raw() == kUnknownPosition; } bool IsUnknown() const { return raw() == kUnknownPosition; }
bool IsKnown() const { return raw() != kUnknownPosition; }
static SourcePosition Invalid() { return SourcePosition(kInvalidPosition); }
bool IsInvalid() const { return raw() == kInvalidPosition; }
int raw() const { return raw_; } int raw() const { return raw_; }
private: private:
static const int kInvalidPosition = -2;
static const int kUnknownPosition = RelocInfo::kNoPosition; static const int kUnknownPosition = RelocInfo::kNoPosition;
STATIC_ASSERT(kInvalidPosition != kUnknownPosition);
int raw_; int raw_;
}; };
...@@ -61,9 +57,7 @@ class SourcePositionTable final { ...@@ -61,9 +57,7 @@ class SourcePositionTable final {
private: private:
void Init(SourcePosition position) { void Init(SourcePosition position) {
if (!position.IsUnknown() || prev_position_.IsInvalid()) { if (position.IsKnown()) source_positions_->current_position_ = position;
source_positions_->current_position_ = position;
}
} }
SourcePositionTable* const source_positions_; SourcePositionTable* const source_positions_;
......
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