@@ -212,7 +212,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
212212 // -- esp[4] : name
213213 // -- esp[8] : receiver
214214 // -----------------------------------
215- Label slow, fast, check_string;
215+ Label slow, fast, check_string, index_int, index_string ;
216216
217217 __ mov (eax, (Operand (esp, kPointerSize )));
218218 __ mov (ecx, (Operand (esp, 2 * kPointerSize )));
@@ -234,6 +234,7 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
234234 __ j (not_zero, &check_string, not_taken);
235235 __ sar (eax, kSmiTagSize );
236236 // Get the elements array of the object.
237+ __ bind (&index_int);
237238 __ mov (ecx, FieldOperand (ecx, JSObject::kElementsOffset ));
238239 // Check that the object is in fast mode (not dictionary).
239240 __ cmp (FieldOperand (ecx, HeapObject::kMapOffset ),
@@ -248,18 +249,28 @@ void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
248249 KeyedLoadIC::Generate (masm, ExternalReference (Runtime::kKeyedGetProperty ));
249250 // Check if the key is a symbol that is not an array index.
250251 __ bind (&check_string);
252+ __ mov (ebx, FieldOperand (eax, String::kLengthOffset ));
253+ __ test (ebx, Immediate (String::kIsArrayIndexMask ));
254+ __ j (not_zero, &index_string, not_taken);
251255 __ mov (ebx, FieldOperand (eax, HeapObject::kMapOffset ));
252256 __ movzx_b (ebx, FieldOperand (ebx, Map::kInstanceTypeOffset ));
253257 __ test (ebx, Immediate (kIsSymbolMask ));
254- __ j (zero, &slow, not_taken);
255- __ mov (ebx, FieldOperand (eax, String::kLengthOffset ));
256- __ test (ebx, Immediate (String::kIsArrayIndexMask ));
257258 __ j (not_zero, &slow, not_taken);
258259 // Probe the dictionary leaving result in ecx.
259260 GenerateDictionaryLoad (masm, &slow, ebx, ecx, edx, eax);
260261 __ mov (eax, Operand (ecx));
261262 __ IncrementCounter (&Counters::keyed_load_generic_symbol, 1 );
262263 __ ret (0 );
264+ // Array index string: If short enough use cache in length/hash field (ebx).
265+ __ bind (&index_string);
266+ const int kLengthFieldLimit =
267+ (String::kMaxCachedArrayIndexLength + 1 ) << String::kShortLengthShift ;
268+ __ cmp (ebx, kLengthFieldLimit );
269+ __ j (above_equal, &slow);
270+ __ mov (eax, Operand (ebx));
271+ __ and_ (eax, (1 << String::kShortLengthShift ) - 1 );
272+ __ shr (eax, String::kLongLengthShift );
273+ __ jmp (&index_int);
263274 // Fast case: Do the load.
264275 __ bind (&fast);
265276 __ mov (eax, Operand (ecx, eax, times_4, Array::kHeaderSize - kHeapObjectTag ));
0 commit comments