v8/test/cctest/test-feedback-vector.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.8 KiB
C
Raw Normal View History

// 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_
#include "src/feedback-vector.h"
#include "src/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:
explicit FeedbackVectorHelper(Handle<FeedbackVector> vector)
: vector_(vector) {
int slot_count = vector->length();
slots_.reserve(slot_count);
FeedbackMetadataIterator iter(vector->metadata());
while (iter.HasNext()) {
FeedbackSlot slot = iter.Next();
slots_.push_back(slot);
}
}
Handle<FeedbackVector> vector() { return vector_; }
// Returns slot identifier by numerical index.
FeedbackSlot slot(int index) const { return slots_[index]; }
// Returns the number of slots in the feedback vector.
int slot_count() const { return static_cast<int>(slots_.size()); }
private:
Handle<FeedbackVector> vector_;
std::vector<FeedbackSlot> slots_;
};
template <typename Spec>
Handle<FeedbackVector> NewFeedbackVector(Isolate* isolate, Spec* spec) {
Handle<FeedbackMetadata> metadata = FeedbackMetadata::New(isolate, spec);
Revert "Reland: Remove SFI code field" This reverts commit d8f564eac6152c05f6521572b6f06146c2e99eb1. Reason for revert: Breaks mac asan (https://build.chromium.org/p/client.v8/builders/V8%20Mac64%20ASAN/builds/17067) Original change's description: > Reland: Remove SFI code field > > Remove the SharedFunctionInfo code field, inferring the code object > from the function_data field instead. In some cases, the function_data > field can now hold a Code object (e.g. some WASM cases). > > (Reland of https://chromium-review.googlesource.com/952452) > > TBR=mstarzinger@chromium.org > > Bug: chromium:783853 > Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng > Change-Id: I10ea5be7ceed1b51362a2fad9be7397624d69343 > Reviewed-on: https://chromium-review.googlesource.com/970649 > Commit-Queue: Leszek Swirski <leszeks@chromium.org> > Reviewed-by: Yang Guo <yangguo@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Leszek Swirski <leszeks@chromium.org> > Cr-Commit-Position: refs/heads/master@{#52136} TBR=yangguo@chromium.org,mstarzinger@chromium.org,jgruber@chromium.org,leszeks@chromium.org Change-Id: I348ec7a9d837a7b068fd08312b77e87abf21be7b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:783853 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Reviewed-on: https://chromium-review.googlesource.com/975305 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#52143}
2018-03-22 12:56:40 +00:00
Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo(
isolate->factory()->empty_string(), MaybeHandle<Code>(), false);
shared->set_feedback_metadata(*metadata);
return FeedbackVector::New(isolate, shared);
}
template <typename Spec>
Handle<FeedbackMetadata> NewFeedbackMetadata(Isolate* isolate, Spec* spec) {
return FeedbackMetadata::New(isolate, spec);
}
} // namespace internal
} // namespace v8
#endif