OLD | NEW |
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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 | 1203 |
1204 // Write the C code | 1204 // Write the C code |
1205 // const char* <varname> = "<str>"; | 1205 // const char* <varname> = "<str>"; |
1206 // const int <varname>_len = <len>; | 1206 // const int <varname>_len = <len>; |
1207 // to the file given by filename. Only the first len chars are written. | 1207 // to the file given by filename. Only the first len chars are written. |
1208 int WriteAsCFile(const char* filename, const char* varname, | 1208 int WriteAsCFile(const char* filename, const char* varname, |
1209 const char* str, int size, bool verbose = true); | 1209 const char* str, int size, bool verbose = true); |
1210 | 1210 |
1211 | 1211 |
1212 // ---------------------------------------------------------------------------- | 1212 // ---------------------------------------------------------------------------- |
1213 // Data structures | |
1214 | |
1215 template <typename T> | |
1216 inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms, | |
1217 int length) { | |
1218 return Vector< Handle<Object> >( | |
1219 reinterpret_cast<v8::internal::Handle<Object>*>(elms), length); | |
1220 } | |
1221 | |
1222 | |
1223 // ---------------------------------------------------------------------------- | |
1224 // Memory | 1213 // Memory |
1225 | 1214 |
1226 // Copies words from |src| to |dst|. The data spans must not overlap. | 1215 // Copies words from |src| to |dst|. The data spans must not overlap. |
1227 template <typename T> | 1216 template <typename T> |
1228 inline void CopyWords(T* dst, const T* src, size_t num_words) { | 1217 inline void CopyWords(T* dst, const T* src, size_t num_words) { |
1229 STATIC_ASSERT(sizeof(T) == kPointerSize); | 1218 STATIC_ASSERT(sizeof(T) == kPointerSize); |
1230 // TODO(mvstanton): disabled because mac builds are bogus failing on this | 1219 // TODO(mvstanton): disabled because mac builds are bogus failing on this |
1231 // assert. They are doing a signed comparison. Investigate in | 1220 // assert. They are doing a signed comparison. Investigate in |
1232 // the morning. | 1221 // the morning. |
1233 // DCHECK(Min(dst, const_cast<T*>(src)) + num_words <= | 1222 // DCHECK(Min(dst, const_cast<T*>(src)) + num_words <= |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); | 1737 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); |
1749 *ptr = c.u[0]; | 1738 *ptr = c.u[0]; |
1750 *(ptr + 1) = c.u[1]; | 1739 *(ptr + 1) = c.u[1]; |
1751 #endif // V8_TARGET_ARCH_MIPS | 1740 #endif // V8_TARGET_ARCH_MIPS |
1752 } | 1741 } |
1753 | 1742 |
1754 } // namespace internal | 1743 } // namespace internal |
1755 } // namespace v8 | 1744 } // namespace v8 |
1756 | 1745 |
1757 #endif // V8_UTILS_H_ | 1746 #endif // V8_UTILS_H_ |
OLD | NEW |