Index: src/runtime/runtime-utils.h |
diff --git a/src/runtime/runtime-utils.h b/src/runtime/runtime-utils.h |
index 147efed092a742724f66013147e76ee4d1b66d0f..3452bfe073b2eaa296c71c95875ec5101e9464a4 100644 |
--- a/src/runtime/runtime-utils.h |
+++ b/src/runtime/runtime-utils.h |
@@ -6,6 +6,7 @@ |
#define V8_RUNTIME_RUNTIME_UTILS_H_ |
#include "src/base/logging.h" |
+#include "src/globals.h" |
#include "src/runtime/runtime.h" |
namespace v8 { |
@@ -167,6 +168,36 @@ static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { |
return result; |
} |
+const uintptr_t kOneInEveryByte = kUintptrAllBitsSet / 0xFF; |
+const uintptr_t kAsciiMask = kOneInEveryByte << 7; |
+ |
+// Given a word and two range boundaries returns a word with high bit |
+// set in every byte iff the corresponding input byte was strictly in |
+// the range (m, n). All the other bits in the result are cleared. |
+// This function is only useful when it can be inlined and the |
+// boundaries are statically known. |
+// Requires: all bytes in the input word and the boundaries must be |
+// ASCII (less than 0x7F). |
+static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) { |
+ // Use strict inequalities since in edge cases the function could be |
+ // further simplified. |
+ DCHECK(0 < m && m < n); |
+ // Has high bit set in every w byte less than n. |
+ uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; |
+ // Has high bit set in every w byte greater than m. |
+ uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); |
+ return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); |
+} |
+ |
+#ifdef DEBUG |
+bool CheckFastAsciiConvert(char* dst, const char* src, int length, bool changed, |
+ bool is_to_lower); |
+#endif |
+ |
+template <bool is_lower> |
+bool FastAsciiConvert(char* dst, const char* src, int length, |
+ bool* changed_out); |
+ |
} // namespace internal |
} // namespace v8 |