| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 template <typename T> | 116 template <typename T> |
| 117 inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms, | 117 inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms, |
| 118 int length) { | 118 int length) { |
| 119 return Vector< Handle<Object> >( | 119 return Vector< Handle<Object> >( |
| 120 reinterpret_cast<v8::internal::Handle<Object>*>(elms), length); | 120 reinterpret_cast<v8::internal::Handle<Object>*>(elms), length); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Memory | 123 // Memory |
| 124 | 124 |
| 125 // Copies data from |src| to |dst|. The data spans MUST not overlap. | 125 // Copies data from |src| to |dst|. The data spans must not overlap. |
| 126 template <typename T> | 126 template <typename T> |
| 127 inline void CopyWords(T* dst, T* src, int num_words) { | 127 inline void CopyWords(T* dst, T* src, int num_words) { |
| 128 STATIC_ASSERT(sizeof(T) == kPointerSize); | 128 STATIC_ASSERT(sizeof(T) == kPointerSize); |
| 129 ASSERT(Min(dst, src) + num_words <= Max(dst, src)); | 129 ASSERT(Min(dst, src) + num_words <= Max(dst, src)); |
| 130 ASSERT(num_words > 0); | 130 ASSERT(num_words > 0); |
| 131 | 131 |
| 132 // Use block copying memcpy if the segment we're copying is | 132 // Use block copying memcpy if the segment we're copying is |
| 133 // enough to justify the extra call/setup overhead. | 133 // enough to justify the extra call/setup overhead. |
| 134 static const int kBlockCopyLimit = 16; | 134 static const int kBlockCopyLimit = 16; |
| 135 | 135 |
| 136 if (num_words >= kBlockCopyLimit) { | 136 if (num_words >= kBlockCopyLimit) { |
| 137 memcpy(dst, src, num_words * kPointerSize); | 137 memcpy(dst, src, num_words * kPointerSize); |
| 138 } else { | 138 } else { |
| 139 int remaining = num_words; | 139 int remaining = num_words; |
| 140 do { | 140 do { |
| 141 remaining--; | 141 remaining--; |
| 142 *dst++ = *src++; | 142 *dst++ = *src++; |
| 143 } while (remaining > 0); | 143 } while (remaining > 0); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 // Copies data from |src| to |dst|. The data spans must not overlap. |
| 149 template <typename T> |
| 150 inline void CopyBytes(T* dst, T* src, int num_bytes) { |
| 151 STATIC_ASSERT(sizeof(T) == 1); |
| 152 ASSERT(Min(dst, src) + num_bytes <= Max(dst, src)); |
| 153 ASSERT(num_bytes >= 0); |
| 154 if (num_bytes == 0) return; |
| 155 |
| 156 // Use block copying memcpy if the segment we're copying is |
| 157 // enough to justify the extra call/setup overhead. |
| 158 static const int kBlockCopyLimit = OS::kMinComplexMemCopy; |
| 159 |
| 160 if (num_bytes >= kBlockCopyLimit) { |
| 161 OS::MemCopy(dst, src, num_bytes); |
| 162 } else { |
| 163 int remaining = num_bytes; |
| 164 do { |
| 165 remaining--; |
| 166 *dst++ = *src++; |
| 167 } while (remaining > 0); |
| 168 } |
| 169 } |
| 170 |
| 171 |
| 148 template <typename T, typename U> | 172 template <typename T, typename U> |
| 149 inline void MemsetPointer(T** dest, U* value, int counter) { | 173 inline void MemsetPointer(T** dest, U* value, int counter) { |
| 150 #ifdef DEBUG | 174 #ifdef DEBUG |
| 151 T* a = NULL; | 175 T* a = NULL; |
| 152 U* b = NULL; | 176 U* b = NULL; |
| 153 a = b; // Fake assignment to check assignability. | 177 a = b; // Fake assignment to check assignability. |
| 154 USE(a); | 178 USE(a); |
| 155 #endif // DEBUG | 179 #endif // DEBUG |
| 156 #if defined(V8_HOST_ARCH_IA32) | 180 #if defined(V8_HOST_ARCH_IA32) |
| 157 #define STOS "stosl" | 181 #define STOS "stosl" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 298 |
| 275 // Add formatted contents like printf based on a va_list. | 299 // Add formatted contents like printf based on a va_list. |
| 276 void AddFormattedList(const char* format, va_list list); | 300 void AddFormattedList(const char* format, va_list list); |
| 277 private: | 301 private: |
| 278 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 302 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
| 279 }; | 303 }; |
| 280 | 304 |
| 281 } } // namespace v8::internal | 305 } } // namespace v8::internal |
| 282 | 306 |
| 283 #endif // V8_V8UTILS_H_ | 307 #endif // V8_V8UTILS_H_ |
| OLD | NEW |