Index: test/cctest/test-feedback-vector.cc |
diff --git a/test/cctest/test-feedback-vector.cc b/test/cctest/test-feedback-vector.cc |
index 28a15f2029ef2f100cb5cc5b61c035e8c372b4e5..52aaf918e5e11a52a212dbcd6a22f54843feba3a 100644 |
--- a/test/cctest/test-feedback-vector.cc |
+++ b/test/cctest/test-feedback-vector.cc |
@@ -53,6 +53,7 @@ TEST(VectorStructure) { |
} |
int index = vector->GetIndex(FeedbackVectorSlot(0)); |
+ |
CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + metadata_length, index); |
CHECK(FeedbackVectorSlot(0) == vector->ToSlot(index)); |
@@ -188,7 +189,7 @@ TEST(VectorICProfilerStatistics) { |
CHECK_EQ(1, feedback_vector->ic_with_type_info_count()); |
CHECK_EQ(0, feedback_vector->ic_generic_count()); |
- int ic_slot = FLAG_vector_ics ? 1 : 0; |
+ int ic_slot = 0; |
CHECK( |
feedback_vector->Get(FeedbackVectorICSlot(ic_slot))->IsAllocationSite()); |
heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
@@ -217,7 +218,7 @@ TEST(VectorCallICStates) { |
// There should be one IC. |
Handle<TypeFeedbackVector> feedback_vector = |
Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); |
- FeedbackVectorICSlot slot(FLAG_vector_ics ? 1 : 0); |
+ FeedbackVectorICSlot slot(0); |
CallICNexus nexus(feedback_vector, slot); |
CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
// CallIC doesn't return map feedback. |
@@ -239,4 +240,58 @@ TEST(VectorCallICStates) { |
heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
} |
+ |
+ |
+TEST(VectorLoadICStates) { |
+ if (i::FLAG_always_opt || !i::FLAG_vector_ics) return; |
+ CcTest::InitializeVM(); |
+ LocalContext context; |
+ v8::HandleScope scope(context->GetIsolate()); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ Heap* heap = isolate->heap(); |
+ |
+ // Make sure function f has a call that uses a type feedback slot. |
+ CompileRun( |
+ "var o = { foo: 3 };" |
+ "function f(a) { return a.foo; } f(o);"); |
+ Handle<JSFunction> f = v8::Utils::OpenHandle( |
+ *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); |
+ // There should be one IC. |
+ Handle<TypeFeedbackVector> feedback_vector = |
+ Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); |
+ FeedbackVectorICSlot slot(0); |
+ LoadICNexus nexus(feedback_vector, slot); |
+ CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); |
+ |
+ CompileRun("f(o)"); |
+ CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
+ // Verify that the monomorphic map is the one we expect. |
+ Handle<JSObject> o = v8::Utils::OpenHandle( |
+ *v8::Handle<v8::Object>::Cast(CcTest::global()->Get(v8_str("o")))); |
+ CHECK_EQ(o->map(), nexus.FindFirstMap()); |
+ |
+ // Now go polymorphic. |
+ CompileRun("f({ blarg: 3, foo: 2 })"); |
+ CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
+ |
+ CompileRun( |
+ "delete o.foo;" |
+ "f(o)"); |
+ CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
+ |
+ CompileRun("f({ blarg: 3, torino: 10, foo: 2 })"); |
+ CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
+ MapHandleList maps; |
+ nexus.FindAllMaps(&maps); |
+ CHECK_EQ(4, maps.length()); |
+ |
+ // Finally driven megamorphic. |
+ CompileRun("f({ blarg: 3, gran: 3, torino: 10, foo: 2 })"); |
+ CHECK_EQ(MEGAMORPHIC, nexus.StateFromFeedback()); |
+ CHECK_EQ(NULL, nexus.FindFirstMap()); |
+ |
+ // After a collection, state should be reset to PREMONOMORPHIC. |
+ heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
+ CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); |
+} |
} |