v8/test/cctest/interpreter/interpreter-tester.cc
Jakob Kummerow 6cac1382f4 [cleanup] #include heap-inl.h less often
This takes heap-inl.h out of the "Giant Include Cluster".
Naturally, that means adding a bunch of explicit includes
in a bunch of places that relied on transitively including
them before.
As of this patch, no header file outside src/heap/ includes
heap-inl.h.

Bug: v8:8562,v8:8499
Change-Id: I65fa763f90e66afc30d105b9277792721f05a6d4
Reviewed-on: https://chromium-review.googlesource.com/c/1459659
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59617}
2019-02-15 06:22:53 +00:00

80 lines
2.7 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/cctest/interpreter/interpreter-tester.h"
#include "src/api-inl.h"
#include "src/heap/heap-inl.h"
#include "src/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_opt = false;
}
InterpreterTester::InterpreterTester(
Isolate* isolate, Handle<BytecodeArray> bytecode,
MaybeHandle<FeedbackMetadata> feedback_metadata, const char* filter)
: InterpreterTester(
isolate, nullptr, bytecode,
FLAG_lite_mode ? MaybeHandle<FeedbackMetadata>() : 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->factory()->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