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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index 8eca39207d4aa55b222870a2e36e7ce53a273bc8..8111076f606715e776fe01d73efb373e9185e489 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -441,6 +441,18 @@ typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size);
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
MemMove(dest, src, size);
}
+#elif defined(V8_TARGET_ARCH_X64)
+// Limit below which the extra overhead of the MemCopy function is likely
+// to outweigh the benefits of faster copying.
+const int kMinComplexMemCopy = 8;
+
+// Copy memory area to disjoint memory area.
+V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
+ memcpy(dest, src, size);
+}
+V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
+ memmove(dest, src, size);
+}
#elif defined(V8_HOST_ARCH_ARM)
typedef void (*MemCopyUint8Function)(uint8_t* dest, const uint8_t* src,
size_t size);
@@ -1154,7 +1166,9 @@ Vector<const char> ReadFile(FILE* file,
template <typename sourcechar, typename sinkchar>
INLINE(static void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src,
size_t chars));
-#if defined(V8_HOST_ARCH_ARM)
+#if defined(V8_HOST_ARCH_X64)
+INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars));
+#elif defined(V8_HOST_ARCH_ARM)
INLINE(void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars));
INLINE(void CopyCharsUnsigned(uint16_t* dest, const uint8_t* src,
size_t chars));
@@ -1213,7 +1227,16 @@ void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, size_t chars) {
}
-#if defined(V8_HOST_ARCH_ARM)
+#if defined(V8_HOST_ARCH_X64)
+void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) {
+ uint8_t* limit = dest + chars;
+ if (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest))) {
+ MemCopy(dest, src, chars * sizeof(*dest));
+ } else {
+ while (dest < limit) *dest++ = *src++;
+ }
+}
+#elif defined(V8_HOST_ARCH_ARM)
void CopyCharsUnsigned(uint8_t* dest, const uint8_t* src, size_t chars) {
switch (static_cast<unsigned>(chars)) {
case 0:
« 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