Commit f47eec07 authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[ic] Fix -Wshadow by making InlineCacheState an enum class

Bug: v8:12244,v8:12245
Change-Id: Ie2b1801d7535e142774a1d912b992a203b1b8ecc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3284005
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78000}
parent 4dab3a31
...@@ -959,7 +959,7 @@ enum ParseRestriction : bool { ...@@ -959,7 +959,7 @@ enum ParseRestriction : bool {
}; };
// State for inline cache call sites. Aliased as IC::State. // State for inline cache call sites. Aliased as IC::State.
enum InlineCacheState { enum class InlineCacheState {
// No feedback will be collected. // No feedback will be collected.
NO_FEEDBACK, NO_FEEDBACK,
// Has never been executed. // Has never been executed.
...@@ -978,24 +978,26 @@ enum InlineCacheState { ...@@ -978,24 +978,26 @@ enum InlineCacheState {
GENERIC, GENERIC,
}; };
inline size_t hash_value(InlineCacheState mode) { return bit_cast<int>(mode); }
// Printing support. // Printing support.
inline const char* InlineCacheState2String(InlineCacheState state) { inline const char* InlineCacheState2String(InlineCacheState state) {
switch (state) { switch (state) {
case NO_FEEDBACK: case InlineCacheState::NO_FEEDBACK:
return "NOFEEDBACK"; return "NOFEEDBACK";
case UNINITIALIZED: case InlineCacheState::UNINITIALIZED:
return "UNINITIALIZED"; return "UNINITIALIZED";
case MONOMORPHIC: case InlineCacheState::MONOMORPHIC:
return "MONOMORPHIC"; return "MONOMORPHIC";
case RECOMPUTE_HANDLER: case InlineCacheState::RECOMPUTE_HANDLER:
return "RECOMPUTE_HANDLER"; return "RECOMPUTE_HANDLER";
case POLYMORPHIC: case InlineCacheState::POLYMORPHIC:
return "POLYMORPHIC"; return "POLYMORPHIC";
case MEGAMORPHIC: case InlineCacheState::MEGAMORPHIC:
return "MEGAMORPHIC"; return "MEGAMORPHIC";
case MEGADOM: case InlineCacheState::MEGADOM:
return "MEGADOM"; return "MEGADOM";
case GENERIC: case InlineCacheState::GENERIC:
return "GENERIC"; return "GENERIC";
} }
UNREACHABLE(); UNREACHABLE();
......
...@@ -582,13 +582,14 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForPropertyAccess( ...@@ -582,13 +582,14 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForPropertyAccess(
// If no maps were found for a non-megamorphic access, then our maps died // If no maps were found for a non-megamorphic access, then our maps died
// and we should soft-deopt. // and we should soft-deopt.
if (maps.empty() && nexus.ic_state() != MEGAMORPHIC) { if (maps.empty() && nexus.ic_state() != InlineCacheState::MEGAMORPHIC) {
return NewInsufficientFeedback(kind); return NewInsufficientFeedback(kind);
} }
if (name.has_value()) { if (name.has_value()) {
// We rely on this invariant in JSGenericLowering. // We rely on this invariant in JSGenericLowering.
DCHECK_IMPLIES(maps.empty(), nexus.ic_state() == MEGAMORPHIC); DCHECK_IMPLIES(maps.empty(),
nexus.ic_state() == InlineCacheState::MEGAMORPHIC);
return *zone()->New<NamedAccessFeedback>(*name, maps, kind); return *zone()->New<NamedAccessFeedback>(*name, maps, kind);
} else if (nexus.GetKeyType() == IcCheckType::kElement && !maps.empty()) { } else if (nexus.GetKeyType() == IcCheckType::kElement && !maps.empty()) {
return ProcessFeedbackMapsForElementAccess( return ProcessFeedbackMapsForElementAccess(
...@@ -596,7 +597,7 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForPropertyAccess( ...@@ -596,7 +597,7 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForPropertyAccess(
} else { } else {
// No actionable feedback. // No actionable feedback.
DCHECK(maps.empty()); DCHECK(maps.empty());
DCHECK_EQ(nexus.ic_state(), MEGAMORPHIC); DCHECK_EQ(nexus.ic_state(), InlineCacheState::MEGAMORPHIC);
// TODO(neis): Using ElementAccessFeedback here is kind of an abuse. // TODO(neis): Using ElementAccessFeedback here is kind of an abuse.
return *zone()->New<ElementAccessFeedback>( return *zone()->New<ElementAccessFeedback>(
zone(), KeyedAccessMode::FromNexus(nexus), kind); zone(), KeyedAccessMode::FromNexus(nexus), kind);
...@@ -611,7 +612,8 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForGlobalAccess( ...@@ -611,7 +612,8 @@ ProcessedFeedback const& JSHeapBroker::ReadFeedbackForGlobalAccess(
nexus.kind() == FeedbackSlotKind::kStoreGlobalSloppy || nexus.kind() == FeedbackSlotKind::kStoreGlobalSloppy ||
nexus.kind() == FeedbackSlotKind::kStoreGlobalStrict); nexus.kind() == FeedbackSlotKind::kStoreGlobalStrict);
if (nexus.IsUninitialized()) return NewInsufficientFeedback(nexus.kind()); if (nexus.IsUninitialized()) return NewInsufficientFeedback(nexus.kind());
if (nexus.ic_state() != MONOMORPHIC || nexus.GetFeedback()->IsCleared()) { if (nexus.ic_state() != InlineCacheState::MONOMORPHIC ||
nexus.GetFeedback()->IsCleared()) {
return *zone()->New<GlobalAccessFeedback>(nexus.kind()); return *zone()->New<GlobalAccessFeedback>(nexus.kind());
} }
......
...@@ -35,8 +35,8 @@ bool IC::IsHandler(MaybeObject object) { ...@@ -35,8 +35,8 @@ bool IC::IsHandler(MaybeObject object) {
} }
bool IC::vector_needs_update() { bool IC::vector_needs_update() {
if (state() == NO_FEEDBACK) return false; if (state() == InlineCacheState::NO_FEEDBACK) return false;
return (!vector_set_ && (state() != MEGAMORPHIC || return (!vector_set_ && (state() != InlineCacheState::MEGAMORPHIC ||
nexus()->GetKeyType() != IcCheckType::kElement)); nexus()->GetKeyType() != IcCheckType::kElement));
} }
......
...@@ -50,6 +50,18 @@ ...@@ -50,6 +50,18 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// Aliases to avoid having to repeat the class.
// With C++20 we can use "using" to introduce scoped enums.
constexpr InlineCacheState NO_FEEDBACK = InlineCacheState::NO_FEEDBACK;
constexpr InlineCacheState UNINITIALIZED = InlineCacheState::UNINITIALIZED;
constexpr InlineCacheState MONOMORPHIC = InlineCacheState::MONOMORPHIC;
constexpr InlineCacheState RECOMPUTE_HANDLER =
InlineCacheState::RECOMPUTE_HANDLER;
constexpr InlineCacheState POLYMORPHIC = InlineCacheState::POLYMORPHIC;
constexpr InlineCacheState MEGAMORPHIC = InlineCacheState::MEGAMORPHIC;
constexpr InlineCacheState MEGADOM = InlineCacheState::MEGADOM;
constexpr InlineCacheState GENERIC = InlineCacheState::GENERIC;
char IC::TransitionMarkFromState(IC::State state) { char IC::TransitionMarkFromState(IC::State state) {
switch (state) { switch (state) {
case NO_FEEDBACK: case NO_FEEDBACK:
......
...@@ -45,7 +45,7 @@ class IC { ...@@ -45,7 +45,7 @@ class IC {
void MarkRecomputeHandler(Handle<Object> name) { void MarkRecomputeHandler(Handle<Object> name) {
DCHECK(RecomputeHandlerForName(name)); DCHECK(RecomputeHandlerForName(name));
old_state_ = state_; old_state_ = state_;
state_ = RECOMPUTE_HANDLER; state_ = InlineCacheState::RECOMPUTE_HANDLER;
} }
bool IsAnyHas() const { return IsKeyedHasIC(); } bool IsAnyHas() const { return IsKeyedHasIC(); }
......
...@@ -725,20 +725,20 @@ InlineCacheState FeedbackNexus::ic_state() const { ...@@ -725,20 +725,20 @@ InlineCacheState FeedbackNexus::ic_state() const {
switch (kind()) { switch (kind()) {
case FeedbackSlotKind::kLiteral: case FeedbackSlotKind::kLiteral:
if (feedback->IsSmi()) return UNINITIALIZED; if (feedback->IsSmi()) return InlineCacheState::UNINITIALIZED;
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
case FeedbackSlotKind::kStoreGlobalSloppy: case FeedbackSlotKind::kStoreGlobalSloppy:
case FeedbackSlotKind::kStoreGlobalStrict: case FeedbackSlotKind::kStoreGlobalStrict:
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof: case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
case FeedbackSlotKind::kLoadGlobalInsideTypeof: { case FeedbackSlotKind::kLoadGlobalInsideTypeof: {
if (feedback->IsSmi()) return MONOMORPHIC; if (feedback->IsSmi()) return InlineCacheState::MONOMORPHIC;
DCHECK(feedback->IsWeakOrCleared()); DCHECK(feedback->IsWeakOrCleared());
if (!feedback->IsCleared() || extra != UninitializedSentinel()) { if (!feedback->IsCleared() || extra != UninitializedSentinel()) {
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
case FeedbackSlotKind::kStoreNamedSloppy: case FeedbackSlotKind::kStoreNamedSloppy:
...@@ -752,32 +752,33 @@ InlineCacheState FeedbackNexus::ic_state() const { ...@@ -752,32 +752,33 @@ InlineCacheState FeedbackNexus::ic_state() const {
case FeedbackSlotKind::kLoadKeyed: case FeedbackSlotKind::kLoadKeyed:
case FeedbackSlotKind::kHasKeyed: { case FeedbackSlotKind::kHasKeyed: {
if (feedback == UninitializedSentinel()) { if (feedback == UninitializedSentinel()) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
if (feedback == MegamorphicSentinel()) { if (feedback == MegamorphicSentinel()) {
return MEGAMORPHIC; return InlineCacheState::MEGAMORPHIC;
} }
if (feedback == MegaDOMSentinel()) { if (feedback == MegaDOMSentinel()) {
DCHECK(IsLoadICKind(kind())); DCHECK(IsLoadICKind(kind()));
return MEGADOM; return InlineCacheState::MEGADOM;
} }
if (feedback->IsWeakOrCleared()) { if (feedback->IsWeakOrCleared()) {
// Don't check if the map is cleared. // Don't check if the map is cleared.
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
HeapObject heap_object; HeapObject heap_object;
if (feedback->GetHeapObjectIfStrong(&heap_object)) { if (feedback->GetHeapObjectIfStrong(&heap_object)) {
if (heap_object.IsWeakFixedArray()) { if (heap_object.IsWeakFixedArray()) {
// Determine state purely by our structure, don't check if the maps // Determine state purely by our structure, don't check if the maps
// are cleared. // are cleared.
return POLYMORPHIC; return InlineCacheState::POLYMORPHIC;
} }
if (heap_object.IsName()) { if (heap_object.IsName()) {
DCHECK(IsKeyedLoadICKind(kind()) || IsKeyedStoreICKind(kind()) || DCHECK(IsKeyedLoadICKind(kind()) || IsKeyedStoreICKind(kind()) ||
IsKeyedHasICKind(kind()) || IsDefineOwnICKind(kind())); IsKeyedHasICKind(kind()) || IsDefineOwnICKind(kind()));
Object extra_object = extra->GetHeapObjectAssumeStrong(); Object extra_object = extra->GetHeapObjectAssumeStrong();
WeakFixedArray extra_array = WeakFixedArray::cast(extra_object); WeakFixedArray extra_array = WeakFixedArray::cast(extra_object);
return extra_array.length() > 2 ? POLYMORPHIC : MONOMORPHIC; return extra_array.length() > 2 ? InlineCacheState::POLYMORPHIC
: InlineCacheState::MONOMORPHIC;
} }
} }
UNREACHABLE(); UNREACHABLE();
...@@ -785,97 +786,97 @@ InlineCacheState FeedbackNexus::ic_state() const { ...@@ -785,97 +786,97 @@ InlineCacheState FeedbackNexus::ic_state() const {
case FeedbackSlotKind::kCall: { case FeedbackSlotKind::kCall: {
HeapObject heap_object; HeapObject heap_object;
if (feedback == MegamorphicSentinel()) { if (feedback == MegamorphicSentinel()) {
return GENERIC; return InlineCacheState::GENERIC;
} else if (feedback->IsWeakOrCleared()) { } else if (feedback->IsWeakOrCleared()) {
if (feedback->GetHeapObjectIfWeak(&heap_object)) { if (feedback->GetHeapObjectIfWeak(&heap_object)) {
if (heap_object.IsFeedbackCell()) { if (heap_object.IsFeedbackCell()) {
return POLYMORPHIC; return InlineCacheState::POLYMORPHIC;
} }
CHECK(heap_object.IsJSFunction() || heap_object.IsJSBoundFunction()); CHECK(heap_object.IsJSFunction() || heap_object.IsJSBoundFunction());
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} else if (feedback->GetHeapObjectIfStrong(&heap_object) && } else if (feedback->GetHeapObjectIfStrong(&heap_object) &&
heap_object.IsAllocationSite()) { heap_object.IsAllocationSite()) {
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
CHECK_EQ(feedback, UninitializedSentinel()); CHECK_EQ(feedback, UninitializedSentinel());
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
case FeedbackSlotKind::kBinaryOp: { case FeedbackSlotKind::kBinaryOp: {
BinaryOperationHint hint = GetBinaryOperationFeedback(); BinaryOperationHint hint = GetBinaryOperationFeedback();
if (hint == BinaryOperationHint::kNone) { if (hint == BinaryOperationHint::kNone) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} else if (hint == BinaryOperationHint::kAny) { } else if (hint == BinaryOperationHint::kAny) {
return GENERIC; return InlineCacheState::GENERIC;
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
case FeedbackSlotKind::kCompareOp: { case FeedbackSlotKind::kCompareOp: {
CompareOperationHint hint = GetCompareOperationFeedback(); CompareOperationHint hint = GetCompareOperationFeedback();
if (hint == CompareOperationHint::kNone) { if (hint == CompareOperationHint::kNone) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} else if (hint == CompareOperationHint::kAny) { } else if (hint == CompareOperationHint::kAny) {
return GENERIC; return InlineCacheState::GENERIC;
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
case FeedbackSlotKind::kForIn: { case FeedbackSlotKind::kForIn: {
ForInHint hint = GetForInFeedback(); ForInHint hint = GetForInFeedback();
if (hint == ForInHint::kNone) { if (hint == ForInHint::kNone) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} else if (hint == ForInHint::kAny) { } else if (hint == ForInHint::kAny) {
return GENERIC; return InlineCacheState::GENERIC;
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
case FeedbackSlotKind::kInstanceOf: { case FeedbackSlotKind::kInstanceOf: {
if (feedback == UninitializedSentinel()) { if (feedback == UninitializedSentinel()) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} else if (feedback == MegamorphicSentinel()) { } else if (feedback == MegamorphicSentinel()) {
return MEGAMORPHIC; return InlineCacheState::MEGAMORPHIC;
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
case FeedbackSlotKind::kStoreDataPropertyInLiteral: { case FeedbackSlotKind::kStoreDataPropertyInLiteral: {
if (feedback == UninitializedSentinel()) { if (feedback == UninitializedSentinel()) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} else if (feedback->IsWeakOrCleared()) { } else if (feedback->IsWeakOrCleared()) {
// Don't check if the map is cleared. // Don't check if the map is cleared.
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
return MEGAMORPHIC; return InlineCacheState::MEGAMORPHIC;
} }
case FeedbackSlotKind::kTypeProfile: { case FeedbackSlotKind::kTypeProfile: {
if (feedback == UninitializedSentinel()) { if (feedback == UninitializedSentinel()) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
case FeedbackSlotKind::kCloneObject: { case FeedbackSlotKind::kCloneObject: {
if (feedback == UninitializedSentinel()) { if (feedback == UninitializedSentinel()) {
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
if (feedback == MegamorphicSentinel()) { if (feedback == MegamorphicSentinel()) {
return MEGAMORPHIC; return InlineCacheState::MEGAMORPHIC;
} }
if (feedback->IsWeakOrCleared()) { if (feedback->IsWeakOrCleared()) {
return MONOMORPHIC; return InlineCacheState::MONOMORPHIC;
} }
DCHECK(feedback->GetHeapObjectAssumeStrong().IsWeakFixedArray()); DCHECK(feedback->GetHeapObjectAssumeStrong().IsWeakFixedArray());
return POLYMORPHIC; return InlineCacheState::POLYMORPHIC;
} }
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber: case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
return UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
} }
void FeedbackNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) { void FeedbackNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) {
...@@ -925,12 +926,12 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map, ...@@ -925,12 +926,12 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
} }
} }
switch (ic_state()) { switch (ic_state()) {
case UNINITIALIZED: case InlineCacheState::UNINITIALIZED:
// Cache the first map seen which meets the fast case requirements. // Cache the first map seen which meets the fast case requirements.
SetFeedback(HeapObjectReference::Weak(*source_map), UPDATE_WRITE_BARRIER, SetFeedback(HeapObjectReference::Weak(*source_map), UPDATE_WRITE_BARRIER,
*result_map); *result_map);
break; break;
case MONOMORPHIC: case InlineCacheState::MONOMORPHIC:
if (feedback.is_null() || feedback.is_identical_to(source_map) || if (feedback.is_null() || feedback.is_identical_to(source_map) ||
Map::cast(*feedback).is_deprecated()) { Map::cast(*feedback).is_deprecated()) {
SetFeedback(HeapObjectReference::Weak(*source_map), SetFeedback(HeapObjectReference::Weak(*source_map),
...@@ -947,7 +948,7 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map, ...@@ -947,7 +948,7 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
HeapObjectReference::ClearedValue(isolate)); HeapObjectReference::ClearedValue(isolate));
} }
break; break;
case POLYMORPHIC: { case InlineCacheState::POLYMORPHIC: {
const int kMaxElements = FLAG_max_valid_polymorphic_map_count * const int kMaxElements = FLAG_max_valid_polymorphic_map_count *
kCloneObjectPolymorphicEntrySize; kCloneObjectPolymorphicEntrySize;
Handle<WeakFixedArray> array = Handle<WeakFixedArray>::cast(feedback); Handle<WeakFixedArray> array = Handle<WeakFixedArray>::cast(feedback);
......
...@@ -747,9 +747,13 @@ class V8_EXPORT_PRIVATE FeedbackNexus final { ...@@ -747,9 +747,13 @@ class V8_EXPORT_PRIVATE FeedbackNexus final {
} }
InlineCacheState ic_state() const; InlineCacheState ic_state() const;
bool IsUninitialized() const { return ic_state() == UNINITIALIZED; } bool IsUninitialized() const {
bool IsMegamorphic() const { return ic_state() == MEGAMORPHIC; } return ic_state() == InlineCacheState::UNINITIALIZED;
bool IsGeneric() const { return ic_state() == GENERIC; } }
bool IsMegamorphic() const {
return ic_state() == InlineCacheState::MEGAMORPHIC;
}
bool IsGeneric() const { return ic_state() == InlineCacheState::GENERIC; }
void Print(std::ostream& os); void Print(std::ostream& os);
...@@ -773,7 +777,7 @@ class V8_EXPORT_PRIVATE FeedbackNexus final { ...@@ -773,7 +777,7 @@ class V8_EXPORT_PRIVATE FeedbackNexus final {
bool IsCleared() const { bool IsCleared() const {
InlineCacheState state = ic_state(); InlineCacheState state = ic_state();
return !FLAG_use_ic || state == UNINITIALIZED; return !FLAG_use_ic || state == InlineCacheState::UNINITIALIZED;
} }
// Clear() returns true if the state of the underlying vector was changed. // Clear() returns true if the state of the underlying vector was changed.
......
...@@ -1095,14 +1095,14 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) { ...@@ -1095,14 +1095,14 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyInLiteral) {
DCHECK(maybe_vector->IsFeedbackVector()); DCHECK(maybe_vector->IsFeedbackVector());
Handle<FeedbackVector> vector = Handle<FeedbackVector>::cast(maybe_vector); Handle<FeedbackVector> vector = Handle<FeedbackVector>::cast(maybe_vector);
FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index)); FeedbackNexus nexus(vector, FeedbackVector::ToSlot(index));
if (nexus.ic_state() == UNINITIALIZED) { if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) {
if (name->IsUniqueName()) { if (name->IsUniqueName()) {
nexus.ConfigureMonomorphic(name, handle(object->map(), isolate), nexus.ConfigureMonomorphic(name, handle(object->map(), isolate),
MaybeObjectHandle()); MaybeObjectHandle());
} else { } else {
nexus.ConfigureMegamorphic(IcCheckType::kProperty); nexus.ConfigureMegamorphic(IcCheckType::kProperty);
} }
} else if (nexus.ic_state() == MONOMORPHIC) { } else if (nexus.ic_state() == InlineCacheState::MONOMORPHIC) {
if (nexus.GetFirstMap() != object->map() || nexus.GetName() != *name) { if (nexus.GetFirstMap() != object->map() || nexus.GetName() != *name) {
nexus.ConfigureMegamorphic(IcCheckType::kProperty); nexus.ConfigureMegamorphic(IcCheckType::kProperty);
} }
......
...@@ -3327,12 +3327,12 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) { ...@@ -3327,12 +3327,12 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) {
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, MONOMORPHIC); CheckVectorIC(f, 0, InlineCacheState::MONOMORPHIC);
heap::SimulateIncrementalMarking(CcTest::heap()); heap::SimulateIncrementalMarking(CcTest::heap());
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CheckVectorIC(f, 0, MONOMORPHIC); CheckVectorIC(f, 0, InlineCacheState::MONOMORPHIC);
} }
TEST(IncrementalMarkingPreservesPolymorphicIC) { TEST(IncrementalMarkingPreservesPolymorphicIC) {
...@@ -3369,13 +3369,13 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) { ...@@ -3369,13 +3369,13 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) {
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, POLYMORPHIC); CheckVectorIC(f, 0, InlineCacheState::POLYMORPHIC);
// Fire context dispose notification. // Fire context dispose notification.
heap::SimulateIncrementalMarking(CcTest::heap()); heap::SimulateIncrementalMarking(CcTest::heap());
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CheckVectorIC(f, 0, POLYMORPHIC); CheckVectorIC(f, 0, InlineCacheState::POLYMORPHIC);
} }
TEST(ContextDisposeDoesntClearPolymorphicIC) { TEST(ContextDisposeDoesntClearPolymorphicIC) {
...@@ -3412,14 +3412,14 @@ TEST(ContextDisposeDoesntClearPolymorphicIC) { ...@@ -3412,14 +3412,14 @@ TEST(ContextDisposeDoesntClearPolymorphicIC) {
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
CheckVectorIC(f, 0, POLYMORPHIC); CheckVectorIC(f, 0, InlineCacheState::POLYMORPHIC);
// Fire context dispose notification. // Fire context dispose notification.
CcTest::isolate()->ContextDisposedNotification(); CcTest::isolate()->ContextDisposedNotification();
heap::SimulateIncrementalMarking(CcTest::heap()); heap::SimulateIncrementalMarking(CcTest::heap());
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CheckVectorIC(f, 0, POLYMORPHIC); CheckVectorIC(f, 0, InlineCacheState::POLYMORPHIC);
} }
...@@ -4758,12 +4758,12 @@ TEST(MonomorphicStaysMonomorphicAfterGC) { ...@@ -4758,12 +4758,12 @@ TEST(MonomorphicStaysMonomorphicAfterGC) {
CompileRun("(testIC())"); CompileRun("(testIC())");
} }
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CheckIC(loadIC, 0, MONOMORPHIC); CheckIC(loadIC, 0, InlineCacheState::MONOMORPHIC);
{ {
v8::HandleScope new_scope(CcTest::isolate()); v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())"); CompileRun("(testIC())");
} }
CheckIC(loadIC, 0, MONOMORPHIC); CheckIC(loadIC, 0, InlineCacheState::MONOMORPHIC);
} }
...@@ -4797,12 +4797,12 @@ TEST(PolymorphicStaysPolymorphicAfterGC) { ...@@ -4797,12 +4797,12 @@ TEST(PolymorphicStaysPolymorphicAfterGC) {
CompileRun("(testIC())"); CompileRun("(testIC())");
} }
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CheckIC(loadIC, 0, POLYMORPHIC); CheckIC(loadIC, 0, InlineCacheState::POLYMORPHIC);
{ {
v8::HandleScope new_scope(CcTest::isolate()); v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())"); CompileRun("(testIC())");
} }
CheckIC(loadIC, 0, POLYMORPHIC); CheckIC(loadIC, 0, InlineCacheState::POLYMORPHIC);
} }
#ifdef DEBUG #ifdef DEBUG
......
...@@ -10778,7 +10778,7 @@ THREADED_TEST(ShadowObjectAndDataProperty) { ...@@ -10778,7 +10778,7 @@ THREADED_TEST(ShadowObjectAndDataProperty) {
i::FeedbackNexus nexus(foo->feedback_vector(), slot); i::FeedbackNexus nexus(foo->feedback_vector(), slot);
CHECK_EQ(i::FeedbackSlotKind::kStoreGlobalSloppy, nexus.kind()); CHECK_EQ(i::FeedbackSlotKind::kStoreGlobalSloppy, nexus.kind());
CompileRun("foo(1)"); CompileRun("foo(1)");
CHECK_EQ(i::MONOMORPHIC, nexus.ic_state()); CHECK_EQ(i::InlineCacheState::MONOMORPHIC, nexus.ic_state());
// We go a bit further, checking that the form of monomorphism is // We go a bit further, checking that the form of monomorphism is
// a PropertyCell in the vector. This is because we want to make sure // a PropertyCell in the vector. This is because we want to make sure
// we didn't settle for a "poor man's monomorphism," such as a // we didn't settle for a "poor man's monomorphism," such as a
...@@ -10828,7 +10828,7 @@ THREADED_TEST(ShadowObjectAndDataPropertyTurbo) { ...@@ -10828,7 +10828,7 @@ THREADED_TEST(ShadowObjectAndDataPropertyTurbo) {
i::FeedbackNexus nexus(foo->feedback_vector(), slot); i::FeedbackNexus nexus(foo->feedback_vector(), slot);
CHECK_EQ(i::FeedbackSlotKind::kStoreGlobalSloppy, nexus.kind()); CHECK_EQ(i::FeedbackSlotKind::kStoreGlobalSloppy, nexus.kind());
CompileRun("%OptimizeFunctionOnNextCall(foo); foo(1)"); CompileRun("%OptimizeFunctionOnNextCall(foo); foo(1)");
CHECK_EQ(i::MONOMORPHIC, nexus.ic_state()); CHECK_EQ(i::InlineCacheState::MONOMORPHIC, nexus.ic_state());
i::HeapObject heap_object; i::HeapObject heap_object;
CHECK(nexus.GetFeedback().GetHeapObject(&heap_object)); CHECK(nexus.GetFeedback().GetHeapObject(&heap_object));
CHECK(heap_object.IsPropertyCell()); CHECK(heap_object.IsPropertyCell());
...@@ -40,12 +40,13 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -40,12 +40,13 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
vector_ready_(vector_ready), vector_ready_(vector_ready),
vector_consumed_(vector_consumed) {} vector_consumed_(vector_consumed) {}
using InlineCacheSet = std::unordered_set<InlineCacheState, std::hash<int>>; using InlineCacheSet = std::unordered_set<InlineCacheState>;
bool AllRequiredStatesSeen(const InlineCacheSet& found) { bool AllRequiredStatesSeen(const InlineCacheSet& found) {
auto end = found.end(); auto end = found.end();
return (found.find(UNINITIALIZED) != end && return (found.find(InlineCacheState::UNINITIALIZED) != end &&
found.find(MONOMORPHIC) != end && found.find(POLYMORPHIC) != end && found.find(InlineCacheState::MONOMORPHIC) != end &&
found.find(MEGAMORPHIC) != end); found.find(InlineCacheState::POLYMORPHIC) != end &&
found.find(InlineCacheState::MEGAMORPHIC) != end);
} }
void Run() override { void Run() override {
...@@ -65,7 +66,8 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -65,7 +66,8 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
for (int i = 0; i < kCycles; i++) { for (int i = 0; i < kCycles; i++) {
FeedbackNexus nexus(feedback_vector_, slot, nexus_config); FeedbackNexus nexus(feedback_vector_, slot, nexus_config);
auto state = nexus.ic_state(); auto state = nexus.ic_state();
if (state == MONOMORPHIC || state == POLYMORPHIC) { if (state == InlineCacheState::MONOMORPHIC ||
state == InlineCacheState::POLYMORPHIC) {
MapHandles maps; MapHandles maps;
nexus.ExtractMaps(&maps); nexus.ExtractMaps(&maps);
for (unsigned int j = 0; j < maps.size(); j++) { for (unsigned int j = 0; j < maps.size(); j++) {
...@@ -93,7 +95,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -93,7 +95,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
{ {
FeedbackNexus nexus(feedback_vector_, slot, nexus_config); FeedbackNexus nexus(feedback_vector_, slot, nexus_config);
auto state = nexus.ic_state(); auto state = nexus.ic_state();
CHECK_EQ(state, UNINITIALIZED); CHECK_EQ(state, InlineCacheState::UNINITIALIZED);
} }
vector_consumed_->Signal(); vector_consumed_->Signal();
vector_ready_->Wait(); vector_ready_->Wait();
...@@ -101,7 +103,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -101,7 +103,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
{ {
FeedbackNexus nexus(feedback_vector_, slot, nexus_config); FeedbackNexus nexus(feedback_vector_, slot, nexus_config);
auto state = nexus.ic_state(); auto state = nexus.ic_state();
CHECK_EQ(state, MONOMORPHIC); CHECK_EQ(state, InlineCacheState::MONOMORPHIC);
MapHandles maps; MapHandles maps;
nexus.ExtractMaps(&maps); nexus.ExtractMaps(&maps);
CHECK(maps[0]->IsMap()); CHECK(maps[0]->IsMap());
...@@ -112,7 +114,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -112,7 +114,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
{ {
FeedbackNexus nexus(feedback_vector_, slot, nexus_config); FeedbackNexus nexus(feedback_vector_, slot, nexus_config);
auto state = nexus.ic_state(); auto state = nexus.ic_state();
CHECK_EQ(state, POLYMORPHIC); CHECK_EQ(state, InlineCacheState::POLYMORPHIC);
MapHandles maps; MapHandles maps;
nexus.ExtractMaps(&maps); nexus.ExtractMaps(&maps);
for (unsigned int i = 0; i < maps.size(); i++) { for (unsigned int i = 0; i < maps.size(); i++) {
...@@ -125,7 +127,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread { ...@@ -125,7 +127,7 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
{ {
FeedbackNexus nexus(feedback_vector_, slot, nexus_config); FeedbackNexus nexus(feedback_vector_, slot, nexus_config);
auto state = nexus.ic_state(); auto state = nexus.ic_state();
CHECK_EQ(state, MEGAMORPHIC); CHECK_EQ(state, InlineCacheState::MEGAMORPHIC);
} }
} }
...@@ -184,7 +186,7 @@ TEST(CheckLoadICStates) { ...@@ -184,7 +186,7 @@ TEST(CheckLoadICStates) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(vector, slot); FeedbackNexus nexus(vector, slot);
CHECK(IsLoadICKind(nexus.kind())); CHECK(IsLoadICKind(nexus.kind()));
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
nexus.ConfigureUninitialized(); nexus.ConfigureUninitialized();
// Now the basic environment is set up. Start the worker thread. // Now the basic environment is set up. Start the worker thread.
...@@ -208,7 +210,7 @@ TEST(CheckLoadICStates) { ...@@ -208,7 +210,7 @@ TEST(CheckLoadICStates) {
for (int i = 0; i < kCycles; i++) { for (int i = 0; i < kCycles; i++) {
if (all_states_seen.load(std::memory_order_acquire)) break; if (all_states_seen.load(std::memory_order_acquire)) break;
CHECK_EQ(UNINITIALIZED, nexus.ic_state()); CHECK_EQ(InlineCacheState::UNINITIALIZED, nexus.ic_state());
if (i == (kCycles - 1)) { if (i == (kCycles - 1)) {
// If we haven't seen all states by the last attempt, enter an explicit // If we haven't seen all states by the last attempt, enter an explicit
// handshaking mode. // handshaking mode.
...@@ -218,7 +220,7 @@ TEST(CheckLoadICStates) { ...@@ -218,7 +220,7 @@ TEST(CheckLoadICStates) {
} }
nexus.ConfigureMonomorphic(Handle<Name>(), Handle<Map>(o1->map(), isolate), nexus.ConfigureMonomorphic(Handle<Name>(), Handle<Map>(o1->map(), isolate),
dummy_handler); dummy_handler);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
if (i == (kCycles - 1)) { if (i == (kCycles - 1)) {
vector_ready.Signal(); vector_ready.Signal();
...@@ -237,7 +239,7 @@ TEST(CheckLoadICStates) { ...@@ -237,7 +239,7 @@ TEST(CheckLoadICStates) {
map_and_handlers.push_back( map_and_handlers.push_back(
MapAndHandler(Handle<Map>(o4->map(), isolate), dummy_handler)); MapAndHandler(Handle<Map>(o4->map(), isolate), dummy_handler));
nexus.ConfigurePolymorphic(Handle<Name>(), map_and_handlers); nexus.ConfigurePolymorphic(Handle<Name>(), map_and_handlers);
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
if (i == (kCycles - 1)) { if (i == (kCycles - 1)) {
vector_ready.Signal(); vector_ready.Signal();
...@@ -247,7 +249,7 @@ TEST(CheckLoadICStates) { ...@@ -247,7 +249,7 @@ TEST(CheckLoadICStates) {
// Go Megamorphic // Go Megamorphic
nexus.ConfigureMegamorphic(); nexus.ConfigureMegamorphic();
CHECK_EQ(MEGAMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MEGAMORPHIC, nexus.ic_state());
if (i == (kCycles - 1)) { if (i == (kCycles - 1)) {
vector_ready.Signal(); vector_ready.Signal();
......
...@@ -174,14 +174,14 @@ TEST(VectorCallICStates) { ...@@ -174,14 +174,14 @@ TEST(VectorCallICStates) {
Handle<FeedbackVector>(f->feedback_vector(), isolate); Handle<FeedbackVector>(f->feedback_vector(), isolate);
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CompileRun("f(function() { return 16; })"); CompileRun("f(function() { return 16; })");
CHECK_EQ(GENERIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::GENERIC, nexus.ic_state());
// After a collection, state should remain GENERIC. // After a collection, state should remain GENERIC.
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CHECK_EQ(GENERIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::GENERIC, nexus.ic_state());
} }
// Test the Call IC states transfer with Function.prototype.apply // Test the Call IC states transfer with Function.prototype.apply
...@@ -207,7 +207,7 @@ TEST(VectorCallICStateApply) { ...@@ -207,7 +207,7 @@ TEST(VectorCallICStateApply) {
Handle<FeedbackVector>(foo->feedback_vector(), isolate); Handle<FeedbackVector>(foo->feedback_vector(), isolate);
FeedbackSlot slot(4); FeedbackSlot slot(4);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent()); CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent());
HeapObject heap_object; HeapObject heap_object;
CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object));
...@@ -216,7 +216,7 @@ TEST(VectorCallICStateApply) { ...@@ -216,7 +216,7 @@ TEST(VectorCallICStateApply) {
CompileRun( CompileRun(
"F = Math.max;" "F = Math.max;"
"foo();"); "foo();");
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(CallFeedbackContent::kTarget, nexus.GetCallFeedbackContent()); CHECK_EQ(CallFeedbackContent::kTarget, nexus.GetCallFeedbackContent());
CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object));
CHECK_EQ(*isolate->function_prototype_apply(), heap_object); CHECK_EQ(*isolate->function_prototype_apply(), heap_object);
...@@ -224,7 +224,7 @@ TEST(VectorCallICStateApply) { ...@@ -224,7 +224,7 @@ TEST(VectorCallICStateApply) {
CompileRun( CompileRun(
"F.apply = (function () { return; });" "F.apply = (function () { return; });"
"foo();"); "foo();");
CHECK_EQ(GENERIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::GENERIC, nexus.ic_state());
} }
TEST(VectorCallFeedback) { TEST(VectorCallFeedback) {
...@@ -249,14 +249,14 @@ TEST(VectorCallFeedback) { ...@@ -249,14 +249,14 @@ TEST(VectorCallFeedback) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
HeapObject heap_object; HeapObject heap_object;
CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object));
CHECK_EQ(*foo, heap_object); CHECK_EQ(*foo, heap_object);
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
// It should stay monomorphic even after a GC. // It should stay monomorphic even after a GC.
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
} }
TEST(VectorPolymorphicCallFeedback) { TEST(VectorPolymorphicCallFeedback) {
...@@ -283,7 +283,7 @@ TEST(VectorPolymorphicCallFeedback) { ...@@ -283,7 +283,7 @@ TEST(VectorPolymorphicCallFeedback) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
HeapObject heap_object; HeapObject heap_object;
CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object));
CHECK(heap_object.IsFeedbackCell(isolate)); CHECK(heap_object.IsFeedbackCell(isolate));
...@@ -313,14 +313,14 @@ TEST(VectorCallFeedbackForArray) { ...@@ -313,14 +313,14 @@ TEST(VectorCallFeedbackForArray) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
HeapObject heap_object; HeapObject heap_object;
CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object)); CHECK(nexus.GetFeedback()->GetHeapObjectIfWeak(&heap_object));
CHECK_EQ(*isolate->array_function(), heap_object); CHECK_EQ(*isolate->array_function(), heap_object);
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
// It should stay monomorphic even after a GC. // It should stay monomorphic even after a GC.
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
} }
TEST(VectorCallCounts) { TEST(VectorCallCounts) {
...@@ -344,15 +344,15 @@ TEST(VectorCallCounts) { ...@@ -344,15 +344,15 @@ TEST(VectorCallCounts) {
Handle<FeedbackVector>(f->feedback_vector(), isolate); Handle<FeedbackVector>(f->feedback_vector(), isolate);
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CompileRun("f(foo); f(foo);"); CompileRun("f(foo); f(foo);");
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(3, nexus.GetCallCount()); CHECK_EQ(3, nexus.GetCallCount());
// Send the IC megamorphic, but we should still have incrementing counts. // Send the IC megamorphic, but we should still have incrementing counts.
CompileRun("f(function() { return 12; });"); CompileRun("f(function() { return 12; });");
CHECK_EQ(GENERIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::GENERIC, nexus.ic_state());
CHECK_EQ(4, nexus.GetCallCount()); CHECK_EQ(4, nexus.GetCallCount());
} }
...@@ -377,17 +377,17 @@ TEST(VectorConstructCounts) { ...@@ -377,17 +377,17 @@ TEST(VectorConstructCounts) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK(feedback_vector->Get(slot)->IsWeak()); CHECK(feedback_vector->Get(slot)->IsWeak());
CompileRun("f(Foo); f(Foo);"); CompileRun("f(Foo); f(Foo);");
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(3, nexus.GetCallCount()); CHECK_EQ(3, nexus.GetCallCount());
// Send the IC megamorphic, but we should still have incrementing counts. // Send the IC megamorphic, but we should still have incrementing counts.
CompileRun("f(function() {});"); CompileRun("f(function() {});");
CHECK_EQ(GENERIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::GENERIC, nexus.ic_state());
CHECK_EQ(4, nexus.GetCallCount()); CHECK_EQ(4, nexus.GetCallCount());
} }
...@@ -452,15 +452,15 @@ TEST(VectorCallSpeculationModeAndFeedbackContent) { ...@@ -452,15 +452,15 @@ TEST(VectorCallSpeculationModeAndFeedbackContent) {
FeedbackSlot slot(6); FeedbackSlot slot(6);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(SpeculationMode::kAllowSpeculation, nexus.GetSpeculationMode()); CHECK_EQ(SpeculationMode::kAllowSpeculation, nexus.GetSpeculationMode());
CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent()); CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent());
CompileRun("%OptimizeFunctionOnNextCall(f); f(1);"); CompileRun("%OptimizeFunctionOnNextCall(f); f(1);");
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(SpeculationMode::kAllowSpeculation, nexus.GetSpeculationMode()); CHECK_EQ(SpeculationMode::kAllowSpeculation, nexus.GetSpeculationMode());
CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent()); CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent());
CompileRun("f({});"); // Deoptimizes. CompileRun("f({});"); // Deoptimizes.
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
CHECK_EQ(SpeculationMode::kDisallowSpeculation, nexus.GetSpeculationMode()); CHECK_EQ(SpeculationMode::kDisallowSpeculation, nexus.GetSpeculationMode());
CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent()); CHECK_EQ(CallFeedbackContent::kReceiver, nexus.GetCallFeedbackContent());
} }
...@@ -487,7 +487,7 @@ TEST(VectorLoadICStates) { ...@@ -487,7 +487,7 @@ TEST(VectorLoadICStates) {
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
// Verify that the monomorphic map is the one we expect. // Verify that the monomorphic map is the one we expect.
v8::MaybeLocal<v8::Value> v8_o = v8::MaybeLocal<v8::Value> v8_o =
CcTest::global()->Get(context.local(), v8_str("o")); CcTest::global()->Get(context.local(), v8_str("o"));
...@@ -497,27 +497,27 @@ TEST(VectorLoadICStates) { ...@@ -497,27 +497,27 @@ TEST(VectorLoadICStates) {
// Now go polymorphic. // Now go polymorphic.
CompileRun("f({ blarg: 3, foo: 2 })"); CompileRun("f({ blarg: 3, foo: 2 })");
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
CompileRun( CompileRun(
"delete o.foo;" "delete o.foo;"
"f(o)"); "f(o)");
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
CompileRun("f({ blarg: 3, torino: 10, foo: 2 })"); CompileRun("f({ blarg: 3, torino: 10, foo: 2 })");
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
MapHandles maps; MapHandles maps;
nexus.ExtractMaps(&maps); nexus.ExtractMaps(&maps);
CHECK_EQ(4, maps.size()); CHECK_EQ(4, maps.size());
// Finally driven megamorphic. // Finally driven megamorphic.
CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })");
CHECK_EQ(MEGAMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MEGAMORPHIC, nexus.ic_state());
CHECK(nexus.GetFirstMap().is_null()); CHECK(nexus.GetFirstMap().is_null());
// After a collection, state should not be reset to PREMONOMORPHIC. // After a collection, state should not be reset to PREMONOMORPHIC.
CcTest::CollectAllGarbage(); CcTest::CollectAllGarbage();
CHECK_EQ(MEGAMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MEGAMORPHIC, nexus.ic_state());
} }
TEST(VectorLoadGlobalICSlotSharing) { TEST(VectorLoadGlobalICSlotSharing) {
...@@ -552,8 +552,10 @@ TEST(VectorLoadGlobalICSlotSharing) { ...@@ -552,8 +552,10 @@ TEST(VectorLoadGlobalICSlotSharing) {
CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kLoadGlobalInsideTypeof); CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kLoadGlobalInsideTypeof);
FeedbackSlot slot1 = helper.slot(0); FeedbackSlot slot1 = helper.slot(0);
FeedbackSlot slot2 = helper.slot(1); FeedbackSlot slot2 = helper.slot(1);
CHECK_EQ(MONOMORPHIC, FeedbackNexus(feedback_vector, slot1).ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC,
CHECK_EQ(MONOMORPHIC, FeedbackNexus(feedback_vector, slot2).ic_state()); FeedbackNexus(feedback_vector, slot1).ic_state());
CHECK_EQ(InlineCacheState::MONOMORPHIC,
FeedbackNexus(feedback_vector, slot2).ic_state());
} }
...@@ -579,14 +581,14 @@ TEST(VectorLoadICOnSmi) { ...@@ -579,14 +581,14 @@ TEST(VectorLoadICOnSmi) {
Handle<FeedbackVector>(f->feedback_vector(), isolate); Handle<FeedbackVector>(f->feedback_vector(), isolate);
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
// Verify that the monomorphic map is the one we expect. // Verify that the monomorphic map is the one we expect.
Map number_map = ReadOnlyRoots(heap).heap_number_map(); Map number_map = ReadOnlyRoots(heap).heap_number_map();
CHECK_EQ(number_map, nexus.GetFirstMap()); CHECK_EQ(number_map, nexus.GetFirstMap());
// Now go polymorphic on o. // Now go polymorphic on o.
CompileRun("f(o)"); CompileRun("f(o)");
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
MapHandles maps; MapHandles maps;
nexus.ExtractMaps(&maps); nexus.ExtractMaps(&maps);
...@@ -609,7 +611,7 @@ TEST(VectorLoadICOnSmi) { ...@@ -609,7 +611,7 @@ TEST(VectorLoadICOnSmi) {
// The degree of polymorphism doesn't change. // The degree of polymorphism doesn't change.
CompileRun("f(100)"); CompileRun("f(100)");
CHECK_EQ(POLYMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::POLYMORPHIC, nexus.ic_state());
MapHandles maps2; MapHandles maps2;
nexus.ExtractMaps(&maps2); nexus.ExtractMaps(&maps2);
CHECK_EQ(2, maps2.size()); CHECK_EQ(2, maps2.size());
...@@ -788,7 +790,7 @@ TEST(VectorStoreICBasic) { ...@@ -788,7 +790,7 @@ TEST(VectorStoreICBasic) {
CHECK_EQ(1, helper.slot_count()); CHECK_EQ(1, helper.slot_count());
FeedbackSlot slot(0); FeedbackSlot slot(0);
FeedbackNexus nexus(feedback_vector, slot); FeedbackNexus nexus(feedback_vector, slot);
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
} }
TEST(StoreOwnIC) { TEST(StoreOwnIC) {
...@@ -816,7 +818,7 @@ TEST(StoreOwnIC) { ...@@ -816,7 +818,7 @@ TEST(StoreOwnIC) {
CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLiteral); CHECK_SLOT_KIND(helper, 0, FeedbackSlotKind::kLiteral);
CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreOwnNamed); CHECK_SLOT_KIND(helper, 1, FeedbackSlotKind::kStoreOwnNamed);
FeedbackNexus nexus(feedback_vector, helper.slot(1)); FeedbackNexus nexus(feedback_vector, helper.slot(1));
CHECK_EQ(MONOMORPHIC, nexus.ic_state()); CHECK_EQ(InlineCacheState::MONOMORPHIC, nexus.ic_state());
} }
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment