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 6814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6825 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, | 6825 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, |
6826 Register target) { | 6826 Register target) { |
6827 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), | 6827 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), |
6828 RelocInfo::CODE_TARGET)); | 6828 RelocInfo::CODE_TARGET)); |
6829 // Push return address (accessible to GC through exit frame pc). | 6829 // Push return address (accessible to GC through exit frame pc). |
6830 __ str(pc, MemOperand(sp, 0)); | 6830 __ str(pc, MemOperand(sp, 0)); |
6831 __ Jump(target); // Call the C++ function. | 6831 __ Jump(target); // Call the C++ function. |
6832 } | 6832 } |
6833 | 6833 |
6834 | 6834 |
6835 void GenerateFastPixelArrayLoad(MacroAssembler* masm, | |
6836 Register receiver, | |
6837 Register key, | |
6838 Register elements_map, | |
6839 Register elements, | |
6840 Register scratch1, | |
6841 Register scratch2, | |
6842 Register result, | |
6843 Label* not_pixel_array, | |
6844 Label* key_not_smi, | |
6845 Label* out_of_range) { | |
6846 // Register use: | |
6847 // | |
6848 // receiver - holds the receiver on entry. | |
6849 // Unchanged unless 'result' is the same register. | |
6850 // | |
6851 // key - holds the smi key on entry. | |
6852 // Unchanged unless 'result' is the same register. | |
6853 // | |
6854 // elements - set to be the receiver's elements on exit. | |
6855 // | |
6856 // elements_map - set to be the map of the receiver's elements | |
6857 // on exit. | |
6858 // | |
6859 // result - holds the result of the pixel array load on exit, | |
6860 // tagged as a smi if successful. | |
6861 // | |
6862 // Scratch registers: | |
6863 // | |
6864 // scratch1 - used a scratch register in map check, if map | |
6865 // check is successful, contains the length of the | |
6866 // pixel array, the pointer to external elements and | |
6867 // the untagged result. | |
6868 // | |
6869 // scratch2 - holds the untaged key. | |
6870 | |
6871 // Some callers already have verified that the key is a smi. key_not_smi is | |
6872 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
6873 // to ensure the key is a smi must be added. | |
6874 if (key_not_smi != NULL) { | |
6875 __ JumpIfNotSmi(key, key_not_smi); | |
6876 } else { | |
6877 if (FLAG_debug_code) { | |
6878 __ AbortIfNotSmi(key); | |
6879 } | |
6880 } | |
6881 __ SmiUntag(scratch2, key); | |
6882 | |
6883 // Verify that the receiver has pixel array elements. | |
6884 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
6885 __ CheckMap(elements, scratch1, Heap::kPixelArrayMapRootIndex, | |
6886 not_pixel_array, true); | |
6887 | |
6888 // Key must be in range of the pixel array. | |
6889 __ ldr(scratch1, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
6890 __ cmp(scratch2, scratch1); | |
6891 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
6892 | |
6893 // Perform the indexed load and tag the result as a smi. | |
6894 __ ldr(scratch1, | |
6895 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
6896 __ ldrb(scratch1, MemOperand(scratch1, scratch2)); | |
6897 __ SmiTag(r0, scratch1); | |
6898 __ Ret(); | |
6899 } | |
6900 | |
6901 | |
6902 void GenerateFastPixelArrayStore(MacroAssembler* masm, | |
6903 Register receiver, | |
6904 Register key, | |
6905 Register value, | |
6906 Register elements, | |
6907 Register elements_map, | |
6908 Register scratch1, | |
6909 Register scratch2, | |
6910 bool load_elements_from_receiver, | |
6911 bool load_elements_map_from_elements, | |
6912 Label* key_not_smi, | |
6913 Label* value_not_smi, | |
6914 Label* not_pixel_array, | |
6915 Label* out_of_range) { | |
6916 // Register use: | |
6917 // receiver - holds the receiver and is unchanged unless the | |
6918 // store succeeds. | |
6919 // key - holds the key (must be a smi) and is unchanged. | |
6920 // value - holds the value (must be a smi) and is unchanged. | |
6921 // elements - holds the element object of the receiver on entry if | |
6922 // load_elements_from_receiver is false, otherwise used | |
6923 // internally to store the pixel arrays elements and | |
6924 // external array pointer. | |
6925 // elements_map - holds the map of the element object if | |
6926 // load_elements_map_from_elements is false, otherwise | |
6927 // loaded with the element map. | |
6928 // | |
6929 Register external_pointer = elements; | |
6930 Register untagged_key = scratch1; | |
6931 Register untagged_value = scratch2; | |
6932 | |
6933 if (load_elements_from_receiver) { | |
6934 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
6935 } | |
6936 | |
6937 // By passing NULL as not_pixel_array, callers signal that they have already | |
6938 // verified that the receiver has pixel array elements. | |
6939 if (not_pixel_array != NULL) { | |
6940 if (load_elements_map_from_elements) { | |
6941 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6942 } | |
6943 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6944 __ cmp(elements_map, ip); | |
6945 __ b(ne, not_pixel_array); | |
6946 } else { | |
6947 if (FLAG_debug_code) { | |
6948 // Map check should have already made sure that elements is a pixel array. | |
6949 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6950 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6951 __ cmp(elements_map, ip); | |
6952 __ Assert(eq, "Elements isn't a pixel array"); | |
6953 } | |
6954 } | |
6955 | |
6956 // Some callers already have verified that the key is a smi. key_not_smi is | |
6957 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
6958 // to ensure the key is a smi must be added. | |
6959 if (key_not_smi != NULL) { | |
6960 __ JumpIfNotSmi(key, key_not_smi); | |
6961 } else { | |
6962 if (FLAG_debug_code) { | |
6963 __ AbortIfNotSmi(key); | |
6964 } | |
6965 } | |
6966 | |
6967 __ SmiUntag(untagged_key, key); | |
6968 | |
6969 // Perform bounds check. | |
6970 __ ldr(scratch2, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
6971 __ cmp(untagged_key, scratch2); | |
6972 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
6973 | |
6974 __ JumpIfNotSmi(value, value_not_smi); | |
6975 __ SmiUntag(untagged_value, value); | |
6976 | |
6977 // Clamp the value to [0..255]. | |
6978 __ Usat(untagged_value, 8, Operand(untagged_value)); | |
6979 // Get the pointer to the external array. This clobbers elements. | |
6980 __ ldr(external_pointer, | |
6981 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
6982 __ strb(untagged_value, MemOperand(external_pointer, untagged_key)); | |
6983 __ Ret(); | |
6984 } | |
6985 | |
6986 | |
6987 #undef __ | 6835 #undef __ |
6988 | 6836 |
6989 } } // namespace v8::internal | 6837 } } // namespace v8::internal |
6990 | 6838 |
6991 #endif // V8_TARGET_ARCH_ARM | 6839 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |