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

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

Issue 6546036: Combine typed and pixel arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: final version Created 9 years, 9 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
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('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 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 524
525 525
526 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 526 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
527 // ----------- S t a t e ------------- 527 // ----------- S t a t e -------------
528 // -- eax : key 528 // -- eax : key
529 // -- edx : receiver 529 // -- edx : receiver
530 // -- esp[0] : return address 530 // -- esp[0] : return address
531 // ----------------------------------- 531 // -----------------------------------
532 Label slow, check_string, index_smi, index_string, property_array_property; 532 Label slow, check_string, index_smi, index_string, property_array_property;
533 Label check_pixel_array, probe_dictionary, check_number_dictionary; 533 Label probe_dictionary, check_number_dictionary;
534 534
535 // Check that the key is a smi. 535 // Check that the key is a smi.
536 __ test(eax, Immediate(kSmiTagMask)); 536 __ test(eax, Immediate(kSmiTagMask));
537 __ j(not_zero, &check_string, not_taken); 537 __ j(not_zero, &check_string, not_taken);
538 __ bind(&index_smi); 538 __ bind(&index_smi);
539 // Now the key is known to be a smi. This place is also jumped to from 539 // Now the key is known to be a smi. This place is also jumped to from
540 // where a numeric string is converted to a smi. 540 // where a numeric string is converted to a smi.
541 541
542 GenerateKeyedLoadReceiverCheck( 542 GenerateKeyedLoadReceiverCheck(
543 masm, edx, ecx, Map::kHasIndexedInterceptor, &slow); 543 masm, edx, ecx, Map::kHasIndexedInterceptor, &slow);
544 544
545 // Check the "has fast elements" bit in the receiver's map which is 545 // Check the "has fast elements" bit in the receiver's map which is
546 // now in ecx. 546 // now in ecx.
547 __ test_b(FieldOperand(ecx, Map::kBitField2Offset), 547 __ test_b(FieldOperand(ecx, Map::kBitField2Offset),
548 1 << Map::kHasFastElements); 548 1 << Map::kHasFastElements);
549 __ j(zero, &check_pixel_array, not_taken); 549 __ j(zero, &check_number_dictionary, not_taken);
550 550
551 GenerateFastArrayLoad(masm, 551 GenerateFastArrayLoad(masm,
552 edx, 552 edx,
553 eax, 553 eax,
554 ecx, 554 ecx,
555 eax, 555 eax,
556 NULL, 556 NULL,
557 &slow); 557 &slow);
558 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); 558 __ IncrementCounter(&Counters::keyed_load_generic_smi, 1);
559 __ ret(0); 559 __ ret(0);
560 560
561 __ bind(&check_pixel_array); 561 __ bind(&check_number_dictionary);
562 GenerateFastPixelArrayLoad(masm, 562 __ mov(ebx, eax);
563 edx, 563 __ SmiUntag(ebx);
564 eax, 564 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset));
565 ecx,
566 ebx,
567 eax,
568 &check_number_dictionary,
569 NULL,
570 &slow);
571 565
572 __ bind(&check_number_dictionary);
573 // Check whether the elements is a number dictionary. 566 // Check whether the elements is a number dictionary.
574 // edx: receiver 567 // edx: receiver
575 // ebx: untagged index 568 // ebx: untagged index
576 // eax: key 569 // eax: key
577 // ecx: elements 570 // ecx: elements
578 __ CheckMap(ecx, Factory::hash_table_map(), &slow, true); 571 __ CheckMap(ecx, Factory::hash_table_map(), &slow, true);
579 Label slow_pop_receiver; 572 Label slow_pop_receiver;
580 // Push receiver on the stack to free up a register for the dictionary 573 // Push receiver on the stack to free up a register for the dictionary
581 // probing. 574 // probing.
582 __ push(edx); 575 __ push(edx);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 755
763 756
764 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, 757 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
765 StrictModeFlag strict_mode) { 758 StrictModeFlag strict_mode) {
766 // ----------- S t a t e ------------- 759 // ----------- S t a t e -------------
767 // -- eax : value 760 // -- eax : value
768 // -- ecx : key 761 // -- ecx : key
769 // -- edx : receiver 762 // -- edx : receiver
770 // -- esp[0] : return address 763 // -- esp[0] : return address
771 // ----------------------------------- 764 // -----------------------------------
772 Label slow, fast, array, extra, check_pixel_array; 765 Label slow, fast, array, extra;
773 766
774 // Check that the object isn't a smi. 767 // Check that the object isn't a smi.
775 __ test(edx, Immediate(kSmiTagMask)); 768 __ test(edx, Immediate(kSmiTagMask));
776 __ j(zero, &slow, not_taken); 769 __ j(zero, &slow, not_taken);
777 // Get the map from the receiver. 770 // Get the map from the receiver.
778 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); 771 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
779 // Check that the receiver does not require access checks. We need 772 // Check that the receiver does not require access checks. We need
780 // to do this because this generic stub does not perform map checks. 773 // to do this because this generic stub does not perform map checks.
781 __ test_b(FieldOperand(edi, Map::kBitFieldOffset), 774 __ test_b(FieldOperand(edi, Map::kBitFieldOffset),
782 1 << Map::kIsAccessCheckNeeded); 775 1 << Map::kIsAccessCheckNeeded);
783 __ j(not_zero, &slow, not_taken); 776 __ j(not_zero, &slow, not_taken);
784 // Check that the key is a smi. 777 // Check that the key is a smi.
785 __ test(ecx, Immediate(kSmiTagMask)); 778 __ test(ecx, Immediate(kSmiTagMask));
786 __ j(not_zero, &slow, not_taken); 779 __ j(not_zero, &slow, not_taken);
787 __ CmpInstanceType(edi, JS_ARRAY_TYPE); 780 __ CmpInstanceType(edi, JS_ARRAY_TYPE);
788 __ j(equal, &array); 781 __ j(equal, &array);
789 // Check that the object is some kind of JS object. 782 // Check that the object is some kind of JS object.
790 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE); 783 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE);
791 __ j(below, &slow, not_taken); 784 __ j(below, &slow, not_taken);
792 785
793 // Object case: Check key against length in the elements array. 786 // Object case: Check key against length in the elements array.
794 // eax: value 787 // eax: value
795 // edx: JSObject 788 // edx: JSObject
796 // ecx: key (a smi) 789 // ecx: key (a smi)
797 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 790 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
798 // Check that the object is in fast mode and writable. 791 // Check that the object is in fast mode and writable.
799 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true); 792 __ CheckMap(edi, Factory::fixed_array_map(), &slow, true);
800 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 793 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
801 __ j(below, &fast, taken); 794 __ j(below, &fast, taken);
802 795
803 // Slow case: call runtime. 796 // Slow case: call runtime.
804 __ bind(&slow); 797 __ bind(&slow);
805 GenerateRuntimeSetProperty(masm, strict_mode); 798 GenerateRuntimeSetProperty(masm, strict_mode);
806 799
807 // Check whether the elements is a pixel array.
808 __ bind(&check_pixel_array);
809 // eax: value
810 // ecx: key (a smi)
811 // edx: receiver
812 // edi: elements array
813 GenerateFastPixelArrayStore(masm,
814 edx,
815 ecx,
816 eax,
817 edi,
818 ebx,
819 false,
820 NULL,
821 &slow,
822 &slow,
823 &slow);
824
825 // Extra capacity case: Check if there is extra capacity to 800 // Extra capacity case: Check if there is extra capacity to
826 // perform the store and update the length. Used for adding one 801 // perform the store and update the length. Used for adding one
827 // element to the array by writing to array[array.length]. 802 // element to the array by writing to array[array.length].
828 __ bind(&extra); 803 __ bind(&extra);
829 // eax: value 804 // eax: value
830 // edx: receiver, a JSArray 805 // edx: receiver, a JSArray
831 // ecx: key, a smi. 806 // ecx: key, a smi.
832 // edi: receiver->elements, a FixedArray 807 // edi: receiver->elements, a FixedArray
833 // flags: compare (ecx, edx.length()) 808 // flags: compare (ecx, edx.length())
834 __ j(not_equal, &slow, not_taken); // do not leave holes in the array 809 __ j(not_equal, &slow, not_taken); // do not leave holes in the array
835 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 810 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
836 __ j(above_equal, &slow, not_taken); 811 __ j(above_equal, &slow, not_taken);
837 // Add 1 to receiver->length, and go to fast array write. 812 // Add 1 to receiver->length, and go to fast array write.
838 __ add(FieldOperand(edx, JSArray::kLengthOffset), 813 __ add(FieldOperand(edx, JSArray::kLengthOffset),
839 Immediate(Smi::FromInt(1))); 814 Immediate(Smi::FromInt(1)));
840 __ jmp(&fast); 815 __ jmp(&fast);
841 816
842 // Array case: Get the length and the elements array from the JS 817 // Array case: Get the length and the elements array from the JS
843 // array. Check that the array is in fast mode (and writable); if it 818 // array. Check that the array is in fast mode (and writable); if it
844 // is the length is always a smi. 819 // is the length is always a smi.
845 __ bind(&array); 820 __ bind(&array);
846 // eax: value 821 // eax: value
847 // edx: receiver, a JSArray 822 // edx: receiver, a JSArray
848 // ecx: key, a smi. 823 // ecx: key, a smi.
849 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 824 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
850 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true); 825 __ CheckMap(edi, Factory::fixed_array_map(), &slow, true);
851 826
852 // Check the key against the length in the array, compute the 827 // Check the key against the length in the array, compute the
853 // address to store into and fall through to fast case. 828 // address to store into and fall through to fast case.
854 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. 829 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis.
855 __ j(above_equal, &extra, not_taken); 830 __ j(above_equal, &extra, not_taken);
856 831
857 // Fast case: Do the store. 832 // Fast case: Do the store.
858 __ bind(&fast); 833 __ bind(&fast);
859 // eax: value 834 // eax: value
860 // ecx: key (a smi) 835 // ecx: key (a smi)
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1511
1537 void StoreIC::GenerateArrayLength(MacroAssembler* masm) { 1512 void StoreIC::GenerateArrayLength(MacroAssembler* masm) {
1538 // ----------- S t a t e ------------- 1513 // ----------- S t a t e -------------
1539 // -- eax : value 1514 // -- eax : value
1540 // -- ecx : name 1515 // -- ecx : name
1541 // -- edx : receiver 1516 // -- edx : receiver
1542 // -- esp[0] : return address 1517 // -- esp[0] : return address
1543 // ----------------------------------- 1518 // -----------------------------------
1544 // 1519 //
1545 // This accepts as a receiver anything JSObject::SetElementsLength accepts 1520 // This accepts as a receiver anything JSObject::SetElementsLength accepts
1546 // (currently anything except for external and pixel arrays which means 1521 // (currently anything except for external arrays which means anything with
1547 // anything with elements of FixedArray type.), but currently is restricted 1522 // elements of FixedArray type.), but currently is restricted to JSArray.
1548 // to JSArray.
1549 // Value must be a number, but only smis are accepted as the most common case. 1523 // Value must be a number, but only smis are accepted as the most common case.
1550 1524
1551 Label miss; 1525 Label miss;
1552 1526
1553 Register receiver = edx; 1527 Register receiver = edx;
1554 Register value = eax; 1528 Register value = eax;
1555 Register scratch = ebx; 1529 Register scratch = ebx;
1556 1530
1557 // Check that the receiver isn't a smi. 1531 // Check that the receiver isn't a smi.
1558 __ test(receiver, Immediate(kSmiTagMask)); 1532 __ test(receiver, Immediate(kSmiTagMask));
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 Condition cc = *jmp_address == Assembler::kJncShortOpcode 1751 Condition cc = *jmp_address == Assembler::kJncShortOpcode
1778 ? not_zero 1752 ? not_zero
1779 : zero; 1753 : zero;
1780 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1754 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1781 } 1755 }
1782 1756
1783 1757
1784 } } // namespace v8::internal 1758 } } // namespace v8::internal
1785 1759
1786 #endif // V8_TARGET_ARCH_IA32 1760 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698