Commit f951a2e8 authored by ishell@chromium.org's avatar ishell@chromium.org

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
parent f4c28204
......@@ -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);
......
......@@ -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_;
......
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