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

Side by Side Diff: test/cctest/test-feedback-vector.cc

Issue 1384673002: The metadata part of TypeFeedbackVector is extracted to TypeFeedbackMetadata array. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-feedback-vector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 13 matching lines...) Expand all
24 24
25 TEST(VectorStructure) { 25 TEST(VectorStructure) {
26 LocalContext context; 26 LocalContext context;
27 v8::HandleScope scope(context->GetIsolate()); 27 v8::HandleScope scope(context->GetIsolate());
28 Isolate* isolate = CcTest::i_isolate(); 28 Isolate* isolate = CcTest::i_isolate();
29 Factory* factory = isolate->factory(); 29 Factory* factory = isolate->factory();
30 Zone* zone = isolate->runtime_zone(); 30 Zone* zone = isolate->runtime_zone();
31 31
32 // Empty vectors are the empty fixed array. 32 // Empty vectors are the empty fixed array.
33 StaticFeedbackVectorSpec empty; 33 StaticFeedbackVectorSpec empty;
34 Handle<TypeFeedbackVector> vector = TypeFeedbackVector::New(isolate, &empty); 34 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &empty);
35 CHECK(Handle<FixedArray>::cast(vector) 35 CHECK(Handle<FixedArray>::cast(vector)
36 .is_identical_to(factory->empty_fixed_array())); 36 .is_identical_to(factory->empty_fixed_array()));
37 // Which can nonetheless be queried. 37 // Which can nonetheless be queried.
38 CHECK_EQ(0, vector->ic_with_type_info_count()); 38 CHECK_EQ(0, vector->ic_with_type_info_count());
39 CHECK_EQ(0, vector->ic_generic_count()); 39 CHECK_EQ(0, vector->ic_generic_count());
40 CHECK(vector->is_empty()); 40 CHECK(vector->is_empty());
41 41
42 { 42 {
43 FeedbackVectorSpec one_slot(zone); 43 FeedbackVectorSpec one_slot(zone);
44 one_slot.AddGeneralSlot(); 44 one_slot.AddGeneralSlot();
45 vector = TypeFeedbackVector::New(isolate, &one_slot); 45 vector = NewTypeFeedbackVector(isolate, &one_slot);
46 FeedbackVectorHelper helper(vector); 46 FeedbackVectorHelper helper(vector);
47 CHECK_EQ(1, helper.slot_count()); 47 CHECK_EQ(1, helper.slot_count());
48 } 48 }
49 49
50 { 50 {
51 FeedbackVectorSpec one_icslot(zone); 51 FeedbackVectorSpec one_icslot(zone);
52 one_icslot.AddCallICSlot(); 52 one_icslot.AddCallICSlot();
53 vector = TypeFeedbackVector::New(isolate, &one_icslot); 53 vector = NewTypeFeedbackVector(isolate, &one_icslot);
54 FeedbackVectorHelper helper(vector); 54 FeedbackVectorHelper helper(vector);
55 CHECK_EQ(1, helper.slot_count()); 55 CHECK_EQ(1, helper.slot_count());
56 } 56 }
57 57
58 { 58 {
59 FeedbackVectorSpec spec(zone); 59 FeedbackVectorSpec spec(zone);
60 for (int i = 0; i < 3; i++) { 60 for (int i = 0; i < 3; i++) {
61 spec.AddGeneralSlot(); 61 spec.AddGeneralSlot();
62 } 62 }
63 for (int i = 0; i < 5; i++) { 63 for (int i = 0; i < 5; i++) {
64 spec.AddCallICSlot(); 64 spec.AddCallICSlot();
65 } 65 }
66 vector = TypeFeedbackVector::New(isolate, &spec); 66 vector = NewTypeFeedbackVector(isolate, &spec);
67 FeedbackVectorHelper helper(vector); 67 FeedbackVectorHelper helper(vector);
68 CHECK_EQ(8, helper.slot_count()); 68 CHECK_EQ(8, helper.slot_count());
69 69
70 int metadata_length = vector->ic_metadata_length();
71 CHECK(metadata_length > 0);
72
73 int index = vector->GetIndex(helper.slot(0)); 70 int index = vector->GetIndex(helper.slot(0));
74 71
75 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + metadata_length, index); 72 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount, index);
76 CHECK(helper.slot(0) == vector->ToSlot(index)); 73 CHECK_EQ(helper.slot(0), vector->ToSlot(index));
77 74
78 index = vector->GetIndex(helper.slot(3)); 75 index = vector->GetIndex(helper.slot(3));
79 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + metadata_length + 3, 76 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + 3, index);
80 index); 77 CHECK_EQ(helper.slot(3), vector->ToSlot(index));
81 CHECK(helper.slot(3) == vector->ToSlot(index));
82 78
83 index = vector->GetIndex(helper.slot(7)); 79 index = vector->GetIndex(helper.slot(7));
84 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + metadata_length + 3 + 80 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + 3 +
85 4 * TypeFeedbackVector::GetSlotSize( 81 4 * TypeFeedbackMetadata::GetSlotSize(
86 FeedbackVectorSlotKind::CALL_IC), 82 FeedbackVectorSlotKind::CALL_IC),
87 index); 83 index);
88 CHECK(helper.slot(7) == vector->ToSlot(index)); 84 CHECK_EQ(helper.slot(7), vector->ToSlot(index));
89 85
90 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + metadata_length + 3 + 86 CHECK_EQ(TypeFeedbackVector::kReservedIndexCount + 3 +
91 5 * TypeFeedbackVector::GetSlotSize( 87 5 * TypeFeedbackMetadata::GetSlotSize(
92 FeedbackVectorSlotKind::CALL_IC), 88 FeedbackVectorSlotKind::CALL_IC),
93 vector->length()); 89 vector->length());
94 } 90 }
95 } 91 }
96 92
97 93
98 // IC slots need an encoding to recognize what is in there. 94 // IC slots need an encoding to recognize what is in there.
99 TEST(VectorICMetadata) { 95 TEST(VectorICMetadata) {
100 LocalContext context; 96 LocalContext context;
101 v8::HandleScope scope(context->GetIsolate()); 97 v8::HandleScope scope(context->GetIsolate());
(...skipping 12 matching lines...) Expand all
114 break; 110 break;
115 case 2: 111 case 2:
116 spec.AddLoadICSlot(); 112 spec.AddLoadICSlot();
117 break; 113 break;
118 case 3: 114 case 3:
119 spec.AddKeyedLoadICSlot(); 115 spec.AddKeyedLoadICSlot();
120 break; 116 break;
121 } 117 }
122 } 118 }
123 119
124 Handle<TypeFeedbackVector> vector = TypeFeedbackVector::New(isolate, &spec); 120 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &spec);
125 FeedbackVectorHelper helper(vector); 121 FeedbackVectorHelper helper(vector);
126 CHECK_EQ(40, helper.slot_count()); 122 CHECK_EQ(40, helper.slot_count());
127 123
128 // Meanwhile set some feedback values and type feedback values to 124 // Meanwhile set some feedback values and type feedback values to
129 // verify the data structure remains intact. 125 // verify the data structure remains intact.
130 vector->change_ic_with_type_info_count(100); 126 vector->change_ic_with_type_info_count(100);
131 vector->change_ic_generic_count(3333); 127 vector->change_ic_generic_count(3333);
132 vector->Set(FeedbackVectorSlot(0), *vector); 128 vector->Set(FeedbackVectorSlot(0), *vector);
133 129
134 // Verify the metadata is correctly set up from the spec. 130 // Verify the metadata is correctly set up from the spec.
(...skipping 24 matching lines...) Expand all
159 Factory* factory = isolate->factory(); 155 Factory* factory = isolate->factory();
160 Zone* zone = isolate->runtime_zone(); 156 Zone* zone = isolate->runtime_zone();
161 157
162 // We only test clearing FeedbackVectorSlots, not FeedbackVectorSlots. 158 // We only test clearing FeedbackVectorSlots, not FeedbackVectorSlots.
163 // The reason is that FeedbackVectorSlots need a full code environment 159 // The reason is that FeedbackVectorSlots need a full code environment
164 // to fully test (See VectorICProfilerStatistics test below). 160 // to fully test (See VectorICProfilerStatistics test below).
165 FeedbackVectorSpec spec(zone); 161 FeedbackVectorSpec spec(zone);
166 for (int i = 0; i < 5; i++) { 162 for (int i = 0; i < 5; i++) {
167 spec.AddGeneralSlot(); 163 spec.AddGeneralSlot();
168 } 164 }
169 Handle<TypeFeedbackVector> vector = TypeFeedbackVector::New(isolate, &spec); 165 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &spec);
170 FeedbackVectorHelper helper(vector); 166 FeedbackVectorHelper helper(vector);
171 167
172 // Fill with information 168 // Fill with information
173 vector->Set(helper.slot(0), Smi::FromInt(1)); 169 vector->Set(helper.slot(0), Smi::FromInt(1));
174 Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map()); 170 Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map());
175 vector->Set(helper.slot(1), *cell); 171 vector->Set(helper.slot(1), *cell);
176 Handle<AllocationSite> site = factory->NewAllocationSite(); 172 Handle<AllocationSite> site = factory->NewAllocationSite();
177 vector->Set(helper.slot(2), *site); 173 vector->Set(helper.slot(2), *site);
178 174
179 // GC time clearing leaves slots alone. 175 // GC time clearing leaves slots alone.
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // There should be one IC slot. 595 // There should be one IC slot.
600 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 596 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
601 FeedbackVectorHelper helper(feedback_vector); 597 FeedbackVectorHelper helper(feedback_vector);
602 CHECK_EQ(1, helper.slot_count()); 598 CHECK_EQ(1, helper.slot_count());
603 FeedbackVectorSlot slot(0); 599 FeedbackVectorSlot slot(0);
604 StoreICNexus nexus(feedback_vector, slot); 600 StoreICNexus nexus(feedback_vector, slot);
605 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 601 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
606 } 602 }
607 603
608 } // namespace 604 } // namespace
OLDNEW
« no previous file with comments | « test/cctest/test-feedback-vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698