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

Side by Side Diff: src/globals.h

Issue 1773653002: [strong] Remove all remainders of strong mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // (sorted alphabetically) 236 // (sorted alphabetically)
237 237
238 class FreeStoreAllocationPolicy; 238 class FreeStoreAllocationPolicy;
239 template <typename T, class P = FreeStoreAllocationPolicy> class List; 239 template <typename T, class P = FreeStoreAllocationPolicy> class List;
240 240
241 // ----------------------------------------------------------------------------- 241 // -----------------------------------------------------------------------------
242 // Declarations for use in both the preparser and the rest of V8. 242 // Declarations for use in both the preparser and the rest of V8.
243 243
244 // The Strict Mode (ECMA-262 5th edition, 4.2.2). 244 // The Strict Mode (ECMA-262 5th edition, 4.2.2).
245 245
246 enum LanguageMode { 246 enum LanguageMode { SLOPPY, STRICT, LANGUAGE_END = 3 };
Michael Starzinger 2016/03/08 10:53:45 As discussed offline: A nice follow-up to this CL
247 // LanguageMode is expressed as a bitmask. Descriptions of the bits:
248 STRICT_BIT = 1 << 0,
249 STRONG_BIT = 1 << 1,
250 LANGUAGE_END,
251
252 // Shorthands for some common language modes.
253 SLOPPY = 0,
254 STRICT = STRICT_BIT,
255 STRONG = STRICT_BIT | STRONG_BIT
256 };
257 247
258 248
259 inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) { 249 inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) {
260 switch (mode) { 250 switch (mode) {
261 case SLOPPY: 251 case SLOPPY: return os << "sloppy";
262 return os << "sloppy"; 252 case STRICT: return os << "strict";
263 case STRICT: 253 default: UNREACHABLE();
264 return os << "strict";
265 case STRONG:
266 return os << "strong";
267 default:
268 return os << "unknown";
269 } 254 }
270 } 255 }
271 256
272 257
273 inline bool is_sloppy(LanguageMode language_mode) { 258 inline bool is_sloppy(LanguageMode language_mode) {
274 return (language_mode & STRICT_BIT) == 0; 259 return language_mode == SLOPPY;
275 } 260 }
276 261
277 262
278 inline bool is_strict(LanguageMode language_mode) { 263 inline bool is_strict(LanguageMode language_mode) {
279 return language_mode & STRICT_BIT; 264 return language_mode != SLOPPY;
280 }
281
282
283 inline bool is_strong(LanguageMode language_mode) {
284 return language_mode & STRONG_BIT;
285 } 265 }
286 266
287 267
288 inline bool is_valid_language_mode(int language_mode) { 268 inline bool is_valid_language_mode(int language_mode) {
289 return language_mode == SLOPPY || language_mode == STRICT || 269 return language_mode == SLOPPY || language_mode == STRICT;
290 language_mode == STRONG;
291 } 270 }
292 271
293 272
294 inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) { 273 inline LanguageMode construct_language_mode(bool strict_bit) {
295 int language_mode = 0; 274 return static_cast<LanguageMode>(strict_bit);
296 if (strict_bit) language_mode |= STRICT_BIT;
297 if (strong_bit) language_mode |= STRONG_BIT;
298 DCHECK(is_valid_language_mode(language_mode));
299 return static_cast<LanguageMode>(language_mode);
300 } 275 }
301 276
302 277
303 // Mask for the sign bit in a smi. 278 // Mask for the sign bit in a smi.
304 const intptr_t kSmiSignMask = kIntptrSignBit; 279 const intptr_t kSmiSignMask = kIntptrSignBit;
305 280
306 const int kObjectAlignmentBits = kPointerSizeLog2; 281 const int kObjectAlignmentBits = kPointerSizeLog2;
307 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits; 282 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
308 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; 283 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
309 284
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 DCHECK(IsValidFunctionKind(kind)); 1002 DCHECK(IsValidFunctionKind(kind));
1028 return kind & FunctionKind::kClassConstructor; 1003 return kind & FunctionKind::kClassConstructor;
1029 } 1004 }
1030 1005
1031 1006
1032 inline bool IsConstructable(FunctionKind kind, LanguageMode mode) { 1007 inline bool IsConstructable(FunctionKind kind, LanguageMode mode) {
1033 if (IsAccessorFunction(kind)) return false; 1008 if (IsAccessorFunction(kind)) return false;
1034 if (IsConciseMethod(kind)) return false; 1009 if (IsConciseMethod(kind)) return false;
1035 if (IsArrowFunction(kind)) return false; 1010 if (IsArrowFunction(kind)) return false;
1036 if (IsGeneratorFunction(kind)) return false; 1011 if (IsGeneratorFunction(kind)) return false;
1037 if (is_strong(mode)) return IsClassConstructor(kind);
1038 return true; 1012 return true;
1039 } 1013 }
1040 1014
1041 1015
1042 inline uint32_t ObjectHash(Address address) { 1016 inline uint32_t ObjectHash(Address address) {
1043 // All objects are at least pointer aligned, so we can remove the trailing 1017 // All objects are at least pointer aligned, so we can remove the trailing
1044 // zeros. 1018 // zeros.
1045 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> 1019 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >>
1046 kPointerSizeLog2); 1020 kPointerSizeLog2);
1047 } 1021 }
1048 1022
1049 } // namespace internal 1023 } // namespace internal
1050 } // namespace v8 1024 } // namespace v8
1051 1025
1052 namespace i = v8::internal; 1026 namespace i = v8::internal;
1053 1027
1054 #endif // V8_GLOBALS_H_ 1028 #endif // V8_GLOBALS_H_
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/heap-symbols.h » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698