| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_RUNTIME_RUNTIME_UTILS_H_ | 5 #ifndef V8_RUNTIME_RUNTIME_UTILS_H_ |
| 6 #define V8_RUNTIME_RUNTIME_UTILS_H_ | 6 #define V8_RUNTIME_RUNTIME_UTILS_H_ |
| 7 | 7 |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/globals.h" |
| 9 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 // Cast the given object to a value of the specified type and store | 15 // Cast the given object to a value of the specified type and store |
| 15 // it in a variable with the given name. If the object is not of the | 16 // it in a variable with the given name. If the object is not of the |
| 16 // expected type we crash safely. | 17 // expected type we crash safely. |
| 17 #define CONVERT_ARG_CHECKED(Type, name, index) \ | 18 #define CONVERT_ARG_CHECKED(Type, name, index) \ |
| 18 CHECK(args[index]->Is##Type()); \ | 19 CHECK(args[index]->Is##Type()); \ |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 Object* y; | 161 Object* y; |
| 161 Object* z; | 162 Object* z; |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { | 165 static inline ObjectTriple MakeTriple(Object* x, Object* y, Object* z) { |
| 165 ObjectTriple result = {x, y, z}; | 166 ObjectTriple result = {x, y, z}; |
| 166 // ObjectTriple is assigned to a hidden first argument. | 167 // ObjectTriple is assigned to a hidden first argument. |
| 167 return result; | 168 return result; |
| 168 } | 169 } |
| 169 | 170 |
| 171 const uintptr_t kOneInEveryByte = kUintptrAllBitsSet / 0xFF; |
| 172 const uintptr_t kAsciiMask = kOneInEveryByte << 7; |
| 173 |
| 174 // Given a word and two range boundaries returns a word with high bit |
| 175 // set in every byte iff the corresponding input byte was strictly in |
| 176 // the range (m, n). All the other bits in the result are cleared. |
| 177 // This function is only useful when it can be inlined and the |
| 178 // boundaries are statically known. |
| 179 // Requires: all bytes in the input word and the boundaries must be |
| 180 // ASCII (less than 0x7F). |
| 181 static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) { |
| 182 // Use strict inequalities since in edge cases the function could be |
| 183 // further simplified. |
| 184 DCHECK(0 < m && m < n); |
| 185 // Has high bit set in every w byte less than n. |
| 186 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; |
| 187 // Has high bit set in every w byte greater than m. |
| 188 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); |
| 189 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); |
| 190 } |
| 191 |
| 192 #ifdef DEBUG |
| 193 bool CheckFastAsciiConvert(char* dst, const char* src, int length, bool changed, |
| 194 bool is_to_lower); |
| 195 #endif |
| 196 |
| 197 template <bool is_lower> |
| 198 bool FastAsciiConvert(char* dst, const char* src, int length, |
| 199 bool* changed_out); |
| 200 |
| 170 } // namespace internal | 201 } // namespace internal |
| 171 } // namespace v8 | 202 } // namespace v8 |
| 172 | 203 |
| 173 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ | 204 #endif // V8_RUNTIME_RUNTIME_UTILS_H_ |
| OLD | NEW |