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
3 // found in the LICENSE file.
5 #ifndef V8_TYPE_INFO_H_
6 #define V8_TYPE_INFO_H_
8 #include "src/allocation.h"
9 #include "src/globals.h"
10 #include "src/types.h"
11 #include "src/zone-inl.h"
16 // Forward declarations.
20 class TypeFeedbackOracle: public ZoneObject {
22 TypeFeedbackOracle(Handle<Code> code,
23 Handle<TypeFeedbackVector> feedback_vector,
24 Handle<Context> native_context, Zone* zone);
26 bool LoadIsUninitialized(TypeFeedbackId id);
27 bool StoreIsUninitialized(TypeFeedbackId id);
28 bool StoreIsKeyedPolymorphic(TypeFeedbackId id);
29 bool CallIsMonomorphic(int slot);
30 bool CallIsMonomorphic(TypeFeedbackId aid);
31 bool KeyedArrayCallIsHoley(TypeFeedbackId id);
32 bool CallNewIsMonomorphic(int slot);
34 // TODO(1571) We can't use ForInStatement::ForInType as the return value due
35 // to various cycles in our headers.
36 // TODO(rossberg): once all oracle access is removed from ast.cc, it should
38 byte ForInType(int feedback_vector_slot);
40 KeyedAccessStoreMode GetStoreMode(TypeFeedbackId id);
42 void PropertyReceiverTypes(TypeFeedbackId id, Handle<String> name,
43 SmallMapList* receiver_types);
44 void KeyedPropertyReceiverTypes(TypeFeedbackId id,
45 SmallMapList* receiver_types,
47 void AssignmentReceiverTypes(TypeFeedbackId id,
49 SmallMapList* receiver_types);
50 void KeyedAssignmentReceiverTypes(TypeFeedbackId id,
51 SmallMapList* receiver_types,
52 KeyedAccessStoreMode* store_mode);
53 void CountReceiverTypes(TypeFeedbackId id,
54 SmallMapList* receiver_types);
56 void CollectReceiverTypes(TypeFeedbackId id,
59 static bool CanRetainOtherContext(Map* map, Context* native_context);
60 static bool CanRetainOtherContext(JSFunction* function,
61 Context* native_context);
63 Handle<JSFunction> GetCallTarget(int slot);
64 Handle<AllocationSite> GetCallAllocationSite(int slot);
65 Handle<JSFunction> GetCallNewTarget(int slot);
66 Handle<AllocationSite> GetCallNewAllocationSite(int slot);
68 bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id);
70 // TODO(1571) We can't use ToBooleanStub::Types as the return value because
71 // of various cycles in our headers. Death to tons of implementations in
73 byte ToBooleanTypes(TypeFeedbackId id);
75 // Get type information for arithmetic operations and compares.
76 void BinaryType(TypeFeedbackId id,
80 Maybe<int>* fixed_right_arg,
81 Handle<AllocationSite>* allocation_site,
82 Token::Value operation);
84 void CompareType(TypeFeedbackId id,
89 Type* CountType(TypeFeedbackId id);
91 Zone* zone() const { return zone_; }
92 Isolate* isolate() const { return zone_->isolate(); }
95 void CollectReceiverTypes(TypeFeedbackId id,
100 void SetInfo(TypeFeedbackId id, Object* target);
102 void BuildDictionary(Handle<Code> code);
103 void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos);
104 void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos);
105 void RelocateRelocInfos(ZoneList<RelocInfo>* infos,
108 void ProcessRelocInfos(ZoneList<RelocInfo>* infos);
110 // Returns an element from the backing store. Returns undefined if
111 // there is no information.
112 Handle<Object> GetInfo(TypeFeedbackId id);
114 // Returns an element from the type feedback vector. Returns undefined
115 // if there is no information.
116 Handle<Object> GetInfo(int slot);
119 Handle<Context> native_context_;
121 Handle<UnseededNumberDictionary> dictionary_;
122 Handle<TypeFeedbackVector> feedback_vector_;
124 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
127 } } // namespace v8::internal
129 #endif // V8_TYPE_INFO_H_