| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 STRONG_BIT = 1 << 1, | 246 STRONG_BIT = 1 << 1, |
| 247 LANGUAGE_END, | 247 LANGUAGE_END, |
| 248 | 248 |
| 249 // Shorthands for some common language modes. | 249 // Shorthands for some common language modes. |
| 250 SLOPPY = 0, | 250 SLOPPY = 0, |
| 251 STRICT = STRICT_BIT, | 251 STRICT = STRICT_BIT, |
| 252 STRONG = STRICT_BIT | STRONG_BIT | 252 STRONG = STRICT_BIT | STRONG_BIT |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 | 255 |
| 256 enum AsmMode { |
| 257 ASM_FUNCTION_BIT = 1 << 0, |
| 258 ASM_MODULE_BIT = 1 << 1, |
| 259 ASM_END, |
| 260 |
| 261 ASM_NO = 0, |
| 262 ASM_FUNCTION = ASM_FUNCTION_BIT, |
| 263 ASM_MODULE = ASM_MODULE_BIT |
| 264 }; |
| 265 |
| 266 |
| 256 inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) { | 267 inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) { |
| 257 switch (mode) { | 268 switch (mode) { |
| 258 case SLOPPY: | 269 case SLOPPY: |
| 259 return os << "sloppy"; | 270 return os << "sloppy"; |
| 260 case STRICT: | 271 case STRICT: |
| 261 return os << "strict"; | 272 return os << "strict"; |
| 262 case STRONG: | 273 case STRONG: |
| 263 return os << "strong"; | 274 return os << "strong"; |
| 264 default: | 275 default: |
| 265 return os << "unknown"; | 276 return os << "unknown"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 290 | 301 |
| 291 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { | 302 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { |
| 292 int language_mode = 0; | 303 int language_mode = 0; |
| 293 if (strict_bit) language_mode |= STRICT_BIT; | 304 if (strict_bit) language_mode |= STRICT_BIT; |
| 294 if (strong_bit) language_mode |= STRONG_BIT; | 305 if (strong_bit) language_mode |= STRONG_BIT; |
| 295 DCHECK(is_valid_language_mode(language_mode)); | 306 DCHECK(is_valid_language_mode(language_mode)); |
| 296 return static_cast<LanguageMode>(language_mode); | 307 return static_cast<LanguageMode>(language_mode); |
| 297 } | 308 } |
| 298 | 309 |
| 299 | 310 |
| 311 inline bool is_valid_asm_mode(int asm_mode) { |
| 312 return asm_mode == ASM_NO || asm_mode == ASM_FUNCTION || |
| 313 asm_mode == ASM_MODULE; |
| 314 } |
| 315 |
| 316 |
| 317 inline AsmMode construct_asm_mode(bool asm_function, bool asm_module) { |
| 318 int asm_mode = 0; |
| 319 if (asm_function) asm_mode |= ASM_FUNCTION_BIT; |
| 320 if (asm_module) asm_mode |= ASM_MODULE_BIT; |
| 321 DCHECK(is_valid_asm_mode(asm_mode)); |
| 322 return static_cast<AsmMode>(asm_mode); |
| 323 } |
| 324 |
| 325 |
| 300 inline ObjectStrength strength(LanguageMode language_mode) { | 326 inline ObjectStrength strength(LanguageMode language_mode) { |
| 301 return is_strong(language_mode) ? FIRM : WEAK; | 327 return is_strong(language_mode) ? FIRM : WEAK; |
| 302 } | 328 } |
| 303 | 329 |
| 304 | 330 |
| 305 // Mask for the sign bit in a smi. | 331 // Mask for the sign bit in a smi. |
| 306 const intptr_t kSmiSignMask = kIntptrSignBit; | 332 const intptr_t kSmiSignMask = kIntptrSignBit; |
| 307 | 333 |
| 308 const int kObjectAlignmentBits = kPointerSizeLog2; | 334 const int kObjectAlignmentBits = kPointerSizeLog2; |
| 309 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; | 335 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 inline FunctionKind WithObjectLiteralBit(FunctionKind kind) { | 996 inline FunctionKind WithObjectLiteralBit(FunctionKind kind) { |
| 971 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral); | 997 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral); |
| 972 DCHECK(IsValidFunctionKind(kind)); | 998 DCHECK(IsValidFunctionKind(kind)); |
| 973 return kind; | 999 return kind; |
| 974 } | 1000 } |
| 975 } } // namespace v8::internal | 1001 } } // namespace v8::internal |
| 976 | 1002 |
| 977 namespace i = v8::internal; | 1003 namespace i = v8::internal; |
| 978 | 1004 |
| 979 #endif // V8_GLOBALS_H_ | 1005 #endif // V8_GLOBALS_H_ |
| OLD | NEW |