b3d004aaf9
... /interpreter. This CL moves cctest/interpreter/{bytecode-expectations-printer, test-bytecode-generator, test-interpreter-intrinsics, interpreter-tester, test-interpreter, test-source-positions, source-position-matcher} to unittests/interpreter/{ bytecode-expectations-printer, bytecode-generator-unittest, interpreter-intrinsics-unittest, interpreter-tester, interpreter-unittest, source-positions-unittest, source-position-matcher}. Bug: v8:12781 Change-Id: I187583bd34f709dd0d7dfc0f92e18f191da0e30f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3609752 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: 王澳 <wangao.james@bytedance.com> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/main@{#81057}
78 lines
2.6 KiB
C++
78 lines
2.6 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.
|
|
|
|
#include "test/unittests/interpreter/interpreter-tester.h"
|
|
|
|
#include "src/api/api-inl.h"
|
|
#include "src/heap/heap-inl.h"
|
|
#include "src/objects/objects-inl.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace interpreter {
|
|
|
|
MaybeHandle<Object> CallInterpreter(Isolate* isolate,
|
|
Handle<JSFunction> function) {
|
|
return Execution::Call(isolate, function,
|
|
isolate->factory()->undefined_value(), 0, nullptr);
|
|
}
|
|
|
|
InterpreterTester::InterpreterTester(
|
|
Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode,
|
|
MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter)
|
|
: isolate_(isolate),
|
|
source_(source),
|
|
bytecode_(bytecode),
|
|
feedback_metadata_(feedback_metadata) {
|
|
i::FLAG_always_turbofan = false;
|
|
}
|
|
|
|
InterpreterTester::InterpreterTester(
|
|
Isolate* isolate, Handle<BytecodeArray> bytecode,
|
|
MaybeHandle<FeedbackMetadata> 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<FeedbackMetadata>(), filter) {}
|
|
|
|
InterpreterTester::~InterpreterTester() = default;
|
|
|
|
Local<Message> InterpreterTester::CheckThrowsReturnMessage() {
|
|
TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate_));
|
|
auto callable = GetCallable<>();
|
|
MaybeHandle<Object> no_result = callable();
|
|
CHECK(isolate_->has_pending_exception());
|
|
CHECK(try_catch.HasCaught());
|
|
CHECK(no_result.is_null());
|
|
isolate_->OptionalRescheduleException(true);
|
|
CHECK(!try_catch.Message().IsEmpty());
|
|
return try_catch.Message();
|
|
}
|
|
|
|
Handle<Object> InterpreterTester::NewObject(const char* script) {
|
|
return v8::Utils::OpenHandle(*CompileRun(script));
|
|
}
|
|
|
|
Handle<String> InterpreterTester::GetName(Isolate* isolate, const char* name) {
|
|
Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(name);
|
|
return isolate->string_table()->LookupString(isolate, result);
|
|
}
|
|
|
|
std::string InterpreterTester::SourceForBody(const char* body) {
|
|
return "function " + function_name() + "() {\n" + std::string(body) + "\n}";
|
|
}
|
|
|
|
std::string InterpreterTester::function_name() {
|
|
return std::string(kFunctionName);
|
|
}
|
|
|
|
const char InterpreterTester::kFunctionName[] = "f";
|
|
|
|
} // namespace interpreter
|
|
} // namespace internal
|
|
} // namespace v8
|