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

Side by Side Diff: src/type-feedback-vector-inl.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
« no previous file with comments | « src/type-feedback-vector.cc ('k') | src/type-hints.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 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 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_INL_H_ 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_
6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ 6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_
7 7
8 #include "src/globals.h"
8 #include "src/type-feedback-vector.h" 9 #include "src/type-feedback-vector.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 14
14 template <typename Derived> 15 template <typename Derived>
15 FeedbackVectorSlot FeedbackVectorSpecBase<Derived>::AddSlot( 16 FeedbackVectorSlot FeedbackVectorSpecBase<Derived>::AddSlot(
16 FeedbackVectorSlotKind kind) { 17 FeedbackVectorSlotKind kind) {
17 int slot = This()->slots(); 18 int slot = This()->slots();
(...skipping 27 matching lines...) Expand all
45 // static 46 // static
46 TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) { 47 TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) {
47 DCHECK(obj->IsTypeFeedbackVector()); 48 DCHECK(obj->IsTypeFeedbackVector());
48 return reinterpret_cast<TypeFeedbackVector*>(obj); 49 return reinterpret_cast<TypeFeedbackVector*>(obj);
49 } 50 }
50 51
51 52
52 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { 53 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) {
53 DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind); 54 DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind);
54 DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind); 55 DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind);
55 return kind == FeedbackVectorSlotKind::GENERAL ? 1 : 2; 56 if (kind == FeedbackVectorSlotKind::GENERAL ||
57 kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC ||
58 kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC) {
59 return 1;
60 }
61
62 return 2;
56 } 63 }
57 64
58 bool TypeFeedbackMetadata::SlotRequiresName(FeedbackVectorSlotKind kind) { 65 bool TypeFeedbackMetadata::SlotRequiresName(FeedbackVectorSlotKind kind) {
59 switch (kind) { 66 switch (kind) {
60 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: 67 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC:
61 return true; 68 return true;
62 69
63 case FeedbackVectorSlotKind::CALL_IC: 70 case FeedbackVectorSlotKind::CALL_IC:
64 case FeedbackVectorSlotKind::LOAD_IC: 71 case FeedbackVectorSlotKind::LOAD_IC:
65 case FeedbackVectorSlotKind::KEYED_LOAD_IC: 72 case FeedbackVectorSlotKind::KEYED_LOAD_IC:
66 case FeedbackVectorSlotKind::STORE_IC: 73 case FeedbackVectorSlotKind::STORE_IC:
67 case FeedbackVectorSlotKind::KEYED_STORE_IC: 74 case FeedbackVectorSlotKind::KEYED_STORE_IC:
75 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC:
76 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC:
68 case FeedbackVectorSlotKind::GENERAL: 77 case FeedbackVectorSlotKind::GENERAL:
69 case FeedbackVectorSlotKind::INVALID: 78 case FeedbackVectorSlotKind::INVALID:
70 return false; 79 return false;
71 80
72 case FeedbackVectorSlotKind::KINDS_NUMBER: 81 case FeedbackVectorSlotKind::KINDS_NUMBER:
73 break; 82 break;
74 } 83 }
75 UNREACHABLE(); 84 UNREACHABLE();
76 return false; 85 return false;
77 } 86 }
(...skipping 26 matching lines...) Expand all
104 Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) const { 113 Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) const {
105 return get(GetIndex(slot)); 114 return get(GetIndex(slot));
106 } 115 }
107 116
108 117
109 void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value, 118 void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value,
110 WriteBarrierMode mode) { 119 WriteBarrierMode mode) {
111 set(GetIndex(slot), value, mode); 120 set(GetIndex(slot), value, mode);
112 } 121 }
113 122
123 // Helper function to transform the feedback to BinaryOperationHint.
124 BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback) {
125 switch (type_feedback) {
126 case BinaryOperationFeedback::kSignedSmall:
127 return BinaryOperationHint::kSignedSmall;
128 case BinaryOperationFeedback::kNumber:
129 return BinaryOperationHint::kNumberOrOddball;
130 case BinaryOperationFeedback::kAny:
131 default:
132 return BinaryOperationHint::kAny;
133 }
134 UNREACHABLE();
135 return BinaryOperationHint::kNone;
136 }
114 137
115 void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic) { 138 // Helper function to transform the feedback to CompareOperationHint.
139 CompareOperationHint CompareOperationHintFromFeedback(int type_feedback) {
140 switch (type_feedback) {
141 case CompareOperationFeedback::kSignedSmall:
142 return CompareOperationHint::kSignedSmall;
143 case CompareOperationFeedback::kNumber:
144 return CompareOperationHint::kNumber;
145 default:
146 return CompareOperationHint::kAny;
147 }
148 }
149
150 void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic,
151 bool code_is_interpreted) {
116 Object* uninitialized_sentinel = 152 Object* uninitialized_sentinel =
117 TypeFeedbackVector::RawUninitializedSentinel(GetIsolate()); 153 TypeFeedbackVector::RawUninitializedSentinel(GetIsolate());
118 Object* megamorphic_sentinel = 154 Object* megamorphic_sentinel =
119 *TypeFeedbackVector::MegamorphicSentinel(GetIsolate()); 155 *TypeFeedbackVector::MegamorphicSentinel(GetIsolate());
120 int with = 0; 156 int with = 0;
121 int gen = 0; 157 int gen = 0;
122 TypeFeedbackMetadataIterator iter(metadata()); 158 TypeFeedbackMetadataIterator iter(metadata());
123 while (iter.HasNext()) { 159 while (iter.HasNext()) {
124 FeedbackVectorSlot slot = iter.Next(); 160 FeedbackVectorSlot slot = iter.Next();
125 FeedbackVectorSlotKind kind = iter.kind(); 161 FeedbackVectorSlotKind kind = iter.kind();
126 162
127 Object* obj = Get(slot); 163 Object* obj = Get(slot);
128 if (obj != uninitialized_sentinel && 164 if (obj != uninitialized_sentinel &&
129 kind != FeedbackVectorSlotKind::GENERAL) { 165 kind != FeedbackVectorSlotKind::GENERAL) {
130 if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) { 166 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC ||
167 kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC) {
168 // If we are not running interpreted code, we need to ignore
169 // the special ic slots for binaryop/compare used by the
170 // interpreter.
171 // TODO(mvstanton): Remove code_is_interpreted when full code
172 // is retired from service.
173 if (code_is_interpreted) continue;
Benedikt Meurer 2016/09/20 17:15:00 Ops, this is missing an exclamation mark.
174
175 DCHECK(obj->IsSmi());
176 int op_feedback = static_cast<int>(Smi::cast(obj)->value());
177 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC) {
178 CompareOperationHint hint =
179 CompareOperationHintFromFeedback(op_feedback);
180 if (hint == CompareOperationHint::kAny) {
181 gen++;
182 } else if (hint != CompareOperationHint::kNone) {
183 with++;
184 }
185 } else {
186 DCHECK(kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC);
187 BinaryOperationHint hint =
188 BinaryOperationHintFromFeedback(op_feedback);
189 if (hint == BinaryOperationHint::kAny) {
190 gen++;
191 } else if (hint != BinaryOperationHint::kNone) {
192 with++;
193 }
194 }
195 } else if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) {
131 with++; 196 with++;
132 } else if (obj == megamorphic_sentinel) { 197 } else if (obj == megamorphic_sentinel) {
133 gen++; 198 gen++;
134 } 199 }
135 } 200 }
136 } 201 }
137 202
138 *with_type_info = with; 203 *with_type_info = with;
139 *generic = gen; 204 *generic = gen;
140 } 205 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 int index = vector()->GetIndex(slot()) + 1; 263 int index = vector()->GetIndex(slot()) + 1;
199 vector()->set(index, feedback_extra, mode); 264 vector()->set(index, feedback_extra, mode);
200 } 265 }
201 266
202 267
203 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } 268 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); }
204 } // namespace internal 269 } // namespace internal
205 } // namespace v8 270 } // namespace v8
206 271
207 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ 272 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_
OLDNEW
« no previous file with comments | « src/type-feedback-vector.cc ('k') | src/type-hints.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698