OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 Handle<JSFunction>::cast(v8::Utils::OpenHandle(*v8_f.ToLocalChecked())); | 29 Handle<JSFunction>::cast(v8::Utils::OpenHandle(*v8_f.ToLocalChecked())); |
30 return f; | 30 return f; |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 TEST(VectorStructure) { | 34 TEST(VectorStructure) { |
35 LocalContext context; | 35 LocalContext context; |
36 v8::HandleScope scope(context->GetIsolate()); | 36 v8::HandleScope scope(context->GetIsolate()); |
37 Isolate* isolate = CcTest::i_isolate(); | 37 Isolate* isolate = CcTest::i_isolate(); |
38 Factory* factory = isolate->factory(); | 38 Factory* factory = isolate->factory(); |
39 Zone* zone = isolate->runtime_zone(); | 39 Zone zone(isolate->allocator()); |
40 | 40 |
41 // Empty vectors are the empty fixed array. | 41 // Empty vectors are the empty fixed array. |
42 StaticFeedbackVectorSpec empty; | 42 StaticFeedbackVectorSpec empty; |
43 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &empty); | 43 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &empty); |
44 CHECK(Handle<FixedArray>::cast(vector) | 44 CHECK(Handle<FixedArray>::cast(vector) |
45 .is_identical_to(factory->empty_fixed_array())); | 45 .is_identical_to(factory->empty_fixed_array())); |
46 // Which can nonetheless be queried. | 46 // Which can nonetheless be queried. |
47 CHECK(vector->is_empty()); | 47 CHECK(vector->is_empty()); |
48 | 48 |
49 { | 49 { |
50 FeedbackVectorSpec one_slot(zone); | 50 FeedbackVectorSpec one_slot(&zone); |
51 one_slot.AddGeneralSlot(); | 51 one_slot.AddGeneralSlot(); |
52 vector = NewTypeFeedbackVector(isolate, &one_slot); | 52 vector = NewTypeFeedbackVector(isolate, &one_slot); |
53 FeedbackVectorHelper helper(vector); | 53 FeedbackVectorHelper helper(vector); |
54 CHECK_EQ(1, helper.slot_count()); | 54 CHECK_EQ(1, helper.slot_count()); |
55 } | 55 } |
56 | 56 |
57 { | 57 { |
58 FeedbackVectorSpec one_icslot(zone); | 58 FeedbackVectorSpec one_icslot(&zone); |
59 one_icslot.AddCallICSlot(); | 59 one_icslot.AddCallICSlot(); |
60 vector = NewTypeFeedbackVector(isolate, &one_icslot); | 60 vector = NewTypeFeedbackVector(isolate, &one_icslot); |
61 FeedbackVectorHelper helper(vector); | 61 FeedbackVectorHelper helper(vector); |
62 CHECK_EQ(1, helper.slot_count()); | 62 CHECK_EQ(1, helper.slot_count()); |
63 } | 63 } |
64 | 64 |
65 { | 65 { |
66 FeedbackVectorSpec spec(zone); | 66 FeedbackVectorSpec spec(&zone); |
67 for (int i = 0; i < 3; i++) { | 67 for (int i = 0; i < 3; i++) { |
68 spec.AddGeneralSlot(); | 68 spec.AddGeneralSlot(); |
69 } | 69 } |
70 for (int i = 0; i < 5; i++) { | 70 for (int i = 0; i < 5; i++) { |
71 spec.AddCallICSlot(); | 71 spec.AddCallICSlot(); |
72 } | 72 } |
73 vector = NewTypeFeedbackVector(isolate, &spec); | 73 vector = NewTypeFeedbackVector(isolate, &spec); |
74 FeedbackVectorHelper helper(vector); | 74 FeedbackVectorHelper helper(vector); |
75 CHECK_EQ(8, helper.slot_count()); | 75 CHECK_EQ(8, helper.slot_count()); |
76 | 76 |
(...skipping 19 matching lines...) Expand all Loading... |
96 vector->length()); | 96 vector->length()); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 // IC slots need an encoding to recognize what is in there. | 101 // IC slots need an encoding to recognize what is in there. |
102 TEST(VectorICMetadata) { | 102 TEST(VectorICMetadata) { |
103 LocalContext context; | 103 LocalContext context; |
104 v8::HandleScope scope(context->GetIsolate()); | 104 v8::HandleScope scope(context->GetIsolate()); |
105 Isolate* isolate = CcTest::i_isolate(); | 105 Isolate* isolate = CcTest::i_isolate(); |
106 Zone* zone = isolate->runtime_zone(); | 106 Zone zone(isolate->allocator()); |
107 | 107 |
108 FeedbackVectorSpec spec(zone); | 108 FeedbackVectorSpec spec(&zone); |
109 // Set metadata. | 109 // Set metadata. |
110 for (int i = 0; i < 40; i++) { | 110 for (int i = 0; i < 40; i++) { |
111 switch (i % 4) { | 111 switch (i % 4) { |
112 case 0: | 112 case 0: |
113 spec.AddGeneralSlot(); | 113 spec.AddGeneralSlot(); |
114 break; | 114 break; |
115 case 1: | 115 case 1: |
116 spec.AddCallICSlot(); | 116 spec.AddCallICSlot(); |
117 break; | 117 break; |
118 case 2: | 118 case 2: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 TEST(VectorSlotClearing) { | 156 TEST(VectorSlotClearing) { |
157 LocalContext context; | 157 LocalContext context; |
158 v8::HandleScope scope(context->GetIsolate()); | 158 v8::HandleScope scope(context->GetIsolate()); |
159 Isolate* isolate = CcTest::i_isolate(); | 159 Isolate* isolate = CcTest::i_isolate(); |
160 Factory* factory = isolate->factory(); | 160 Factory* factory = isolate->factory(); |
161 Zone* zone = isolate->runtime_zone(); | 161 Zone zone(isolate->allocator()); |
162 | 162 |
163 // We only test clearing FeedbackVectorSlots, not FeedbackVectorSlots. | 163 // We only test clearing FeedbackVectorSlots, not FeedbackVectorSlots. |
164 // The reason is that FeedbackVectorSlots need a full code environment | 164 // The reason is that FeedbackVectorSlots need a full code environment |
165 // to fully test (See VectorICProfilerStatistics test below). | 165 // to fully test (See VectorICProfilerStatistics test below). |
166 FeedbackVectorSpec spec(zone); | 166 FeedbackVectorSpec spec(&zone); |
167 for (int i = 0; i < 5; i++) { | 167 for (int i = 0; i < 5; i++) { |
168 spec.AddGeneralSlot(); | 168 spec.AddGeneralSlot(); |
169 } | 169 } |
170 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &spec); | 170 Handle<TypeFeedbackVector> vector = NewTypeFeedbackVector(isolate, &spec); |
171 FeedbackVectorHelper helper(vector); | 171 FeedbackVectorHelper helper(vector); |
172 | 172 |
173 // Fill with information | 173 // Fill with information |
174 vector->Set(helper.slot(0), Smi::FromInt(1)); | 174 vector->Set(helper.slot(0), Smi::FromInt(1)); |
175 Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map()); | 175 Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map()); |
176 vector->Set(helper.slot(1), *cell); | 176 vector->Set(helper.slot(1), *cell); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // There should be one IC slot. | 574 // There should be one IC slot. |
575 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); | 575 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); |
576 FeedbackVectorHelper helper(feedback_vector); | 576 FeedbackVectorHelper helper(feedback_vector); |
577 CHECK_EQ(1, helper.slot_count()); | 577 CHECK_EQ(1, helper.slot_count()); |
578 FeedbackVectorSlot slot(0); | 578 FeedbackVectorSlot slot(0); |
579 StoreICNexus nexus(feedback_vector, slot); | 579 StoreICNexus nexus(feedback_vector, slot); |
580 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 580 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
581 } | 581 } |
582 | 582 |
583 } // namespace | 583 } // namespace |
OLD | NEW |