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

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

Issue 2614373002: [FeedbackVector] Infrastructure for literal arrays in the vector. (Closed)
Patch Set: Release compile fix. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-feedback-vector.cc
diff --git a/src/type-feedback-vector.cc b/src/type-feedback-vector.cc
index e015cd95dd934cde219ac6bb15e33f2de2e10942..c5908c717b40f7964381fab7579947d00ece39fa 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -37,6 +37,11 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind(
return VectorICComputer::decode(data, slot.ToInt());
}
+int TypeFeedbackMetadata::GetParameter(int parameter_index) const {
+ FixedArray* parameters = FixedArray::cast(get(kParametersTableIndex));
+ return Smi::cast(parameters->get(parameter_index))->value();
+}
+
void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot,
FeedbackVectorSlotKind kind) {
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
@@ -91,6 +96,18 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate,
metadata->SetKind(FeedbackVectorSlot(i), kind);
}
+ if (spec->parameters_count() > 0) {
+ const int parameters_count = spec->parameters_count();
+ Handle<FixedArray> params_array =
+ factory->NewFixedArray(parameters_count, TENURED);
+ for (int i = 0; i < parameters_count; i++) {
+ params_array->set(i, Smi::FromInt(spec->GetParameter(i)));
+ }
+ metadata->set(kParametersTableIndex, *params_array);
+ } else {
+ metadata->set(kParametersTableIndex, *factory->empty_fixed_array());
+ }
+
// It's important that the TypeFeedbackMetadata have a COW map, since it's
// pointed to by both a SharedFunctionInfo and indirectly by closures through
// the TypeFeedbackVector. The serializer uses the COW map type to decide
@@ -109,6 +126,7 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
}
int slots = slot_count();
+ int parameter_index = 0;
for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot);
@@ -117,6 +135,14 @@ bool TypeFeedbackMetadata::SpecDiffersFrom(
if (kind != other_spec->GetKind(i)) {
return true;
}
+ if (SlotRequiresParameter(kind)) {
+ int parameter = GetParameter(parameter_index);
+ int other_parameter = other_spec->GetParameter(parameter_index);
+ if (parameter != other_parameter) {
+ return true;
+ }
+ parameter_index++;
+ }
i += entry_size;
}
return false;
@@ -129,6 +155,7 @@ bool TypeFeedbackMetadata::DiffersFrom(
}
int slots = slot_count();
+ int parameter_index = 0;
for (int i = 0; i < slots;) {
FeedbackVectorSlot slot(i);
FeedbackVectorSlotKind kind = GetKind(slot);
@@ -136,6 +163,13 @@ bool TypeFeedbackMetadata::DiffersFrom(
if (GetKind(slot) != other_metadata->GetKind(slot)) {
return true;
}
+ if (SlotRequiresParameter(kind)) {
+ if (GetParameter(parameter_index) !=
+ other_metadata->GetParameter(parameter_index)) {
+ return true;
+ }
+ parameter_index++;
+ }
i += entry_size;
}
return false;
@@ -163,6 +197,8 @@ const char* TypeFeedbackMetadata::Kind2String(FeedbackVectorSlotKind kind) {
return "INTERPRETER_COMPARE_IC";
case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC:
return "STORE_DATA_PROPERTY_IN_LITERAL_IC";
+ case FeedbackVectorSlotKind::CREATE_CLOSURE:
+ return "CREATE_CLOSURE";
case FeedbackVectorSlotKind::GENERAL:
return "STUB";
case FeedbackVectorSlotKind::KINDS_NUMBER:
@@ -178,6 +214,13 @@ FeedbackVectorSlotKind TypeFeedbackVector::GetKind(
return metadata()->GetKind(slot);
}
+int TypeFeedbackVector::GetParameter(FeedbackVectorSlot slot) const {
+ DCHECK(!is_empty());
+ DCHECK(
+ TypeFeedbackMetadata::SlotRequiresParameter(metadata()->GetKind(slot)));
+ return FixedArray::cast(Get(slot))->length();
+}
+
// static
Handle<TypeFeedbackVector> TypeFeedbackVector::New(
Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
@@ -194,6 +237,29 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
array->set_map_no_write_barrier(isolate->heap()->type_feedback_vector_map());
array->set(kMetadataIndex, *metadata);
array->set(kInvocationCountIndex, Smi::kZero);
+ int parameter_index = 0;
+ for (int i = 0; i < slot_count;) {
+ FeedbackVectorSlot slot(i);
+ FeedbackVectorSlotKind kind = metadata->GetKind(slot);
+ int index = TypeFeedbackVector::GetIndex(slot);
+ int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
+
+ if (kind == FeedbackVectorSlotKind::CREATE_CLOSURE) {
+ // This fixed array is filled with undefined.
+ int length = metadata->GetParameter(parameter_index++);
+ if (length == 0) {
+ // This is a native function literal. We can always point to
+ // the empty literals array here.
+ array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
+ } else {
+ // TODO(mvstanton): Create the array.
+ // Handle<FixedArray> value = factory->NewFixedArray(length);
+ // array->set(index, *value);
+ array->set(index, *factory->empty_literals_array(), SKIP_WRITE_BARRIER);
+ }
+ }
+ i += entry_size;
+ }
DisallowHeapAllocation no_gc;
@@ -215,12 +281,14 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::New(
} else {
value = *uninitialized_sentinel;
}
- array->set(index, value, SKIP_WRITE_BARRIER);
- value = kind == FeedbackVectorSlotKind::CALL_IC ? Smi::kZero
- : *uninitialized_sentinel;
- for (int j = 1; j < entry_size; j++) {
- array->set(index + j, value, SKIP_WRITE_BARRIER);
+ if (kind != FeedbackVectorSlotKind::CREATE_CLOSURE) {
+ array->set(index, value, SKIP_WRITE_BARRIER);
+ value = kind == FeedbackVectorSlotKind::CALL_IC ? Smi::kZero
+ : *uninitialized_sentinel;
+ for (int j = 1; j < entry_size; j++) {
+ array->set(index + j, value, SKIP_WRITE_BARRIER);
+ }
}
i += entry_size;
}
@@ -255,9 +323,10 @@ static bool ClearLogic(Isolate* isolate) {
void TypeFeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared,
bool force_clear) {
Isolate* isolate = GetIsolate();
-
if (!force_clear && !ClearLogic(isolate)) return;
+ if (this == isolate->heap()->empty_type_feedback_vector()) return;
+
Object* uninitialized_sentinel =
TypeFeedbackVector::RawUninitializedSentinel(isolate);
@@ -306,6 +375,14 @@ void TypeFeedbackVector::ClearSlotsImpl(SharedFunctionInfo* shared,
// Set(slot, Smi::kZero);
break;
}
+ case FeedbackVectorSlotKind::CREATE_CLOSURE: {
+ // Fill the array with undefined.
+ FixedArray* array = FixedArray::cast(Get(slot));
+ for (int i = 1; i < array->length(); i++) {
+ array->set_undefined(i);
+ }
+ break;
+ }
case FeedbackVectorSlotKind::GENERAL: {
if (obj->IsHeapObject()) {
InstanceType instance_type =
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698