[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}
This commit is contained in:
titzer 2015-05-13 09:08:03 -07:00 committed by Commit bot
parent 6c96d6564c
commit 8cc7e70098
7 changed files with 11 additions and 48 deletions

View File

@ -38,7 +38,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
info_(info),
labels_(zone()->NewArray<Label>(code->InstructionBlockCount())),
current_block_(RpoNumber::Invalid()),
current_source_position_(SourcePosition::Invalid()),
current_source_position_(SourcePosition::Unknown()),
masm_(info->isolate(), NULL, 0),
resolver_(this),
safepoints_(code->zone()),
@ -256,11 +256,10 @@ void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
SourcePosition source_position;
if (!code()->GetSourcePosition(instr, &source_position)) return;
if (source_position == current_source_position_) return;
DCHECK(!source_position.IsInvalid());
current_source_position_ = source_position;
if (source_position.IsUnknown()) return;
int code_pos = source_position.raw();
masm()->positions_recorder()->RecordPosition(source_position.raw());
masm()->positions_recorder()->RecordPosition(code_pos);
masm()->positions_recorder()->WriteRecordedPositions();
if (FLAG_code_comments) {
Vector<char> buffer = Vector<char>::New(256);

View File

@ -122,8 +122,7 @@ class JSONGraphNodeWriter {
os_ << ",\"rankInputs\":[0]";
}
SourcePosition position = positions_->GetSourcePosition(node);
if (!position.IsUnknown()) {
DCHECK(!position.IsInvalid());
if (position.IsKnown()) {
os_ << ",\"pos\":" << position.raw();
}
os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\"";
@ -650,8 +649,7 @@ void GraphC1Visualizer::PrintSchedule(const char* phase,
}
if (positions != NULL) {
SourcePosition position = positions->GetSourcePosition(node);
if (!position.IsUnknown()) {
DCHECK(!position.IsInvalid());
if (position.IsKnown()) {
os_ << " pos:" << position.raw();
}
}

View File

@ -423,10 +423,9 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
if (instructions_.size() == current_node_end) continue;
// Mark source position on first instruction emitted.
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsUnknown()) continue;
DCHECK(!source_position.IsInvalid());
if (source_position_mode_ == kAllSourcePositions ||
node->opcode() == IrOpcode::kCall) {
if (source_position.IsKnown() &&
(source_position_mode_ == kAllSourcePositions ||
node->opcode() == IrOpcode::kCall)) {
sequence()->SetSourcePosition(instructions_[current_node_end],
source_position);
}

View File

@ -657,8 +657,6 @@ bool InstructionSequence::GetSourcePosition(const Instruction* instr,
void InstructionSequence::SetSourcePosition(const Instruction* instr,
SourcePosition value) {
DCHECK(!value.IsInvalid());
DCHECK(!value.IsUnknown());
source_positions_.insert(std::make_pair(instr, value));
}

View File

@ -488,8 +488,6 @@ struct ContextSpecializerPhase {
static const char* phase_name() { return "context specializing"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
JSContextSpecializer spec(data->jsgraph());
GraphReducer graph_reducer(data->graph(), temp_zone);
AddReducer(data, &graph_reducer, &spec);
@ -502,8 +500,6 @@ struct InliningPhase {
static const char* phase_name() { return "inlining"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
GraphReducer graph_reducer(data->graph(), temp_zone);
JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled()
? JSInliner::kGeneralInlining
@ -526,8 +522,6 @@ struct OsrDeconstructionPhase {
static const char* phase_name() { return "OSR deconstruction"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
OsrHelper osr_helper(data->info());
osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone);
}
@ -538,8 +532,6 @@ struct JSTypeFeedbackPhase {
static const char* phase_name() { return "type feedback specializing"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
Handle<Context> native_context(data->info()->context()->native_context());
TypeFeedbackOracle oracle(data->isolate(), temp_zone,
data->info()->unoptimized_code(),
@ -565,8 +557,6 @@ struct TypedLoweringPhase {
static const char* phase_name() { return "typed lowering"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
LoadElimination load_elimination;
JSBuiltinReducer builtin_reducer(data->jsgraph());
JSTypedLowering typed_lowering(data->jsgraph(), temp_zone);
@ -589,8 +579,6 @@ struct SimplifiedLoweringPhase {
static const char* phase_name() { return "simplified lowering"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
SimplifiedLowering lowering(data->jsgraph(), temp_zone,
data->source_positions());
lowering.LowerAllNodes();
@ -612,8 +600,6 @@ struct ControlFlowOptimizationPhase {
static const char* phase_name() { return "control flow optimization"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlFlowOptimizer optimizer(data->jsgraph(), temp_zone);
optimizer.Optimize();
}
@ -624,8 +610,6 @@ struct ChangeLoweringPhase {
static const char* phase_name() { return "change lowering"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
ChangeLowering lowering(data->jsgraph());
@ -645,8 +629,6 @@ struct ChangeLoweringPhase {
struct EarlyControlReductionPhase {
static const char* phase_name() { return "early control reduction"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0);
}
};
@ -655,8 +637,6 @@ struct EarlyControlReductionPhase {
struct LateControlReductionPhase {
static const char* phase_name() { return "late control reduction"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0);
}
};
@ -666,8 +646,6 @@ struct StressLoopPeelingPhase {
static const char* phase_name() { return "stress loop peeling"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
// Peel the first outer loop for testing.
// TODO(titzer): peel all loops? the N'th loop? Innermost loops?
LoopTree* loop_tree = LoopFinder::BuildLoopTree(data->graph(), temp_zone);
@ -683,8 +661,6 @@ struct GenericLoweringPhase {
static const char* phase_name() { return "generic lowering"; }
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
JSGenericLowering generic(data->info()->is_typing_enabled(),
data->jsgraph());
SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());

View File

@ -16,7 +16,6 @@ class SourcePositionTable::Decorator final : public GraphDecorator {
: source_positions_(source_positions) {}
void Decorate(Node* node, bool incomplete) final {
DCHECK(!source_positions_->current_position_.IsInvalid());
source_positions_->table_.Set(node, source_positions_->current_position_);
}
@ -28,7 +27,7 @@ class SourcePositionTable::Decorator final : public GraphDecorator {
SourcePositionTable::SourcePositionTable(Graph* graph)
: graph_(graph),
decorator_(nullptr),
current_position_(SourcePosition::Invalid()),
current_position_(SourcePosition::Unknown()),
table_(graph->zone()) {}
@ -56,7 +55,7 @@ void SourcePositionTable::Print(std::ostream& os) const {
bool needs_comma = false;
for (auto i : table_) {
SourcePosition pos = i.second;
if (!pos.IsUnknown()) {
if (pos.IsKnown()) {
if (needs_comma) {
os << ",";
}

View File

@ -20,16 +20,12 @@ class SourcePosition final {
static SourcePosition Unknown() { return SourcePosition(kUnknownPosition); }
bool IsUnknown() const { return raw() == kUnknownPosition; }
static SourcePosition Invalid() { return SourcePosition(kInvalidPosition); }
bool IsInvalid() const { return raw() == kInvalidPosition; }
bool IsKnown() const { return raw() != kUnknownPosition; }
int raw() const { return raw_; }
private:
static const int kInvalidPosition = -2;
static const int kUnknownPosition = RelocInfo::kNoPosition;
STATIC_ASSERT(kInvalidPosition != kUnknownPosition);
int raw_;
};
@ -61,9 +57,7 @@ class SourcePositionTable final {
private:
void Init(SourcePosition position) {
if (!position.IsUnknown() || prev_position_.IsInvalid()) {
source_positions_->current_position_ = position;
}
if (position.IsKnown()) source_positions_->current_position_ = position;
}
SourcePositionTable* const source_positions_;