| 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_GLOBALS_H_ | 5 #ifndef V8_GLOBALS_H_ |
| 6 #define V8_GLOBALS_H_ | 6 #define V8_GLOBALS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { | 294 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { |
| 295 int language_mode = 0; | 295 int language_mode = 0; |
| 296 if (strict_bit) language_mode |= STRICT_BIT; | 296 if (strict_bit) language_mode |= STRICT_BIT; |
| 297 if (strong_bit) language_mode |= STRONG_BIT; | 297 if (strong_bit) language_mode |= STRONG_BIT; |
| 298 DCHECK(is_valid_language_mode(language_mode)); | 298 DCHECK(is_valid_language_mode(language_mode)); |
| 299 return static_cast<LanguageMode>(language_mode); | 299 return static_cast<LanguageMode>(language_mode); |
| 300 } | 300 } |
| 301 | 301 |
| 302 | 302 |
| 303 // Strong mode behaviour must sometimes be signalled by a two valued enum where | |
| 304 // caching is involved, to prevent sloppy and strict mode from being incorrectly | |
| 305 // differentiated. | |
| 306 enum class Strength : bool { | |
| 307 WEAK, // sloppy, strict behaviour | |
| 308 STRONG // strong behaviour | |
| 309 }; | |
| 310 | |
| 311 | |
| 312 inline bool is_strong(Strength strength) { | |
| 313 return strength == Strength::STRONG; | |
| 314 } | |
| 315 | |
| 316 | |
| 317 inline std::ostream& operator<<(std::ostream& os, const Strength& strength) { | |
| 318 return os << (is_strong(strength) ? "strong" : "weak"); | |
| 319 } | |
| 320 | |
| 321 | |
| 322 inline Strength strength(LanguageMode language_mode) { | |
| 323 return is_strong(language_mode) ? Strength::STRONG : Strength::WEAK; | |
| 324 } | |
| 325 | |
| 326 | |
| 327 inline size_t hash_value(Strength strength) { | |
| 328 return static_cast<size_t>(strength); | |
| 329 } | |
| 330 | |
| 331 | |
| 332 // Mask for the sign bit in a smi. | 303 // Mask for the sign bit in a smi. |
| 333 const intptr_t kSmiSignMask = kIntptrSignBit; | 304 const intptr_t kSmiSignMask = kIntptrSignBit; |
| 334 | 305 |
| 335 const int kObjectAlignmentBits = kPointerSizeLog2; | 306 const int kObjectAlignmentBits = kPointerSizeLog2; |
| 336 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; | 307 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 337 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; | 308 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 338 | 309 |
| 339 // Desired alignment for pointers. | 310 // Desired alignment for pointers. |
| 340 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); | 311 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 341 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; | 312 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> | 1051 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> |
| 1081 kPointerSizeLog2); | 1052 kPointerSizeLog2); |
| 1082 } | 1053 } |
| 1083 | 1054 |
| 1084 } // namespace internal | 1055 } // namespace internal |
| 1085 } // namespace v8 | 1056 } // namespace v8 |
| 1086 | 1057 |
| 1087 namespace i = v8::internal; | 1058 namespace i = v8::internal; |
| 1088 | 1059 |
| 1089 #endif // V8_GLOBALS_H_ | 1060 #endif // V8_GLOBALS_H_ |
| OLD | NEW |