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

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 1582041: Reapply: Inline fast cases in string keyed load IC. (Closed)
Patch Set: . Created 10 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | test/mjsunit/string-index.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 (1 << String::kArrayIndexValueBits)); 484 (1 << String::kArrayIndexValueBits));
485 __ bind(&index_string); 485 __ bind(&index_string);
486 __ and_(ebx, String::kArrayIndexHashMask); 486 __ and_(ebx, String::kArrayIndexHashMask);
487 __ shr(ebx, String::kHashShift); 487 __ shr(ebx, String::kHashShift);
488 __ jmp(&index_int); 488 __ jmp(&index_int);
489 } 489 }
490 490
491 491
492 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { 492 void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
493 // ----------- S t a t e ------------- 493 // ----------- S t a t e -------------
494 // -- eax : key 494 // -- eax : key (index)
495 // -- edx : receiver 495 // -- edx : receiver
496 // -- esp[0] : return address 496 // -- esp[0] : return address
497 // ----------------------------------- 497 // -----------------------------------
498 Label miss, index_ok; 498 Label miss;
499 Label not_positive_smi;
500 Label slow_char_code;
501 Label got_char_code;
499 502
500 // Pop return address. 503 Register receiver = edx;
501 // Performing the load early is better in the common case. 504 Register index = eax;
502 __ pop(ebx); 505 Register code = ebx;
506 Register scratch = ecx;
503 507
504 __ test(edx, Immediate(kSmiTagMask)); 508 StringHelper::GenerateFastCharCodeAt(masm,
505 __ j(zero, &miss); 509 receiver,
506 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); 510 index,
507 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); 511 scratch,
508 __ test(ecx, Immediate(kIsNotStringMask)); 512 code,
509 __ j(not_zero, &miss); 513 &miss, // When not a string.
514 &not_positive_smi,
515 &slow_char_code);
516 // If we didn't bail out, code register contains smi tagged char
517 // code.
518 __ bind(&got_char_code);
519 StringHelper::GenerateCharFromCode(masm, code, eax, JUMP_FUNCTION);
520 #ifdef DEBUG
521 __ Abort("Unexpected fall-through from char from code tail call");
522 #endif
510 523
511 // Check if key is a smi or a heap number. 524 // Check if key is a smi or a heap number.
512 __ test(eax, Immediate(kSmiTagMask)); 525 __ bind(&not_positive_smi);
513 __ j(zero, &index_ok); 526 ASSERT(kSmiTag == 0);
527 __ test(index, Immediate(kSmiTagMask));
528 __ j(zero, &slow_char_code);
514 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset)); 529 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset));
515 __ cmp(ecx, Factory::heap_number_map()); 530 __ cmp(ecx, Factory::heap_number_map());
516 __ j(not_equal, &miss); 531 __ j(not_equal, &miss);
517 532
518 __ bind(&index_ok); 533 // Push receiver and key on the stack (now that we know they are a
519 // Push receiver and key on the stack, and make a tail call. 534 // string and a number), and call runtime.
520 __ push(edx); // receiver 535 __ bind(&slow_char_code);
521 __ push(eax); // key 536 __ EnterInternalFrame();
522 __ push(ebx); // return address 537 __ push(receiver);
523 __ InvokeBuiltin(Builtins::STRING_CHAR_AT, JUMP_FUNCTION); 538 __ push(index);
539 __ CallRuntime(Runtime::kStringCharCodeAt, 2);
540 ASSERT(!code.is(eax));
541 __ mov(code, eax);
542 __ LeaveInternalFrame();
543
544 // Check if the runtime call returned NaN char code. If yes, return
545 // undefined. Otherwise, we can continue.
546 if (FLAG_debug_code) {
Mads Ager (chromium) 2010/04/20 10:36:50 I'm not sure this debug_code code adds much?
547 ASSERT(kSmiTag == 0);
548 __ test(code, Immediate(kSmiTagMask));
549 __ j(zero, &got_char_code);
550 __ mov(scratch, FieldOperand(code, HeapObject::kMapOffset));
551 __ cmp(scratch, Factory::heap_number_map());
552 __ Assert(equal, "StringCharCodeAt must return smi or heap number");
553 }
554 __ cmp(code, Factory::nan_value());
555 __ j(not_equal, &got_char_code);
556 __ Set(eax, Immediate(Factory::undefined_value()));
557 __ ret(0);
524 558
525 __ bind(&miss); 559 __ bind(&miss);
526 __ push(ebx);
527 GenerateMiss(masm); 560 GenerateMiss(masm);
528 } 561 }
529 562
530 563
531 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, 564 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm,
532 ExternalArrayType array_type) { 565 ExternalArrayType array_type) {
533 // ----------- S t a t e ------------- 566 // ----------- S t a t e -------------
534 // -- eax : key 567 // -- eax : key
535 // -- edx : receiver 568 // -- edx : receiver
536 // -- esp[0] : return address 569 // -- esp[0] : return address
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 1638
1606 // Do tail-call to runtime routine. 1639 // Do tail-call to runtime routine.
1607 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); 1640 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss));
1608 __ TailCallExternalReference(ref, 3, 1); 1641 __ TailCallExternalReference(ref, 3, 1);
1609 } 1642 }
1610 1643
1611 #undef __ 1644 #undef __
1612 1645
1613 1646
1614 } } // namespace v8::internal 1647 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | test/mjsunit/string-index.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698