Chromium Code Reviews| 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 class FreeStoreAllocationPolicy; | 220 class FreeStoreAllocationPolicy; |
| 221 template <typename T, class P = FreeStoreAllocationPolicy> class List; | 221 template <typename T, class P = FreeStoreAllocationPolicy> class List; |
| 222 | 222 |
| 223 // ----------------------------------------------------------------------------- | 223 // ----------------------------------------------------------------------------- |
| 224 // Declarations for use in both the preparser and the rest of V8. | 224 // Declarations for use in both the preparser and the rest of V8. |
| 225 | 225 |
| 226 // The Strict Mode (ECMA-262 5th edition, 4.2.2). | 226 // The Strict Mode (ECMA-262 5th edition, 4.2.2). |
| 227 | 227 |
| 228 enum LanguageMode { | 228 enum LanguageMode { |
| 229 // LanguageMode is expressed as a bitmask. Descriptions of the bits: | 229 // LanguageMode is expressed as a bitmask. Descriptions of the bits: |
| 230 STRICT = 1 << 0, | 230 STRICT_BIT = 1 << 0, |
| 231 SANE_BIT = 1 << 1, | |
| 231 LANGUAGE_END, | 232 LANGUAGE_END, |
| 232 | 233 |
| 233 // Shorthands for some common language modes. | 234 // Shorthands for some common language modes. |
| 234 SLOPPY = 0 | 235 SLOPPY = 0, |
| 236 STRICT = STRICT_BIT, | |
| 237 SANE = STRICT_BIT | SANE_BIT | |
| 235 }; | 238 }; |
| 236 | 239 |
| 237 inline bool is_strict(LanguageMode language_mode) { | 240 inline bool is_strict(LanguageMode language_mode) { |
| 238 return language_mode & STRICT; | 241 return language_mode & STRICT_BIT; |
| 239 } | 242 } |
| 240 | 243 |
| 244 | |
| 241 inline bool is_sloppy(LanguageMode language_mode) { | 245 inline bool is_sloppy(LanguageMode language_mode) { |
|
rossberg
2015/02/04 16:18:08
Nit: perhaps reorder methods.
marja
2015/02/05 12:11:37
Done.
| |
| 242 return (language_mode & STRICT) == 0; | 246 return (language_mode & STRICT_BIT) == 0; |
| 243 } | 247 } |
| 244 | 248 |
| 249 | |
| 250 inline bool is_sane(LanguageMode language_mode) { | |
| 251 return language_mode & SANE_BIT; | |
| 252 } | |
| 253 | |
| 254 | |
| 245 inline bool is_valid_language_mode(int language_mode) { | 255 inline bool is_valid_language_mode(int language_mode) { |
| 246 return language_mode == SLOPPY || language_mode == STRICT; | 256 return language_mode == SLOPPY || language_mode == STRICT || |
| 257 language_mode == SANE; | |
| 247 } | 258 } |
| 248 | 259 |
| 260 | |
| 261 inline LanguageMode construct_language_mode(bool strict_bit, bool sane_bit) { | |
| 262 int language_mode = 0; | |
| 263 if (strict_bit) language_mode |= STRICT_BIT; | |
| 264 if (sane_bit) language_mode |= SANE_BIT; | |
| 265 DCHECK(is_valid_language_mode(language_mode)); | |
| 266 return static_cast<LanguageMode>(language_mode); | |
| 267 } | |
| 268 | |
| 269 | |
| 249 // Mask for the sign bit in a smi. | 270 // Mask for the sign bit in a smi. |
| 250 const intptr_t kSmiSignMask = kIntptrSignBit; | 271 const intptr_t kSmiSignMask = kIntptrSignBit; |
| 251 | 272 |
| 252 const int kObjectAlignmentBits = kPointerSizeLog2; | 273 const int kObjectAlignmentBits = kPointerSizeLog2; |
| 253 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; | 274 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; |
| 254 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; | 275 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; |
| 255 | 276 |
| 256 // Desired alignment for pointers. | 277 // Desired alignment for pointers. |
| 257 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); | 278 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); |
| 258 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; | 279 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 | 858 |
| 838 inline bool IsSubclassConstructor(FunctionKind kind) { | 859 inline bool IsSubclassConstructor(FunctionKind kind) { |
| 839 DCHECK(IsValidFunctionKind(kind)); | 860 DCHECK(IsValidFunctionKind(kind)); |
| 840 return kind & FunctionKind::kSubclassConstructor; | 861 return kind & FunctionKind::kSubclassConstructor; |
| 841 } | 862 } |
| 842 } } // namespace v8::internal | 863 } } // namespace v8::internal |
| 843 | 864 |
| 844 namespace i = v8::internal; | 865 namespace i = v8::internal; |
| 845 | 866 |
| 846 #endif // V8_GLOBALS_H_ | 867 #endif // V8_GLOBALS_H_ |
| OLD | NEW |