Commit 4679e4c0 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[osr] Allocate feedback vector slots for JumpLoop

These will soon be used to store cached OSR code.

Bug: v8:12161
Change-Id: I49b6f1cd648e1fd033ac09b2e590bc185f5461e7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3596165
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80045}
parent 71ed79be
...@@ -665,7 +665,7 @@ void FeedbackMetadata::FeedbackMetadataVerify(Isolate* isolate) { ...@@ -665,7 +665,7 @@ void FeedbackMetadata::FeedbackMetadataVerify(Isolate* isolate) {
iter.Next(); iter.Next();
FeedbackSlotKind kind = iter.kind(); FeedbackSlotKind kind = iter.kind();
CHECK_NE(FeedbackSlotKind::kInvalid, kind); CHECK_NE(FeedbackSlotKind::kInvalid, kind);
CHECK_GT(FeedbackSlotKind::kKindsNumber, kind); CHECK_GT(kFeedbackSlotKindCount, kind);
} }
} }
} }
......
...@@ -1274,8 +1274,10 @@ void FeedbackNexus::Print(std::ostream& os) { ...@@ -1274,8 +1274,10 @@ void FeedbackNexus::Print(std::ostream& os) {
case FeedbackSlotKind::kLiteral: case FeedbackSlotKind::kLiteral:
case FeedbackSlotKind::kTypeProfile: case FeedbackSlotKind::kTypeProfile:
break; break;
case FeedbackSlotKind::kJumpLoop:
os << "JumpLoop";
break;
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
} }
......
...@@ -71,6 +71,7 @@ int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) { ...@@ -71,6 +71,7 @@ int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) {
case FeedbackSlotKind::kBinaryOp: case FeedbackSlotKind::kBinaryOp:
case FeedbackSlotKind::kLiteral: case FeedbackSlotKind::kLiteral:
case FeedbackSlotKind::kTypeProfile: case FeedbackSlotKind::kTypeProfile:
case FeedbackSlotKind::kJumpLoop:
return 1; return 1;
case FeedbackSlotKind::kCall: case FeedbackSlotKind::kCall:
...@@ -93,10 +94,8 @@ int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) { ...@@ -93,10 +94,8 @@ int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) {
return 2; return 2;
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
return 1;
} }
Handle<FeedbackCell> ClosureFeedbackCellArray::GetFeedbackCell(int index) { Handle<FeedbackCell> ClosureFeedbackCellArray::GetFeedbackCell(int index) {
......
...@@ -192,10 +192,9 @@ const char* FeedbackMetadata::Kind2String(FeedbackSlotKind kind) { ...@@ -192,10 +192,9 @@ const char* FeedbackMetadata::Kind2String(FeedbackSlotKind kind) {
return "InstanceOf"; return "InstanceOf";
case FeedbackSlotKind::kCloneObject: case FeedbackSlotKind::kCloneObject:
return "CloneObject"; return "CloneObject";
case FeedbackSlotKind::kKindsNumber: case FeedbackSlotKind::kJumpLoop:
break; return "JumpLoop";
} }
UNREACHABLE();
} }
bool FeedbackMetadata::HasTypeProfileSlot() const { bool FeedbackMetadata::HasTypeProfileSlot() const {
...@@ -282,6 +281,7 @@ Handle<FeedbackVector> FeedbackVector::New( ...@@ -282,6 +281,7 @@ Handle<FeedbackVector> FeedbackVector::New(
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof: case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
case FeedbackSlotKind::kStoreGlobalSloppy: case FeedbackSlotKind::kStoreGlobalSloppy:
case FeedbackSlotKind::kStoreGlobalStrict: case FeedbackSlotKind::kStoreGlobalStrict:
case FeedbackSlotKind::kJumpLoop:
vector->Set(slot, HeapObjectReference::ClearedValue(isolate), vector->Set(slot, HeapObjectReference::ClearedValue(isolate),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
break; break;
...@@ -315,7 +315,6 @@ Handle<FeedbackVector> FeedbackVector::New( ...@@ -315,7 +315,6 @@ Handle<FeedbackVector> FeedbackVector::New(
break; break;
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
for (int j = 1; j < entry_size; j++) { for (int j = 1; j < entry_size; j++) {
...@@ -550,22 +549,19 @@ void FeedbackNexus::ConfigureUninitialized() { ...@@ -550,22 +549,19 @@ void FeedbackNexus::ConfigureUninitialized() {
case FeedbackSlotKind::kStoreGlobalSloppy: case FeedbackSlotKind::kStoreGlobalSloppy:
case FeedbackSlotKind::kStoreGlobalStrict: case FeedbackSlotKind::kStoreGlobalStrict:
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof: case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
case FeedbackSlotKind::kLoadGlobalInsideTypeof: { case FeedbackSlotKind::kLoadGlobalInsideTypeof:
SetFeedback(HeapObjectReference::ClearedValue(isolate), SetFeedback(HeapObjectReference::ClearedValue(isolate),
SKIP_WRITE_BARRIER, UninitializedSentinel(), SKIP_WRITE_BARRIER, UninitializedSentinel(),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
break; break;
}
case FeedbackSlotKind::kCloneObject: case FeedbackSlotKind::kCloneObject:
case FeedbackSlotKind::kCall: { case FeedbackSlotKind::kCall:
SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER, Smi::zero(), SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER, Smi::zero(),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
break; break;
} case FeedbackSlotKind::kInstanceOf:
case FeedbackSlotKind::kInstanceOf: {
SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER); SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER);
break; break;
}
case FeedbackSlotKind::kSetNamedSloppy: case FeedbackSlotKind::kSetNamedSloppy:
case FeedbackSlotKind::kSetNamedStrict: case FeedbackSlotKind::kSetNamedStrict:
case FeedbackSlotKind::kSetKeyedSloppy: case FeedbackSlotKind::kSetKeyedSloppy:
...@@ -576,11 +572,14 @@ void FeedbackNexus::ConfigureUninitialized() { ...@@ -576,11 +572,14 @@ void FeedbackNexus::ConfigureUninitialized() {
case FeedbackSlotKind::kLoadProperty: case FeedbackSlotKind::kLoadProperty:
case FeedbackSlotKind::kLoadKeyed: case FeedbackSlotKind::kLoadKeyed:
case FeedbackSlotKind::kHasKeyed: case FeedbackSlotKind::kHasKeyed:
case FeedbackSlotKind::kDefineKeyedOwnPropertyInLiteral: { case FeedbackSlotKind::kDefineKeyedOwnPropertyInLiteral:
SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER, SetFeedback(UninitializedSentinel(), SKIP_WRITE_BARRIER,
UninitializedSentinel(), SKIP_WRITE_BARRIER); UninitializedSentinel(), SKIP_WRITE_BARRIER);
break; break;
} case FeedbackSlotKind::kJumpLoop:
SetFeedback(HeapObjectReference::ClearedValue(isolate),
SKIP_WRITE_BARRIER);
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -623,6 +622,7 @@ bool FeedbackNexus::Clear() { ...@@ -623,6 +622,7 @@ bool FeedbackNexus::Clear() {
case FeedbackSlotKind::kInstanceOf: case FeedbackSlotKind::kInstanceOf:
case FeedbackSlotKind::kDefineKeyedOwnPropertyInLiteral: case FeedbackSlotKind::kDefineKeyedOwnPropertyInLiteral:
case FeedbackSlotKind::kCloneObject: case FeedbackSlotKind::kCloneObject:
case FeedbackSlotKind::kJumpLoop:
if (!IsCleared()) { if (!IsCleared()) {
ConfigureUninitialized(); ConfigureUninitialized();
feedback_updated = true; feedback_updated = true;
...@@ -630,7 +630,6 @@ bool FeedbackNexus::Clear() { ...@@ -630,7 +630,6 @@ bool FeedbackNexus::Clear() {
break; break;
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
return feedback_updated; return feedback_updated;
...@@ -692,7 +691,8 @@ InlineCacheState FeedbackNexus::ic_state() const { ...@@ -692,7 +691,8 @@ InlineCacheState FeedbackNexus::ic_state() const {
case FeedbackSlotKind::kStoreGlobalSloppy: case FeedbackSlotKind::kStoreGlobalSloppy:
case FeedbackSlotKind::kStoreGlobalStrict: case FeedbackSlotKind::kStoreGlobalStrict:
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof: case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
case FeedbackSlotKind::kLoadGlobalInsideTypeof: { case FeedbackSlotKind::kLoadGlobalInsideTypeof:
case FeedbackSlotKind::kJumpLoop: {
if (feedback->IsSmi()) return InlineCacheState::MONOMORPHIC; if (feedback->IsSmi()) return InlineCacheState::MONOMORPHIC;
DCHECK(feedback->IsWeakOrCleared()); DCHECK(feedback->IsWeakOrCleared());
...@@ -834,7 +834,6 @@ InlineCacheState FeedbackNexus::ic_state() const { ...@@ -834,7 +834,6 @@ InlineCacheState FeedbackNexus::ic_state() const {
} }
case FeedbackSlotKind::kInvalid: case FeedbackSlotKind::kInvalid:
case FeedbackSlotKind::kKindsNumber:
UNREACHABLE(); UNREACHABLE();
} }
return InlineCacheState::UNINITIALIZED; return InlineCacheState::UNINITIALIZED;
......
...@@ -61,10 +61,14 @@ enum class FeedbackSlotKind : uint8_t { ...@@ -61,10 +61,14 @@ enum class FeedbackSlotKind : uint8_t {
kForIn, kForIn,
kInstanceOf, kInstanceOf,
kCloneObject, kCloneObject,
kJumpLoop,
kKindsNumber // Last value indicating number of kinds. kLast = kJumpLoop // Always update this if the list above changes.
}; };
static constexpr int kFeedbackSlotKindCount =
static_cast<int>(FeedbackSlotKind::kLast) + 1;
using MapAndHandler = std::pair<Handle<Map>, MaybeObjectHandle>; using MapAndHandler = std::pair<Handle<Map>, MaybeObjectHandle>;
using MapAndFeedback = std::pair<Handle<Map>, MaybeObjectHandle>; using MapAndFeedback = std::pair<Handle<Map>, MaybeObjectHandle>;
...@@ -470,6 +474,10 @@ class V8_EXPORT_PRIVATE FeedbackVectorSpec { ...@@ -470,6 +474,10 @@ class V8_EXPORT_PRIVATE FeedbackVectorSpec {
return AddSlot(FeedbackSlotKind::kCloneObject); return AddSlot(FeedbackSlotKind::kCloneObject);
} }
FeedbackSlot AddJumpLoopSlot() {
return AddSlot(FeedbackSlotKind::kJumpLoop);
}
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
// For gdb debugging. // For gdb debugging.
void Print(); void Print();
...@@ -581,8 +589,7 @@ class FeedbackMetadata : public HeapObject { ...@@ -581,8 +589,7 @@ class FeedbackMetadata : public HeapObject {
inline int length() const; inline int length() const;
static const int kFeedbackSlotKindBits = 5; static const int kFeedbackSlotKindBits = 5;
STATIC_ASSERT(static_cast<int>(FeedbackSlotKind::kKindsNumber) < STATIC_ASSERT(kFeedbackSlotKindCount <= (1 << kFeedbackSlotKindBits));
(1 << kFeedbackSlotKindBits));
void SetKind(FeedbackSlot slot, FeedbackSlotKind kind); void SetKind(FeedbackSlot slot, FeedbackSlotKind kind);
...@@ -619,7 +626,6 @@ class FeedbackMetadataIterator { ...@@ -619,7 +626,6 @@ class FeedbackMetadataIterator {
// Returns slot kind of the last slot returned by Next(). // Returns slot kind of the last slot returned by Next().
FeedbackSlotKind kind() const { FeedbackSlotKind kind() const {
DCHECK_NE(FeedbackSlotKind::kInvalid, slot_kind_); DCHECK_NE(FeedbackSlotKind::kInvalid, slot_kind_);
DCHECK_NE(FeedbackSlotKind::kKindsNumber, slot_kind_);
return slot_kind_; return slot_kind_;
} }
......
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