1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
28 #ifndef V8_TYPE_INFO_H_
29 #define V8_TYPE_INFO_H_
31 #include "allocation.h"
39 // Forward declarations.
44 class TypeFeedbackOracle: public ZoneObject {
46 TypeFeedbackOracle(Handle<Code> code,
47 Handle<Context> native_context,
50 bool LoadIsUninitialized(TypeFeedbackId id);
51 bool StoreIsUninitialized(TypeFeedbackId id);
52 bool StoreIsKeyedPolymorphic(TypeFeedbackId id);
53 bool CallIsMonomorphic(TypeFeedbackId aid);
54 bool CallNewIsMonomorphic(TypeFeedbackId id);
56 // TODO(1571) We can't use ForInStatement::ForInType as the return value due
57 // to various cycles in our headers.
58 // TODO(rossberg): once all oracle access is removed from ast.cc, it should
60 byte ForInType(TypeFeedbackId id);
62 KeyedAccessStoreMode GetStoreMode(TypeFeedbackId id);
64 void PropertyReceiverTypes(TypeFeedbackId id,
66 SmallMapList* receiver_types,
68 void KeyedPropertyReceiverTypes(TypeFeedbackId id,
69 SmallMapList* receiver_types,
71 void AssignmentReceiverTypes(TypeFeedbackId id,
73 SmallMapList* receiver_types);
74 void KeyedAssignmentReceiverTypes(TypeFeedbackId id,
75 SmallMapList* receiver_types,
76 KeyedAccessStoreMode* store_mode);
77 void CountReceiverTypes(TypeFeedbackId id,
78 SmallMapList* receiver_types);
80 void CollectReceiverTypes(TypeFeedbackId id,
83 static bool CanRetainOtherContext(Map* map, Context* native_context);
84 static bool CanRetainOtherContext(JSFunction* function,
85 Context* native_context);
87 Handle<JSFunction> GetCallTarget(TypeFeedbackId id);
88 Handle<JSFunction> GetCallNewTarget(TypeFeedbackId id);
89 Handle<AllocationSite> GetCallNewAllocationSite(TypeFeedbackId id);
91 bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id);
92 bool LoadIsStub(TypeFeedbackId id, ICStub* stub);
94 // TODO(1571) We can't use ToBooleanStub::Types as the return value because
95 // of various cycles in our headers. Death to tons of implementations in
97 byte ToBooleanTypes(TypeFeedbackId id);
99 // Get type information for arithmetic operations and compares.
100 void BinaryType(TypeFeedbackId id,
104 Maybe<int>* fixed_right_arg,
105 Handle<AllocationSite>* allocation_site,
106 Token::Value operation);
108 void CompareType(TypeFeedbackId id,
113 Type* CountType(TypeFeedbackId id);
115 Zone* zone() const { return zone_; }
116 Isolate* isolate() const { return zone_->isolate(); }
119 void CollectReceiverTypes(TypeFeedbackId id,
122 SmallMapList* types);
124 void SetInfo(TypeFeedbackId id, Object* target);
126 void BuildDictionary(Handle<Code> code);
127 void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos);
128 void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos);
129 void RelocateRelocInfos(ZoneList<RelocInfo>* infos,
132 void ProcessRelocInfos(ZoneList<RelocInfo>* infos);
133 void ProcessTypeFeedbackCells(Handle<Code> code);
135 // Returns an element from the backing store. Returns undefined if
136 // there is no information.
137 Handle<Object> GetInfo(TypeFeedbackId id);
140 Handle<Context> native_context_;
142 Handle<UnseededNumberDictionary> dictionary_;
144 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
147 } } // namespace v8::internal
149 #endif // V8_TYPE_INFO_H_