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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 kNormalFunction = 0, | 956 kNormalFunction = 0, |
| 957 kArrowFunction = 1 << 0, | 957 kArrowFunction = 1 << 0, |
| 958 kGeneratorFunction = 1 << 1, | 958 kGeneratorFunction = 1 << 1, |
| 959 kConciseMethod = 1 << 2, | 959 kConciseMethod = 1 << 2, |
| 960 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, | 960 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod, |
| 961 kDefaultConstructor = 1 << 3, | 961 kDefaultConstructor = 1 << 3, |
| 962 kSubclassConstructor = 1 << 4, | 962 kSubclassConstructor = 1 << 4, |
| 963 kBaseConstructor = 1 << 5, | 963 kBaseConstructor = 1 << 5, |
| 964 kGetterFunction = 1 << 6, | 964 kGetterFunction = 1 << 6, |
| 965 kSetterFunction = 1 << 7, | 965 kSetterFunction = 1 << 7, |
| 966 kAsyncFunction = 1 << 8, | |
| 966 kAccessorFunction = kGetterFunction | kSetterFunction, | 967 kAccessorFunction = kGetterFunction | kSetterFunction, |
| 967 kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor, | 968 kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor, |
| 968 kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor, | 969 kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor, |
| 969 kClassConstructor = | 970 kClassConstructor = |
| 970 kBaseConstructor | kSubclassConstructor | kDefaultConstructor, | 971 kBaseConstructor | kSubclassConstructor | kDefaultConstructor, |
| 972 kAsyncArrowFunction = kArrowFunction | kAsyncFunction, | |
| 973 kAsyncConciseMethod = kAsyncFunction | kConciseMethod | |
| 971 }; | 974 }; |
| 972 | 975 |
| 973 inline bool IsValidFunctionKind(FunctionKind kind) { | 976 inline bool IsValidFunctionKind(FunctionKind kind) { |
| 974 return kind == FunctionKind::kNormalFunction || | 977 return kind == FunctionKind::kNormalFunction || |
| 975 kind == FunctionKind::kArrowFunction || | 978 kind == FunctionKind::kArrowFunction || |
| 976 kind == FunctionKind::kGeneratorFunction || | 979 kind == FunctionKind::kGeneratorFunction || |
| 977 kind == FunctionKind::kConciseMethod || | 980 kind == FunctionKind::kConciseMethod || |
| 978 kind == FunctionKind::kConciseGeneratorMethod || | 981 kind == FunctionKind::kConciseGeneratorMethod || |
| 979 kind == FunctionKind::kGetterFunction || | 982 kind == FunctionKind::kGetterFunction || |
| 980 kind == FunctionKind::kSetterFunction || | 983 kind == FunctionKind::kSetterFunction || |
| 981 kind == FunctionKind::kAccessorFunction || | 984 kind == FunctionKind::kAccessorFunction || |
| 982 kind == FunctionKind::kDefaultBaseConstructor || | 985 kind == FunctionKind::kDefaultBaseConstructor || |
| 983 kind == FunctionKind::kDefaultSubclassConstructor || | 986 kind == FunctionKind::kDefaultSubclassConstructor || |
| 984 kind == FunctionKind::kBaseConstructor || | 987 kind == FunctionKind::kBaseConstructor || |
| 985 kind == FunctionKind::kSubclassConstructor; | 988 kind == FunctionKind::kSubclassConstructor || |
| 989 kind == FunctionKind::kAsyncFunction || | |
| 990 kind == FunctionKind::kAsyncArrowFunction || | |
| 991 kind == FunctionKind::kAsyncConciseMethod; | |
| 986 } | 992 } |
| 987 | 993 |
| 988 | 994 |
| 989 inline bool IsArrowFunction(FunctionKind kind) { | 995 inline bool IsArrowFunction(FunctionKind kind) { |
| 990 DCHECK(IsValidFunctionKind(kind)); | 996 DCHECK(IsValidFunctionKind(kind)); |
| 991 return kind & FunctionKind::kArrowFunction; | 997 return kind & FunctionKind::kArrowFunction; |
| 992 } | 998 } |
| 993 | 999 |
| 994 | 1000 |
| 995 inline bool IsGeneratorFunction(FunctionKind kind) { | 1001 inline bool IsGeneratorFunction(FunctionKind kind) { |
| 996 DCHECK(IsValidFunctionKind(kind)); | 1002 DCHECK(IsValidFunctionKind(kind)); |
| 997 return kind & FunctionKind::kGeneratorFunction; | 1003 return kind & FunctionKind::kGeneratorFunction; |
| 998 } | 1004 } |
| 999 | 1005 |
| 1006 inline bool IsAsyncFunction(FunctionKind kind) { | |
| 1007 DCHECK(IsValidFunctionKind(kind)); | |
| 1008 return kind & FunctionKind::kAsyncFunction; | |
| 1009 } | |
| 1000 | 1010 |
| 1001 inline bool IsConciseMethod(FunctionKind kind) { | 1011 inline bool IsConciseMethod(FunctionKind kind) { |
| 1002 DCHECK(IsValidFunctionKind(kind)); | 1012 DCHECK(IsValidFunctionKind(kind)); |
| 1003 return kind & FunctionKind::kConciseMethod; | 1013 return kind & FunctionKind::kConciseMethod; |
| 1004 } | 1014 } |
| 1005 | 1015 |
| 1006 inline bool IsGetterFunction(FunctionKind kind) { | 1016 inline bool IsGetterFunction(FunctionKind kind) { |
| 1007 DCHECK(IsValidFunctionKind(kind)); | 1017 DCHECK(IsValidFunctionKind(kind)); |
| 1008 return kind & FunctionKind::kGetterFunction; | 1018 return kind & FunctionKind::kGetterFunction; |
| 1009 } | 1019 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 } | 1062 } |
| 1053 | 1063 |
| 1054 | 1064 |
| 1055 inline uint32_t ObjectHash(Address address) { | 1065 inline uint32_t ObjectHash(Address address) { |
| 1056 // All objects are at least pointer aligned, so we can remove the trailing | 1066 // All objects are at least pointer aligned, so we can remove the trailing |
| 1057 // zeros. | 1067 // zeros. |
| 1058 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> | 1068 return static_cast<uint32_t>(bit_cast<uintptr_t>(address) >> |
| 1059 kPointerSizeLog2); | 1069 kPointerSizeLog2); |
| 1060 } | 1070 } |
| 1061 | 1071 |
| 1072 enum class MethodKind { | |
| 1073 None = 0, | |
| 1074 Static = 1 << 0, | |
| 1075 Generator = 1 << 1, | |
| 1076 StaticGenerator = Static | Generator, | |
| 1077 Async = 1 << 2, | |
| 1078 StaticAsync = Static | Async, | |
| 1079 }; | |
|
Dan Ehrenberg
2016/05/11 21:04:17
This seems to overlap a lot with ObjectLiteralProp
caitp (gmail)
2016/05/11 21:14:07
goal was to get rid of a boolean trap in CheckProp
| |
| 1080 | |
| 1081 inline bool IsValidMethodKind(MethodKind kind) { | |
| 1082 return kind == MethodKind::None || kind == MethodKind::Static || | |
| 1083 kind == MethodKind::Generator || kind == MethodKind::StaticGenerator || | |
| 1084 kind == MethodKind::Async || kind == MethodKind::StaticAsync; | |
| 1085 } | |
| 1086 | |
| 1087 static inline MethodKind operator|(MethodKind lhs, MethodKind rhs) { | |
| 1088 typedef unsigned char T; | |
| 1089 return static_cast<MethodKind>(static_cast<T>(lhs) | static_cast<T>(rhs)); | |
| 1090 } | |
| 1091 | |
| 1092 static inline MethodKind& operator|=(MethodKind& lhs, const MethodKind& rhs) { | |
| 1093 lhs = lhs | rhs; | |
| 1094 DCHECK(IsValidMethodKind(lhs)); | |
| 1095 return lhs; | |
| 1096 } | |
| 1097 | |
| 1098 static inline bool operator&(MethodKind bitfield, MethodKind mask) { | |
| 1099 typedef unsigned char T; | |
| 1100 return static_cast<T>(bitfield) & static_cast<T>(mask); | |
| 1101 } | |
| 1102 | |
| 1103 inline bool IsMethod(MethodKind kind) { return kind != MethodKind::None; } | |
|
Dan Ehrenberg
2016/05/11 21:04:17
Huh? What about an ordinary non-static non-generat
caitp (gmail)
2016/05/11 21:14:07
good point, although it doesnt seem to actually ma
| |
| 1104 | |
| 1105 inline bool IsStaticMethod(MethodKind kind) { | |
| 1106 return kind & MethodKind::Static; | |
| 1107 } | |
| 1108 | |
| 1109 inline bool IsGeneratorMethod(MethodKind kind) { | |
| 1110 return kind & MethodKind::Generator; | |
| 1111 } | |
| 1112 | |
| 1113 inline bool IsAsyncMethod(MethodKind kind) { return kind & MethodKind::Async; } | |
| 1114 | |
| 1062 } // namespace internal | 1115 } // namespace internal |
| 1063 } // namespace v8 | 1116 } // namespace v8 |
| 1064 | 1117 |
| 1065 namespace i = v8::internal; | 1118 namespace i = v8::internal; |
| 1066 | 1119 |
| 1067 #endif // V8_GLOBALS_H_ | 1120 #endif // V8_GLOBALS_H_ |
| OLD | NEW |