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

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: fix wrong external element call 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 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 754 }
762 755
763 756
764 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { 757 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {
765 // ----------- S t a t e ------------- 758 // ----------- S t a t e -------------
766 // -- eax : value 759 // -- eax : value
767 // -- ecx : key 760 // -- ecx : key
768 // -- edx : receiver 761 // -- edx : receiver
769 // -- esp[0] : return address 762 // -- esp[0] : return address
770 // ----------------------------------- 763 // -----------------------------------
771 Label slow, fast, array, extra, check_pixel_array; 764 Label slow, fast, array, extra;
772 765
773 // Check that the object isn't a smi. 766 // Check that the object isn't a smi.
774 __ test(edx, Immediate(kSmiTagMask)); 767 __ test(edx, Immediate(kSmiTagMask));
775 __ j(zero, &slow, not_taken); 768 __ j(zero, &slow, not_taken);
776 // Get the map from the receiver. 769 // Get the map from the receiver.
777 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); 770 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
778 // Check that the receiver does not require access checks. We need 771 // Check that the receiver does not require access checks. We need
779 // to do this because this generic stub does not perform map checks. 772 // to do this because this generic stub does not perform map checks.
780 __ test_b(FieldOperand(edi, Map::kBitFieldOffset), 773 __ test_b(FieldOperand(edi, Map::kBitFieldOffset),
781 1 << Map::kIsAccessCheckNeeded); 774 1 << Map::kIsAccessCheckNeeded);
782 __ j(not_zero, &slow, not_taken); 775 __ j(not_zero, &slow, not_taken);
783 // Check that the key is a smi. 776 // Check that the key is a smi.
784 __ test(ecx, Immediate(kSmiTagMask)); 777 __ test(ecx, Immediate(kSmiTagMask));
785 __ j(not_zero, &slow, not_taken); 778 __ j(not_zero, &slow, not_taken);
786 __ CmpInstanceType(edi, JS_ARRAY_TYPE); 779 __ CmpInstanceType(edi, JS_ARRAY_TYPE);
787 __ j(equal, &array); 780 __ j(equal, &array);
788 // Check that the object is some kind of JS object. 781 // Check that the object is some kind of JS object.
789 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE); 782 __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE);
790 __ j(below, &slow, not_taken); 783 __ j(below, &slow, not_taken);
791 784
792 // Object case: Check key against length in the elements array. 785 // Object case: Check key against length in the elements array.
793 // eax: value 786 // eax: value
794 // edx: JSObject 787 // edx: JSObject
795 // ecx: key (a smi) 788 // ecx: key (a smi)
796 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 789 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
797 // Check that the object is in fast mode and writable. 790 // Check that the object is in fast mode and writable.
798 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true); 791 __ CheckMap(edi, Factory::fixed_array_map(), &slow, true);
799 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 792 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
800 __ j(below, &fast, taken); 793 __ j(below, &fast, taken);
801 794
802 // Slow case: call runtime. 795 // Slow case: call runtime.
803 __ bind(&slow); 796 __ bind(&slow);
804 GenerateRuntimeSetProperty(masm); 797 GenerateRuntimeSetProperty(masm);
805 798
806 // Check whether the elements is a pixel array.
807 __ bind(&check_pixel_array);
808 // eax: value
809 // ecx: key (a smi)
810 // edx: receiver
811 // edi: elements array
812 GenerateFastPixelArrayStore(masm,
813 edx,
814 ecx,
815 eax,
816 edi,
817 ebx,
818 false,
819 NULL,
820 &slow,
821 &slow,
822 &slow);
823
824 // Extra capacity case: Check if there is extra capacity to 799 // Extra capacity case: Check if there is extra capacity to
825 // perform the store and update the length. Used for adding one 800 // perform the store and update the length. Used for adding one
826 // element to the array by writing to array[array.length]. 801 // element to the array by writing to array[array.length].
827 __ bind(&extra); 802 __ bind(&extra);
828 // eax: value 803 // eax: value
829 // edx: receiver, a JSArray 804 // edx: receiver, a JSArray
830 // ecx: key, a smi. 805 // ecx: key, a smi.
831 // edi: receiver->elements, a FixedArray 806 // edi: receiver->elements, a FixedArray
832 // flags: compare (ecx, edx.length()) 807 // flags: compare (ecx, edx.length())
833 __ j(not_equal, &slow, not_taken); // do not leave holes in the array 808 __ j(not_equal, &slow, not_taken); // do not leave holes in the array
834 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 809 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
835 __ j(above_equal, &slow, not_taken); 810 __ j(above_equal, &slow, not_taken);
836 // Add 1 to receiver->length, and go to fast array write. 811 // Add 1 to receiver->length, and go to fast array write.
837 __ add(FieldOperand(edx, JSArray::kLengthOffset), 812 __ add(FieldOperand(edx, JSArray::kLengthOffset),
838 Immediate(Smi::FromInt(1))); 813 Immediate(Smi::FromInt(1)));
839 __ jmp(&fast); 814 __ jmp(&fast);
840 815
841 // Array case: Get the length and the elements array from the JS 816 // Array case: Get the length and the elements array from the JS
842 // array. Check that the array is in fast mode (and writable); if it 817 // array. Check that the array is in fast mode (and writable); if it
843 // is the length is always a smi. 818 // is the length is always a smi.
844 __ bind(&array); 819 __ bind(&array);
845 // eax: value 820 // eax: value
846 // edx: receiver, a JSArray 821 // edx: receiver, a JSArray
847 // ecx: key, a smi. 822 // ecx: key, a smi.
848 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 823 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
849 __ CheckMap(edi, Factory::fixed_array_map(), &check_pixel_array, true); 824 __ CheckMap(edi, Factory::fixed_array_map(), &slow, true);
850 825
851 // Check the key against the length in the array, compute the 826 // Check the key against the length in the array, compute the
852 // address to store into and fall through to fast case. 827 // address to store into and fall through to fast case.
853 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. 828 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis.
854 __ j(above_equal, &extra, not_taken); 829 __ j(above_equal, &extra, not_taken);
855 830
856 // Fast case: Do the store. 831 // Fast case: Do the store.
857 __ bind(&fast); 832 __ bind(&fast);
858 // eax: value 833 // eax: value
859 // ecx: key (a smi) 834 // ecx: key (a smi)
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 1510
1536 void StoreIC::GenerateArrayLength(MacroAssembler* masm) { 1511 void StoreIC::GenerateArrayLength(MacroAssembler* masm) {
1537 // ----------- S t a t e ------------- 1512 // ----------- S t a t e -------------
1538 // -- eax : value 1513 // -- eax : value
1539 // -- ecx : name 1514 // -- ecx : name
1540 // -- edx : receiver 1515 // -- edx : receiver
1541 // -- esp[0] : return address 1516 // -- esp[0] : return address
1542 // ----------------------------------- 1517 // -----------------------------------
1543 // 1518 //
1544 // This accepts as a receiver anything JSObject::SetElementsLength accepts 1519 // This accepts as a receiver anything JSObject::SetElementsLength accepts
1545 // (currently anything except for external and pixel arrays which means 1520 // (currently anything except for external arrays which means anything with
1546 // anything with elements of FixedArray type.), but currently is restricted 1521 // elements of FixedArray type.), but currently is restricted to JSArray.
1547 // to JSArray.
1548 // Value must be a number, but only smis are accepted as the most common case. 1522 // Value must be a number, but only smis are accepted as the most common case.
1549 1523
1550 Label miss; 1524 Label miss;
1551 1525
1552 Register receiver = edx; 1526 Register receiver = edx;
1553 Register value = eax; 1527 Register value = eax;
1554 Register scratch = ebx; 1528 Register scratch = ebx;
1555 1529
1556 // Check that the receiver isn't a smi. 1530 // Check that the receiver isn't a smi.
1557 __ test(receiver, Immediate(kSmiTagMask)); 1531 __ test(receiver, Immediate(kSmiTagMask));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 Condition cc = *jmp_address == Assembler::kJncShortOpcode 1744 Condition cc = *jmp_address == Assembler::kJncShortOpcode
1771 ? not_zero 1745 ? not_zero
1772 : zero; 1746 : zero;
1773 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1747 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1774 } 1748 }
1775 1749
1776 1750
1777 } } // namespace v8::internal 1751 } } // namespace v8::internal
1778 1752
1779 #endif // V8_TARGET_ARCH_IA32 1753 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698