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

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

Issue 6323002: Add custom typed ICs for pixel array loads. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 __ CompareRoot(scratch, Heap::kTheHoleValueRootIndex); 508 __ CompareRoot(scratch, Heap::kTheHoleValueRootIndex);
509 // In case the loaded value is the_hole we have to consult GetProperty 509 // In case the loaded value is the_hole we have to consult GetProperty
510 // to ensure the prototype chain is searched. 510 // to ensure the prototype chain is searched.
511 __ j(equal, out_of_range); 511 __ j(equal, out_of_range);
512 if (!result.is(scratch)) { 512 if (!result.is(scratch)) {
513 __ movq(result, scratch); 513 __ movq(result, scratch);
514 } 514 }
515 } 515 }
516 516
517 517
518 // Loads a indexed element from a pixel array.
519 static void GenerateFastPixelArrayLoad(MacroAssembler* masm,
520 Register receiver,
521 Register key,
522 Register elements,
523 Register untagged_key,
524 Register result,
525 Label* not_pixel_array,
526 Label* key_not_smi,
527 Label* out_of_range) {
528 // Register use:
529 // receiver - holds the receiver and is unchanged.
530 // key - holds the key and is unchanged (must be a smi).
531 // elements - is set to the the receiver's element if
532 // the receiver doesn't have a pixel array or the
533 // key is not a smi, otherwise it's the elements'
534 // external pointer.
535 // untagged_key - is set to the untagged key
536
537 // Check that the key is a smi.
538 if (key_not_smi != NULL)
Mads Ager (chromium) 2011/01/28 10:39:16 Braces or one-liner.
539 __ JumpIfNotSmi(key, key_not_smi);
540 __ SmiToInteger32(untagged_key, key);
541
542 // Verify that the receiver has pixel array elements.
543 __ movq(elements, FieldOperand(receiver, JSObject::kElementsOffset));
544 __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
545 Heap::kPixelArrayMapRootIndex);
546 __ j(not_equal, not_pixel_array);
547
548 // Check that the smi is in range.
549 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
550 __ j(above_equal, out_of_range);
551
552 // Load and tag the element as a smi.
553 __ movq(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset));
554 __ movzxbq(result, Operand(elements, untagged_key, times_1, 0));
555 __ Integer32ToSmi(result, result);
556 __ ret(0);
557 }
558
559
518 // Checks whether a key is an array index string or a symbol string. 560 // Checks whether a key is an array index string or a symbol string.
519 // Falls through if the key is a symbol. 561 // Falls through if the key is a symbol.
520 static void GenerateKeyStringCheck(MacroAssembler* masm, 562 static void GenerateKeyStringCheck(MacroAssembler* masm,
521 Register key, 563 Register key,
522 Register map, 564 Register map,
523 Register hash, 565 Register hash,
524 Label* index_string, 566 Label* index_string,
525 Label* not_symbol) { 567 Label* not_symbol) {
526 // Register use: 568 // Register use:
527 // key - holds the key and is unchanged. Assumed to be non-smi. 569 // key - holds the key and is unchanged. Assumed to be non-smi.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 rax, 615 rax,
574 rcx, 616 rcx,
575 rbx, 617 rbx,
576 rax, 618 rax,
577 NULL, 619 NULL,
578 &slow); 620 &slow);
579 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); 621 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1);
580 __ ret(0); 622 __ ret(0);
581 623
582 __ bind(&check_pixel_array); 624 __ bind(&check_pixel_array);
583 // Check whether the elements object is a pixel array. 625 GenerateFastPixelArrayLoad(masm,
584 // rdx: receiver 626 rdx,
585 // rax: key 627 rax,
586 __ movq(rcx, FieldOperand(rdx, JSObject::kElementsOffset)); 628 rcx,
587 __ SmiToInteger32(rbx, rax); // Used on both directions of next branch. 629 rbx,
588 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), 630 rax,
589 Heap::kPixelArrayMapRootIndex); 631 &check_number_dictionary,
590 __ j(not_equal, &check_number_dictionary); 632 NULL,
591 __ cmpl(rbx, FieldOperand(rcx, PixelArray::kLengthOffset)); 633 &slow);
592 __ j(above_equal, &slow);
593 __ movq(rax, FieldOperand(rcx, PixelArray::kExternalPointerOffset));
594 __ movzxbq(rax, Operand(rax, rbx, times_1, 0));
595 __ Integer32ToSmi(rax, rax);
596 __ ret(0);
597 634
598 __ bind(&check_number_dictionary); 635 __ bind(&check_number_dictionary);
599 // Check whether the elements is a number dictionary. 636 // Check whether the elements is a number dictionary.
600 // rdx: receiver 637 // rdx: receiver
601 // rax: key 638 // rax: key
602 // rbx: key as untagged int32 639 // rbx: key as untagged int32
603 // rcx: elements 640 // rcx: elements
604 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset), 641 __ CompareRoot(FieldOperand(rcx, HeapObject::kMapOffset),
605 Heap::kHashTableMapRootIndex); 642 Heap::kHashTableMapRootIndex);
606 __ j(not_equal, &slow); 643 __ j(not_equal, &slow);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 __ push(rcx); // return address 797 __ push(rcx); // return address
761 798
762 // Perform tail call to the entry. 799 // Perform tail call to the entry.
763 __ TailCallExternalReference(ExternalReference( 800 __ TailCallExternalReference(ExternalReference(
764 IC_Utility(kKeyedLoadPropertyWithInterceptor)), 2, 1); 801 IC_Utility(kKeyedLoadPropertyWithInterceptor)), 2, 1);
765 802
766 __ bind(&slow); 803 __ bind(&slow);
767 GenerateMiss(masm); 804 GenerateMiss(masm);
768 } 805 }
769 806
807 void KeyedLoadIC::GeneratePixelArray(MacroAssembler* masm) {
808 // ----------- S t a t e -------------
809 // -- rax : key
810 // -- rdx : receiver
811 // -- rsp[0] : return address
812 // -----------------------------------
813 Label slow;
814
815 // Verify that it's safe to access the receiver's elements.
816 GenerateKeyedLoadReceiverCheck(
817 masm, rdx, rcx, Map::kHasNamedInterceptor, &slow);
818
819 // Generate the indexed load from the pixel array.
820 GenerateFastPixelArrayLoad(masm,
821 rdx,
822 rax,
823 rcx,
824 rbx,
825 rax,
826 &slow,
827 &slow,
828 &slow);
829
830 __ bind(&slow);
831 GenerateMiss(masm);
832 }
833
770 834
771 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { 835 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
772 // ----------- S t a t e ------------- 836 // ----------- S t a t e -------------
773 // -- rax : value 837 // -- rax : value
774 // -- rcx : key 838 // -- rcx : key
775 // -- rdx : receiver 839 // -- rdx : receiver
776 // -- rsp[0] : return address 840 // -- rsp[0] : return address
777 // ----------------------------------- 841 // -----------------------------------
778 Label slow, slow_with_tagged_index, fast, array, extra, check_pixel_array; 842 Label slow, slow_with_tagged_index, fast, array, extra, check_pixel_array;
779 843
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 } 1767 }
1704 1768
1705 void PatchInlinedSmiCode(Address address) { 1769 void PatchInlinedSmiCode(Address address) {
1706 UNIMPLEMENTED(); 1770 UNIMPLEMENTED();
1707 } 1771 }
1708 1772
1709 1773
1710 } } // namespace v8::internal 1774 } } // namespace v8::internal
1711 1775
1712 #endif // V8_TARGET_ARCH_X64 1776 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698