2015-10-01 13:48:05 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_TEST_FEEDBACK_VECTOR_H_
|
|
|
|
#define V8_TEST_FEEDBACK_VECTOR_H_
|
|
|
|
|
2022-07-18 10:54:58 +00:00
|
|
|
#include "src/execution/isolate.h"
|
2018-03-07 10:05:14 +00:00
|
|
|
#include "src/objects/feedback-vector.h"
|
2015-10-01 13:48:05 +00:00
|
|
|
#include "src/objects/objects.h"
|
|
|
|
#include "src/objects/shared-function-info.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// Helper class that allows to write tests in a slot size independent manner.
|
|
|
|
// Use helper.slot(X) to get X'th slot identifier.
|
|
|
|
class FeedbackVectorHelper {
|
|
|
|
public:
|
2017-02-07 14:05:02 +00:00
|
|
|
explicit FeedbackVectorHelper(Handle<FeedbackVector> vector)
|
2015-10-01 13:48:05 +00:00
|
|
|
: vector_(vector) {
|
2017-07-27 12:45:00 +00:00
|
|
|
int slot_count = vector->length();
|
2015-10-01 13:48:05 +00:00
|
|
|
slots_.reserve(slot_count);
|
2017-02-07 14:05:02 +00:00
|
|
|
FeedbackMetadataIterator iter(vector->metadata());
|
2015-10-01 13:48:05 +00:00
|
|
|
while (iter.HasNext()) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot = iter.Next();
|
2015-10-01 13:48:05 +00:00
|
|
|
slots_.push_back(slot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackVector> vector() { return vector_; }
|
2015-10-01 13:48:05 +00:00
|
|
|
|
|
|
|
// Returns slot identifier by numerical index.
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot(int index) const { return slots_[index]; }
|
2015-10-01 13:48:05 +00:00
|
|
|
|
|
|
|
// Returns the number of slots in the feedback vector.
|
|
|
|
int slot_count() const { return static_cast<int>(slots_.size()); }
|
|
|
|
|
|
|
|
private:
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackVector> vector_;
|
2017-02-07 15:19:35 +00:00
|
|
|
std::vector<FeedbackSlot> slots_;
|
2015-10-01 13:48:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif
|