From 0832d08dd9e7a6426d46d51ecc789b48673701ea Mon Sep 17 00:00:00 2001 From: "mmassi@chromium.org" Date: Thu, 21 Feb 2013 09:09:01 +0000 Subject: [PATCH] Also check if the length ia a smi in a HBoundsCheck. Review URL: https://codereview.chromium.org/12301026 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13701 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/hydrogen.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 62fa571bbc..117e6bfede 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -784,11 +784,16 @@ HBoundsCheck* HGraphBuilder::AddBoundsCheck(HValue* index, HValue* length, BoundsCheckKeyMode key_mode, Representation r) { - HCheckSmiOrInt32* checked_index = - new(graph()->zone()) HCheckSmiOrInt32(index); - AddInstruction(checked_index); + if (!index->type().IsSmi()) { + index = new(graph()->zone()) HCheckSmiOrInt32(index); + AddInstruction(HCheckSmiOrInt32::cast(index)); + } + if (!length->type().IsSmi()) { + length = new(graph()->zone()) HCheckSmiOrInt32(length); + AddInstruction(HCheckSmiOrInt32::cast(length)); + } HBoundsCheck* result = new(graph()->zone()) HBoundsCheck( - checked_index, length, key_mode, r); + index, length, key_mode, r); AddInstruction(result); return result; }