Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: src/utils.h

Issue 2291773002: The function CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) is now a specializa…
Patch Set: Changing kMinComplexMemCopy to 8 on x64 architecture. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_UTILS_H_ 5 #ifndef V8_UTILS_H_
6 #define V8_UTILS_H_ 6 #define V8_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 // Copy memory area. No restrictions. 435 // Copy memory area. No restrictions.
436 void MemMove(void* dest, const void* src, size_t size); 436 void MemMove(void* dest, const void* src, size_t size);
437 typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size); 437 typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size);
438 438
439 // Keep the distinction of "move" vs. "copy" for the benefit of other 439 // Keep the distinction of "move" vs. "copy" for the benefit of other
440 // architectures. 440 // architectures.
441 V8_INLINE void MemCopy(void* dest, const void* src, size_t size) { 441 V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
442 MemMove(dest, src, size); 442 MemMove(dest, src, size);
443 } 443 }
444 #elif defined(V8_TARGET_ARCH_X64)
445 // Limit below which the extra overhead of the MemCopy function is likely
446 // to outweigh the benefits of faster copying.
447 const int kMinComplexMemCopy = 8;
448
449 // Copy memory area to disjoint memory area.
450 V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
451 memcpy(dest, src, size);
452 }
453 V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
454 memmove(dest, src, size);
455 }
444 #elif defined(V8_HOST_ARCH_ARM) 456 #elif defined(V8_HOST_ARCH_ARM)
445 typedef void (*MemCopyUint8Function)(uint8_t* dest, const uint8_t* src, 457 typedef void (*MemCopyUint8Function)(uint8_t* dest, const uint8_t* src,
446 size_t size); 458 size_t size);
447 extern MemCopyUint8Function memcopy_uint8_function; 459 extern MemCopyUint8Function memcopy_uint8_function;
448 V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src, 460 V8_INLINE void MemCopyUint8Wrapper(uint8_t* dest, const uint8_t* src,
449 size_t chars) { 461 size_t chars) {
450 memcpy(dest, src, chars); 462 memcpy(dest, src, chars);
451 } 463 }
452 // For values < 16, the assembler function is slower than the inlined C code. 464 // For values < 16, the assembler function is slower than the inlined C code.
453 const int kMinComplexMemCopy = 16; 465 const int kMinComplexMemCopy = 16;
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 bool* exists, 1159 bool* exists,
1148 bool verbose = true); 1160 bool verbose = true);
1149 Vector<const char> ReadFile(FILE* file, 1161 Vector<const char> ReadFile(FILE* file,
1150 bool* exists, 1162 bool* exists,
1151 bool verbose = true); 1163 bool verbose = true);
1152 1164
1153 1165
1154 template <typename sourcechar, typename sinkchar> 1166 template <typename sourcechar, typename sinkchar>
1155 INLINE(static void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, 1167 INLINE(static void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src,
1156 size_t chars)); 1168 size_t chars));
1157 #if defined(V8_HOST_ARCH_ARM) 1169 #if defined(V8_HOST_ARCH_X64)
1170 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars));
1171 #elif defined(V8_HOST_ARCH_ARM)
1158 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars)); 1172 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars));
1159 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src, 1173 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src,
1160 size_t chars)); 1174 size_t chars));
1161 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, 1175 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src,
1162 size_t chars)); 1176 size_t chars));
1163 #elif defined(V8_HOST_ARCH_MIPS) 1177 #elif defined(V8_HOST_ARCH_MIPS)
1164 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars)); 1178 INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars));
1165 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src, 1179 INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint16_t* src,
1166 size_t chars)); 1180 size_t chars));
1167 #elif defined(V8_HOST_ARCH_PPC) || defined(V8_HOST_ARCH_S390) 1181 #elif defined(V8_HOST_ARCH_PPC) || defined(V8_HOST_ARCH_S390)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 sinkchar* limit = dest + chars; 1220 sinkchar* limit = dest + chars;
1207 if ((sizeof(*dest) == sizeof(*src)) && 1221 if ((sizeof(*dest) == sizeof(*src)) &&
1208 (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest)))) { 1222 (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest)))) {
1209 MemCopy(dest, src, chars * sizeof(*dest)); 1223 MemCopy(dest, src, chars * sizeof(*dest));
1210 } else { 1224 } else {
1211 while (dest < limit) *dest++ = static_cast<sinkchar>(*src++); 1225 while (dest < limit) *dest++ = static_cast<sinkchar>(*src++);
1212 } 1226 }
1213 } 1227 }
1214 1228
1215 1229
1216 #if defined(V8_HOST_ARCH_ARM) 1230 #if defined(V8_HOST_ARCH_X64)
1231 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) {
1232 uint8_t* limit = dest + chars;
1233 if (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest))) {
1234 MemCopy(dest, src, chars * sizeof(*dest));
1235 } else {
1236 while (dest < limit) *dest++ = *src++;
1237 }
1238 }
1239 #elif defined(V8_HOST_ARCH_ARM)
1217 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) { 1240 void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) {
1218 switch (static_cast<unsigned>(chars)) { 1241 switch (static_cast<unsigned>(chars)) {
1219 case 0: 1242 case 0:
1220 break; 1243 break;
1221 case 1: 1244 case 1:
1222 *dest = *src; 1245 *dest = *src;
1223 break; 1246 break;
1224 case 2: 1247 case 2:
1225 memcpy(dest, src, 2); 1248 memcpy(dest, src, 2);
1226 break; 1249 break;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 byte* dst = reinterpret_cast<byte*>(p); 1610 byte* dst = reinterpret_cast<byte*>(p);
1588 for (size_t i = 0; i < sizeof(V); i++) { 1611 for (size_t i = 0; i < sizeof(V); i++) {
1589 dst[i] = src[sizeof(V) - i - 1]; 1612 dst[i] = src[sizeof(V) - i - 1];
1590 } 1613 }
1591 #endif // V8_TARGET_LITTLE_ENDIAN 1614 #endif // V8_TARGET_LITTLE_ENDIAN
1592 } 1615 }
1593 } // namespace internal 1616 } // namespace internal
1594 } // namespace v8 1617 } // namespace v8
1595 1618
1596 #endif // V8_UTILS_H_ 1619 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698