Reviewers: Michael Starzinger,
Description:
[turbofan] Treat uninitialized source positions as unknown.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/1109763002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+10, -47 lines):
M src/compiler/code-generator.cc
M src/compiler/graph-visualizer.cc
M src/compiler/instruction.cc
M src/compiler/instruction-selector.cc
M src/compiler/pipeline.cc
M src/compiler/source-position.h
M src/compiler/source-position.cc
Index: src/compiler/code-generator.cc
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
index
dd6565c17b58dba25cd3c7cedb9e48d065ee8ffa..110f756bbbcb545ed4344a2442e45adb385b4db0
100644
--- a/src/compiler/code-generator.cc
+++ b/src/compiler/code-generator.cc
@@ -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()),
@@ -252,11 +252,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);
Index: src/compiler/graph-visualizer.cc
diff --git a/src/compiler/graph-visualizer.cc
b/src/compiler/graph-visualizer.cc
index
b281cdba3ccc99386268e5f79db2ea6f91fef0b3..4d2d81eacd1c7459be99c009244b500ef63db6af
100644
--- a/src/compiler/graph-visualizer.cc
+++ b/src/compiler/graph-visualizer.cc
@@ -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();
}
}
Index: src/compiler/instruction-selector.cc
diff --git a/src/compiler/instruction-selector.cc
b/src/compiler/instruction-selector.cc
index
1e2ab974854fd563640ae20861be9871eb9dfceb..ead5efda8493c232344316775a5c01246b83c822
100644
--- a/src/compiler/instruction-selector.cc
+++ b/src/compiler/instruction-selector.cc
@@ -477,9 +477,8 @@ 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 (FLAG_turbo_source_positions || node->opcode() == IrOpcode::kCall) {
+ if (source_position.IsKnown() &&
+ (FLAG_turbo_source_positions || node->opcode() ==
IrOpcode::kCall)) {
sequence()->SetSourcePosition(instructions_[current_node_end],
source_position);
}
Index: src/compiler/instruction.cc
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index
9d157a1251b14ce87de5df7301c803bfcff6eea8..12ddfee98d65009d61a176a3d1f644826c18efd1
100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -604,8 +604,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));
}
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index
022b6b5d1b2fb4eb24519d825f8548a2dde44d9c..0fc9b56848a6fe105692725e2b67349d41ca2c29
100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -483,8 +483,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);
@@ -497,8 +495,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());
JSInliner inliner(data->info()->is_inlining_enabled()
? JSInliner::kGeneralInlining
: JSInliner::kBuiltinsInlining,
@@ -521,8 +517,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());
bool success =
osr_helper.Deconstruct(data->jsgraph(), data->common(), temp_zone);
@@ -535,8 +529,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(),
@@ -554,8 +546,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);
@@ -578,8 +568,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();
@@ -601,8 +589,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();
}
@@ -613,8 +599,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());
@@ -634,8 +618,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());
// TODO(turbofan): enable select matching in early control reduction.
ControlReducer::ReduceGraph(temp_zone, data->jsgraph(),
data->common(), 0);
}
@@ -645,8 +627,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(),
data->common(), 0);
}
};
@@ -656,8 +636,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);
@@ -673,8 +651,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());
Index: src/compiler/source-position.cc
diff --git a/src/compiler/source-position.cc
b/src/compiler/source-position.cc
index
61d0ad97bbce082e90000a7d0cf651693be43218..f39e11fb73ee4ed083f5b1bb2dbfaf06989fcbe7
100644
--- a/src/compiler/source-position.cc
+++ b/src/compiler/source-position.cc
@@ -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_(NULL),
- 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 << ",";
}
Index: src/compiler/source-position.h
diff --git a/src/compiler/source-position.h b/src/compiler/source-position.h
index
68c4b4eadf30dbc1fa937ba2e9b0a25de44b7456..b7e3d795b7e34d4e796ad9f99c34ba048f5da0e0
100644
--- a/src/compiler/source-position.h
+++ b/src/compiler/source-position.h
@@ -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* source_positions_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.