Index: src/utils.h |
diff --git a/src/utils.h b/src/utils.h |
index 2cad4c12e4a8f93ee46cd4d2214b8583d8f09dbb..deab09fb1193215b6d4dd06f910d2da3256a24ba 100644 |
--- a/src/utils.h |
+++ b/src/utils.h |
@@ -572,6 +572,30 @@ static inline int CompareChars(const lchar* lhs, const rchar* rhs, int chars) { |
} |
+template <typename T> |
+static inline void MemsetPointer(T** dest, T* value, int counter) { |
+#if defined(V8_HOST_ARCH_IA32) |
+#define STOS "stosl" |
+#elif defined(V8_HOST_ARCH_X64) |
+#define STOS "stosq" |
+#endif |
+ |
+#if defined(__GNUC__) && defined(STOS) |
+ asm("cld;" |
+ "rep ; " STOS |
+ : /* no output */ |
+ : "c" (counter), "a" (value), "D" (dest) |
+ : /* no clobbered list as all inputs are considered clobbered */); |
+#else |
+ for (int i = 0; i < counter; i++) { |
+ dest[i] = value; |
+ } |
+#endif |
+ |
+#undef STOS |
+} |
+ |
+ |
// Calculate 10^exponent. |
int TenToThe(int exponent); |