Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 138bee04de4677d8178ae359c852f27a1a965724..f44c715b46e44f54fa81b976459f201c466b42f3 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -760,6 +760,28 @@ void HBoundsCheck::PrintDataTo(StringStream* stream) { |
} |
+void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) { |
+ ASSERT(CheckFlag(kFlexibleRepresentation)); |
+ Representation r; |
+ if (key_mode_ == DONT_ALLOW_SMI_KEY || |
+ !length()->representation().IsTagged()) { |
+ r = Representation::Integer32(); |
+ } else if (index()->representation().IsTagged() || |
+ (index()->IsConstant() && |
+ HConstant::cast(index())->HasInteger32Value() && |
+ Smi::IsValid(HConstant::cast(index())->Integer32Value()))) { |
+ // If the index is tagged, or a constant that holds a Smi, allow the length |
+ // to be tagged, since it is usually already tagged from loading it out of |
+ // the length field of a JSArray. This allows for direct comparison without |
+ // untagging. |
+ r = Representation::Tagged(); |
+ } else { |
+ r = Representation::Integer32(); |
+ } |
+ UpdateRepresentation(r, h_infer, "boundscheck"); |
+} |
+ |
+ |
void HCallConstantFunction::PrintDataTo(StringStream* stream) { |
if (IsApplyFunction()) { |
stream->Add("optimized apply "); |