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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: src/type-feedback-vector.h
diff --git a/src/type-feedback-vector.h b/src/type-feedback-vector.h
index 61463b0394fc8a5ed631ab8d76430755f9def6cc..5450a418b2366a580bf1c01dfdd04771a0be4f95 100644
--- a/src/type-feedback-vector.h
+++ b/src/type-feedback-vector.h
@@ -173,6 +173,104 @@ class TypeFeedbackVector : public FixedArray {
DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector);
};
+
+
+// A FeedbackNexus is the combination of a TypeFeedbackVector and a slot.
+// Derived classes customize the update and retrieval of feedback.
+class FeedbackNexus {
+ public:
+ FeedbackNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
+ : vector_handle_(vector), use_handle_(true), slot_(slot) {}
+ FeedbackNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
+ : vector_(vector), use_handle_(false), slot_(slot) {}
+ virtual ~FeedbackNexus() {}
+
+ Handle<TypeFeedbackVector> vector_handle() const {
+ DCHECK(use_handle_);
+ return vector_handle_;
+ }
+ TypeFeedbackVector* vector() const {
+ return use_handle_ ? *vector_handle_ : vector_;
+ }
+ FeedbackVectorICSlot slot() const { return slot_; }
+
+ InlineCacheState ic_state() const { return StateFromFeedback(); }
+ Map* FindFirstMap() const {
+ MapHandleList maps;
+ ExtractMaps(&maps);
+ if (maps.length() > 0) return *maps.at(0);
+ return NULL;
+ }
+
+ 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.
+
+ virtual InlineCacheState StateFromFeedback() const = 0;
+ virtual int ExtractMaps(MapHandleList* maps) const = 0;
+ virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const = 0;
+ virtual bool FindHandlers(CodeHandleList* code_list, int length = -1) const {
+ return length == 0;
+ }
+ virtual Name* FindFirstName() const { return NULL; }
+
+ Object* GetFeedback() const { return vector()->Get(slot()); }
+
+ protected:
+ Isolate* GetIsolate() const { return vector()->GetIsolate(); }
+
+ void SetFeedback(Object* feedback) { vector()->Set(slot(), feedback); }
+
+ Handle<FixedArray> EnsureArrayOfSize(int length);
+ void InstallHandlers(int start_index, TypeHandleList* types,
+ CodeHandleList* handlers);
+ int ExtractMaps(int start_index, MapHandleList* maps) const;
+ MaybeHandle<Code> FindHandlerForMap(int start_index, Handle<Map> map) const;
+ bool FindHandlers(int start_index, CodeHandleList* code_list,
+ int length) const;
+
+ private:
+ // The reason for the union is that we can use handles during IC miss,
+ // but not during GC when we clear ICs. If you have a handle to the
+ // vector that is better because more operations can be done, like
+ // allocation.
+ union {
+ Handle<TypeFeedbackVector> vector_handle_;
+ TypeFeedbackVector* vector_;
+ };
+ bool use_handle_;
+ FeedbackVectorICSlot slot_;
+};
+
+
+class CallICNexus : public FeedbackNexus {
+ public:
+ CallICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK(vector->GetKind(slot) == Code::CALL_IC);
+ }
+ CallICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
+ : FeedbackNexus(vector, slot) {
+ DCHECK(vector->GetKind(slot) == Code::CALL_IC);
+ }
+
+ void ConfigureUninitialized();
+ void ConfigureGeneric();
+ void ConfigureMonomorphicArray();
+ void ConfigureMonomorphic(Handle<JSFunction> function);
+
+ virtual InlineCacheState StateFromFeedback() const OVERRIDE;
+
+ virtual int ExtractMaps(MapHandleList* maps) const OVERRIDE {
+ // CallICs don't record map feedback.
+ return 0;
+ }
+ virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const OVERRIDE {
+ return MaybeHandle<Code>();
+ }
+ virtual bool FindHandlers(CodeHandleList* code_list,
+ int length = -1) const OVERRIDE {
+ return length == 0;
+ }
+};
}
} // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698