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

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

Issue 2342853002: [TypeFeedbackVector] special ic slots for interpreter compare/binary ops. (Closed)
Patch Set: Code comments. Created 4 years, 3 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 unified diff | Download patch
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 <vector> 8 #include <vector>
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
11 #include "src/elements-kind.h" 11 #include "src/elements-kind.h"
12 #include "src/objects.h" 12 #include "src/objects.h"
13 #include "src/type-hints.h"
13 #include "src/zone-containers.h" 14 #include "src/zone-containers.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
18 enum class FeedbackVectorSlotKind { 19 enum class FeedbackVectorSlotKind {
19 // This kind means that the slot points to the middle of other slot 20 // This kind means that the slot points to the middle of other slot
20 // which occupies more than one feedback vector element. 21 // which occupies more than one feedback vector element.
21 // There must be no such slots in the system. 22 // There must be no such slots in the system.
22 INVALID, 23 INVALID,
23 24
24 CALL_IC, 25 CALL_IC,
25 LOAD_IC, 26 LOAD_IC,
26 LOAD_GLOBAL_IC, 27 LOAD_GLOBAL_IC,
27 KEYED_LOAD_IC, 28 KEYED_LOAD_IC,
28 STORE_IC, 29 STORE_IC,
29 KEYED_STORE_IC, 30 KEYED_STORE_IC,
31 INTERPRETER_BINARYOP_IC,
32 INTERPRETER_COMPARE_IC,
30 33
31 // This is a general purpose slot that occupies one feedback vector element. 34 // This is a general purpose slot that occupies one feedback vector element.
32 GENERAL, 35 GENERAL,
33 36
34 KINDS_NUMBER // Last value indicating number of kinds. 37 KINDS_NUMBER // Last value indicating number of kinds.
35 }; 38 };
36 39
37 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind); 40 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind);
38 41
39 42
(...skipping 20 matching lines...) Expand all
60 } 63 }
61 64
62 FeedbackVectorSlot AddStoreICSlot() { 65 FeedbackVectorSlot AddStoreICSlot() {
63 return AddSlot(FeedbackVectorSlotKind::STORE_IC); 66 return AddSlot(FeedbackVectorSlotKind::STORE_IC);
64 } 67 }
65 68
66 FeedbackVectorSlot AddKeyedStoreICSlot() { 69 FeedbackVectorSlot AddKeyedStoreICSlot() {
67 return AddSlot(FeedbackVectorSlotKind::KEYED_STORE_IC); 70 return AddSlot(FeedbackVectorSlotKind::KEYED_STORE_IC);
68 } 71 }
69 72
73 FeedbackVectorSlot AddInterpreterBinaryOpICSlot() {
74 return AddSlot(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC);
75 }
76
77 FeedbackVectorSlot AddInterpreterCompareICSlot() {
78 return AddSlot(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC);
79 }
80
70 FeedbackVectorSlot AddGeneralSlot() { 81 FeedbackVectorSlot AddGeneralSlot() {
71 return AddSlot(FeedbackVectorSlotKind::GENERAL); 82 return AddSlot(FeedbackVectorSlotKind::GENERAL);
72 } 83 }
73 84
74 #ifdef OBJECT_PRINT 85 #ifdef OBJECT_PRINT
75 // For gdb debugging. 86 // For gdb debugging.
76 void Print(); 87 void Print();
77 #endif // OBJECT_PRINT 88 #endif // OBJECT_PRINT
78 89
79 DECLARE_PRINTER(FeedbackVectorSpec) 90 DECLARE_PRINTER(FeedbackVectorSpec)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 #ifdef OBJECT_PRINT 211 #ifdef OBJECT_PRINT
201 // For gdb debugging. 212 // For gdb debugging.
202 void Print(); 213 void Print();
203 #endif // OBJECT_PRINT 214 #endif // OBJECT_PRINT
204 215
205 DECLARE_PRINTER(TypeFeedbackMetadata) 216 DECLARE_PRINTER(TypeFeedbackMetadata)
206 217
207 static const char* Kind2String(FeedbackVectorSlotKind kind); 218 static const char* Kind2String(FeedbackVectorSlotKind kind);
208 219
209 private: 220 private:
210 static const int kFeedbackVectorSlotKindBits = 4; 221 static const int kFeedbackVectorSlotKindBits = 5;
211 STATIC_ASSERT(static_cast<int>(FeedbackVectorSlotKind::KINDS_NUMBER) < 222 STATIC_ASSERT(static_cast<int>(FeedbackVectorSlotKind::KINDS_NUMBER) <
212 (1 << kFeedbackVectorSlotKindBits)); 223 (1 << kFeedbackVectorSlotKindBits));
213 224
214 void SetKind(FeedbackVectorSlot slot, FeedbackVectorSlotKind kind); 225 void SetKind(FeedbackVectorSlot slot, FeedbackVectorSlotKind kind);
215 226
216 typedef BitSetComputer<FeedbackVectorSlotKind, kFeedbackVectorSlotKindBits, 227 typedef BitSetComputer<FeedbackVectorSlotKind, kFeedbackVectorSlotKindBits,
217 kSmiValueSize, uint32_t> VectorICComputer; 228 kSmiValueSize, uint32_t> VectorICComputer;
218 229
219 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackMetadata); 230 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackMetadata);
220 }; 231 };
221 232
222 233
223 // The shape of the TypeFeedbackVector is an array with: 234 // The shape of the TypeFeedbackVector is an array with:
224 // 0: feedback metadata 235 // 0: feedback metadata
225 // 1: invocation count 236 // 1: invocation count
226 // 2: feedback slot #0 237 // 2: feedback slot #0
227 // ... 238 // ...
228 // 2 + slot_count - 1: feedback slot #(slot_count-1) 239 // 2 + slot_count - 1: feedback slot #(slot_count-1)
229 // 240 //
230 class TypeFeedbackVector : public FixedArray { 241 class TypeFeedbackVector : public FixedArray {
231 public: 242 public:
232 // Casting. 243 // Casting.
233 static inline TypeFeedbackVector* cast(Object* obj); 244 static inline TypeFeedbackVector* cast(Object* obj);
234 245
235 static const int kMetadataIndex = 0; 246 static const int kMetadataIndex = 0;
236 static const int kInvocationCountIndex = 1; 247 static const int kInvocationCountIndex = 1;
237 static const int kReservedIndexCount = 2; 248 static const int kReservedIndexCount = 2;
238 249
239 inline void ComputeCounts(int* with_type_info, int* generic); 250 inline void ComputeCounts(int* with_type_info, int* generic,
251 bool code_is_interpreted);
240 252
241 inline bool is_empty() const; 253 inline bool is_empty() const;
242 254
243 // Returns number of slots in the vector. 255 // Returns number of slots in the vector.
244 inline int slot_count() const; 256 inline int slot_count() const;
245 257
246 inline TypeFeedbackMetadata* metadata() const; 258 inline TypeFeedbackMetadata* metadata() const;
247 inline int invocation_count() const; 259 inline int invocation_count() const;
248 260
249 // Conversion from a slot to an integer index to the underlying array. 261 // Conversion from a slot to an integer index to the underlying array.
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 MapHandleList* transitioned_maps, 641 MapHandleList* transitioned_maps,
630 CodeHandleList* handlers); 642 CodeHandleList* handlers);
631 void ConfigureMegamorphicKeyed(IcCheckType property_type); 643 void ConfigureMegamorphicKeyed(IcCheckType property_type);
632 644
633 KeyedAccessStoreMode GetKeyedAccessStoreMode() const; 645 KeyedAccessStoreMode GetKeyedAccessStoreMode() const;
634 IcCheckType GetKeyType() const; 646 IcCheckType GetKeyType() const;
635 647
636 InlineCacheState StateFromFeedback() const override; 648 InlineCacheState StateFromFeedback() const override;
637 Name* FindFirstName() const override; 649 Name* FindFirstName() const override;
638 }; 650 };
651
652 class BinaryOpICNexus final : public FeedbackNexus {
653 public:
654 BinaryOpICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
655 : FeedbackNexus(vector, slot) {
656 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC,
657 vector->GetKind(slot));
658 }
659 BinaryOpICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
660 : FeedbackNexus(vector, slot) {
661 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC,
662 vector->GetKind(slot));
663 }
664
665 void Clear(Code* host);
666
667 InlineCacheState StateFromFeedback() const final;
668 BinaryOperationHint GetBinaryOperationFeedback() const;
669
670 int ExtractMaps(MapHandleList* maps) const final {
671 // BinaryOpICs don't record map feedback.
672 return 0;
673 }
674 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final {
675 return MaybeHandle<Code>();
676 }
677 bool FindHandlers(List<Handle<Object>>* code_list,
678 int length = -1) const final {
679 return length == 0;
680 }
681 };
682
683 class CompareICNexus final : public FeedbackNexus {
684 public:
685 CompareICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
686 : FeedbackNexus(vector, slot) {
687 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC,
688 vector->GetKind(slot));
689 }
690 CompareICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
691 : FeedbackNexus(vector, slot) {
692 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC,
693 vector->GetKind(slot));
694 }
695
696 void Clear(Code* host);
697
698 InlineCacheState StateFromFeedback() const final;
699 CompareOperationHint GetCompareOperationFeedback() const;
700
701 int ExtractMaps(MapHandleList* maps) const final {
702 // BinaryOpICs don't record map feedback.
703 return 0;
704 }
705 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final {
706 return MaybeHandle<Code>();
707 }
708 bool FindHandlers(List<Handle<Object>>* code_list,
709 int length = -1) const final {
710 return length == 0;
711 }
712 };
713
714 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback);
715 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback);
716
639 } // namespace internal 717 } // namespace internal
640 } // namespace v8 718 } // namespace v8
641 719
642 #endif // V8_TRANSITIONS_H_ 720 #endif // V8_TRANSITIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698