Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1203)

Side by Side Diff: src/type-feedback-vector.h

Issue 680883004: Introduce FeedbackNexus for vector-based ics. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Patch One. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_FEEDBACK_VECTOR_H_ 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_
6 #define V8_TYPE_FEEDBACK_VECTOR_H_ 6 #define V8_TYPE_FEEDBACK_VECTOR_H_
7 7
8 #include "src/checks.h" 8 #include "src/checks.h"
9 #include "src/elements-kind.h" 9 #include "src/elements-kind.h"
10 #include "src/heap/heap.h" 10 #include "src/heap/heap.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 }; 166 };
167 167
168 static const int kVectorICKindBits = 2; 168 static const int kVectorICKindBits = 2;
169 static VectorICKind FromCodeKind(Code::Kind kind); 169 static VectorICKind FromCodeKind(Code::Kind kind);
170 static Code::Kind FromVectorICKind(VectorICKind kind); 170 static Code::Kind FromVectorICKind(VectorICKind kind);
171 typedef BitSetComputer<VectorICKind, kVectorICKindBits, kSmiValueSize, 171 typedef BitSetComputer<VectorICKind, kVectorICKindBits, kSmiValueSize,
172 uint32_t> VectorICComputer; 172 uint32_t> VectorICComputer;
173 173
174 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector); 174 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector);
175 }; 175 };
176
177
178 // A FeedbackNexus is the combination of a TypeFeedbackVector and a slot.
179 // Derived classes customize the update and retrieval of feedback.
180 class FeedbackNexus {
181 public:
182 FeedbackNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
183 : vector_handle_(vector), use_handle_(true), slot_(slot) {}
184 FeedbackNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
185 : vector_(vector), use_handle_(false), slot_(slot) {}
186 virtual ~FeedbackNexus() {}
187
188 Handle<TypeFeedbackVector> vector_handle() const {
189 DCHECK(use_handle_);
190 return vector_handle_;
191 }
192 TypeFeedbackVector* vector() const {
193 return use_handle_ ? *vector_handle_ : vector_;
194 }
195 FeedbackVectorICSlot slot() const { return slot_; }
196
197 InlineCacheState ic_state() const { return StateFromFeedback(); }
198 Map* FindFirstMap() const {
199 MapHandleList maps;
200 ExtractMaps(&maps);
201 if (maps.length() > 0) return *maps.at(0);
202 return NULL;
203 }
204
205 void FindAllMaps(MapHandleList* maps) const { ExtractMaps(maps); }
Igor Sheludko 2014/10/28 11:12:36 Do we really need this method? Why not just call E
mvstanton 2014/10/28 13:23:28 Good point, removed.
206
207 virtual InlineCacheState StateFromFeedback() const = 0;
208 virtual int ExtractMaps(MapHandleList* maps) const = 0;
209 virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const = 0;
210 virtual bool FindHandlers(CodeHandleList* code_list, int length = -1) const {
211 return length == 0;
212 }
213 virtual Name* FindFirstName() const { return NULL; }
214
215 Object* GetFeedback() const { return vector()->Get(slot()); }
216
217 protected:
218 Isolate* GetIsolate() const { return vector()->GetIsolate(); }
219
220 void SetFeedback(Object* feedback) { vector()->Set(slot(), feedback); }
221
222 Handle<FixedArray> EnsureArrayOfSize(int length);
223 void InstallHandlers(int start_index, TypeHandleList* types,
224 CodeHandleList* handlers);
225 int ExtractMaps(int start_index, MapHandleList* maps) const;
226 MaybeHandle<Code> FindHandlerForMap(int start_index, Handle<Map> map) const;
227 bool FindHandlers(int start_index, CodeHandleList* code_list,
228 int length) const;
229
230 private:
231 // The reason for the union is that we can use handles during IC miss,
232 // but not during GC when we clear ICs. If you have a handle to the
233 // vector that is better because more operations can be done, like
234 // allocation.
235 union {
236 Handle<TypeFeedbackVector> vector_handle_;
237 TypeFeedbackVector* vector_;
238 };
239 bool use_handle_;
240 FeedbackVectorICSlot slot_;
241 };
242
243
244 class CallICNexus : public FeedbackNexus {
245 public:
246 CallICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
247 : FeedbackNexus(vector, slot) {
248 DCHECK(vector->GetKind(slot) == Code::CALL_IC);
249 }
250 CallICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
251 : FeedbackNexus(vector, slot) {
252 DCHECK(vector->GetKind(slot) == Code::CALL_IC);
253 }
254
255 void ConfigureUninitialized();
256 void ConfigureGeneric();
257 void ConfigureMonomorphicArray();
258 void ConfigureMonomorphic(Handle<JSFunction> function);
259
260 virtual InlineCacheState StateFromFeedback() const OVERRIDE;
261
262 virtual int ExtractMaps(MapHandleList* maps) const OVERRIDE {
263 // CallICs don't record map feedback.
264 return 0;
265 }
266 virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const OVERRIDE {
267 return MaybeHandle<Code>();
268 }
269 virtual bool FindHandlers(CodeHandleList* code_list,
270 int length = -1) const OVERRIDE {
271 return length == 0;
272 }
273 };
176 } 274 }
177 } // namespace v8::internal 275 } // namespace v8::internal
178 276
179 #endif // V8_TRANSITIONS_H_ 277 #endif // V8_TRANSITIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698