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, ...@@ -18,24 +18,25 @@ MaybeHandle<Object> CallInterpreter(Isolate* isolate,
InterpreterTester::InterpreterTester( InterpreterTester::InterpreterTester(
Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode, Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
: isolate_(isolate), : isolate_(isolate),
source_(source), source_(source),
bytecode_(bytecode), bytecode_(bytecode),
feedback_vector_(feedback_vector) { feedback_metadata_(feedback_metadata) {
i::FLAG_ignition = true; i::FLAG_ignition = true;
i::FLAG_always_opt = false; i::FLAG_always_opt = false;
} }
InterpreterTester::InterpreterTester( InterpreterTester::InterpreterTester(
Isolate* isolate, Handle<BytecodeArray> bytecode, Isolate* isolate, Handle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
: InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {} : InterpreterTester(isolate, nullptr, bytecode, feedback_metadata, filter) {
}
InterpreterTester::InterpreterTester(Isolate* isolate, const char* source, InterpreterTester::InterpreterTester(Isolate* isolate, const char* source,
const char* filter) const char* filter)
: InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(), : InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(),
MaybeHandle<TypeFeedbackVector>(), filter) {} MaybeHandle<TypeFeedbackMetadata>(), filter) {}
InterpreterTester::~InterpreterTester() {} InterpreterTester::~InterpreterTester() {}
......
...@@ -39,6 +39,8 @@ class InterpreterCallable { ...@@ -39,6 +39,8 @@ class InterpreterCallable {
return CallInterpreter(isolate_, function_, args...); return CallInterpreter(isolate_, function_, args...);
} }
TypeFeedbackVector* vector() const { return function_->feedback_vector(); }
private: private:
Isolate* isolate_; Isolate* isolate_;
Handle<JSFunction> function_; Handle<JSFunction> function_;
...@@ -52,12 +54,12 @@ class InterpreterTester { ...@@ -52,12 +54,12 @@ class InterpreterTester {
public: public:
InterpreterTester(Isolate* isolate, const char* source, InterpreterTester(Isolate* isolate, const char* source,
MaybeHandle<BytecodeArray> bytecode, MaybeHandle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector, MaybeHandle<TypeFeedbackMetadata> feedback_metadata,
const char* filter); const char* filter);
InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode, InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode,
MaybeHandle<TypeFeedbackVector> feedback_vector = MaybeHandle<TypeFeedbackMetadata> feedback_metadata =
MaybeHandle<TypeFeedbackVector>(), MaybeHandle<TypeFeedbackMetadata>(),
const char* filter = kFunctionName); const char* filter = kFunctionName);
InterpreterTester(Isolate* isolate, const char* source, InterpreterTester(Isolate* isolate, const char* source,
...@@ -84,7 +86,7 @@ class InterpreterTester { ...@@ -84,7 +86,7 @@ class InterpreterTester {
Isolate* isolate_; Isolate* isolate_;
const char* source_; const char* source_;
MaybeHandle<BytecodeArray> bytecode_; MaybeHandle<BytecodeArray> bytecode_;
MaybeHandle<TypeFeedbackVector> feedback_vector_; MaybeHandle<TypeFeedbackMetadata> feedback_metadata_;
template <class... A> template <class... A>
Handle<JSFunction> GetBytecodeFunction() { Handle<JSFunction> GetBytecodeFunction() {
...@@ -114,9 +116,13 @@ class InterpreterTester { ...@@ -114,9 +116,13 @@ class InterpreterTester {
if (!bytecode_.is_null()) { if (!bytecode_.is_null()) {
function->shared()->set_function_data(*bytecode_.ToHandleChecked()); function->shared()->set_function_data(*bytecode_.ToHandleChecked());
} }
if (!feedback_vector_.is_null()) { if (!feedback_metadata_.is_null()) {
function->literals()->set_feedback_vector( // TODO(mvstanton): The call to ClearOptimizedCodeMap can be removed
*feedback_vector_.ToHandleChecked()); // 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; return function;
} }
......
This diff is collapsed.
...@@ -46,6 +46,11 @@ Handle<TypeFeedbackVector> NewTypeFeedbackVector(Isolate* isolate, Spec* spec) { ...@@ -46,6 +46,11 @@ Handle<TypeFeedbackVector> NewTypeFeedbackVector(Isolate* isolate, Spec* spec) {
return TypeFeedbackVector::New(isolate, metadata); return TypeFeedbackVector::New(isolate, metadata);
} }
template <typename Spec>
Handle<TypeFeedbackMetadata> NewTypeFeedbackMetadata(Isolate* isolate,
Spec* spec) {
return TypeFeedbackMetadata::New(isolate, spec);
}
} // namespace internal } // namespace internal
} // namespace v8 } // 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