| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_TYPE_INFO_H_ | 5 #ifndef V8_TYPE_INFO_H_ | 
| 6 #define V8_TYPE_INFO_H_ | 6 #define V8_TYPE_INFO_H_ | 
| 7 | 7 | 
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" | 
| 9 #include "src/contexts.h" | 9 #include "src/contexts.h" | 
| 10 #include "src/globals.h" | 10 #include "src/globals.h" | 
| 11 #include "src/token.h" | 11 #include "src/token.h" | 
| 12 #include "src/types.h" | 12 #include "src/types.h" | 
| 13 #include "src/zone.h" | 13 #include "src/zone.h" | 
| 14 | 14 | 
| 15 namespace v8 { | 15 namespace v8 { | 
| 16 namespace internal { | 16 namespace internal { | 
| 17 | 17 | 
| 18 // Forward declarations. | 18 // Forward declarations. | 
| 19 class SmallMapList; | 19 class SmallMapList; | 
| 20 | 20 | 
| 21 | 21 | 
| 22 class TypeFeedbackOracle: public ZoneObject { | 22 class TypeFeedbackOracle: public ZoneObject { | 
| 23  public: | 23  public: | 
| 24   TypeFeedbackOracle(Isolate* isolate, Zone* zone, Handle<Code> code, | 24   TypeFeedbackOracle(Isolate* isolate, Zone* zone, Handle<Code> code, | 
| 25                      Handle<TypeFeedbackVector> feedback_vector, | 25                      Handle<TypeFeedbackVector> feedback_vector, | 
| 26                      Handle<Context> native_context); | 26                      Handle<Context> native_context); | 
| 27 | 27 | 
| 28   InlineCacheState LoadInlineCacheState(TypeFeedbackId id); | 28   InlineCacheState LoadInlineCacheState(TypeFeedbackId id); | 
| 29   InlineCacheState LoadInlineCacheState(FeedbackVectorICSlot slot); | 29   InlineCacheState LoadInlineCacheState(FeedbackVectorSlot slot); | 
| 30   bool StoreIsUninitialized(TypeFeedbackId id); | 30   bool StoreIsUninitialized(TypeFeedbackId id); | 
| 31   bool StoreIsUninitialized(FeedbackVectorICSlot slot); | 31   bool StoreIsUninitialized(FeedbackVectorSlot slot); | 
| 32   bool CallIsUninitialized(FeedbackVectorICSlot slot); | 32   bool CallIsUninitialized(FeedbackVectorSlot slot); | 
| 33   bool CallIsMonomorphic(FeedbackVectorICSlot slot); | 33   bool CallIsMonomorphic(FeedbackVectorSlot slot); | 
| 34   bool KeyedArrayCallIsHoley(TypeFeedbackId id); | 34   bool KeyedArrayCallIsHoley(TypeFeedbackId id); | 
| 35   bool CallNewIsMonomorphic(FeedbackVectorSlot slot); | 35   bool CallNewIsMonomorphic(FeedbackVectorSlot slot); | 
| 36 | 36 | 
| 37   // TODO(1571) We can't use ForInStatement::ForInType as the return value due | 37   // TODO(1571) We can't use ForInStatement::ForInType as the return value due | 
| 38   // to various cycles in our headers. | 38   // to various cycles in our headers. | 
| 39   // TODO(rossberg): once all oracle access is removed from ast.cc, it should | 39   // TODO(rossberg): once all oracle access is removed from ast.cc, it should | 
| 40   // be possible. | 40   // be possible. | 
| 41   byte ForInType(FeedbackVectorSlot feedback_vector_slot); | 41   byte ForInType(FeedbackVectorSlot feedback_vector_slot); | 
| 42 | 42 | 
| 43   void GetStoreModeAndKeyType(TypeFeedbackId id, | 43   void GetStoreModeAndKeyType(TypeFeedbackId id, | 
| 44                               KeyedAccessStoreMode* store_mode, | 44                               KeyedAccessStoreMode* store_mode, | 
| 45                               IcCheckType* key_type); | 45                               IcCheckType* key_type); | 
| 46   void GetStoreModeAndKeyType(FeedbackVectorICSlot slot, | 46   void GetStoreModeAndKeyType(FeedbackVectorSlot slot, | 
| 47                               KeyedAccessStoreMode* store_mode, | 47                               KeyedAccessStoreMode* store_mode, | 
| 48                               IcCheckType* key_type); | 48                               IcCheckType* key_type); | 
| 49 | 49 | 
| 50   void PropertyReceiverTypes(FeedbackVectorICSlot slot, Handle<Name> name, | 50   void PropertyReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 
| 51                              SmallMapList* receiver_types); | 51                              SmallMapList* receiver_types); | 
| 52   void KeyedPropertyReceiverTypes(FeedbackVectorICSlot slot, | 52   void KeyedPropertyReceiverTypes(FeedbackVectorSlot slot, | 
| 53                                   SmallMapList* receiver_types, bool* is_string, | 53                                   SmallMapList* receiver_types, bool* is_string, | 
| 54                                   IcCheckType* key_type); | 54                                   IcCheckType* key_type); | 
| 55   void AssignmentReceiverTypes(TypeFeedbackId id, Handle<Name> name, | 55   void AssignmentReceiverTypes(TypeFeedbackId id, Handle<Name> name, | 
| 56                                SmallMapList* receiver_types); | 56                                SmallMapList* receiver_types); | 
| 57   void AssignmentReceiverTypes(FeedbackVectorICSlot slot, Handle<Name> name, | 57   void AssignmentReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 
| 58                                SmallMapList* receiver_types); | 58                                SmallMapList* receiver_types); | 
| 59   void KeyedAssignmentReceiverTypes(TypeFeedbackId id, | 59   void KeyedAssignmentReceiverTypes(TypeFeedbackId id, | 
| 60                                     SmallMapList* receiver_types, | 60                                     SmallMapList* receiver_types, | 
| 61                                     KeyedAccessStoreMode* store_mode, | 61                                     KeyedAccessStoreMode* store_mode, | 
| 62                                     IcCheckType* key_type); | 62                                     IcCheckType* key_type); | 
| 63   void KeyedAssignmentReceiverTypes(FeedbackVectorICSlot slot, | 63   void KeyedAssignmentReceiverTypes(FeedbackVectorSlot slot, | 
| 64                                     SmallMapList* receiver_types, | 64                                     SmallMapList* receiver_types, | 
| 65                                     KeyedAccessStoreMode* store_mode, | 65                                     KeyedAccessStoreMode* store_mode, | 
| 66                                     IcCheckType* key_type); | 66                                     IcCheckType* key_type); | 
| 67   void CountReceiverTypes(TypeFeedbackId id, | 67   void CountReceiverTypes(TypeFeedbackId id, | 
| 68                           SmallMapList* receiver_types); | 68                           SmallMapList* receiver_types); | 
| 69   void CountReceiverTypes(FeedbackVectorICSlot slot, | 69   void CountReceiverTypes(FeedbackVectorSlot slot, | 
| 70                           SmallMapList* receiver_types); | 70                           SmallMapList* receiver_types); | 
| 71 | 71 | 
| 72   void CollectReceiverTypes(FeedbackVectorICSlot slot, SmallMapList* types); | 72   void CollectReceiverTypes(FeedbackVectorSlot slot, SmallMapList* types); | 
| 73   void CollectReceiverTypes(TypeFeedbackId id, | 73   void CollectReceiverTypes(TypeFeedbackId id, | 
| 74                             SmallMapList* types); | 74                             SmallMapList* types); | 
| 75   template <class T> | 75   template <class T> | 
| 76   void CollectReceiverTypes(T* obj, SmallMapList* types); | 76   void CollectReceiverTypes(T* obj, SmallMapList* types); | 
| 77 | 77 | 
| 78   static bool IsRelevantFeedback(Map* map, Context* native_context) { | 78   static bool IsRelevantFeedback(Map* map, Context* native_context) { | 
| 79     Object* constructor = map->GetConstructor(); | 79     Object* constructor = map->GetConstructor(); | 
| 80     return !constructor->IsJSFunction() || | 80     return !constructor->IsJSFunction() || | 
| 81            JSFunction::cast(constructor)->context()->native_context() == | 81            JSFunction::cast(constructor)->context()->native_context() == | 
| 82                native_context; | 82                native_context; | 
| 83   } | 83   } | 
| 84 | 84 | 
| 85   Handle<JSFunction> GetCallTarget(FeedbackVectorICSlot slot); | 85   Handle<JSFunction> GetCallTarget(FeedbackVectorSlot slot); | 
| 86   Handle<AllocationSite> GetCallAllocationSite(FeedbackVectorICSlot slot); | 86   Handle<AllocationSite> GetCallAllocationSite(FeedbackVectorSlot slot); | 
| 87   Handle<JSFunction> GetCallNewTarget(FeedbackVectorSlot slot); | 87   Handle<JSFunction> GetCallNewTarget(FeedbackVectorSlot slot); | 
| 88   Handle<AllocationSite> GetCallNewAllocationSite(FeedbackVectorSlot slot); | 88   Handle<AllocationSite> GetCallNewAllocationSite(FeedbackVectorSlot slot); | 
| 89 | 89 | 
| 90   bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id); | 90   bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id); | 
| 91 | 91 | 
| 92   // TODO(1571) We can't use ToBooleanStub::Types as the return value because | 92   // TODO(1571) We can't use ToBooleanStub::Types as the return value because | 
| 93   // of various cycles in our headers. Death to tons of implementations in | 93   // of various cycles in our headers. Death to tons of implementations in | 
| 94   // headers!! :-P | 94   // headers!! :-P | 
| 95   uint16_t ToBooleanTypes(TypeFeedbackId id); | 95   uint16_t ToBooleanTypes(TypeFeedbackId id); | 
| 96 | 96 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 107                    Type** left, | 107                    Type** left, | 
| 108                    Type** right, | 108                    Type** right, | 
| 109                    Type** combined); | 109                    Type** combined); | 
| 110 | 110 | 
| 111   Type* CountType(TypeFeedbackId id); | 111   Type* CountType(TypeFeedbackId id); | 
| 112 | 112 | 
| 113   Zone* zone() const { return zone_; } | 113   Zone* zone() const { return zone_; } | 
| 114   Isolate* isolate() const { return isolate_; } | 114   Isolate* isolate() const { return isolate_; } | 
| 115 | 115 | 
| 116  private: | 116  private: | 
| 117   void CollectReceiverTypes(FeedbackVectorICSlot slot, Handle<Name> name, | 117   void CollectReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 
| 118                             Code::Flags flags, SmallMapList* types); | 118                             Code::Flags flags, SmallMapList* types); | 
| 119   void CollectReceiverTypes(TypeFeedbackId id, Handle<Name> name, | 119   void CollectReceiverTypes(TypeFeedbackId id, Handle<Name> name, | 
| 120                             Code::Flags flags, SmallMapList* types); | 120                             Code::Flags flags, SmallMapList* types); | 
| 121   template <class T> | 121   template <class T> | 
| 122   void CollectReceiverTypes(T* obj, Handle<Name> name, Code::Flags flags, | 122   void CollectReceiverTypes(T* obj, Handle<Name> name, Code::Flags flags, | 
| 123                             SmallMapList* types); | 123                             SmallMapList* types); | 
| 124 | 124 | 
| 125   // Returns true if there is at least one string map and if | 125   // Returns true if there is at least one string map and if | 
| 126   // all maps are string maps. | 126   // all maps are string maps. | 
| 127   bool HasOnlyStringMaps(SmallMapList* receiver_types); | 127   bool HasOnlyStringMaps(SmallMapList* receiver_types); | 
| 128 | 128 | 
| 129   void SetInfo(TypeFeedbackId id, Object* target); | 129   void SetInfo(TypeFeedbackId id, Object* target); | 
| 130 | 130 | 
| 131   void BuildDictionary(Handle<Code> code); | 131   void BuildDictionary(Handle<Code> code); | 
| 132   void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos); | 132   void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos); | 
| 133   void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos); | 133   void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos); | 
| 134   void RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 134   void RelocateRelocInfos(ZoneList<RelocInfo>* infos, | 
| 135                           Code* old_code, | 135                           Code* old_code, | 
| 136                           Code* new_code); | 136                           Code* new_code); | 
| 137   void ProcessRelocInfos(ZoneList<RelocInfo>* infos); | 137   void ProcessRelocInfos(ZoneList<RelocInfo>* infos); | 
| 138 | 138 | 
| 139   // Returns an element from the backing store. Returns undefined if | 139   // Returns an element from the backing store. Returns undefined if | 
| 140   // there is no information. | 140   // there is no information. | 
| 141   Handle<Object> GetInfo(TypeFeedbackId id); | 141   Handle<Object> GetInfo(TypeFeedbackId id); | 
| 142 | 142 | 
| 143   // Returns an element from the type feedback vector. Returns undefined | 143   // Returns an element from the type feedback vector. Returns undefined | 
| 144   // if there is no information. | 144   // if there is no information. | 
| 145   Handle<Object> GetInfo(FeedbackVectorSlot slot); | 145   Handle<Object> GetInfo(FeedbackVectorSlot slot); | 
| 146   Handle<Object> GetInfo(FeedbackVectorICSlot slot); |  | 
| 147 | 146 | 
| 148  private: | 147  private: | 
| 149   Handle<Context> native_context_; | 148   Handle<Context> native_context_; | 
| 150   Isolate* isolate_; | 149   Isolate* isolate_; | 
| 151   Zone* zone_; | 150   Zone* zone_; | 
| 152   Handle<UnseededNumberDictionary> dictionary_; | 151   Handle<UnseededNumberDictionary> dictionary_; | 
| 153   Handle<TypeFeedbackVector> feedback_vector_; | 152   Handle<TypeFeedbackVector> feedback_vector_; | 
| 154 | 153 | 
| 155   DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 154   DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 
| 156 }; | 155 }; | 
| 157 | 156 | 
| 158 }  // namespace internal | 157 }  // namespace internal | 
| 159 }  // namespace v8 | 158 }  // namespace v8 | 
| 160 | 159 | 
| 161 #endif  // V8_TYPE_INFO_H_ | 160 #endif  // V8_TYPE_INFO_H_ | 
| OLD | NEW | 
|---|