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

Unified Diff: src/type-feedback-vector.cc

Issue 1217943004: Vector ICs: Introduce an InstanceType for the type feedback vector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix for failing test. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/type-feedback-vector.cc
diff --git a/src/type-feedback-vector.cc b/src/type-feedback-vector.cc
index adf0a5078af05c056bc1e765bd87f25a008f3357..151d40b34031ed184b76216ab11c3f73e49091dc 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -78,61 +78,75 @@ void TypeFeedbackVector::SetKind(FeedbackVectorICSlot slot, Code::Kind kind) {
}
-template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(
- Isolate* isolate, const FeedbackVectorSpec* spec);
-template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(
- Isolate* isolate, const ZoneFeedbackVectorSpec* spec);
+template int TypeFeedbackVector::SizeFor(const FeedbackVectorSpec* spec);
+template int TypeFeedbackVector::SizeFor(const ZoneFeedbackVectorSpec* spec);
+template void TypeFeedbackVector::Init(Isolate* isolate,
+ const FeedbackVectorSpec* spec);
+template void TypeFeedbackVector::Init(Isolate* isolate,
+ const ZoneFeedbackVectorSpec* spec);
// static
template <typename Spec>
-Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(Isolate* isolate,
- const Spec* spec) {
+int TypeFeedbackVector::SizeFor(const Spec* spec) {
const int slot_count = spec->slots();
const int ic_slot_count = spec->ic_slots();
+ // In this case, we'll use a sentinel, heap()->empty_feedback_vector().
+ if (slot_count == 0 && ic_slot_count == 0) {
+ return TypeFeedbackVector::kHeaderSize;
+ }
const int index_count = VectorICComputer::word_count(ic_slot_count);
const int length = slot_count + (ic_slot_count * elements_per_ic_slot()) +
index_count + kReservedIndexCount;
- if (length == kReservedIndexCount) {
- return Handle<TypeFeedbackVector>::cast(
- isolate->factory()->empty_fixed_array());
- }
+ return length * kPointerSize + TypeFeedbackVector::kHeaderSize;
+}
+
+
+template <typename Spec>
+void TypeFeedbackVector::Init(Isolate* isolate, const Spec* spec) {
+ const int slot_count = spec->slots();
+ const int ic_slot_count = spec->ic_slots();
+ const int index_count = VectorICComputer::word_count(ic_slot_count);
+ const int length = slot_count + (ic_slot_count * elements_per_ic_slot()) +
+ index_count + kReservedIndexCount;
+
+ set_length(length);
+
+ // We shouldn't create one of these if we don't have useful information to
+ // store.
+ DCHECK(slot_count > 0 || ic_slot_count > 0);
- Handle<FixedArray> array = isolate->factory()->NewFixedArray(length, TENURED);
if (ic_slot_count > 0) {
- array->set(kFirstICSlotIndex,
- Smi::FromInt(slot_count + index_count + kReservedIndexCount));
+ set(kFirstICSlotIndex,
+ Smi::FromInt(slot_count + index_count + kReservedIndexCount));
} else {
- array->set(kFirstICSlotIndex, Smi::FromInt(length));
+ set(kFirstICSlotIndex, Smi::FromInt(length));
}
- array->set(kWithTypesIndex, Smi::FromInt(0));
- array->set(kGenericCountIndex, Smi::FromInt(0));
+ set(kWithTypesIndex, Smi::FromInt(0));
+ set(kGenericCountIndex, Smi::FromInt(0));
// Fill the indexes with zeros.
for (int i = 0; i < index_count; i++) {
- array->set(kReservedIndexCount + i, Smi::FromInt(0));
+ set(kReservedIndexCount + i, Smi::FromInt(0));
}
// Ensure we can skip the write barrier
Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
for (int i = kReservedIndexCount + index_count; i < length; i++) {
- array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
+ set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
}
- Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array);
for (int i = 0; i < ic_slot_count; i++) {
- vector->SetKind(FeedbackVectorICSlot(i), spec->GetKind(i));
+ SetKind(FeedbackVectorICSlot(i), spec->GetKind(i));
}
- return vector;
}
// static
Handle<TypeFeedbackVector> TypeFeedbackVector::Copy(
Isolate* isolate, Handle<TypeFeedbackVector> vector) {
- Handle<TypeFeedbackVector> result;
- result = Handle<TypeFeedbackVector>::cast(
- isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector)));
+ Handle<TypeFeedbackVector> result =
+ isolate->factory()->CopyTypeFeedbackVector(vector);
return result;
}
« src/runtime/runtime-array.cc ('K') | « src/type-feedback-vector.h ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698