| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 static TypeInfo Unknown() { return TypeInfo(kUnknown); } | 58 static TypeInfo Unknown() { return TypeInfo(kUnknown); } |
| 59 // We know it's a primitive type. | 59 // We know it's a primitive type. |
| 60 static TypeInfo Primitive() { return TypeInfo(kPrimitive); } | 60 static TypeInfo Primitive() { return TypeInfo(kPrimitive); } |
| 61 // We know it's a number of some sort. | 61 // We know it's a number of some sort. |
| 62 static TypeInfo Number() { return TypeInfo(kNumber); } | 62 static TypeInfo Number() { return TypeInfo(kNumber); } |
| 63 // We know it's a signed 32 bit integer. | 63 // We know it's a signed 32 bit integer. |
| 64 static TypeInfo Integer32() { return TypeInfo(kInteger32); } | 64 static TypeInfo Integer32() { return TypeInfo(kInteger32); } |
| 65 // We know it's a Smi. | 65 // We know it's a Smi. |
| 66 static TypeInfo Smi() { return TypeInfo(kSmi); } | 66 static TypeInfo Smi() { return TypeInfo(kSmi); } |
| 67 // We know it's a Symbol. | |
| 68 static TypeInfo Symbol() { return TypeInfo(kSymbol); } | |
| 69 // We know it's a heap number. | 67 // We know it's a heap number. |
| 70 static TypeInfo Double() { return TypeInfo(kDouble); } | 68 static TypeInfo Double() { return TypeInfo(kDouble); } |
| 71 // We know it's a string. | 69 // We know it's a string. |
| 72 static TypeInfo String() { return TypeInfo(kString); } | 70 static TypeInfo String() { return TypeInfo(kString); } |
| 73 // We know it's a non-primitive (object) type. | 71 // We know it's a non-primitive (object) type. |
| 74 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } | 72 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } |
| 75 // We haven't started collecting info yet. | 73 // We haven't started collecting info yet. |
| 76 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } | 74 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } |
| 77 | 75 |
| 78 int ToInt() { | 76 int ToInt() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 inline bool IsNumber() { | 130 inline bool IsNumber() { |
| 133 ASSERT(type_ != kUninitialized); | 131 ASSERT(type_ != kUninitialized); |
| 134 return ((type_ & kNumber) == kNumber); | 132 return ((type_ & kNumber) == kNumber); |
| 135 } | 133 } |
| 136 | 134 |
| 137 inline bool IsSmi() { | 135 inline bool IsSmi() { |
| 138 ASSERT(type_ != kUninitialized); | 136 ASSERT(type_ != kUninitialized); |
| 139 return ((type_ & kSmi) == kSmi); | 137 return ((type_ & kSmi) == kSmi); |
| 140 } | 138 } |
| 141 | 139 |
| 142 inline bool IsSymbol() { | |
| 143 ASSERT(type_ != kUninitialized); | |
| 144 return ((type_ & kSymbol) == kSymbol); | |
| 145 } | |
| 146 | |
| 147 inline bool IsNonSymbol() { | |
| 148 ASSERT(type_ != kUninitialized); | |
| 149 return ((type_ & kSymbol) == kString); | |
| 150 } | |
| 151 | |
| 152 inline bool IsInteger32() { | 140 inline bool IsInteger32() { |
| 153 ASSERT(type_ != kUninitialized); | 141 ASSERT(type_ != kUninitialized); |
| 154 return ((type_ & kInteger32) == kInteger32); | 142 return ((type_ & kInteger32) == kInteger32); |
| 155 } | 143 } |
| 156 | 144 |
| 157 inline bool IsDouble() { | 145 inline bool IsDouble() { |
| 158 ASSERT(type_ != kUninitialized); | 146 ASSERT(type_ != kUninitialized); |
| 159 return ((type_ & kDouble) == kDouble); | 147 return ((type_ & kDouble) == kDouble); |
| 160 } | 148 } |
| 161 | 149 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 173 return type_ == kUninitialized; | 161 return type_ == kUninitialized; |
| 174 } | 162 } |
| 175 | 163 |
| 176 const char* ToString() { | 164 const char* ToString() { |
| 177 switch (type_) { | 165 switch (type_) { |
| 178 case kUnknown: return "Unknown"; | 166 case kUnknown: return "Unknown"; |
| 179 case kPrimitive: return "Primitive"; | 167 case kPrimitive: return "Primitive"; |
| 180 case kNumber: return "Number"; | 168 case kNumber: return "Number"; |
| 181 case kInteger32: return "Integer32"; | 169 case kInteger32: return "Integer32"; |
| 182 case kSmi: return "Smi"; | 170 case kSmi: return "Smi"; |
| 183 case kSymbol: return "Symbol"; | |
| 184 case kDouble: return "Double"; | 171 case kDouble: return "Double"; |
| 185 case kString: return "String"; | 172 case kString: return "String"; |
| 186 case kNonPrimitive: return "Object"; | 173 case kNonPrimitive: return "Object"; |
| 187 case kUninitialized: return "Uninitialized"; | 174 case kUninitialized: return "Uninitialized"; |
| 188 } | 175 } |
| 189 UNREACHABLE(); | 176 UNREACHABLE(); |
| 190 return "Unreachable code"; | 177 return "Unreachable code"; |
| 191 } | 178 } |
| 192 | 179 |
| 193 private: | 180 private: |
| 194 enum Type { | 181 enum Type { |
| 195 kUnknown = 0, // 0000000 | 182 kUnknown = 0, // 0000000 |
| 196 kPrimitive = 0x10, // 0010000 | 183 kPrimitive = 0x10, // 0010000 |
| 197 kNumber = 0x11, // 0010001 | 184 kNumber = 0x11, // 0010001 |
| 198 kInteger32 = 0x13, // 0010011 | 185 kInteger32 = 0x13, // 0010011 |
| 199 kSmi = 0x17, // 0010111 | 186 kSmi = 0x17, // 0010111 |
| 200 kDouble = 0x19, // 0011001 | 187 kDouble = 0x19, // 0011001 |
| 201 kString = 0x30, // 0110000 | 188 kString = 0x30, // 0110000 |
| 202 kSymbol = 0x32, // 0110010 | |
| 203 kNonPrimitive = 0x40, // 1000000 | 189 kNonPrimitive = 0x40, // 1000000 |
| 204 kUninitialized = 0x7f // 1111111 | 190 kUninitialized = 0x7f // 1111111 |
| 205 }; | 191 }; |
| 206 explicit inline TypeInfo(Type t) : type_(t) { } | 192 explicit inline TypeInfo(Type t) : type_(t) { } |
| 207 | 193 |
| 208 Type type_; | 194 Type type_; |
| 209 }; | 195 }; |
| 210 | 196 |
| 211 | 197 |
| 212 enum StringStubFeedback { | 198 enum StringStubFeedback { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 Handle<Context> global_context_; | 285 Handle<Context> global_context_; |
| 300 Isolate* isolate_; | 286 Isolate* isolate_; |
| 301 Handle<NumberDictionary> dictionary_; | 287 Handle<NumberDictionary> dictionary_; |
| 302 | 288 |
| 303 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 289 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
| 304 }; | 290 }; |
| 305 | 291 |
| 306 } } // namespace v8::internal | 292 } } // namespace v8::internal |
| 307 | 293 |
| 308 #endif // V8_TYPE_INFO_H_ | 294 #endif // V8_TYPE_INFO_H_ |
| OLD | NEW |