| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 __ mov(dst, Operand(esp, stack_offset + kDestinationOffset)); | 105 __ mov(dst, Operand(esp, stack_offset + kDestinationOffset)); |
| 106 __ mov(src, Operand(esp, stack_offset + kSourceOffset)); | 106 __ mov(src, Operand(esp, stack_offset + kSourceOffset)); |
| 107 __ mov(count, Operand(esp, stack_offset + kSizeOffset)); | 107 __ mov(count, Operand(esp, stack_offset + kSizeOffset)); |
| 108 | 108 |
| 109 | 109 |
| 110 __ movdqu(xmm0, Operand(src, 0)); | 110 __ movdqu(xmm0, Operand(src, 0)); |
| 111 __ movdqu(Operand(dst, 0), xmm0); | 111 __ movdqu(Operand(dst, 0), xmm0); |
| 112 __ mov(edx, dst); | 112 __ mov(edx, dst); |
| 113 __ and_(edx, 0xF); | 113 __ and_(edx, 0xF); |
| 114 __ neg(edx); | 114 __ neg(edx); |
| 115 __ add(Operand(edx), Immediate(16)); | 115 __ add(edx, Immediate(16)); |
| 116 __ add(dst, Operand(edx)); | 116 __ add(dst, edx); |
| 117 __ add(src, Operand(edx)); | 117 __ add(src, edx); |
| 118 __ sub(Operand(count), edx); | 118 __ sub(count, edx); |
| 119 | 119 |
| 120 // edi is now aligned. Check if esi is also aligned. | 120 // edi is now aligned. Check if esi is also aligned. |
| 121 Label unaligned_source; | 121 Label unaligned_source; |
| 122 __ test(Operand(src), Immediate(0x0F)); | 122 __ test(src, Immediate(0x0F)); |
| 123 __ j(not_zero, &unaligned_source); | 123 __ j(not_zero, &unaligned_source); |
| 124 { | 124 { |
| 125 // Copy loop for aligned source and destination. | 125 // Copy loop for aligned source and destination. |
| 126 __ mov(edx, count); | 126 __ mov(edx, count); |
| 127 Register loop_count = ecx; | 127 Register loop_count = ecx; |
| 128 Register count = edx; | 128 Register count = edx; |
| 129 __ shr(loop_count, 5); | 129 __ shr(loop_count, 5); |
| 130 { | 130 { |
| 131 // Main copy loop. | 131 // Main copy loop. |
| 132 Label loop; | 132 Label loop; |
| 133 __ bind(&loop); | 133 __ bind(&loop); |
| 134 __ prefetch(Operand(src, 0x20), 1); | 134 __ prefetch(Operand(src, 0x20), 1); |
| 135 __ movdqa(xmm0, Operand(src, 0x00)); | 135 __ movdqa(xmm0, Operand(src, 0x00)); |
| 136 __ movdqa(xmm1, Operand(src, 0x10)); | 136 __ movdqa(xmm1, Operand(src, 0x10)); |
| 137 __ add(Operand(src), Immediate(0x20)); | 137 __ add(src, Immediate(0x20)); |
| 138 | 138 |
| 139 __ movdqa(Operand(dst, 0x00), xmm0); | 139 __ movdqa(Operand(dst, 0x00), xmm0); |
| 140 __ movdqa(Operand(dst, 0x10), xmm1); | 140 __ movdqa(Operand(dst, 0x10), xmm1); |
| 141 __ add(Operand(dst), Immediate(0x20)); | 141 __ add(dst, Immediate(0x20)); |
| 142 | 142 |
| 143 __ dec(loop_count); | 143 __ dec(loop_count); |
| 144 __ j(not_zero, &loop); | 144 __ j(not_zero, &loop); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // At most 31 bytes to copy. | 147 // At most 31 bytes to copy. |
| 148 Label move_less_16; | 148 Label move_less_16; |
| 149 __ test(Operand(count), Immediate(0x10)); | 149 __ test(count, Immediate(0x10)); |
| 150 __ j(zero, &move_less_16); | 150 __ j(zero, &move_less_16); |
| 151 __ movdqa(xmm0, Operand(src, 0)); | 151 __ movdqa(xmm0, Operand(src, 0)); |
| 152 __ add(Operand(src), Immediate(0x10)); | 152 __ add(src, Immediate(0x10)); |
| 153 __ movdqa(Operand(dst, 0), xmm0); | 153 __ movdqa(Operand(dst, 0), xmm0); |
| 154 __ add(Operand(dst), Immediate(0x10)); | 154 __ add(dst, Immediate(0x10)); |
| 155 __ bind(&move_less_16); | 155 __ bind(&move_less_16); |
| 156 | 156 |
| 157 // At most 15 bytes to copy. Copy 16 bytes at end of string. | 157 // At most 15 bytes to copy. Copy 16 bytes at end of string. |
| 158 __ and_(count, 0xF); | 158 __ and_(count, 0xF); |
| 159 __ movdqu(xmm0, Operand(src, count, times_1, -0x10)); | 159 __ movdqu(xmm0, Operand(src, count, times_1, -0x10)); |
| 160 __ movdqu(Operand(dst, count, times_1, -0x10), xmm0); | 160 __ movdqu(Operand(dst, count, times_1, -0x10), xmm0); |
| 161 | 161 |
| 162 __ mov(eax, Operand(esp, stack_offset + kDestinationOffset)); | 162 __ mov(eax, Operand(esp, stack_offset + kDestinationOffset)); |
| 163 __ pop(esi); | 163 __ pop(esi); |
| 164 __ pop(edi); | 164 __ pop(edi); |
| 165 __ ret(0); | 165 __ ret(0); |
| 166 } | 166 } |
| 167 __ Align(16); | 167 __ Align(16); |
| 168 { | 168 { |
| 169 // Copy loop for unaligned source and aligned destination. | 169 // Copy loop for unaligned source and aligned destination. |
| 170 // If source is not aligned, we can't read it as efficiently. | 170 // If source is not aligned, we can't read it as efficiently. |
| 171 __ bind(&unaligned_source); | 171 __ bind(&unaligned_source); |
| 172 __ mov(edx, ecx); | 172 __ mov(edx, ecx); |
| 173 Register loop_count = ecx; | 173 Register loop_count = ecx; |
| 174 Register count = edx; | 174 Register count = edx; |
| 175 __ shr(loop_count, 5); | 175 __ shr(loop_count, 5); |
| 176 { | 176 { |
| 177 // Main copy loop | 177 // Main copy loop |
| 178 Label loop; | 178 Label loop; |
| 179 __ bind(&loop); | 179 __ bind(&loop); |
| 180 __ prefetch(Operand(src, 0x20), 1); | 180 __ prefetch(Operand(src, 0x20), 1); |
| 181 __ movdqu(xmm0, Operand(src, 0x00)); | 181 __ movdqu(xmm0, Operand(src, 0x00)); |
| 182 __ movdqu(xmm1, Operand(src, 0x10)); | 182 __ movdqu(xmm1, Operand(src, 0x10)); |
| 183 __ add(Operand(src), Immediate(0x20)); | 183 __ add(src, Immediate(0x20)); |
| 184 | 184 |
| 185 __ movdqa(Operand(dst, 0x00), xmm0); | 185 __ movdqa(Operand(dst, 0x00), xmm0); |
| 186 __ movdqa(Operand(dst, 0x10), xmm1); | 186 __ movdqa(Operand(dst, 0x10), xmm1); |
| 187 __ add(Operand(dst), Immediate(0x20)); | 187 __ add(dst, Immediate(0x20)); |
| 188 | 188 |
| 189 __ dec(loop_count); | 189 __ dec(loop_count); |
| 190 __ j(not_zero, &loop); | 190 __ j(not_zero, &loop); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // At most 31 bytes to copy. | 193 // At most 31 bytes to copy. |
| 194 Label move_less_16; | 194 Label move_less_16; |
| 195 __ test(Operand(count), Immediate(0x10)); | 195 __ test(count, Immediate(0x10)); |
| 196 __ j(zero, &move_less_16); | 196 __ j(zero, &move_less_16); |
| 197 __ movdqu(xmm0, Operand(src, 0)); | 197 __ movdqu(xmm0, Operand(src, 0)); |
| 198 __ add(Operand(src), Immediate(0x10)); | 198 __ add(src, Immediate(0x10)); |
| 199 __ movdqa(Operand(dst, 0), xmm0); | 199 __ movdqa(Operand(dst, 0), xmm0); |
| 200 __ add(Operand(dst), Immediate(0x10)); | 200 __ add(dst, Immediate(0x10)); |
| 201 __ bind(&move_less_16); | 201 __ bind(&move_less_16); |
| 202 | 202 |
| 203 // At most 15 bytes to copy. Copy 16 bytes at end of string. | 203 // At most 15 bytes to copy. Copy 16 bytes at end of string. |
| 204 __ and_(count, 0x0F); | 204 __ and_(count, 0x0F); |
| 205 __ movdqu(xmm0, Operand(src, count, times_1, -0x10)); | 205 __ movdqu(xmm0, Operand(src, count, times_1, -0x10)); |
| 206 __ movdqu(Operand(dst, count, times_1, -0x10), xmm0); | 206 __ movdqu(Operand(dst, count, times_1, -0x10), xmm0); |
| 207 | 207 |
| 208 __ mov(eax, Operand(esp, stack_offset + kDestinationOffset)); | 208 __ mov(eax, Operand(esp, stack_offset + kDestinationOffset)); |
| 209 __ pop(esi); | 209 __ pop(esi); |
| 210 __ pop(edi); | 210 __ pop(edi); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 225 __ mov(count, Operand(esp, stack_offset + kSizeOffset)); | 225 __ mov(count, Operand(esp, stack_offset + kSizeOffset)); |
| 226 | 226 |
| 227 // Copy the first word. | 227 // Copy the first word. |
| 228 __ mov(eax, Operand(src, 0)); | 228 __ mov(eax, Operand(src, 0)); |
| 229 __ mov(Operand(dst, 0), eax); | 229 __ mov(Operand(dst, 0), eax); |
| 230 | 230 |
| 231 // Increment src,dstso that dst is aligned. | 231 // Increment src,dstso that dst is aligned. |
| 232 __ mov(edx, dst); | 232 __ mov(edx, dst); |
| 233 __ and_(edx, 0x03); | 233 __ and_(edx, 0x03); |
| 234 __ neg(edx); | 234 __ neg(edx); |
| 235 __ add(Operand(edx), Immediate(4)); // edx = 4 - (dst & 3) | 235 __ add(edx, Immediate(4)); // edx = 4 - (dst & 3) |
| 236 __ add(dst, Operand(edx)); | 236 __ add(dst, edx); |
| 237 __ add(src, Operand(edx)); | 237 __ add(src, edx); |
| 238 __ sub(Operand(count), edx); | 238 __ sub(count, edx); |
| 239 // edi is now aligned, ecx holds number of remaning bytes to copy. | 239 // edi is now aligned, ecx holds number of remaning bytes to copy. |
| 240 | 240 |
| 241 __ mov(edx, count); | 241 __ mov(edx, count); |
| 242 count = edx; | 242 count = edx; |
| 243 __ shr(ecx, 2); // Make word count instead of byte count. | 243 __ shr(ecx, 2); // Make word count instead of byte count. |
| 244 __ rep_movs(); | 244 __ rep_movs(); |
| 245 | 245 |
| 246 // At most 3 bytes left to copy. Copy 4 bytes at end of string. | 246 // At most 3 bytes left to copy. Copy 4 bytes at end of string. |
| 247 __ and_(count, 3); | 247 __ and_(count, 3); |
| 248 __ mov(eax, Operand(src, count, times_1, -4)); | 248 __ mov(eax, Operand(src, count, times_1, -4)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 261 CPU::FlushICache(buffer, actual_size); | 261 CPU::FlushICache(buffer, actual_size); |
| 262 OS::ProtectCode(buffer, actual_size); | 262 OS::ProtectCode(buffer, actual_size); |
| 263 return FUNCTION_CAST<OS::MemCopyFunction>(buffer); | 263 return FUNCTION_CAST<OS::MemCopyFunction>(buffer); |
| 264 } | 264 } |
| 265 | 265 |
| 266 #undef __ | 266 #undef __ |
| 267 | 267 |
| 268 } } // namespace v8::internal | 268 } } // namespace v8::internal |
| 269 | 269 |
| 270 #endif // V8_TARGET_ARCH_IA32 | 270 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |