Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: src/arm/lithium-codegen-arm.cc

Issue 6303013: Fix Smi::IsValid assert in StringCharCodeAt deferred code. (Closed)
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | src/ia32/lithium-codegen-ia32.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | src/ia32/lithium-codegen-ia32.cc » ('j') | src/ia32/lithium-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698