Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8_TEST_FEEDBACK_VECTOR_H_ | |
| 6 #define V8_TEST_FEEDBACK_VECTOR_H_ | |
| 7 | |
| 8 #include "src/objects.h" | |
| 9 | |
| 10 | |
| 11 namespace v8 { | |
| 12 namespace internal { | |
| 13 | |
| 14 // Helper class that allows to write tests in a slot size independent manner. | |
| 15 // Use helper.slot(X) to get X'th slot identifier. | |
| 16 class FeedbackVectorHelper { | |
|
mvstanton
2015/10/01 10:24:31
I wonder if we might want this in /src/type-feedba
Igor Sheludko
2015/10/01 12:46:29
I think the production code must always use slots
| |
| 17 public: | |
| 18 explicit FeedbackVectorHelper(Handle<TypeFeedbackVector> vector) | |
| 19 : vector_(vector) { | |
| 20 int slot_count = vector->Slots(); | |
| 21 slots_.reserve(slot_count); | |
| 22 TypeFeedbackMetadataIterator iter(vector); | |
| 23 while (iter.HasNext()) { | |
| 24 FeedbackVectorSlot slot = iter.Next(); | |
| 25 slots_.push_back(slot); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 Handle<TypeFeedbackVector> vector() { return vector_; } | |
| 30 | |
| 31 // Returns slot identifier by numerical index. | |
| 32 FeedbackVectorSlot slot(int index) const { return slots_[index]; } | |
| 33 | |
| 34 // Returns the number of slots in the feedback vector. | |
| 35 int slot_count() const { return static_cast<int>(slots_.size()); } | |
| 36 | |
| 37 private: | |
| 38 Handle<TypeFeedbackVector> vector_; | |
| 39 std::vector<FeedbackVectorSlot> slots_; | |
| 40 }; | |
| 41 | |
| 42 } // namespace internal | |
| 43 } // namespace v8 | |
| 44 | |
| 45 #endif | |
| OLD | NEW |