Commit d24ce605 authored by mvstanton's avatar mvstanton Committed by Commit bot

Interpreter tester should accept metadata instead of a vector

The InterpreterTester class cobbles together a JSFunction from
a manually created bytecode and feedback vector. However it's
fragile against design changes in the way literal arrays and
feedback vectors are handled. It's better to let it hand in
a feedback vector metadata object, and allow the system to
create the vector from that.

BUG=v8:5456

Review-Url: https://codereview.chromium.org/2652893010
Cr-Commit-Position: refs/heads/master@{#42684}
parent a5e7382d
......@@ -18,24 +18,25 @@ MaybeHandle<Object> CallInterpreter(Isolate* isolate,
InterpreterTester::InterpreterTester(
Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter)
MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
: isolate_(isolate),
source_(source),
bytecode_(bytecode),
feedback_vector_(feedback_vector) {
feedback_metadata_(feedback_metadata) {
i::FLAG_ignition = true;
i::FLAG_always_opt = false;
}
InterpreterTester::InterpreterTester(
Isolate* isolate, Handle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter)
: InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {}
MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
: InterpreterTester(isolate, nullptr, bytecode, feedback_metadata, filter) {
}
InterpreterTester::InterpreterTester(Isolate* isolate, const char* source,
const char* filter)
: InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(),
MaybeHandle<TypeFeedbackVector>(), filter) {}
MaybeHandle<TypeFeedbackMetadata>(), filter) {}
InterpreterTester::~InterpreterTester() {}
......
......@@ -39,6 +39,8 @@ class InterpreterCallable {
return CallInterpreter(isolate_, function_, args...);
}
TypeFeedbackVector* vector() const { return function_->feedback_vector(); }
private:
Isolate* isolate_;
Handle<JSFunction> function_;
......@@ -52,12 +54,12 @@ class InterpreterTester {
public:
InterpreterTester(Isolate* isolate, const char* source,
MaybeHandle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector,
MaybeHandle<TypeFeedbackMetadata> feedback_metadata,
const char* filter);
InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector =
MaybeHandle<TypeFeedbackVector>(),
MaybeHandle<TypeFeedbackMetadata> feedback_metadata =
MaybeHandle<TypeFeedbackMetadata>(),
const char* filter = kFunctionName);
InterpreterTester(Isolate* isolate, const char* source,
......@@ -84,7 +86,7 @@ class InterpreterTester {
Isolate* isolate_;
const char* source_;
MaybeHandle<BytecodeArray> bytecode_;
MaybeHandle<TypeFeedbackVector> feedback_vector_;
MaybeHandle<TypeFeedbackMetadata> feedback_metadata_;
template <class... A>
Handle<JSFunction> GetBytecodeFunction() {
......@@ -114,9 +116,13 @@ class InterpreterTester {
if (!bytecode_.is_null()) {
function->shared()->set_function_data(*bytecode_.ToHandleChecked());
}
if (!feedback_vector_.is_null()) {
function->literals()->set_feedback_vector(
*feedback_vector_.ToHandleChecked());
if (!feedback_metadata_.is_null()) {
// TODO(mvstanton): The call to ClearOptimizedCodeMap can be removed
// when we stop storing literals in the optimized code map (upcoming CL).
function->shared()->ClearOptimizedCodeMap();
function->shared()->set_feedback_metadata(
*feedback_metadata_.ToHandleChecked());
JSFunction::EnsureLiterals(function);
}
return function;
}
......
This diff is collapsed.
......@@ -46,6 +46,11 @@ Handle<TypeFeedbackVector> NewTypeFeedbackVector(Isolate* isolate, Spec* spec) {
return TypeFeedbackVector::New(isolate, metadata);
}
template <typename Spec>
Handle<TypeFeedbackMetadata> NewTypeFeedbackMetadata(Isolate* isolate,
Spec* spec) {
return TypeFeedbackMetadata::New(isolate, spec);
}
} // namespace internal
} // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment