| 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.h" | 9 #include "src/debug.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 Factory* factory = isolate->factory(); | 133 Factory* factory = isolate->factory(); |
| 134 | 134 |
| 135 // We only test clearing FeedbackVectorSlots, not FeedbackVectorICSlots. | 135 // We only test clearing FeedbackVectorSlots, not FeedbackVectorICSlots. |
| 136 // The reason is that FeedbackVectorICSlots need a full code environment | 136 // The reason is that FeedbackVectorICSlots need a full code environment |
| 137 // to fully test (See VectorICProfilerStatistics test below). | 137 // to fully test (See VectorICProfilerStatistics test below). |
| 138 FeedbackVectorSpec spec(5); | 138 FeedbackVectorSpec spec(5); |
| 139 Handle<TypeFeedbackVector> vector = factory->NewTypeFeedbackVector(&spec); | 139 Handle<TypeFeedbackVector> vector = factory->NewTypeFeedbackVector(&spec); |
| 140 | 140 |
| 141 // Fill with information | 141 // Fill with information |
| 142 vector->Set(FeedbackVectorSlot(0), Smi::FromInt(1)); | 142 vector->Set(FeedbackVectorSlot(0), Smi::FromInt(1)); |
| 143 vector->Set(FeedbackVectorSlot(1), *factory->fixed_array_map()); | 143 Handle<WeakCell> cell = factory->NewWeakCell(factory->fixed_array_map()); |
| 144 vector->Set(FeedbackVectorSlot(1), *cell); |
| 144 Handle<AllocationSite> site = factory->NewAllocationSite(); | 145 Handle<AllocationSite> site = factory->NewAllocationSite(); |
| 145 vector->Set(FeedbackVectorSlot(2), *site); | 146 vector->Set(FeedbackVectorSlot(2), *site); |
| 146 | 147 |
| 148 // GC time clearing leaves slots alone. |
| 149 vector->ClearSlotsAtGCTime(NULL); |
| 150 Object* obj = vector->Get(FeedbackVectorSlot(1)); |
| 151 CHECK(obj->IsWeakCell() && !WeakCell::cast(obj)->cleared()); |
| 152 |
| 147 vector->ClearSlots(NULL); | 153 vector->ClearSlots(NULL); |
| 148 | 154 |
| 149 // The feedback vector slots are cleared. AllocationSites are granted | 155 // The feedback vector slots are cleared. AllocationSites are still granted |
| 150 // an exemption from clearing, as are smis. | 156 // an exemption from clearing, as are smis. |
| 151 CHECK_EQ(Smi::FromInt(1), vector->Get(FeedbackVectorSlot(0))); | 157 CHECK_EQ(Smi::FromInt(1), vector->Get(FeedbackVectorSlot(0))); |
| 152 CHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(isolate), | 158 CHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(isolate), |
| 153 vector->Get(FeedbackVectorSlot(1))); | 159 vector->Get(FeedbackVectorSlot(1))); |
| 154 CHECK(vector->Get(FeedbackVectorSlot(2))->IsAllocationSite()); | 160 CHECK(vector->Get(FeedbackVectorSlot(2))->IsAllocationSite()); |
| 155 } | 161 } |
| 156 | 162 |
| 157 | 163 |
| 158 TEST(VectorICProfilerStatistics) { | 164 TEST(VectorICProfilerStatistics) { |
| 159 if (i::FLAG_always_opt) return; | 165 if (i::FLAG_always_opt) return; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 CHECK(number_map_found && o_map_found); | 390 CHECK(number_map_found && o_map_found); |
| 385 | 391 |
| 386 // The degree of polymorphism doesn't change. | 392 // The degree of polymorphism doesn't change. |
| 387 CompileRun("f(100)"); | 393 CompileRun("f(100)"); |
| 388 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); | 394 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); |
| 389 MapHandleList maps2; | 395 MapHandleList maps2; |
| 390 nexus.FindAllMaps(&maps2); | 396 nexus.FindAllMaps(&maps2); |
| 391 CHECK_EQ(2, maps2.length()); | 397 CHECK_EQ(2, maps2.length()); |
| 392 } | 398 } |
| 393 } | 399 } |
| OLD | NEW |