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

Unified Diff: src/v8utils.h

Issue 12593014: Use internal memcpy when initializing code objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Jakob Kummerow's offline comments. Created 7 years, 9 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 | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8utils.h
diff --git a/src/v8utils.h b/src/v8utils.h
index 793d34d9ccb31f47c676797c4e89b899b58f2404..fd785452f8a774969c9829dc704e55707ff0ed5b 100644
--- a/src/v8utils.h
+++ b/src/v8utils.h
@@ -122,7 +122,7 @@ inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms,
// Memory
-// Copies data from |src| to |dst|. The data spans MUST not overlap.
+// Copies data from |src| to |dst|. The data spans must not overlap.
template <typename T>
inline void CopyWords(T* dst, T* src, int num_words) {
STATIC_ASSERT(sizeof(T) == kPointerSize);
@@ -145,6 +145,30 @@ inline void CopyWords(T* dst, T* src, int num_words) {
}
+// Copies data from |src| to |dst|. The data spans must not overlap.
+template <typename T>
+inline void CopyBytes(T* dst, T* src, int num_bytes) {
+ STATIC_ASSERT(sizeof(T) == 1);
+ ASSERT(Min(dst, src) + num_bytes <= Max(dst, src));
+ ASSERT(num_bytes >= 0);
+ if (num_bytes == 0) return;
+
+ // Use block copying memcpy if the segment we're copying is
+ // enough to justify the extra call/setup overhead.
+ static const int kBlockCopyLimit = OS::kMinComplexMemCopy;
+
+ if (num_bytes >= kBlockCopyLimit) {
+ OS::MemCopy(dst, src, num_bytes);
+ } else {
+ int remaining = num_bytes;
+ do {
+ remaining--;
+ *dst++ = *src++;
+ } while (remaining > 0);
+ }
+}
+
+
template <typename T, typename U>
inline void MemsetPointer(T** dest, U* value, int counter) {
#ifdef DEBUG
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698