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

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

Issue 2650853008: [TypeFeedbackVector] Remove unnecessary Parameters metadata (Closed)
Patch Set: compilation failure. Created 3 years, 10 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.h ('k') | src/type-feedback-vector-inl.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 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 #include "src/type-feedback-vector.h" 5 #include "src/type-feedback-vector.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/ic/ic-inl.h" 8 #include "src/ic/ic-inl.h"
9 #include "src/ic/ic-state.h" 9 #include "src/ic/ic-state.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 32
33 FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind( 33 FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
34 FeedbackVectorSlot slot) const { 34 FeedbackVectorSlot slot) const {
35 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt()); 35 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
36 int data = Smi::cast(get(index))->value(); 36 int data = Smi::cast(get(index))->value();
37 return VectorICComputer::decode(data, slot.ToInt()); 37 return VectorICComputer::decode(data, slot.ToInt());
38 } 38 }
39 39
40 int TypeFeedbackMetadata::GetParameter(int parameter_index) const {
41 FixedArray* parameters = FixedArray::cast(get(kParametersTableIndex));
42 return Smi::cast(parameters->get(parameter_index))->value();
43 }
44
45 void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot, 40 void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot,
46 FeedbackVectorSlotKind kind) { 41 FeedbackVectorSlotKind kind) {
47 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt()); 42 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
48 int data = Smi::cast(get(index))->value(); 43 int data = Smi::cast(get(index))->value();
49 int new_data = VectorICComputer::encode(data, slot.ToInt(), kind); 44 int new_data = VectorICComputer::encode(data, slot.ToInt(), kind);
50 set(index, Smi::FromInt(new_data)); 45 set(index, Smi::FromInt(new_data));
51 } 46 }
52 47
53 48
54 template Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New( 49 template Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 84 }
90 85
91 Handle<TypeFeedbackMetadata> metadata = 86 Handle<TypeFeedbackMetadata> metadata =
92 Handle<TypeFeedbackMetadata>::cast(array); 87 Handle<TypeFeedbackMetadata>::cast(array);
93 88
94 for (int i = 0; i < slot_count; i++) { 89 for (int i = 0; i < slot_count; i++) {
95 FeedbackVectorSlotKind kind = spec->GetKind(i); 90 FeedbackVectorSlotKind kind = spec->GetKind(i);
96 metadata->SetKind(FeedbackVectorSlot(i), kind); 91 metadata->SetKind(FeedbackVectorSlot(i), kind);
97 } 92 }
98 93
99 if (spec->parameters_count() > 0) {
100 const int parameters_count = spec->parameters_count();
101 Handle<FixedArray> params_array =
102 factory->NewFixedArray(parameters_count, TENURED);
103 for (int i = 0; i < parameters_count; i++) {
104 params_array->set(i, Smi::FromInt(spec->GetParameter(i)));
105 }
106 metadata->set(kParametersTableIndex, *params_array);
107 } else {
108 metadata->set(kParametersTableIndex, *factory->empty_fixed_array());
109 }
110
111 // It's important that the TypeFeedbackMetadata have a COW map, since it's 94 // It's important that the TypeFeedbackMetadata have a COW map, since it's
112 // pointed to by both a SharedFunctionInfo and indirectly by closures through 95 // pointed to by both a SharedFunctionInfo and indirectly by closures through
113 // the TypeFeedbackVector. The serializer uses the COW map type to decide 96 // the TypeFeedbackVector. The serializer uses the COW map type to decide
114 // this object belongs in the startup snapshot and not the partial 97 // this object belongs in the startup snapshot and not the partial
115 // snapshot(s). 98 // snapshot(s).
116 metadata->set_map(isolate->heap()->fixed_cow_array_map()); 99 metadata->set_map(isolate->heap()->fixed_cow_array_map());
117 100
118 return metadata; 101 return metadata;
119 } 102 }
120 103
121 bool TypeFeedbackMetadata::SpecDiffersFrom( 104 bool TypeFeedbackMetadata::SpecDiffersFrom(
122 const FeedbackVectorSpec* other_spec) const { 105 const FeedbackVectorSpec* other_spec) const {
123 if (other_spec->slots() != slot_count()) { 106 if (other_spec->slots() != slot_count()) {
124 return true; 107 return true;
125 } 108 }
126 109
127 int slots = slot_count(); 110 int slots = slot_count();
128 int parameter_index = 0;
129 for (int i = 0; i < slots;) { 111 for (int i = 0; i < slots;) {
130 FeedbackVectorSlot slot(i); 112 FeedbackVectorSlot slot(i);
131 FeedbackVectorSlotKind kind = GetKind(slot); 113 FeedbackVectorSlotKind kind = GetKind(slot);
132 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); 114 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
133 115
134 if (kind != other_spec->GetKind(i)) { 116 if (kind != other_spec->GetKind(i)) {
135 return true; 117 return true;
136 } 118 }
137 if (SlotRequiresParameter(kind)) {
138 int parameter = GetParameter(parameter_index);
139 int other_parameter = other_spec->GetParameter(parameter_index);
140 if (parameter != other_parameter) {
141 return true;
142 }
143 parameter_index++;
144 }
145 i += entry_size; 119 i += entry_size;
146 } 120 }
147 return false; 121 return false;
148 } 122 }
149 123
150 bool TypeFeedbackMetadata::DiffersFrom( 124 bool TypeFeedbackMetadata::DiffersFrom(
151 const TypeFeedbackMetadata* other_metadata) const { 125 const TypeFeedbackMetadata* other_metadata) const {
152 if (other_metadata->slot_count() != slot_count()) { 126 if (other_metadata->slot_count() != slot_count()) {
153 return true; 127 return true;
154 } 128 }
155 129
156 int slots = slot_count(); 130 int slots = slot_count();
157 int parameter_index = 0;
158 for (int i = 0; i < slots;) { 131 for (int i = 0; i < slots;) {
159 FeedbackVectorSlot slot(i); 132 FeedbackVectorSlot slot(i);
160 FeedbackVectorSlotKind kind = GetKind(slot); 133 FeedbackVectorSlotKind kind = GetKind(slot);
161 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); 134 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
162 if (GetKind(slot) != other_metadata->GetKind(slot)) { 135 if (GetKind(slot) != other_metadata->GetKind(slot)) {
163 return true; 136 return true;
164 } 137 }
165 if (SlotRequiresParameter(kind)) {
166 if (GetParameter(parameter_index) !=
167 other_metadata->GetParameter(parameter_index)) {
168 return true;
169 }
170 parameter_index++;
171 }
172 i += entry_size; 138 i += entry_size;
173 } 139 }
174 return false; 140 return false;
175 } 141 }
176 142
177 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) { 143 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) {
178 switch (kind) { 144 switch (kind) {
179 case FeedbackVectorSlotKind::INVALID: 145 case FeedbackVectorSlotKind::INVALID:
180 return "INVALID"; 146 return "INVALID";
181 case FeedbackVectorSlotKind::CALL_IC: 147 case FeedbackVectorSlotKind::CALL_IC:
(...skipping 24 matching lines...) Expand all
206 UNREACHABLE(); 172 UNREACHABLE();
207 return "?"; 173 return "?";
208 } 174 }
209 175
210 FeedbackVectorSlotKind TypeFeedbackVector::GetKind( 176 FeedbackVectorSlotKind TypeFeedbackVector::GetKind(
211 FeedbackVectorSlot slot) const { 177 FeedbackVectorSlot slot) const {
212 DCHECK(!is_empty()); 178 DCHECK(!is_empty());
213 return metadata()->GetKind(slot); 179 return metadata()->GetKind(slot);
214 } 180 }
215 181
216 int TypeFeedbackVector::GetParameter(FeedbackVectorSlot slot) const {
217 DCHECK(!is_empty());
218 DCHECK(
219 TypeFeedbackMetadata::SlotRequiresParameter(metadata()->GetKind(slot)));
220 return FixedArray::cast(Get(slot))->length();
221 }
222
223 // static 182 // static
224 Handle<TypeFeedbackVector> TypeFeedbackVector::New( 183 Handle<TypeFeedbackVector> TypeFeedbackVector::New(
225 Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) { 184 Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
226 Factory* factory = isolate->factory(); 185 Factory* factory = isolate->factory();
227 186
228 const int slot_count = metadata->slot_count(); 187 const int slot_count = metadata->slot_count();
229 const int length = slot_count + kReservedIndexCount; 188 const int length = slot_count + kReservedIndexCount;
230 if (length == kReservedIndexCount) { 189 if (length == kReservedIndexCount) {
231 return Handle<TypeFeedbackVector>::cast( 190 return Handle<TypeFeedbackVector>::cast(
232 factory->empty_type_feedback_vector()); 191 factory->empty_type_feedback_vector());
233 } 192 }
234 193
235 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); 194 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
236 array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map()); 195 array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map());
237 array->set(kMetadataIndex, *metadata); 196 array->set(kMetadataIndex, *metadata);
238 array->set(kInvocationCountIndex, Smi::kZero); 197 array->set(kInvocationCountIndex, Smi::kZero);
239 int parameter_index = 0;
240 for (int i = 0; i < slot_count;) { 198 for (int i = 0; i < slot_count;) {
241 FeedbackVectorSlot slot(i); 199 FeedbackVectorSlot slot(i);
242 FeedbackVectorSlotKind kind = metadata->GetKind(slot); 200 FeedbackVectorSlotKind kind = metadata->GetKind(slot);
243 int index = TypeFeedbackVector::GetIndex(slot); 201 int index = TypeFeedbackVector::GetIndex(slot);
244 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); 202 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
245 203
246 if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) { 204 if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) {
247 // This fixed array is filled with undefined. 205 // TODO(mvstanton): Root literal arrays in this location.
248 int length = metadata->GetParameter(parameter_index++); 206 array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
249 if (length == 0) {
250 // This is a native function literal. We can always point to
251 // the empty literals array here.
252 array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
253 } else {
254 // TODO(mvstanton): Create the array.
255 // Handle<FixedArray> value = factory->NewFixedArray(length);
256 // array->set(index, *value);
257 array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
258 }
259 } 207 }
260 i += entry_size; 208 i += entry_size;
261 } 209 }
262 210
263 DisallowHeapAllocation no_gc; 211 DisallowHeapAllocation no_gc;
264 212
265 // Ensure we can skip the write barrier 213 // Ensure we can skip the write barrier
266 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); 214 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
267 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel); 215 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
268 for (int i = 0; i < slot_count;) { 216 for (int i = 0; i < slot_count;) {
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic( 1036 void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
1089 Handle<Name> name, Handle<Map> receiver_map) { 1037 Handle<Name> name, Handle<Map> receiver_map) {
1090 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 1038 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
1091 1039
1092 SetFeedback(*cell); 1040 SetFeedback(*cell);
1093 SetFeedbackExtra(*name); 1041 SetFeedbackExtra(*name);
1094 } 1042 }
1095 1043
1096 } // namespace internal 1044 } // namespace internal
1097 } // namespace v8 1045 } // namespace v8
OLDNEW
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698