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

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

Issue 2065113002: [ic] LoadGlobalIC caches PropertyCells in the feedback vector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 6 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/x64/code-stubs-x64.cc » ('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.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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (length == kReservedIndexCount) { 172 if (length == kReservedIndexCount) {
173 return Handle<TypeFeedbackVector>::cast(factory->empty_fixed_array()); 173 return Handle<TypeFeedbackVector>::cast(factory->empty_fixed_array());
174 } 174 }
175 175
176 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); 176 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
177 array->set(kMetadataIndex, *metadata); 177 array->set(kMetadataIndex, *metadata);
178 178
179 // Ensure we can skip the write barrier 179 // Ensure we can skip the write barrier
180 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); 180 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
181 DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel); 181 DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel);
182 for (int i = kReservedIndexCount; i < length; i++) { 182 for (int i = 0; i < slot_count;) {
183 array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER); 183 FeedbackVectorSlot slot(i);
184 FeedbackVectorSlotKind kind = metadata->GetKind(slot);
185 int index = TypeFeedbackVector::GetIndex(slot);
186 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
187
188 Object* value;
189 if (FLAG_new_load_global_ic &&
190 kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC) {
191 value = *factory->empty_weak_cell();
192 } else {
193 value = *uninitialized_sentinel;
194 }
195 array->set(index, value, SKIP_WRITE_BARRIER);
196 for (int j = 1; j < entry_size; j++) {
197 array->set(index + j, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
198 }
199 i += entry_size;
184 } 200 }
185
186 return Handle<TypeFeedbackVector>::cast(array); 201 return Handle<TypeFeedbackVector>::cast(array);
187 } 202 }
188 203
189 204
190 // static 205 // static
191 int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec* spec, 206 int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec* spec,
192 FeedbackVectorSlot slot) { 207 FeedbackVectorSlot slot) {
193 return kReservedIndexCount + slot.ToInt(); 208 return kReservedIndexCount + slot.ToInt();
194 } 209 }
195 210
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return MONOMORPHIC; 456 return MONOMORPHIC;
442 } 457 }
443 458
444 return UNINITIALIZED; 459 return UNINITIALIZED;
445 } 460 }
446 461
447 InlineCacheState LoadGlobalICNexus::StateFromFeedback() const { 462 InlineCacheState LoadGlobalICNexus::StateFromFeedback() const {
448 Isolate* isolate = GetIsolate(); 463 Isolate* isolate = GetIsolate();
449 Object* feedback = GetFeedback(); 464 Object* feedback = GetFeedback();
450 465
451 if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) { 466 if (FLAG_new_load_global_ic) {
452 return UNINITIALIZED; 467 Object* extra = GetFeedbackExtra();
453 } else if (feedback == *TypeFeedbackVector::MegamorphicSentinel(isolate)) { 468 if (!WeakCell::cast(feedback)->cleared() ||
454 return MEGAMORPHIC; 469 extra != *TypeFeedbackVector::UninitializedSentinel(isolate)) {
455 } else if (feedback == *TypeFeedbackVector::PremonomorphicSentinel(isolate)) { 470 return MONOMORPHIC;
456 return PREMONOMORPHIC; 471 }
457 } else if (feedback->IsFixedArray()) { 472
458 // Determine state purely by our structure, don't check if the maps are 473 } else {
459 // cleared. 474 if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) {
460 return POLYMORPHIC; 475 return UNINITIALIZED;
461 } else if (feedback->IsWeakCell()) { 476 } else if (feedback == *TypeFeedbackVector::MegamorphicSentinel(isolate)) {
462 // Don't check if the map is cleared. 477 return MEGAMORPHIC;
463 return MONOMORPHIC; 478 } else if (feedback ==
479 *TypeFeedbackVector::PremonomorphicSentinel(isolate)) {
480 return PREMONOMORPHIC;
481 } else if (feedback->IsFixedArray()) {
482 // Determine state purely by our structure, don't check if the maps are
483 // cleared.
484 return POLYMORPHIC;
485 } else if (feedback->IsWeakCell()) {
486 // Don't check if the map is cleared.
487 return MONOMORPHIC;
488 }
464 } 489 }
465
466 return UNINITIALIZED; 490 return UNINITIALIZED;
467 } 491 }
468 492
469 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const { 493 InlineCacheState KeyedLoadICNexus::StateFromFeedback() const {
470 Isolate* isolate = GetIsolate(); 494 Isolate* isolate = GetIsolate();
471 Object* feedback = GetFeedback(); 495 Object* feedback = GetFeedback();
472 496
473 if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) { 497 if (feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)) {
474 return UNINITIALIZED; 498 return UNINITIALIZED;
475 } else if (feedback == *TypeFeedbackVector::PremonomorphicSentinel(isolate)) { 499 } else if (feedback == *TypeFeedbackVector::PremonomorphicSentinel(isolate)) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 SetFeedbackExtra(*handler); 635 SetFeedbackExtra(*handler);
612 } 636 }
613 637
614 void LoadGlobalICNexus::ConfigureMonomorphic(Handle<Map> receiver_map, 638 void LoadGlobalICNexus::ConfigureMonomorphic(Handle<Map> receiver_map,
615 Handle<Code> handler) { 639 Handle<Code> handler) {
616 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 640 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
617 SetFeedback(*cell); 641 SetFeedback(*cell);
618 SetFeedbackExtra(*handler); 642 SetFeedbackExtra(*handler);
619 } 643 }
620 644
645 void LoadGlobalICNexus::ConfigureUninitialized() {
646 Isolate* isolate = GetIsolate();
647 SetFeedback(isolate->heap()->empty_weak_cell(), SKIP_WRITE_BARRIER);
648 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(isolate),
649 SKIP_WRITE_BARRIER);
650 }
651
652 void LoadGlobalICNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) {
653 Isolate* isolate = GetIsolate();
654 SetFeedback(*isolate->factory()->NewWeakCell(cell));
655 SetFeedbackExtra(*TypeFeedbackVector::UninitializedSentinel(isolate),
656 SKIP_WRITE_BARRIER);
657 }
658
659 void LoadGlobalICNexus::ConfigureHandlerMode(Handle<Code> handler) {
660 SetFeedback(GetIsolate()->heap()->empty_weak_cell());
661 SetFeedbackExtra(*handler);
662 }
663
621 void KeyedLoadICNexus::ConfigureMonomorphic(Handle<Name> name, 664 void KeyedLoadICNexus::ConfigureMonomorphic(Handle<Name> name,
622 Handle<Map> receiver_map, 665 Handle<Map> receiver_map,
623 Handle<Code> handler) { 666 Handle<Code> handler) {
624 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 667 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
625 if (name.is_null()) { 668 if (name.is_null()) {
626 SetFeedback(*cell); 669 SetFeedback(*cell);
627 SetFeedbackExtra(*handler); 670 SetFeedbackExtra(*handler);
628 } else { 671 } else {
629 Handle<FixedArray> array = EnsureExtraArrayOfSize(2); 672 Handle<FixedArray> array = EnsureExtraArrayOfSize(2);
630 SetFeedback(*name); 673 SetFeedback(*name);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 979
937 IcCheckType KeyedStoreICNexus::GetKeyType() const { 980 IcCheckType KeyedStoreICNexus::GetKeyType() const {
938 Object* feedback = GetFeedback(); 981 Object* feedback = GetFeedback();
939 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) { 982 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) {
940 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value()); 983 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
941 } 984 }
942 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; 985 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
943 } 986 }
944 } // namespace internal 987 } // namespace internal
945 } // namespace v8 988 } // namespace v8
OLDNEW
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698