Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: src/globals.h

Issue 898983002: Add strong mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code review + fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 STRONG_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 STRONG = STRICT_BIT | STRONG_BIT
235 }; 238 };
236 239
237 inline bool is_strict(LanguageMode language_mode) { 240
238 return language_mode & STRICT; 241 inline bool is_sloppy(LanguageMode language_mode) {
242 return (language_mode & STRICT_BIT) == 0;
239 } 243 }
240 244
241 inline bool is_sloppy(LanguageMode language_mode) { 245
242 return (language_mode & STRICT) == 0; 246 inline bool is_strict(LanguageMode language_mode) {
247 return language_mode & STRICT_BIT;
243 } 248 }
244 249
250
251 inline bool is_strong(LanguageMode language_mode) {
252 return language_mode & STRONG_BIT;
253 }
254
255
245 inline bool is_valid_language_mode(int language_mode) { 256 inline bool is_valid_language_mode(int language_mode) {
246 return language_mode == SLOPPY || language_mode == STRICT; 257 return language_mode == SLOPPY || language_mode == STRICT ||
258 language_mode == STRONG;
247 } 259 }
248 260
261
262 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) {
263 int language_mode = 0;
264 if (strict_bit) language_mode |= STRICT_BIT;
265 if (strong_bit) language_mode |= STRONG_BIT;
266 DCHECK(is_valid_language_mode(language_mode));
267 return static_cast<LanguageMode>(language_mode);
268 }
269
270
249 // Mask for the sign bit in a smi. 271 // Mask for the sign bit in a smi.
250 const intptr_t kSmiSignMask = kIntptrSignBit; 272 const intptr_t kSmiSignMask = kIntptrSignBit;
251 273
252 const int kObjectAlignmentBits = kPointerSizeLog2; 274 const int kObjectAlignmentBits = kPointerSizeLog2;
253 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; 275 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
254 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; 276 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
255 277
256 // Desired alignment for pointers. 278 // Desired alignment for pointers.
257 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); 279 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
258 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; 280 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 859
838 inline bool IsSubclassConstructor(FunctionKind kind) { 860 inline bool IsSubclassConstructor(FunctionKind kind) {
839 DCHECK(IsValidFunctionKind(kind)); 861 DCHECK(IsValidFunctionKind(kind));
840 return kind & FunctionKind::kSubclassConstructor; 862 return kind & FunctionKind::kSubclassConstructor;
841 } 863 }
842 } } // namespace v8::internal 864 } } // namespace v8::internal
843 865
844 namespace i = v8::internal; 866 namespace i = v8::internal;
845 867
846 #endif // V8_GLOBALS_H_ 868 #endif // V8_GLOBALS_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698