Make sure that ranges are not accessed after range analysis. Remove HValue::PrintRangeTo.

The ranges are simply wrong after range analysis, and we should only rely on computed flags.

R=bmeurer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20674 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2014-04-11 09:17:18 +00:00
parent 260ded821f
commit c5231ccba6
4 changed files with 34 additions and 17 deletions

View File

@ -590,17 +590,6 @@ void HValue::PrintTypeTo(StringStream* stream) {
} }
void HValue::PrintRangeTo(StringStream* stream) {
if (range() == NULL || range()->IsMostGeneric()) return;
// Note: The c1visualizer syntax for locals allows only a sequence of the
// following characters: A-Za-z0-9_-|:
stream->Add(" range:%d_%d%s",
range()->lower(),
range()->upper(),
range()->CanBeMinusZero() ? "_m0" : "");
}
void HValue::PrintChangesTo(StringStream* stream) { void HValue::PrintChangesTo(StringStream* stream) {
GVNFlagSet changes_flags = ChangesFlags(); GVNFlagSet changes_flags = ChangesFlags();
if (changes_flags.IsEmpty()) return; if (changes_flags.IsEmpty()) return;
@ -701,7 +690,6 @@ void HSourcePosition::PrintTo(FILE* out) {
void HInstruction::PrintTo(StringStream* stream) { void HInstruction::PrintTo(StringStream* stream) {
PrintMnemonicTo(stream); PrintMnemonicTo(stream);
PrintDataTo(stream); PrintDataTo(stream);
PrintRangeTo(stream);
PrintChangesTo(stream); PrintChangesTo(stream);
PrintTypeTo(stream); PrintTypeTo(stream);
if (CheckFlag(HValue::kHasNoObservableSideEffects)) { if (CheckFlag(HValue::kHasNoObservableSideEffects)) {
@ -2499,7 +2487,6 @@ void HPhi::PrintTo(StringStream* stream) {
int32_non_phi_uses() + int32_indirect_uses(), int32_non_phi_uses() + int32_indirect_uses(),
double_non_phi_uses() + double_indirect_uses(), double_non_phi_uses() + double_indirect_uses(),
tagged_non_phi_uses() + tagged_indirect_uses()); tagged_non_phi_uses() + tagged_indirect_uses());
PrintRangeTo(stream);
PrintTypeTo(stream); PrintTypeTo(stream);
stream->Add("]"); stream->Add("]");
} }

View File

@ -684,6 +684,9 @@ class HValue : public ZoneObject {
type_(type), type_(type),
use_list_(NULL), use_list_(NULL),
range_(NULL), range_(NULL),
#ifdef DEBUG
range_poisoned_(false),
#endif
flags_(0) {} flags_(0) {}
virtual ~HValue() {} virtual ~HValue() {}
@ -854,9 +857,17 @@ class HValue : public ZoneObject {
return result; return result;
} }
Range* range() const { return range_; } Range* range() const {
// TODO(svenpanne) We should really use the null object pattern here. ASSERT(!range_poisoned_);
bool HasRange() const { return range_ != NULL; } return range_;
}
bool HasRange() const {
ASSERT(!range_poisoned_);
return range_ != NULL;
}
#ifdef DEBUG
void PoisonRange() { range_poisoned_ = true; }
#endif
void AddNewRange(Range* r, Zone* zone); void AddNewRange(Range* r, Zone* zone);
void RemoveLastAddedRange(); void RemoveLastAddedRange();
void ComputeInitialRange(Zone* zone); void ComputeInitialRange(Zone* zone);
@ -888,7 +899,6 @@ class HValue : public ZoneObject {
virtual void PrintTo(StringStream* stream) = 0; virtual void PrintTo(StringStream* stream) = 0;
void PrintNameTo(StringStream* stream); void PrintNameTo(StringStream* stream);
void PrintTypeTo(StringStream* stream); void PrintTypeTo(StringStream* stream);
void PrintRangeTo(StringStream* stream);
void PrintChangesTo(StringStream* stream); void PrintChangesTo(StringStream* stream);
const char* Mnemonic() const; const char* Mnemonic() const;
@ -1028,6 +1038,9 @@ class HValue : public ZoneObject {
HType type_; HType type_;
HUseListNode* use_list_; HUseListNode* use_list_;
Range* range_; Range* range_;
#ifdef DEBUG
bool range_poisoned_;
#endif
int flags_; int flags_;
GVNFlagSet changes_flags_; GVNFlagSet changes_flags_;
GVNFlagSet depends_on_flags_; GVNFlagSet depends_on_flags_;

View File

@ -123,6 +123,22 @@ void HRangeAnalysisPhase::Run() {
block = NULL; block = NULL;
} }
} }
// The ranges are not valid anymore due to SSI vs. SSA!
PoisonRanges();
}
void HRangeAnalysisPhase::PoisonRanges() {
#ifdef DEBUG
for (int i = 0; i < graph()->blocks()->length(); ++i) {
HBasicBlock* block = graph()->blocks()->at(i);
for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
HInstruction* instr = it.Current();
if (instr->HasRange()) instr->PoisonRange();
}
}
#endif
} }

View File

@ -57,6 +57,7 @@ class HRangeAnalysisPhase : public HPhase {
worklist_.Add(value, zone()); worklist_.Add(value, zone());
} }
void PropagateMinusZeroChecks(HValue* value); void PropagateMinusZeroChecks(HValue* value);
void PoisonRanges();
ZoneList<HValue*> changed_ranges_; ZoneList<HValue*> changed_ranges_;