Range info propagation through HBoundsCheck.

R=titzer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18078 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ishell@chromium.org 2013-11-26 13:52:44 +00:00
parent f4c282042e
commit f951a2e893
2 changed files with 21 additions and 0 deletions

View File

@ -947,6 +947,25 @@ void HBoundsCheck::InferRepresentation(HInferRepresentationPhase* h_infer) {
}
Range* HBoundsCheck::InferRange(Zone* zone) {
Representation r = representation();
if (r.IsSmiOrInteger32() && length()->HasRange()) {
int upper = length()->range()->upper() - (allow_equality() ? 0 : 1);
int lower = 0;
Range* result = new(zone) Range(lower, upper);
if (index()->HasRange()) {
result->Intersect(index()->range());
}
// In case of Smi representation, clamp result to Smi::kMaxValue.
if (r.IsSmi()) result->ClampToSmi();
return result;
}
return HValue::InferRange(zone);
}
void HBoundsCheckBaseIndexInformation::PrintDataTo(StringStream* stream) {
stream->Add("base: ");
base_index()->PrintNameTo(stream);

View File

@ -4029,6 +4029,8 @@ class HBoundsCheck V8_FINAL : public HTemplateInstruction<2> {
protected:
friend class HBoundsCheckBaseIndexInformation;
virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
bool skip_check_;
HValue* base_;