| 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); } |
| 67 // We know it's a heap number. | 69 // We know it's a heap number. |
| 68 static TypeInfo Double() { return TypeInfo(kDouble); } | 70 static TypeInfo Double() { return TypeInfo(kDouble); } |
| 69 // We know it's a string. | 71 // We know it's a string. |
| 70 static TypeInfo String() { return TypeInfo(kString); } | 72 static TypeInfo String() { return TypeInfo(kString); } |
| 71 // We know it's a non-primitive (object) type. | 73 // We know it's a non-primitive (object) type. |
| 72 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } | 74 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } |
| 73 // We haven't started collecting info yet. | 75 // We haven't started collecting info yet. |
| 74 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } | 76 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } |
| 75 | 77 |
| 76 int ToInt() { | 78 int ToInt() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 inline bool IsNumber() { | 132 inline bool IsNumber() { |
| 131 ASSERT(type_ != kUninitialized); | 133 ASSERT(type_ != kUninitialized); |
| 132 return ((type_ & kNumber) == kNumber); | 134 return ((type_ & kNumber) == kNumber); |
| 133 } | 135 } |
| 134 | 136 |
| 135 inline bool IsSmi() { | 137 inline bool IsSmi() { |
| 136 ASSERT(type_ != kUninitialized); | 138 ASSERT(type_ != kUninitialized); |
| 137 return ((type_ & kSmi) == kSmi); | 139 return ((type_ & kSmi) == kSmi); |
| 138 } | 140 } |
| 139 | 141 |
| 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 |
| 140 inline bool IsInteger32() { | 152 inline bool IsInteger32() { |
| 141 ASSERT(type_ != kUninitialized); | 153 ASSERT(type_ != kUninitialized); |
| 142 return ((type_ & kInteger32) == kInteger32); | 154 return ((type_ & kInteger32) == kInteger32); |
| 143 } | 155 } |
| 144 | 156 |
| 145 inline bool IsDouble() { | 157 inline bool IsDouble() { |
| 146 ASSERT(type_ != kUninitialized); | 158 ASSERT(type_ != kUninitialized); |
| 147 return ((type_ & kDouble) == kDouble); | 159 return ((type_ & kDouble) == kDouble); |
| 148 } | 160 } |
| 149 | 161 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 161 return type_ == kUninitialized; | 173 return type_ == kUninitialized; |
| 162 } | 174 } |
| 163 | 175 |
| 164 const char* ToString() { | 176 const char* ToString() { |
| 165 switch (type_) { | 177 switch (type_) { |
| 166 case kUnknown: return "Unknown"; | 178 case kUnknown: return "Unknown"; |
| 167 case kPrimitive: return "Primitive"; | 179 case kPrimitive: return "Primitive"; |
| 168 case kNumber: return "Number"; | 180 case kNumber: return "Number"; |
| 169 case kInteger32: return "Integer32"; | 181 case kInteger32: return "Integer32"; |
| 170 case kSmi: return "Smi"; | 182 case kSmi: return "Smi"; |
| 183 case kSymbol: return "Symbol"; |
| 171 case kDouble: return "Double"; | 184 case kDouble: return "Double"; |
| 172 case kString: return "String"; | 185 case kString: return "String"; |
| 173 case kNonPrimitive: return "Object"; | 186 case kNonPrimitive: return "Object"; |
| 174 case kUninitialized: return "Uninitialized"; | 187 case kUninitialized: return "Uninitialized"; |
| 175 } | 188 } |
| 176 UNREACHABLE(); | 189 UNREACHABLE(); |
| 177 return "Unreachable code"; | 190 return "Unreachable code"; |
| 178 } | 191 } |
| 179 | 192 |
| 180 private: | 193 private: |
| 181 enum Type { | 194 enum Type { |
| 182 kUnknown = 0, // 0000000 | 195 kUnknown = 0, // 0000000 |
| 183 kPrimitive = 0x10, // 0010000 | 196 kPrimitive = 0x10, // 0010000 |
| 184 kNumber = 0x11, // 0010001 | 197 kNumber = 0x11, // 0010001 |
| 185 kInteger32 = 0x13, // 0010011 | 198 kInteger32 = 0x13, // 0010011 |
| 186 kSmi = 0x17, // 0010111 | 199 kSmi = 0x17, // 0010111 |
| 187 kDouble = 0x19, // 0011001 | 200 kDouble = 0x19, // 0011001 |
| 188 kString = 0x30, // 0110000 | 201 kString = 0x30, // 0110000 |
| 202 kSymbol = 0x32, // 0110010 |
| 189 kNonPrimitive = 0x40, // 1000000 | 203 kNonPrimitive = 0x40, // 1000000 |
| 190 kUninitialized = 0x7f // 1111111 | 204 kUninitialized = 0x7f // 1111111 |
| 191 }; | 205 }; |
| 192 explicit inline TypeInfo(Type t) : type_(t) { } | 206 explicit inline TypeInfo(Type t) : type_(t) { } |
| 193 | 207 |
| 194 Type type_; | 208 Type type_; |
| 195 }; | 209 }; |
| 196 | 210 |
| 197 | 211 |
| 198 enum StringStubFeedback { | 212 enum StringStubFeedback { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 Handle<Context> global_context_; | 299 Handle<Context> global_context_; |
| 286 Isolate* isolate_; | 300 Isolate* isolate_; |
| 287 Handle<NumberDictionary> dictionary_; | 301 Handle<NumberDictionary> dictionary_; |
| 288 | 302 |
| 289 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 303 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
| 290 }; | 304 }; |
| 291 | 305 |
| 292 } } // namespace v8::internal | 306 } } // namespace v8::internal |
| 293 | 307 |
| 294 #endif // V8_TYPE_INFO_H_ | 308 #endif // V8_TYPE_INFO_H_ |
| OLD | NEW |