| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_TYPE_INFO_H_ | 28 #ifndef V8_TYPE_INFO_H_ |
| 29 #define V8_TYPE_INFO_H_ | 29 #define V8_TYPE_INFO_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "globals.h" | 32 #include "globals.h" |
| 33 #include "types.h" |
| 33 #include "zone-inl.h" | 34 #include "zone-inl.h" |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 const int kMaxKeyedPolymorphism = 4; | 39 const int kMaxKeyedPolymorphism = 4; |
| 39 | 40 |
| 40 // Unknown | 41 // Unknown |
| 41 // | \____________ | 42 // | \____________ |
| 42 // | | | 43 // | | |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 const DoubleRepresentation minus_zero(-0.0); | 107 const DoubleRepresentation minus_zero(-0.0); |
| 107 DoubleRepresentation rep(value); | 108 DoubleRepresentation rep(value); |
| 108 if (rep.bits == minus_zero.bits) return false; | 109 if (rep.bits == minus_zero.bits) return false; |
| 109 if (value >= kMinInt && value <= kMaxInt && | 110 if (value >= kMinInt && value <= kMaxInt && |
| 110 value == static_cast<int32_t>(value)) { | 111 value == static_cast<int32_t>(value)) { |
| 111 return true; | 112 return true; |
| 112 } | 113 } |
| 113 return false; | 114 return false; |
| 114 } | 115 } |
| 115 | 116 |
| 116 static TypeInfo TypeFromValue(Handle<Object> value); | 117 static TypeInfo FromValue(Handle<Object> value); |
| 117 | 118 |
| 118 bool Equals(const TypeInfo& other) { | 119 bool Equals(const TypeInfo& other) { |
| 119 return type_ == other.type_; | 120 return type_ == other.type_; |
| 120 } | 121 } |
| 121 | 122 |
| 122 inline bool IsUnknown() { | 123 inline bool IsUnknown() { |
| 123 ASSERT(type_ != kUninitialized); | 124 ASSERT(type_ != kUninitialized); |
| 124 return type_ == kUnknown; | 125 return type_ == kUnknown; |
| 125 } | 126 } |
| 126 | 127 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 }; | 211 }; |
| 211 | 212 |
| 212 | 213 |
| 213 enum StringStubFeedback { | 214 enum StringStubFeedback { |
| 214 DEFAULT_STRING_STUB = 0, | 215 DEFAULT_STRING_STUB = 0, |
| 215 STRING_INDEX_OUT_OF_BOUNDS = 1 | 216 STRING_INDEX_OUT_OF_BOUNDS = 1 |
| 216 }; | 217 }; |
| 217 | 218 |
| 218 | 219 |
| 219 // Forward declarations. | 220 // Forward declarations. |
| 221 // TODO(rossberg): these should all go away eventually. |
| 220 class Assignment; | 222 class Assignment; |
| 221 class BinaryOperation; | |
| 222 class Call; | 223 class Call; |
| 223 class CallNew; | 224 class CallNew; |
| 224 class CaseClause; | 225 class CaseClause; |
| 225 class CompareOperation; | |
| 226 class CompilationInfo; | 226 class CompilationInfo; |
| 227 class CountOperation; | 227 class CountOperation; |
| 228 class Expression; | 228 class Expression; |
| 229 class ForInStatement; | 229 class ForInStatement; |
| 230 class ICStub; | 230 class ICStub; |
| 231 class Property; | 231 class Property; |
| 232 class SmallMapList; | 232 class SmallMapList; |
| 233 class UnaryOperation; | |
| 234 class ObjectLiteral; | 233 class ObjectLiteral; |
| 235 class ObjectLiteralProperty; | 234 class ObjectLiteralProperty; |
| 236 | 235 |
| 237 | 236 |
| 238 class TypeFeedbackOracle: public ZoneObject { | 237 class TypeFeedbackOracle: public ZoneObject { |
| 239 public: | 238 public: |
| 240 TypeFeedbackOracle(Handle<Code> code, | 239 TypeFeedbackOracle(Handle<Code> code, |
| 241 Handle<Context> native_context, | 240 Handle<Context> native_context, |
| 242 Isolate* isolate, | 241 Isolate* isolate, |
| 243 Zone* zone); | 242 Zone* zone); |
| 244 | 243 |
| 245 bool LoadIsMonomorphicNormal(Property* expr); | 244 bool LoadIsMonomorphicNormal(Property* expr); |
| 246 bool LoadIsUninitialized(Property* expr); | 245 bool LoadIsUninitialized(Property* expr); |
| 247 bool LoadIsPolymorphic(Property* expr); | 246 bool LoadIsPolymorphic(Property* expr); |
| 248 bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id); | 247 bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id); |
| 249 bool StoreIsPolymorphic(TypeFeedbackId ast_id); | 248 bool StoreIsPolymorphic(TypeFeedbackId ast_id); |
| 250 bool CallIsMonomorphic(Call* expr); | 249 bool CallIsMonomorphic(Call* expr); |
| 251 bool CallNewIsMonomorphic(CallNew* expr); | 250 bool CallNewIsMonomorphic(CallNew* expr); |
| 252 bool ObjectLiteralStoreIsMonomorphic(ObjectLiteralProperty* prop); | 251 bool ObjectLiteralStoreIsMonomorphic(ObjectLiteralProperty* prop); |
| 253 | 252 |
| 254 // TODO(1571) We can't use ForInStatement::ForInType as the return value due | 253 // TODO(1571) We can't use ForInStatement::ForInType as the return value due |
| 255 // to various cycles in our headers. | 254 // to various cycles in our headers. |
| 256 byte ForInType(ForInStatement* expr); | 255 byte ForInType(ForInStatement* expr); |
| 257 | 256 |
| 258 Handle<Map> LoadMonomorphicReceiverType(Property* expr); | 257 Handle<Map> LoadMonomorphicReceiverType(Property* expr); |
| 259 Handle<Map> StoreMonomorphicReceiverType(TypeFeedbackId id); | 258 Handle<Map> StoreMonomorphicReceiverType(TypeFeedbackId id); |
| 260 Handle<Map> CompareNilMonomorphicReceiverType(CompareOperation* expr); | |
| 261 | 259 |
| 262 KeyedAccessStoreMode GetStoreMode(TypeFeedbackId ast_id); | 260 KeyedAccessStoreMode GetStoreMode(TypeFeedbackId ast_id); |
| 263 | 261 |
| 264 void LoadReceiverTypes(Property* expr, | 262 void LoadReceiverTypes(Property* expr, |
| 265 Handle<String> name, | 263 Handle<String> name, |
| 266 SmallMapList* types); | 264 SmallMapList* types); |
| 267 void StoreReceiverTypes(Assignment* expr, | 265 void StoreReceiverTypes(Assignment* expr, |
| 268 Handle<String> name, | 266 Handle<String> name, |
| 269 SmallMapList* types); | 267 SmallMapList* types); |
| 270 void CallReceiverTypes(Call* expr, | 268 void CallReceiverTypes(Call* expr, |
| 271 Handle<String> name, | 269 Handle<String> name, |
| 272 CallKind call_kind, | 270 CallKind call_kind, |
| 273 SmallMapList* types); | 271 SmallMapList* types); |
| 274 void CollectKeyedReceiverTypes(TypeFeedbackId ast_id, | 272 void CollectKeyedReceiverTypes(TypeFeedbackId ast_id, |
| 275 SmallMapList* types); | 273 SmallMapList* types); |
| 276 | 274 |
| 277 static bool CanRetainOtherContext(Map* map, Context* native_context); | 275 static bool CanRetainOtherContext(Map* map, Context* native_context); |
| 278 static bool CanRetainOtherContext(JSFunction* function, | 276 static bool CanRetainOtherContext(JSFunction* function, |
| 279 Context* native_context); | 277 Context* native_context); |
| 280 | 278 |
| 281 void CollectPolymorphicMaps(Handle<Code> code, SmallMapList* types); | 279 void CollectPolymorphicMaps(Handle<Code> code, SmallMapList* types); |
| 282 | 280 |
| 283 CheckType GetCallCheckType(Call* expr); | 281 CheckType GetCallCheckType(Call* expr); |
| 284 Handle<JSFunction> GetCallTarget(Call* expr); | 282 Handle<JSFunction> GetCallTarget(Call* expr); |
| 285 Handle<JSFunction> GetCallNewTarget(CallNew* expr); | 283 Handle<JSFunction> GetCallNewTarget(CallNew* expr); |
| 286 Handle<JSGlobalPropertyCell> GetCallNewAllocationInfoCell(CallNew* expr); | 284 Handle<Cell> GetCallNewAllocationInfoCell(CallNew* expr); |
| 287 | 285 |
| 288 Handle<Map> GetObjectLiteralStoreMap(ObjectLiteralProperty* prop); | 286 Handle<Map> GetObjectLiteralStoreMap(ObjectLiteralProperty* prop); |
| 289 | 287 |
| 290 bool LoadIsBuiltin(Property* expr, Builtins::Name id); | 288 bool LoadIsBuiltin(Property* expr, Builtins::Name id); |
| 291 bool LoadIsStub(Property* expr, ICStub* stub); | 289 bool LoadIsStub(Property* expr, ICStub* stub); |
| 292 | 290 |
| 293 // TODO(1571) We can't use ToBooleanStub::Types as the return value because | 291 // TODO(1571) We can't use ToBooleanStub::Types as the return value because |
| 294 // of various cycles in our headers. Death to tons of implementations in | 292 // of various cycles in our headers. Death to tons of implementations in |
| 295 // headers!! :-P | 293 // headers!! :-P |
| 296 byte ToBooleanTypes(TypeFeedbackId ast_id); | 294 byte ToBooleanTypes(TypeFeedbackId id); |
| 297 | |
| 298 // TODO(1571) We can't use CompareNilICStub::Types as the return value because | |
| 299 // of various cylces in our headers. Death to tons of implementations in | |
| 300 // headers!! :-P | |
| 301 byte CompareNilTypes(CompareOperation* expr); | |
| 302 | 295 |
| 303 // Get type information for arithmetic operations and compares. | 296 // Get type information for arithmetic operations and compares. |
| 304 TypeInfo UnaryType(UnaryOperation* expr); | 297 Handle<Type> UnaryType(TypeFeedbackId id); |
| 305 void BinaryType(BinaryOperation* expr, | 298 void BinaryType(TypeFeedbackId id, |
| 306 TypeInfo* left, | 299 Handle<Type>* left, |
| 307 TypeInfo* right, | 300 Handle<Type>* right, |
| 308 TypeInfo* result, | 301 Handle<Type>* result, |
| 309 bool* has_fixed_right_arg, | 302 bool* has_fixed_right_arg, |
| 310 int* fixed_right_arg_value); | 303 int* fixed_right_arg_value); |
| 311 void CompareType(CompareOperation* expr, | 304 |
| 312 TypeInfo* left_type, | 305 void CompareTypes(TypeFeedbackId id, |
| 313 TypeInfo* right_type, | 306 Handle<Type>* left_type, |
| 314 TypeInfo* overall_type); | 307 Handle<Type>* right_type, |
| 315 Handle<Map> GetCompareMap(CompareOperation* expr); | 308 Handle<Type>* overall_type, |
| 316 TypeInfo SwitchType(CaseClause* clause); | 309 Handle<Type>* compare_nil_type); |
| 310 |
| 311 Handle<Type> ClauseType(TypeFeedbackId id); |
| 312 |
| 317 TypeInfo IncrementType(CountOperation* expr); | 313 TypeInfo IncrementType(CountOperation* expr); |
| 318 | 314 |
| 319 Zone* zone() const { return zone_; } | 315 Zone* zone() const { return zone_; } |
| 320 Isolate* isolate() const { return isolate_; } | 316 Isolate* isolate() const { return isolate_; } |
| 321 | 317 |
| 322 private: | 318 private: |
| 323 void CollectReceiverTypes(TypeFeedbackId ast_id, | 319 void CollectReceiverTypes(TypeFeedbackId ast_id, |
| 324 Handle<String> name, | 320 Handle<String> name, |
| 325 Code::Flags flags, | 321 Code::Flags flags, |
| 326 SmallMapList* types); | 322 SmallMapList* types); |
| 327 | 323 |
| 328 void SetInfo(TypeFeedbackId ast_id, Object* target); | 324 void SetInfo(TypeFeedbackId ast_id, Object* target); |
| 329 | 325 |
| 330 void BuildDictionary(Handle<Code> code); | 326 void BuildDictionary(Handle<Code> code); |
| 331 void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos); | 327 void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos); |
| 332 void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos); | 328 void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos); |
| 333 void RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 329 void RelocateRelocInfos(ZoneList<RelocInfo>* infos, |
| 334 byte* old_start, | 330 byte* old_start, |
| 335 byte* new_start); | 331 byte* new_start); |
| 336 void ProcessRelocInfos(ZoneList<RelocInfo>* infos); | 332 void ProcessRelocInfos(ZoneList<RelocInfo>* infos); |
| 337 void ProcessTypeFeedbackCells(Handle<Code> code); | 333 void ProcessTypeFeedbackCells(Handle<Code> code); |
| 338 | 334 |
| 339 // Returns an element from the backing store. Returns undefined if | 335 // Returns an element from the backing store. Returns undefined if |
| 340 // there is no information. | 336 // there is no information. |
| 341 Handle<Object> GetInfo(TypeFeedbackId ast_id); | 337 Handle<Object> GetInfo(TypeFeedbackId ast_id); |
| 342 | 338 |
| 343 // Return the cell that contains type feedback. | 339 // Return the cell that contains type feedback. |
| 344 Handle<JSGlobalPropertyCell> GetInfoCell(TypeFeedbackId ast_id); | 340 Handle<Cell> GetInfoCell(TypeFeedbackId ast_id); |
| 345 | 341 |
| 346 private: | 342 private: |
| 347 Handle<Context> native_context_; | 343 Handle<Context> native_context_; |
| 348 Isolate* isolate_; | 344 Isolate* isolate_; |
| 349 Zone* zone_; | 345 Zone* zone_; |
| 350 Handle<UnseededNumberDictionary> dictionary_; | 346 Handle<UnseededNumberDictionary> dictionary_; |
| 351 | 347 |
| 352 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 348 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
| 353 }; | 349 }; |
| 354 | 350 |
| 355 } } // namespace v8::internal | 351 } } // namespace v8::internal |
| 356 | 352 |
| 357 #endif // V8_TYPE_INFO_H_ | 353 #endif // V8_TYPE_INFO_H_ |
| OLD | NEW |