| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 static TypeInfo Smi() { return TypeInfo(kSmi); } | 65 static TypeInfo Smi() { return TypeInfo(kSmi); } |
| 66 // We know it's a heap number. | 66 // We know it's a heap number. |
| 67 static TypeInfo Double() { return TypeInfo(kDouble); } | 67 static TypeInfo Double() { return TypeInfo(kDouble); } |
| 68 // We know it's a string. | 68 // We know it's a string. |
| 69 static TypeInfo String() { return TypeInfo(kString); } | 69 static TypeInfo String() { return TypeInfo(kString); } |
| 70 // We know it's a non-primitive (object) type. | 70 // We know it's a non-primitive (object) type. |
| 71 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } | 71 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } |
| 72 // We haven't started collecting info yet. | 72 // We haven't started collecting info yet. |
| 73 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } | 73 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } |
| 74 | 74 |
| 75 // Return compact representation. Very sensitive to enum values below! | |
| 76 // Compacting drops information about primitive types and strings types. | |
| 77 // We use the compact representation when we only care about number types. | |
| 78 int ThreeBitRepresentation() { | |
| 79 ASSERT(type_ != kUninitialized); | |
| 80 int answer = type_ & 0xf; | |
| 81 answer = answer > 6 ? answer - 2 : answer; | |
| 82 ASSERT(answer >= 0); | |
| 83 ASSERT(answer <= 7); | |
| 84 return answer; | |
| 85 } | |
| 86 | |
| 87 // Decode compact representation. Very sensitive to enum values below! | |
| 88 static TypeInfo ExpandedRepresentation(int three_bit_representation) { | |
| 89 Type t = static_cast<Type>(three_bit_representation > 4 ? | |
| 90 three_bit_representation + 2 : | |
| 91 three_bit_representation); | |
| 92 t = (t == kUnknown) ? t : static_cast<Type>(t | kPrimitive); | |
| 93 ASSERT(t == kUnknown || | |
| 94 t == kNumber || | |
| 95 t == kInteger32 || | |
| 96 t == kSmi || | |
| 97 t == kDouble); | |
| 98 return TypeInfo(t); | |
| 99 } | |
| 100 | |
| 101 int ToInt() { | 75 int ToInt() { |
| 102 return type_; | 76 return type_; |
| 103 } | 77 } |
| 104 | 78 |
| 105 static TypeInfo FromInt(int bit_representation) { | 79 static TypeInfo FromInt(int bit_representation) { |
| 106 Type t = static_cast<Type>(bit_representation); | 80 Type t = static_cast<Type>(bit_representation); |
| 107 ASSERT(t == kUnknown || | 81 ASSERT(t == kUnknown || |
| 108 t == kPrimitive || | 82 t == kPrimitive || |
| 109 t == kNumber || | 83 t == kNumber || |
| 110 t == kInteger32 || | 84 t == kInteger32 || |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 261 |
| 288 Handle<Context> global_context_; | 262 Handle<Context> global_context_; |
| 289 Handle<NumberDictionary> dictionary_; | 263 Handle<NumberDictionary> dictionary_; |
| 290 | 264 |
| 291 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 265 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
| 292 }; | 266 }; |
| 293 | 267 |
| 294 } } // namespace v8::internal | 268 } } // namespace v8::internal |
| 295 | 269 |
| 296 #endif // V8_TYPE_INFO_H_ | 270 #endif // V8_TYPE_INFO_H_ |
| OLD | NEW |