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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // ----------------------------------------------------------------------------- | 220 // ----------------------------------------------------------------------------- |
221 // Forward declarations for frequently used classes | 221 // Forward declarations for frequently used classes |
222 // (sorted alphabetically) | 222 // (sorted alphabetically) |
223 | 223 |
224 class FreeStoreAllocationPolicy; | 224 class FreeStoreAllocationPolicy; |
225 template <typename T, class P = FreeStoreAllocationPolicy> class List; | 225 template <typename T, class P = FreeStoreAllocationPolicy> class List; |
226 | 226 |
227 // ----------------------------------------------------------------------------- | 227 // ----------------------------------------------------------------------------- |
228 // Declarations for use in both the preparser and the rest of V8. | 228 // Declarations for use in both the preparser and the rest of V8. |
229 | 229 |
230 enum ObjectStrength { | |
231 WEAK, | |
232 FIRM // strong object | |
233 }; | |
234 | |
235 // The Strict Mode (ECMA-262 5th edition, 4.2.2). | 230 // The Strict Mode (ECMA-262 5th edition, 4.2.2). |
236 | 231 |
237 enum LanguageMode { | 232 enum LanguageMode { |
238 // LanguageMode is expressed as a bitmask. Descriptions of the bits: | 233 // LanguageMode is expressed as a bitmask. Descriptions of the bits: |
239 STRICT_BIT = 1 << 0, | 234 STRICT_BIT = 1 << 0, |
240 STRONG_BIT = 1 << 1, | 235 STRONG_BIT = 1 << 1, |
241 LANGUAGE_END, | 236 LANGUAGE_END, |
242 | 237 |
243 // Shorthands for some common language modes. | 238 // Shorthands for some common language modes. |
244 SLOPPY = 0, | 239 SLOPPY = 0, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 279 |
285 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { | 280 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { |
286 int language_mode = 0; | 281 int language_mode = 0; |
287 if (strict_bit) language_mode |= STRICT_BIT; | 282 if (strict_bit) language_mode |= STRICT_BIT; |
288 if (strong_bit) language_mode |= STRONG_BIT; | 283 if (strong_bit) language_mode |= STRONG_BIT; |
289 DCHECK(is_valid_language_mode(language_mode)); | 284 DCHECK(is_valid_language_mode(language_mode)); |
290 return static_cast<LanguageMode>(language_mode); | 285 return static_cast<LanguageMode>(language_mode); |
291 } | 286 } |
292 | 287 |
293 | 288 |
294 inline ObjectStrength strength(LanguageMode language_mode) { | 289 enum class Strength : bool { |
295 return is_strong(language_mode) ? FIRM : WEAK; | 290 WEAK, |
| 291 FIRM // strong behaviour |
| 292 }; |
| 293 |
| 294 |
| 295 inline bool is_strong(Strength strength) { return strength == Strength::FIRM; } |
| 296 |
| 297 |
| 298 inline std::ostream& operator<<(std::ostream& os, const Strength& strength) { |
| 299 return os << (is_strong(strength) ? "firm" : "weak"); |
296 } | 300 } |
297 | 301 |
298 | 302 |
| 303 inline Strength strength(LanguageMode language_mode) { |
| 304 return is_strong(language_mode) ? Strength::FIRM : Strength::WEAK; |
| 305 } |
| 306 |
| 307 |
| 308 inline size_t hash_value(Strength strength) { |
| 309 return static_cast<size_t>(strength); |
| 310 } |
| 311 |
| 312 |
299 // Mask for the sign bit in a smi. | 313 // Mask for the sign bit in a smi. |
300 const intptr_t kSmiSignMask = kIntptrSignBit; | 314 const intptr_t kSmiSignMask = kIntptrSignBit; |
301 | 315 |
302 const int kObjectAlignmentBits = kPointerSizeLog2; | 316 const int kObjectAlignmentBits = kPointerSizeLog2; |
303 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; | 317 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
304 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; | 318 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
305 | 319 |
306 // Desired alignment for pointers. | 320 // Desired alignment for pointers. |
307 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); | 321 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
308 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; | 322 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 inline FunctionKind WithObjectLiteralBit(FunctionKind kind) { | 975 inline FunctionKind WithObjectLiteralBit(FunctionKind kind) { |
962 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral); | 976 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral); |
963 DCHECK(IsValidFunctionKind(kind)); | 977 DCHECK(IsValidFunctionKind(kind)); |
964 return kind; | 978 return kind; |
965 } | 979 } |
966 } } // namespace v8::internal | 980 } } // namespace v8::internal |
967 | 981 |
968 namespace i = v8::internal; | 982 namespace i = v8::internal; |
969 | 983 |
970 #endif // V8_GLOBALS_H_ | 984 #endif // V8_GLOBALS_H_ |
OLD | NEW |