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 5887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5898 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, | 5898 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, |
5899 Register target) { | 5899 Register target) { |
5900 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), | 5900 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), |
5901 RelocInfo::CODE_TARGET)); | 5901 RelocInfo::CODE_TARGET)); |
5902 // Push return address (accessible to GC through exit frame pc). | 5902 // Push return address (accessible to GC through exit frame pc). |
5903 __ str(pc, MemOperand(sp, 0)); | 5903 __ str(pc, MemOperand(sp, 0)); |
5904 __ Jump(target); // Call the C++ function. | 5904 __ Jump(target); // Call the C++ function. |
5905 } | 5905 } |
5906 | 5906 |
5907 | 5907 |
5908 void GenerateFastPixelArrayLoad(MacroAssembler* masm, | |
5909 Register receiver, | |
5910 Register key, | |
5911 Register elements_map, | |
5912 Register elements, | |
5913 Register scratch1, | |
5914 Register scratch2, | |
5915 Register result, | |
5916 Label* not_pixel_array, | |
5917 Label* key_not_smi, | |
5918 Label* out_of_range) { | |
5919 // Register use: | |
5920 // | |
5921 // receiver - holds the receiver on entry. | |
5922 // Unchanged unless 'result' is the same register. | |
5923 // | |
5924 // key - holds the smi key on entry. | |
5925 // Unchanged unless 'result' is the same register. | |
5926 // | |
5927 // elements - set to be the receiver's elements on exit. | |
5928 // | |
5929 // elements_map - set to be the map of the receiver's elements | |
5930 // on exit. | |
5931 // | |
5932 // result - holds the result of the pixel array load on exit, | |
5933 // tagged as a smi if successful. | |
5934 // | |
5935 // Scratch registers: | |
5936 // | |
5937 // scratch1 - used a scratch register in map check, if map | |
5938 // check is successful, contains the length of the | |
5939 // pixel array, the pointer to external elements and | |
5940 // the untagged result. | |
5941 // | |
5942 // scratch2 - holds the untaged key. | |
5943 | |
5944 // Some callers already have verified that the key is a smi. key_not_smi is | |
5945 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
5946 // to ensure the key is a smi must be added. | |
5947 if (key_not_smi != NULL) { | |
5948 __ JumpIfNotSmi(key, key_not_smi); | |
5949 } else { | |
5950 if (FLAG_debug_code) { | |
5951 __ AbortIfNotSmi(key); | |
5952 } | |
5953 } | |
5954 __ SmiUntag(scratch2, key); | |
5955 | |
5956 // Verify that the receiver has pixel array elements. | |
5957 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
5958 __ CheckMap(elements, scratch1, Heap::kPixelArrayMapRootIndex, | |
5959 not_pixel_array, true); | |
5960 | |
5961 // Key must be in range of the pixel array. | |
5962 __ ldr(scratch1, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
5963 __ cmp(scratch2, scratch1); | |
5964 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
5965 | |
5966 // Perform the indexed load and tag the result as a smi. | |
5967 __ ldr(scratch1, | |
5968 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
5969 __ ldrb(scratch1, MemOperand(scratch1, scratch2)); | |
5970 __ SmiTag(r0, scratch1); | |
5971 __ Ret(); | |
5972 } | |
5973 | |
5974 | |
5975 void GenerateFastPixelArrayStore(MacroAssembler* masm, | |
5976 Register receiver, | |
5977 Register key, | |
5978 Register value, | |
5979 Register elements, | |
5980 Register elements_map, | |
5981 Register scratch1, | |
5982 Register scratch2, | |
5983 bool load_elements_from_receiver, | |
5984 bool load_elements_map_from_elements, | |
5985 Label* key_not_smi, | |
5986 Label* value_not_smi, | |
5987 Label* not_pixel_array, | |
5988 Label* out_of_range) { | |
5989 // Register use: | |
5990 // receiver - holds the receiver and is unchanged unless the | |
5991 // store succeeds. | |
5992 // key - holds the key (must be a smi) and is unchanged. | |
5993 // value - holds the value (must be a smi) and is unchanged. | |
5994 // elements - holds the element object of the receiver on entry if | |
5995 // load_elements_from_receiver is false, otherwise used | |
5996 // internally to store the pixel arrays elements and | |
5997 // external array pointer. | |
5998 // elements_map - holds the map of the element object if | |
5999 // load_elements_map_from_elements is false, otherwise | |
6000 // loaded with the element map. | |
6001 // | |
6002 Register external_pointer = elements; | |
6003 Register untagged_key = scratch1; | |
6004 Register untagged_value = scratch2; | |
6005 | |
6006 if (load_elements_from_receiver) { | |
6007 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
6008 } | |
6009 | |
6010 // By passing NULL as not_pixel_array, callers signal that they have already | |
6011 // verified that the receiver has pixel array elements. | |
6012 if (not_pixel_array != NULL) { | |
6013 if (load_elements_map_from_elements) { | |
6014 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6015 } | |
6016 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6017 __ cmp(elements_map, ip); | |
6018 __ b(ne, not_pixel_array); | |
6019 } else { | |
6020 if (FLAG_debug_code) { | |
6021 // Map check should have already made sure that elements is a pixel array. | |
6022 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
6023 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex); | |
6024 __ cmp(elements_map, ip); | |
6025 __ Assert(eq, "Elements isn't a pixel array"); | |
6026 } | |
6027 } | |
6028 | |
6029 // Some callers already have verified that the key is a smi. key_not_smi is | |
6030 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
6031 // to ensure the key is a smi must be added. | |
6032 if (key_not_smi != NULL) { | |
6033 __ JumpIfNotSmi(key, key_not_smi); | |
6034 } else { | |
6035 if (FLAG_debug_code) { | |
6036 __ AbortIfNotSmi(key); | |
6037 } | |
6038 } | |
6039 | |
6040 __ SmiUntag(untagged_key, key); | |
6041 | |
6042 // Perform bounds check. | |
6043 __ ldr(scratch2, FieldMemOperand(elements, PixelArray::kLengthOffset)); | |
6044 __ cmp(untagged_key, scratch2); | |
6045 __ b(hs, out_of_range); // unsigned check handles negative keys. | |
6046 | |
6047 __ JumpIfNotSmi(value, value_not_smi); | |
6048 __ SmiUntag(untagged_value, value); | |
6049 | |
6050 // Clamp the value to [0..255]. | |
6051 __ Usat(untagged_value, 8, Operand(untagged_value)); | |
6052 // Get the pointer to the external array. This clobbers elements. | |
6053 __ ldr(external_pointer, | |
6054 FieldMemOperand(elements, PixelArray::kExternalPointerOffset)); | |
6055 __ strb(untagged_value, MemOperand(external_pointer, untagged_key)); | |
6056 __ Ret(); | |
6057 } | |
6058 | |
6059 | |
6060 #undef __ | 5908 #undef __ |
6061 | 5909 |
6062 } } // namespace v8::internal | 5910 } } // namespace v8::internal |
6063 | 5911 |
6064 #endif // V8_TARGET_ARCH_ARM | 5912 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |