| Index: src/feedback-vector.cc
|
| diff --git a/src/feedback-vector.cc b/src/feedback-vector.cc
|
| index 5d842763994c75d047839b9423b2d2be298b744d..ef62a634fd55c93b9547869505eec7b44e3def25 100644
|
| --- a/src/feedback-vector.cc
|
| +++ b/src/feedback-vector.cc
|
| @@ -149,6 +149,8 @@ const char* FeedbackMetadata::Kind2String(FeedbackSlotKind kind) {
|
| return "kCreateClosure";
|
| case FeedbackSlotKind::kLiteral:
|
| return "LITERAL";
|
| + case FeedbackSlotKind::kTypeProfile:
|
| + return "TYPE_PROFILE";
|
| case FeedbackSlotKind::kGeneral:
|
| return "STUB";
|
| case FeedbackSlotKind::kKindsNumber:
|
| @@ -158,6 +160,18 @@ const char* FeedbackMetadata::Kind2String(FeedbackSlotKind kind) {
|
| return "?";
|
| }
|
|
|
| +bool FeedbackMetadata::HasTypeProfileSlot() {
|
| + FeedbackMetadataIterator iter(this);
|
| + while (iter.HasNext()) {
|
| + iter.Next();
|
| + FeedbackSlotKind kind = iter.kind();
|
| + if (kind == FeedbackSlotKind::kTypeProfile) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const {
|
| DCHECK(!is_empty());
|
| return metadata()->GetKind(slot);
|
| @@ -219,6 +233,7 @@ Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate,
|
| case FeedbackSlotKind::kStoreKeyedStrict:
|
| case FeedbackSlotKind::kStoreDataPropertyInLiteral:
|
| case FeedbackSlotKind::kGeneral:
|
| + case FeedbackSlotKind::kTypeProfile:
|
| array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
|
| break;
|
|
|
| @@ -336,7 +351,8 @@ void FeedbackVector::ClearSlots(JSFunction* host_function) {
|
| break;
|
| }
|
| case FeedbackSlotKind::kCreateClosure: {
|
| - break;
|
| + case FeedbackSlotKind::kTypeProfile:
|
| + break;
|
| }
|
| case FeedbackSlotKind::kGeneral: {
|
| if (obj->IsHeapObject()) {
|
| @@ -1023,5 +1039,49 @@ void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
|
| SetFeedbackExtra(*name);
|
| }
|
|
|
| +InlineCacheState CollectTypeProfileNexus::StateFromFeedback() const {
|
| + Isolate* isolate = GetIsolate();
|
| + Object* const feedback = GetFeedback();
|
| +
|
| + if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
| + return UNINITIALIZED;
|
| + }
|
| + return MONOMORPHIC;
|
| +}
|
| +
|
| +void CollectTypeProfileNexus::Collect(Handle<Name> type) {
|
| + Isolate* isolate = GetIsolate();
|
| +
|
| + Object* const feedback = GetFeedback();
|
| + Handle<ArrayList> types;
|
| +
|
| + if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
| + types = ArrayList::New(isolate, 1);
|
| + } else {
|
| + types = Handle<ArrayList>(ArrayList::cast(feedback), isolate);
|
| + }
|
| + // TODO(franzih): Somehow sort this list. Either avoid duplicates
|
| + // or use the common base type.
|
| + SetFeedback(*ArrayList::Add(types, type));
|
| +}
|
| +
|
| +void CollectTypeProfileNexus::Print() const {
|
| + Isolate* isolate = GetIsolate();
|
| +
|
| + Object* const feedback = GetFeedback();
|
| +
|
| + if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
| + return;
|
| + }
|
| +
|
| + Handle<ArrayList> list;
|
| + list = Handle<ArrayList>(ArrayList::cast(feedback), isolate);
|
| +
|
| + for (int i = 0; i < list->Length(); i++) {
|
| + String* name = String::cast(list->Get(i));
|
| + PrintF("%s\n", name->ToCString().get());
|
| + }
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace v8
|
|
|