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->allocator()); | 39 Zone zone(isolate->allocator(), ZONE_NAME); |
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).is_identical_to( | 44 CHECK(Handle<FixedArray>::cast(vector).is_identical_to( |
45 factory->empty_type_feedback_vector())); | 45 factory->empty_type_feedback_vector())); |
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 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after 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->allocator()); | 106 Zone zone(isolate->allocator(), ZONE_NAME); |
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(); |
(...skipping 34 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->allocator()); | 161 Zone zone(isolate->allocator(), ZONE_NAME); |
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); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // There should be one IC slot. | 583 // There should be one IC slot. |
584 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); | 584 Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector()); |
585 FeedbackVectorHelper helper(feedback_vector); | 585 FeedbackVectorHelper helper(feedback_vector); |
586 CHECK_EQ(1, helper.slot_count()); | 586 CHECK_EQ(1, helper.slot_count()); |
587 FeedbackVectorSlot slot(0); | 587 FeedbackVectorSlot slot(0); |
588 StoreICNexus nexus(feedback_vector, slot); | 588 StoreICNexus nexus(feedback_vector, slot); |
589 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); | 589 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); |
590 } | 590 } |
591 | 591 |
592 } // namespace | 592 } // namespace |
OLD | NEW |