Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 23bfb2144bc658088a111f6e0c235c4c123a3b1d..d9ae6527c0d6348880a551280fe3bd2dfecbafbf 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -2887,9 +2887,16 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { |
__ PushSafepointRegisters(); |
__ push(string); |
- // Push the index as a smi. |
+ // Push the index as a smi. It's safe because this instruction must |
+ // be dominated by a bounds check and because of the assert. |
+ STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
if (instr->index()->IsConstantOperand()) { |
int const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
+ if (!Smi::IsValid(const_index)) { |
+ // Guaranteed to be out of bounds, so we can use "-1" to have a |
+ // valid smi. |
+ const_index = -1; |
+ } |
__ mov(scratch, Operand(Smi::FromInt(const_index))); |
__ push(scratch); |
} else { |