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