Fix a regression in character-at stub when doing a keyed load on a string.

Loading from out-of-range has to go to the runtime system to check if there
exists a property with that index in the prototype.

Review URL: http://codereview.chromium.org/3410011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5471 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b2306a41
...@@ -1236,7 +1236,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -1236,7 +1236,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
// -- r1 : receiver // -- r1 : receiver
// ----------------------------------- // -----------------------------------
Label miss; Label miss;
Label index_out_of_range;
Register receiver = r1; Register receiver = r1;
Register index = r0; Register index = r0;
...@@ -1251,7 +1250,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -1251,7 +1250,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
result, result,
&miss, // When not a string. &miss, // When not a string.
&miss, // When not a number. &miss, // When not a number.
&index_out_of_range, &miss, // When index out of range.
STRING_INDEX_IS_ARRAY_INDEX); STRING_INDEX_IS_ARRAY_INDEX);
char_at_generator.GenerateFast(masm); char_at_generator.GenerateFast(masm);
__ Ret(); __ Ret();
...@@ -1259,10 +1258,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -1259,10 +1258,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
ICRuntimeCallHelper call_helper; ICRuntimeCallHelper call_helper;
char_at_generator.GenerateSlow(masm, call_helper); char_at_generator.GenerateSlow(masm, call_helper);
__ bind(&index_out_of_range);
__ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
__ Ret();
__ bind(&miss); __ bind(&miss);
GenerateMiss(masm); GenerateMiss(masm);
} }
......
...@@ -692,7 +692,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -692,7 +692,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
// -- esp[0] : return address // -- esp[0] : return address
// ----------------------------------- // -----------------------------------
Label miss; Label miss;
Label index_out_of_range;
Register receiver = edx; Register receiver = edx;
Register index = eax; Register index = eax;
...@@ -707,7 +706,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -707,7 +706,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
result, result,
&miss, // When not a string. &miss, // When not a string.
&miss, // When not a number. &miss, // When not a number.
&index_out_of_range, &miss, // When index out of range.
STRING_INDEX_IS_ARRAY_INDEX); STRING_INDEX_IS_ARRAY_INDEX);
char_at_generator.GenerateFast(masm); char_at_generator.GenerateFast(masm);
__ ret(0); __ ret(0);
...@@ -715,10 +714,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -715,10 +714,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
ICRuntimeCallHelper call_helper; ICRuntimeCallHelper call_helper;
char_at_generator.GenerateSlow(masm, call_helper); char_at_generator.GenerateSlow(masm, call_helper);
__ bind(&index_out_of_range);
__ Set(eax, Immediate(Factory::undefined_value()));
__ ret(0);
__ bind(&miss); __ bind(&miss);
GenerateMiss(masm); GenerateMiss(masm);
} }
......
...@@ -730,7 +730,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -730,7 +730,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
// -- rsp[0] : return address // -- rsp[0] : return address
// ----------------------------------- // -----------------------------------
Label miss; Label miss;
Label index_out_of_range;
Register receiver = rdx; Register receiver = rdx;
Register index = rax; Register index = rax;
...@@ -745,7 +744,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -745,7 +744,7 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
result, result,
&miss, // When not a string. &miss, // When not a string.
&miss, // When not a number. &miss, // When not a number.
&index_out_of_range, &miss, // When index out of range.
STRING_INDEX_IS_ARRAY_INDEX); STRING_INDEX_IS_ARRAY_INDEX);
char_at_generator.GenerateFast(masm); char_at_generator.GenerateFast(masm);
__ ret(0); __ ret(0);
...@@ -753,10 +752,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) { ...@@ -753,10 +752,6 @@ void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
ICRuntimeCallHelper call_helper; ICRuntimeCallHelper call_helper;
char_at_generator.GenerateSlow(masm, call_helper); char_at_generator.GenerateSlow(masm, call_helper);
__ bind(&index_out_of_range);
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
__ ret(0);
__ bind(&miss); __ bind(&miss);
GenerateMiss(masm); GenerateMiss(masm);
} }
......
...@@ -29,6 +29,15 @@ assertTrue('abc'[10] === undefined); ...@@ -29,6 +29,15 @@ assertTrue('abc'[10] === undefined);
String.prototype[10] = 'x'; String.prototype[10] = 'x';
assertEquals('abc'[10], 'x'); assertEquals('abc'[10], 'x');
// Test that the fast case character-at stub handles an out-of-bound
// index correctly. We need to call the function twice to initialize
// the character-at stub.
function f() {
assertEquals('abc'[10], 'x');
}
f();
f();
assertTrue(2[11] === undefined); assertTrue(2[11] === undefined);
Number.prototype[11] = 'y'; Number.prototype[11] = 'y';
assertEquals(2[11], 'y'); assertEquals(2[11], 'y');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment