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

Unified Diff: src/ia32/lithium-codegen-ia32.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 | « src/arm/lithium-codegen-arm.cc ('k') | test/mjsunit/string-charcodeat.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index 0fc3f2541b57525d1406372b82a427c10276a623..1a3a1f796283130597be024e5735d17c85857313 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -2750,9 +2750,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)) {
Mads Ager (chromium) 2011/01/20 15:03:17 We shouldn't generate code at all for this instruc
+ // Guaranteed to be out of bounds, so we can use "-1" to have a
+ // valid smi.
+ const_index = -1;
+ }
__ push(Immediate(Smi::FromInt(const_index)));
} else {
Register index = ToRegister(instr->index());
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | test/mjsunit/string-charcodeat.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698