Commit 25b450b2 authored by rafaelw@chromium.org's avatar rafaelw@chromium.org

Revert "Improvements in positions handling in optimizing compiler." (r17765)

Original issue: https://codereview.chromium.org/49203002/

TBR=vegorov

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17768 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f923ff3c
...@@ -642,7 +642,6 @@ class HValue : public ZoneObject { ...@@ -642,7 +642,6 @@ class HValue : public ZoneObject {
virtual ~HValue() {} virtual ~HValue() {}
virtual int position() const { return RelocInfo::kNoPosition; } virtual int position() const { return RelocInfo::kNoPosition; }
virtual int operand_position(int index) const { return position(); }
HBasicBlock* block() const { return block_; } HBasicBlock* block() const { return block_; }
void SetBlock(HBasicBlock* block); void SetBlock(HBasicBlock* block);
...@@ -1106,102 +1105,6 @@ class HValue : public ZoneObject { ...@@ -1106,102 +1105,6 @@ class HValue : public ZoneObject {
} }
// A helper class to represent per-operand position information attached to
// the HInstruction in the compact form. Uses tagging to distinguish between
// case when only instruction's position is available and case when operands'
// positions are also available.
// In the first case it contains intruction's position as a tagged value.
// In the second case it points to an array which contains instruction's
// position and operands' positions.
// TODO(vegorov): what we really want to track here is a combination of
// source position and a script id because cross script inlining can easily
// result in optimized functions composed of several scripts.
class HPositionInfo {
public:
explicit HPositionInfo(int pos) : data_(TagPosition(pos)) { }
int position() const {
if (has_operand_positions()) {
return operand_positions()[kInstructionPosIndex];
}
return UntagPosition(data_);
}
void set_position(int pos) {
if (has_operand_positions()) {
operand_positions()[kInstructionPosIndex] = pos;
} else {
data_ = TagPosition(pos);
}
}
void ensure_storage_for_operand_positions(Zone* zone, int operand_count) {
if (has_operand_positions()) {
return;
}
const int length = kFirstOperandPosIndex + operand_count;
intptr_t* positions =
zone->NewArray<intptr_t>(length);
for (int i = 0; i < length; i++) {
positions[i] = RelocInfo::kNoPosition;
}
const int pos = position();
data_ = reinterpret_cast<intptr_t>(positions);
set_position(pos);
ASSERT(has_operand_positions());
}
int operand_position(int idx) const {
if (!has_operand_positions()) {
return position();
}
return static_cast<int>(*operand_position_slot(idx));
}
void set_operand_position(int idx, int pos) {
*operand_position_slot(idx) = pos;
}
private:
static const intptr_t kInstructionPosIndex = 0;
static const intptr_t kFirstOperandPosIndex = 1;
intptr_t* operand_position_slot(int idx) const {
ASSERT(has_operand_positions());
return &(operand_positions()[kFirstOperandPosIndex + idx]);
}
bool has_operand_positions() const {
return !IsTaggedPosition(data_);
}
intptr_t* operand_positions() const {
ASSERT(has_operand_positions());
return reinterpret_cast<intptr_t*>(data_);
}
static const intptr_t kPositionTag = 1;
static const intptr_t kPositionShift = 1;
static bool IsTaggedPosition(intptr_t val) {
return (val & kPositionTag) != 0;
}
static intptr_t UntagPosition(intptr_t val) {
ASSERT(IsTaggedPosition(val));
return val >> kPositionShift;
}
static intptr_t TagPosition(intptr_t val) {
const intptr_t result = (val << kPositionShift) | kPositionTag;
ASSERT(UntagPosition(result) == val);
return result;
}
intptr_t data_;
};
class HInstruction : public HValue { class HInstruction : public HValue {
public: public:
HInstruction* next() const { return next_; } HInstruction* next() const { return next_; }
...@@ -1216,26 +1119,12 @@ class HInstruction : public HValue { ...@@ -1216,26 +1119,12 @@ class HInstruction : public HValue {
void InsertAfter(HInstruction* previous); void InsertAfter(HInstruction* previous);
// The position is a write-once variable. // The position is a write-once variable.
virtual int position() const V8_OVERRIDE { virtual int position() const V8_OVERRIDE { return position_; }
return position_.position(); bool has_position() const { return position_ != RelocInfo::kNoPosition; }
}
bool has_position() const {
return position_.position() != RelocInfo::kNoPosition;
}
void set_position(int position) { void set_position(int position) {
ASSERT(!has_position()); ASSERT(!has_position());
ASSERT(position != RelocInfo::kNoPosition); ASSERT(position != RelocInfo::kNoPosition);
position_.set_position(position); position_ = position;
}
virtual int operand_position(int index) const V8_OVERRIDE {
const int pos = position_.operand_position(index);
return (pos != RelocInfo::kNoPosition) ? pos : position();
}
void set_operand_position(Zone* zone, int index, int pos) {
ASSERT(0 <= index && index < OperandCount());
position_.ensure_storage_for_operand_positions(zone, OperandCount());
position_.set_operand_position(index, pos);
} }
bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
...@@ -1271,7 +1160,7 @@ class HInstruction : public HValue { ...@@ -1271,7 +1160,7 @@ class HInstruction : public HValue {
HInstruction* next_; HInstruction* next_;
HInstruction* previous_; HInstruction* previous_;
HPositionInfo position_; int position_;
friend class HBasicBlock; friend class HBasicBlock;
}; };
...@@ -3799,11 +3688,6 @@ class HBinaryOperation : public HTemplateInstruction<3> { ...@@ -3799,11 +3688,6 @@ class HBinaryOperation : public HTemplateInstruction<3> {
return representation(); return representation();
} }
void SetOperandPositions(Zone* zone, int left_pos, int right_pos) {
set_operand_position(zone, 1, left_pos);
set_operand_position(zone, 2, right_pos);
}
DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
private: private:
...@@ -4237,11 +4121,6 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { ...@@ -4237,11 +4121,6 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
} }
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
void SetOperandPositions(Zone* zone, int left_pos, int right_pos) {
set_operand_position(zone, 0, left_pos);
set_operand_position(zone, 1, right_pos);
}
DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
private: private:
......
...@@ -61,8 +61,8 @@ void HRepresentationChangesPhase::InsertRepresentationChangeForUse( ...@@ -61,8 +61,8 @@ void HRepresentationChangesPhase::InsertRepresentationChangeForUse(
if (new_value == NULL) { if (new_value == NULL) {
new_value = new(graph()->zone()) HChange( new_value = new(graph()->zone()) HChange(
value, to, is_truncating_to_smi, is_truncating_to_int); value, to, is_truncating_to_smi, is_truncating_to_int);
if (use_value->operand_position(use_index) != RelocInfo::kNoPosition) { if (use_value->position() != RelocInfo::kNoPosition) {
new_value->set_position(use_value->operand_position(use_index)); new_value->set_position(use_value->position());
} else { } else {
ASSERT(!FLAG_emit_opt_code_positions || !graph()->info()->IsOptimizing()); ASSERT(!FLAG_emit_opt_code_positions || !graph()->info()->IsOptimizing());
} }
......
...@@ -8627,14 +8627,10 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { ...@@ -8627,14 +8627,10 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right())); CHECK_ALIVE(VisitForValue(expr->right()));
SetSourcePosition(expr->position()); if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position());
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
HInstruction* instr = BuildBinaryOperation(expr, left, right); HInstruction* instr = BuildBinaryOperation(expr, left, right);
if (FLAG_emit_opt_code_positions && instr->IsBinaryOperation()) {
HBinaryOperation::cast(instr)->SetOperandPositions(
zone(), expr->left()->position(), expr->right()->position());
}
return ast_context()->ReturnInstruction(instr, expr->id()); return ast_context()->ReturnInstruction(instr, expr->id());
} }
...@@ -8643,7 +8639,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, ...@@ -8643,7 +8639,7 @@ void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
Expression* sub_expr, Expression* sub_expr,
Handle<String> check) { Handle<String> check) {
CHECK_ALIVE(VisitForTypeOf(sub_expr)); CHECK_ALIVE(VisitForTypeOf(sub_expr));
SetSourcePosition(expr->position()); if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position());
HValue* value = Pop(); HValue* value = Pop();
HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check); HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check);
return ast_context()->ReturnControl(instr, expr->id()); return ast_context()->ReturnControl(instr, expr->id());
...@@ -8705,8 +8701,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8705,8 +8701,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right())); CHECK_ALIVE(VisitForValue(expr->right()));
if (FLAG_emit_opt_code_positions) SetSourcePosition(expr->position());
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Token::Value op = expr->op(); Token::Value op = expr->op();
...@@ -8785,10 +8779,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8785,10 +8779,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
AddCheckMap(right, map); AddCheckMap(right, map);
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
New<HCompareObjectEqAndBranch>(left, right); New<HCompareObjectEqAndBranch>(left, right);
if (FLAG_emit_opt_code_positions) {
result->set_operand_position(zone(), 0, expr->left()->position());
result->set_operand_position(zone(), 1, expr->right()->position());
}
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} else { } else {
BuildCheckHeapObject(left); BuildCheckHeapObject(left);
...@@ -8830,11 +8820,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ...@@ -8830,11 +8820,6 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
HCompareNumericAndBranch* result = HCompareNumericAndBranch* result =
New<HCompareNumericAndBranch>(left, right, op); New<HCompareNumericAndBranch>(left, right, op);
result->set_observed_input_representation(left_rep, right_rep); result->set_observed_input_representation(left_rep, right_rep);
if (FLAG_emit_opt_code_positions) {
result->SetOperandPositions(zone(),
expr->left()->position(),
expr->right()->position());
}
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} }
} }
...@@ -10151,8 +10136,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { ...@@ -10151,8 +10136,7 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
Tag HIR_tag(this, "HIR"); Tag HIR_tag(this, "HIR");
for (HInstructionIterator it(current); !it.Done(); it.Advance()) { for (HInstructionIterator it(current); !it.Done(); it.Advance()) {
HInstruction* instruction = it.Current(); HInstruction* instruction = it.Current();
int bci = FLAG_emit_opt_code_positions && instruction->has_position() ? int bci = 0;
instruction->position() : 0;
int uses = instruction->UseCount(); int uses = instruction->UseCount();
PrintIndent(); PrintIndent();
trace_.Add("%d %d ", bci, uses); trace_.Add("%d %d ", bci, uses);
...@@ -10177,9 +10161,6 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { ...@@ -10177,9 +10161,6 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
trace_.Add("%d ", trace_.Add("%d ",
LifetimePosition::FromInstructionIndex(i).Value()); LifetimePosition::FromInstructionIndex(i).Value());
linstr->PrintTo(&trace_); linstr->PrintTo(&trace_);
trace_.Add(" [hir:");
linstr->hydrogen_value()->PrintNameTo(&trace_);
trace_.Add("]");
trace_.Add(" <|@\n"); trace_.Add(" <|@\n");
} }
} }
......
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