7629afdb9d
Allocate feedback vectors lazily when the function's interrupt budget has reached a specified threshold. This cl introduces a new field in the ClosureFeedbackCellArray to track the interrupt budget for allocating feedback vectors. Using the interrupt budget on the bytecode array could cause problems when there are closures across native contexts and we may delay allocating feedback vectors in one of them causing unexpected performance cliffs. In the long term we may want to remove interrupt budget from bytecode array and use context specific budget for tiering up decisions as well. Bug: v8:8394 Change-Id: Ia8fbb71f5e8543a92f14c44aa762973da82d445c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1520719 Commit-Queue: Mythri Alle <mythria@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#60450}
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
// 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);
|
|
Handle<SharedFunctionInfo> shared =
|
|
isolate->factory()->NewSharedFunctionInfoForBuiltin(
|
|
isolate->factory()->empty_string(), Builtins::kIllegal);
|
|
// Set the raw feedback metadata to circumvent checks that we are not
|
|
// overwriting existing metadata.
|
|
shared->set_raw_outer_scope_info_or_feedback_metadata(*metadata);
|
|
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array =
|
|
ClosureFeedbackCellArray::New(isolate, shared);
|
|
return FeedbackVector::New(isolate, shared, closure_feedback_cell_array);
|
|
}
|
|
|
|
template <typename Spec>
|
|
Handle<FeedbackMetadata> NewFeedbackMetadata(Isolate* isolate, Spec* spec) {
|
|
return FeedbackMetadata::New(isolate, spec);
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif
|