OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 6709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6720 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, | 6720 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, |
6721 Register target) { | 6721 Register target) { |
6722 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), | 6722 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), |
6723 RelocInfo::CODE_TARGET)); | 6723 RelocInfo::CODE_TARGET)); |
6724 // Push return address (accessible to GC through exit frame pc). | 6724 // Push return address (accessible to GC through exit frame pc). |
6725 __ str(pc, MemOperand(sp, 0)); | 6725 __ str(pc, MemOperand(sp, 0)); |
6726 __ Jump(target); // Call the C++ function. | 6726 __ Jump(target); // Call the C++ function. |
6727 } | 6727 } |
6728 | 6728 |
6729 | 6729 |
6730 void GenerateFastPixelArrayLoad(MacroAssembler* masm, | |
6731 Register receiver, | |
6732 Register key, | |
6733 Register elements_map, | |
6734 Register elements, | |
6735 Register scratch1, | |
6736 Register scratch2, | |
6737 Register result, | |
6738 Label* not_pixel_array, | |
6739 Label* key_not_smi, | |
6740 Label* out_of_range) { | |
6741 // Register use: | |
6742 // | |
6743 // receiver - holds the receiver on entry. | |
6744 // Unchanged unless 'result' is the same register. | |
6745 // | |
6746 // key - holds the smi key on entry. | |
6747 // Unchanged unless 'result' is the same register. | |
6748 // | |
6749 // elements - set to be the receiver's elements on exit. | |
6750 // | |
6751 // elements_map - set to be the map of the receiver's elements | |
6752 // on exit. | |
6753 // | |
6754 // result - holds the result of the pixel array load on exit, | |
6755 // tagged as a smi if successful. | |
6756 // | |
6757 // Scratch registers: | |
6758 // | |
6759 // scratch1 - used a scratch register in map check, if map | |
6760 // check is successful, contains the length of the | |
6761 // pixel array, the pointer to external elements and | |
6762 // the untagged result. | |
6763 // | |
6764 // scratch2 - holds the untaged key. | |
6765 | |
6766 // Some callers already have verified that the key is a smi. key_not_smi is | |
6767 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
6768 // to ensure the key is a smi must be added. | |
6769 if (key_not_smi != NULL) { | |
6770 __ JumpIfNotSmi(key, key_not_smi); | |
6771 } else { | |
6772 if (FLAG_debug_code) { | |
6773 __ AbortIfNotSmi(key); | |
6774 } | |
6775 } | |
6776 __ SmiUntag(scratch2, key); | |
6777 | |
6778 // Verify that the receiver has pixel array elements. | |
6779 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
6780 __ CheckMap(elements, scratch1, Heap::kPixelArrayMapRootIndex, | |
6781 not_pixel_array, true); | |
6782 | |
6783 // Key must be in range of the pixel array. | |
6784 __ ldr(scratch1, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
6785 __ cmp(scratch2, scratch1); | |
6786 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
6787 | |
6788 // Perform the indexed load and tag the result as a smi. | |
6789 __ ldr(scratch1, | |
6790 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
6791 __ ldrb(scratch1, MemOperand(scratch1, scratch2)); | |
6792 __ SmiTag(r0, scratch1); | |
6793 __ Ret(); | |
6794 } | |
6795 | |
6796 | |
6797 void GenerateFastPixelArrayStore(MacroAssembler* masm, | |
6798 Register receiver, | |
6799 Register key, | |
6800 Register value, | |
6801 Register elements, | |
6802 Register elements_map, | |
6803 Register scratch1, | |
6804 Register scratch2, | |
6805 bool load_elements_from_receiver, | |
6806 bool load_elements_map_from_elements, | |
6807 Label* key_not_smi, | |
6808 Label* value_not_smi, | |
6809 Label* not_pixel_array, | |
6810 Label* out_of_range) { | |
6811 // Register use: | |
6812 // receiver - holds the receiver and is unchanged unless the | |
6813 // store succeeds. | |
6814 // key - holds the key (must be a smi) and is unchanged. | |
6815 // value - holds the value (must be a smi) and is unchanged. | |
6816 // elements - holds the element object of the receiver on entry if | |
6817 // load_elements_from_receiver is false, otherwise used | |
6818 // internally to store the pixel arrays elements and | |
6819 // external array pointer. | |
6820 // elements_map - holds the map of the element object if | |
6821 // load_elements_map_from_elements is false, otherwise | |
6822 // loaded with the element map. | |
6823 // | |
6824 Register external_pointer = elements; | |
6825 Register untagged_key = scratch1; | |
6826 Register untagged_value = scratch2; | |
6827 | |
6828 if (load_elements_from_receiver) { | |
6829 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
6830 } | |
6831 | |
6832 // By passing NULL as not_pixel_array, callers signal that they have already | |
6833 // verified that the receiver has pixel array elements. | |
6834 if (not_pixel_array != NULL) { | |
6835 if (load_elements_map_from_elements) { | |
6836 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6837 } | |
6838 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6839 __ cmp(elements_map, ip); | |
6840 __ b(ne, not_pixel_array); | |
6841 } else { | |
6842 if (FLAG_debug_code) { | |
6843 // Map check should have already made sure that elements is a pixel array. | |
6844 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6845 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6846 __ cmp(elements_map, ip); | |
6847 __ Assert(eq, "Elements isn't a pixel array"); | |
6848 } | |
6849 } | |
6850 | |
6851 // Some callers already have verified that the key is a smi. key_not_smi is | |
6852 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
6853 // to ensure the key is a smi must be added. | |
6854 if (key_not_smi != NULL) { | |
6855 __ JumpIfNotSmi(key, key_not_smi); | |
6856 } else { | |
6857 if (FLAG_debug_code) { | |
6858 __ AbortIfNotSmi(key); | |
6859 } | |
6860 } | |
6861 | |
6862 __ SmiUntag(untagged_key, key); | |
6863 | |
6864 // Perform bounds check. | |
6865 __ ldr(scratch2, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
6866 __ cmp(untagged_key, scratch2); | |
6867 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
6868 | |
6869 __ JumpIfNotSmi(value, value_not_smi); | |
6870 __ SmiUntag(untagged_value, value); | |
6871 | |
6872 // Clamp the value to [0..255]. | |
6873 __ Usat(untagged_value, 8, Operand(untagged_value)); | |
6874 // Get the pointer to the external array. This clobbers elements. | |
6875 __ ldr(external_pointer, | |
6876 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
6877 __ strb(untagged_value, MemOperand(external_pointer, untagged_key)); | |
6878 __ Ret(); | |
6879 } | |
6880 | |
6881 | |
6882 #undef __ | 6730 #undef __ |
6883 | 6731 |
6884 } } // namespace v8::internal | 6732 } } // namespace v8::internal |
6885 | 6733 |
6886 #endif // V8_TARGET_ARCH_ARM | 6734 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |