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

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

Issue 1563213002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 4 years, 11 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 #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.h" 8 #include "src/ic/ic.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Fill the bit-vector part with zeros. 76 // Fill the bit-vector part with zeros.
77 for (int i = 0; i < slot_kinds_length; i++) { 77 for (int i = 0; i < slot_kinds_length; i++) {
78 array->set(kReservedIndexCount + i, Smi::FromInt(0)); 78 array->set(kReservedIndexCount + i, Smi::FromInt(0));
79 } 79 }
80 80
81 Handle<TypeFeedbackMetadata> metadata = 81 Handle<TypeFeedbackMetadata> metadata =
82 Handle<TypeFeedbackMetadata>::cast(array); 82 Handle<TypeFeedbackMetadata>::cast(array);
83 for (int i = 0; i < slot_count; i++) { 83 for (int i = 0; i < slot_count; i++) {
84 metadata->SetKind(FeedbackVectorSlot(i), spec->GetKind(i)); 84 metadata->SetKind(FeedbackVectorSlot(i), spec->GetKind(i));
85 } 85 }
86
87 // It's important that the TypeFeedbackMetadata have a COW map, since it's
88 // pointed to by both a SharedFunctionInfo and indirectly by closures through
89 // the TypeFeedbackVector. The serializer uses the COW map type to decide
90 // this object belongs in the startup snapshot and not the partial
91 // snapshot(s).
92 metadata->set_map(isolate->heap()->fixed_cow_array_map());
93
86 return metadata; 94 return metadata;
87 } 95 }
88 96
89 97
90 bool TypeFeedbackMetadata::SpecDiffersFrom( 98 bool TypeFeedbackMetadata::SpecDiffersFrom(
91 const FeedbackVectorSpec* other_spec) const { 99 const FeedbackVectorSpec* other_spec) const {
92 if (other_spec->slots() != slot_count()) { 100 if (other_spec->slots() != slot_count()) {
93 return true; 101 return true;
94 } 102 }
95 103
96 int slots = slot_count(); 104 int slots = slot_count();
97 for (int i = 0; i < slots; i++) { 105 for (int i = 0; i < slots; i++) {
98 if (GetKind(FeedbackVectorSlot(i)) != other_spec->GetKind(i)) { 106 if (GetKind(FeedbackVectorSlot(i)) != other_spec->GetKind(i)) {
99 return true; 107 return true;
100 } 108 }
101 } 109 }
102 return false; 110 return false;
103 } 111 }
104 112
105 113
114 bool TypeFeedbackMetadata::DiffersFrom(
115 const TypeFeedbackMetadata* other_metadata) const {
116 if (other_metadata->slot_count() != slot_count()) {
117 return true;
118 }
119
120 int slots = slot_count();
121 for (int i = 0; i < slots; i++) {
122 FeedbackVectorSlot slot(i);
123 if (GetKind(slot) != other_metadata->GetKind(slot)) {
124 return true;
125 }
126 }
127 return false;
128 }
129
130
106 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) { 131 const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) {
107 switch (kind) { 132 switch (kind) {
108 case FeedbackVectorSlotKind::INVALID: 133 case FeedbackVectorSlotKind::INVALID:
109 return "INVALID"; 134 return "INVALID";
110 case FeedbackVectorSlotKind::CALL_IC: 135 case FeedbackVectorSlotKind::CALL_IC:
111 return "CALL_IC"; 136 return "CALL_IC";
112 case FeedbackVectorSlotKind::LOAD_IC: 137 case FeedbackVectorSlotKind::LOAD_IC:
113 return "LOAD_IC"; 138 return "LOAD_IC";
114 case FeedbackVectorSlotKind::KEYED_LOAD_IC: 139 case FeedbackVectorSlotKind::KEYED_LOAD_IC:
115 return "KEYED_LOAD_IC"; 140 return "KEYED_LOAD_IC";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 264 }
240 } 265 }
241 } 266 }
242 267
243 268
244 // static 269 // static
245 void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) { 270 void TypeFeedbackVector::ClearAllKeyedStoreICs(Isolate* isolate) {
246 SharedFunctionInfo::Iterator iterator(isolate); 271 SharedFunctionInfo::Iterator iterator(isolate);
247 SharedFunctionInfo* shared; 272 SharedFunctionInfo* shared;
248 while ((shared = iterator.Next())) { 273 while ((shared = iterator.Next())) {
249 TypeFeedbackVector* vector = shared->feedback_vector(); 274 if (!shared->OptimizedCodeMapIsCleared()) {
250 vector->ClearKeyedStoreICs(shared); 275 FixedArray* optimized_code_map = shared->optimized_code_map();
276 int length = optimized_code_map->length();
277 for (int i = SharedFunctionInfo::kEntriesStart; i < length;
278 i += SharedFunctionInfo::kEntryLength) {
279 WeakCell* cell = WeakCell::cast(
280 optimized_code_map->get(i + SharedFunctionInfo::kLiteralsOffset));
281 if (cell->value()->IsLiteralsArray()) {
282 TypeFeedbackVector* vector =
283 LiteralsArray::cast(cell->value())->feedback_vector();
284 vector->ClearKeyedStoreICs(shared);
285 }
286 }
287 }
251 } 288 }
252 } 289 }
253 290
254 291
255 void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) { 292 void TypeFeedbackVector::ClearKeyedStoreICs(SharedFunctionInfo* shared) {
256 Isolate* isolate = GetIsolate(); 293 Isolate* isolate = GetIsolate();
257
258 Code* host = shared->code(); 294 Code* host = shared->code();
259 Object* uninitialized_sentinel = 295 Object* uninitialized_sentinel =
260 TypeFeedbackVector::RawUninitializedSentinel(isolate); 296 TypeFeedbackVector::RawUninitializedSentinel(isolate);
261 297
262 TypeFeedbackMetadataIterator iter(metadata()); 298 TypeFeedbackMetadataIterator iter(metadata());
263 while (iter.HasNext()) { 299 while (iter.HasNext()) {
264 FeedbackVectorSlot slot = iter.Next(); 300 FeedbackVectorSlot slot = iter.Next();
265 FeedbackVectorSlotKind kind = iter.kind(); 301 FeedbackVectorSlotKind kind = iter.kind();
266 if (kind != FeedbackVectorSlotKind::KEYED_STORE_IC) continue; 302 if (kind != FeedbackVectorSlotKind::KEYED_STORE_IC) continue;
267 Object* obj = Get(slot); 303 Object* obj = Get(slot);
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 return mode; 855 return mode;
820 } 856 }
821 857
822 858
823 IcCheckType KeyedStoreICNexus::GetKeyType() const { 859 IcCheckType KeyedStoreICNexus::GetKeyType() const {
824 // The structure of the vector slots tells us the type. 860 // The structure of the vector slots tells us the type.
825 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; 861 return GetFeedback()->IsName() ? PROPERTY : ELEMENT;
826 } 862 }
827 } // namespace internal 863 } // namespace internal
828 } // namespace v8 864 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698