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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 enum FunctionKind { | 977 enum FunctionKind { |
978 kNormalFunction = 0, | 978 kNormalFunction = 0, |
979 kArrowFunction = 1 << 0, | 979 kArrowFunction = 1 << 0, |
980 kGeneratorFunction = 1 << 1, | 980 kGeneratorFunction = 1 << 1, |
981 kConciseMethod = 1 << 2, | 981 kConciseMethod = 1 << 2, |
982 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, | 982 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, |
983 kAccessorFunction = 1 << 3, | 983 kAccessorFunction = 1 << 3, |
984 kDefaultConstructor = 1 << 4, | 984 kDefaultConstructor = 1 << 4, |
985 kSubclassConstructor = 1 << 5, | 985 kSubclassConstructor = 1 << 5, |
986 kBaseConstructor = 1 << 6, | 986 kBaseConstructor = 1 << 6, |
987 kInObjectLiteral = 1 << 7, | |
988 kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor, | 987 kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor, |
989 kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor, | 988 kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor, |
990 kClassConstructor = | 989 kClassConstructor = |
991 kBaseConstructor | kSubclassConstructor | kDefaultConstructor, | 990 kBaseConstructor | kSubclassConstructor | kDefaultConstructor, |
992 kConciseMethodInObjectLiteral = kConciseMethod | kInObjectLiteral, | |
993 kConciseGeneratorMethodInObjectLiteral = | |
994 kConciseGeneratorMethod | kInObjectLiteral, | |
995 kAccessorFunctionInObjectLiteral = kAccessorFunction | kInObjectLiteral, | |
996 }; | 991 }; |
997 | 992 |
998 | 993 |
999 inline bool IsValidFunctionKind(FunctionKind kind) { | 994 inline bool IsValidFunctionKind(FunctionKind kind) { |
1000 return kind == FunctionKind::kNormalFunction || | 995 return kind == FunctionKind::kNormalFunction || |
1001 kind == FunctionKind::kArrowFunction || | 996 kind == FunctionKind::kArrowFunction || |
1002 kind == FunctionKind::kGeneratorFunction || | 997 kind == FunctionKind::kGeneratorFunction || |
1003 kind == FunctionKind::kConciseMethod || | 998 kind == FunctionKind::kConciseMethod || |
1004 kind == FunctionKind::kConciseGeneratorMethod || | 999 kind == FunctionKind::kConciseGeneratorMethod || |
1005 kind == FunctionKind::kAccessorFunction || | 1000 kind == FunctionKind::kAccessorFunction || |
1006 kind == FunctionKind::kDefaultBaseConstructor || | 1001 kind == FunctionKind::kDefaultBaseConstructor || |
1007 kind == FunctionKind::kDefaultSubclassConstructor || | 1002 kind == FunctionKind::kDefaultSubclassConstructor || |
1008 kind == FunctionKind::kBaseConstructor || | 1003 kind == FunctionKind::kBaseConstructor || |
1009 kind == FunctionKind::kSubclassConstructor || | 1004 kind == FunctionKind::kSubclassConstructor; |
1010 kind == FunctionKind::kConciseMethodInObjectLiteral || | |
1011 kind == FunctionKind::kConciseGeneratorMethodInObjectLiteral || | |
1012 kind == FunctionKind::kAccessorFunctionInObjectLiteral; | |
1013 } | 1005 } |
1014 | 1006 |
1015 | 1007 |
1016 inline bool IsArrowFunction(FunctionKind kind) { | 1008 inline bool IsArrowFunction(FunctionKind kind) { |
1017 DCHECK(IsValidFunctionKind(kind)); | 1009 DCHECK(IsValidFunctionKind(kind)); |
1018 return kind & FunctionKind::kArrowFunction; | 1010 return kind & FunctionKind::kArrowFunction; |
1019 } | 1011 } |
1020 | 1012 |
1021 | 1013 |
1022 inline bool IsGeneratorFunction(FunctionKind kind) { | 1014 inline bool IsGeneratorFunction(FunctionKind kind) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 inline bool IsConstructable(FunctionKind kind, LanguageMode mode) { | 1056 inline bool IsConstructable(FunctionKind kind, LanguageMode mode) { |
1065 if (IsAccessorFunction(kind)) return false; | 1057 if (IsAccessorFunction(kind)) return false; |
1066 if (IsConciseMethod(kind)) return false; | 1058 if (IsConciseMethod(kind)) return false; |
1067 if (IsArrowFunction(kind)) return false; | 1059 if (IsArrowFunction(kind)) return false; |
1068 if (IsGeneratorFunction(kind)) return false; | 1060 if (IsGeneratorFunction(kind)) return false; |
1069 if (is_strong(mode)) return IsClassConstructor(kind); | 1061 if (is_strong(mode)) return IsClassConstructor(kind); |
1070 return true; | 1062 return true; |
1071 } | 1063 } |
1072 | 1064 |
1073 | 1065 |
1074 inline bool IsInObjectLiteral(FunctionKind kind) { | |
1075 DCHECK(IsValidFunctionKind(kind)); | |
1076 return kind & FunctionKind::kInObjectLiteral; | |
1077 } | |
1078 | |
1079 | |
1080 inline FunctionKind WithObjectLiteralBit(FunctionKind kind) { | |
1081 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral); | |
1082 DCHECK(IsValidFunctionKind(kind)); | |
1083 return kind; | |
1084 } | |
1085 | |
1086 inline uint32_t ObjectHash(Address address) { | 1066 inline uint32_t ObjectHash(Address address) { |
1087 // All objects are at least pointer aligned, so we can remove the trailing | 1067 // All objects are at least pointer aligned, so we can remove the trailing |
1088 // zeros. | 1068 // zeros. |
1089 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> | 1069 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> |
1090 kPointerSizeLog2); | 1070 kPointerSizeLog2); |
1091 } | 1071 } |
1092 | 1072 |
1093 } // namespace internal | 1073 } // namespace internal |
1094 } // namespace v8 | 1074 } // namespace v8 |
1095 | 1075 |
1096 namespace i = v8::internal; | 1076 namespace i = v8::internal; |
1097 | 1077 |
1098 #endif // V8_GLOBALS_H_ | 1078 #endif // V8_GLOBALS_H_ |
OLD | NEW |