| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 t == kNonPrimitive); | 113 t == kNonPrimitive); |
| 114 return TypeInfo(t); | 114 return TypeInfo(t); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Return the weakest (least precise) common type. | 117 // Return the weakest (least precise) common type. |
| 118 static TypeInfo Combine(TypeInfo a, TypeInfo b) { | 118 static TypeInfo Combine(TypeInfo a, TypeInfo b) { |
| 119 return TypeInfo(static_cast<Type>(a.type_ & b.type_)); | 119 return TypeInfo(static_cast<Type>(a.type_ & b.type_)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 // Integer32 is an integer that can be represented as either a signed | 123 // Integer32 is an integer that can be represented as a signed |
| 124 // 32-bit integer or as an unsigned 32-bit integer. It has to be | 124 // 32-bit integer. It has to be |
| 125 // in the range [-2^31, 2^32 - 1]. We also have to check for negative 0 | 125 // in the range [-2^31, 2^31 - 1]. We also have to check for negative 0 |
| 126 // as it is not an Integer32. | 126 // as it is not an Integer32. |
| 127 static inline bool IsInt32Double(double value) { | 127 static inline bool IsInt32Double(double value) { |
| 128 const DoubleRepresentation minus_zero(-0.0); | 128 const DoubleRepresentation minus_zero(-0.0); |
| 129 DoubleRepresentation rep(value); | 129 DoubleRepresentation rep(value); |
| 130 if (rep.bits == minus_zero.bits) return false; | 130 if (rep.bits == minus_zero.bits) return false; |
| 131 if (value >= kMinInt && value <= kMaxInt && | 131 if (value >= kMinInt && value <= kMaxInt && |
| 132 value == static_cast<int32_t>(value)) { | 132 value == static_cast<int32_t>(value)) { |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| 135 return false; | 135 return false; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 kString = 0x30, // 0110000 | 212 kString = 0x30, // 0110000 |
| 213 kNonPrimitive = 0x40, // 1000000 | 213 kNonPrimitive = 0x40, // 1000000 |
| 214 kUninitialized = 0x7f // 1111111 | 214 kUninitialized = 0x7f // 1111111 |
| 215 }; | 215 }; |
| 216 explicit inline TypeInfo(Type t) : type_(t) { } | 216 explicit inline TypeInfo(Type t) : type_(t) { } |
| 217 | 217 |
| 218 Type type_; | 218 Type type_; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 | 221 |
| 222 enum StringStubFeedback { |
| 223 DEFAULT_STRING_STUB = 0, |
| 224 STRING_INDEX_OUT_OF_BOUNDS = 1 |
| 225 }; |
| 226 |
| 227 |
| 222 // Forward declarations. | 228 // Forward declarations. |
| 223 class Assignment; | 229 class Assignment; |
| 224 class BinaryOperation; | 230 class BinaryOperation; |
| 225 class Call; | 231 class Call; |
| 226 class CompareOperation; | 232 class CompareOperation; |
| 227 class CompilationInfo; | 233 class CompilationInfo; |
| 228 class Property; | 234 class Property; |
| 229 class CaseClause; | 235 class CaseClause; |
| 230 | 236 |
| 231 class TypeFeedbackOracle BASE_EMBEDDED { | 237 class TypeFeedbackOracle BASE_EMBEDDED { |
| 232 public: | 238 public: |
| 233 enum Side { | 239 TypeFeedbackOracle(Handle<Code> code, Handle<Context> global_context); |
| 234 LEFT, | |
| 235 RIGHT, | |
| 236 RESULT | |
| 237 }; | |
| 238 | |
| 239 explicit TypeFeedbackOracle(Handle<Code> code); | |
| 240 | 240 |
| 241 bool LoadIsMonomorphic(Property* expr); | 241 bool LoadIsMonomorphic(Property* expr); |
| 242 bool StoreIsMonomorphic(Assignment* expr); | 242 bool StoreIsMonomorphic(Assignment* expr); |
| 243 bool CallIsMonomorphic(Call* expr); | 243 bool CallIsMonomorphic(Call* expr); |
| 244 | 244 |
| 245 Handle<Map> LoadMonomorphicReceiverType(Property* expr); | 245 Handle<Map> LoadMonomorphicReceiverType(Property* expr); |
| 246 Handle<Map> StoreMonomorphicReceiverType(Assignment* expr); | 246 Handle<Map> StoreMonomorphicReceiverType(Assignment* expr); |
| 247 Handle<Map> CallMonomorphicReceiverType(Call* expr); | |
| 248 | 247 |
| 249 ZoneMapList* LoadReceiverTypes(Property* expr, Handle<String> name); | 248 ZoneMapList* LoadReceiverTypes(Property* expr, Handle<String> name); |
| 250 ZoneMapList* StoreReceiverTypes(Assignment* expr, Handle<String> name); | 249 ZoneMapList* StoreReceiverTypes(Assignment* expr, Handle<String> name); |
| 251 ZoneMapList* CallReceiverTypes(Call* expr, Handle<String> name); | 250 ZoneMapList* CallReceiverTypes(Call* expr, Handle<String> name); |
| 252 | 251 |
| 252 CheckType GetCallCheckType(Call* expr); |
| 253 Handle<JSObject> GetPrototypeForPrimitiveCheck(CheckType check); |
| 254 |
| 253 bool LoadIsBuiltin(Property* expr, Builtins::Name id); | 255 bool LoadIsBuiltin(Property* expr, Builtins::Name id); |
| 254 | 256 |
| 255 // Get type information for arithmetic operations and compares. | 257 // Get type information for arithmetic operations and compares. |
| 256 TypeInfo BinaryType(BinaryOperation* expr, Side side); | 258 TypeInfo BinaryType(BinaryOperation* expr); |
| 257 TypeInfo CompareType(CompareOperation* expr, Side side); | 259 TypeInfo CompareType(CompareOperation* expr); |
| 258 TypeInfo SwitchType(CaseClause* clause); | 260 TypeInfo SwitchType(CaseClause* clause); |
| 259 | 261 |
| 260 private: | 262 private: |
| 261 void Initialize(Handle<Code> code); | 263 void Initialize(Handle<Code> code); |
| 262 | 264 |
| 263 bool IsMonomorphic(int pos) { return GetElement(map_, pos)->IsMap(); } | |
| 264 | |
| 265 ZoneMapList* CollectReceiverTypes(int position, | 265 ZoneMapList* CollectReceiverTypes(int position, |
| 266 Handle<String> name, | 266 Handle<String> name, |
| 267 Code::Flags flags); | 267 Code::Flags flags); |
| 268 | 268 |
| 269 void PopulateMap(Handle<Code> code); | 269 void PopulateMap(Handle<Code> code); |
| 270 | 270 |
| 271 void CollectPositions(Code* code, | 271 void CollectPositions(Code* code, |
| 272 List<int>* code_positions, | 272 List<int>* code_positions, |
| 273 List<int>* source_positions); | 273 List<int>* source_positions); |
| 274 | 274 |
| 275 Handle<Context> global_context_; |
| 275 Handle<JSObject> map_; | 276 Handle<JSObject> map_; |
| 276 | 277 |
| 277 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 278 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
| 278 }; | 279 }; |
| 279 | 280 |
| 280 } } // namespace v8::internal | 281 } } // namespace v8::internal |
| 281 | 282 |
| 282 #endif // V8_TYPE_INFO_H_ | 283 #endif // V8_TYPE_INFO_H_ |
| OLD | NEW |