ec06bb6ce5
This is a reland of d1b27019d3
Fixes include:
Adding missing file to bazel build
Forward-declaring classing before friend-classing them to fix win/gcc
Add missing v8-isolate.h include for vtune builds
Original change's description:
> [include] Split out v8.h
>
> This moves every single class/function out of include/v8.h into a
> separate header in include/, which v8.h then includes so that
> externally nothing appears to have changed.
>
> Every include of v8.h from inside v8 has been changed to a more
> fine-grained include.
>
> Previously inline functions defined at the bottom of v8.h would call
> private non-inline functions in the V8 class. Since that class is now
> in v8-initialization.h and is rarely included (as that would create
> dependency cycles), this is not possible and so those methods have been
> moved out of the V8 class into the namespace v8::api_internal.
>
> None of the previous files in include/ now #include v8.h, which means
> if embedders were relying on this transitive dependency then it will
> give compile failures.
>
> v8-inspector.h does depend on v8-scripts.h for the time being to ensure
> that Chrome continue to compile but that change will be reverted once
> those transitive #includes in chrome are changed to include it directly.
>
> Full design:
> https://docs.google.com/document/d/1rTD--I8hCAr-Rho1WTumZzFKaDpEp0IJ8ejZtk4nJdA/edit?usp=sharing
>
> Bug: v8:11965
> Change-Id: I53b84b29581632710edc80eb11f819c2097a2877
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3097448
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Reviewed-by: Camillo Bruni <cbruni@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Dan Elphick <delphick@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#76424}
Cq-Include-Trybots: luci.v8.try:v8_linux_vtunejit
Bug: v8:11965
Change-Id: I99f5d3a73bf8fe25b650adfaf9567dc4e44a09e6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3113629
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76460}
123 lines
4.3 KiB
C++
123 lines
4.3 KiB
C++
// Copyright 2016 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 TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_
|
|
#define TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "include/v8-local-handle.h"
|
|
#include "src/interpreter/bytecodes.h"
|
|
#include "src/objects/objects.h"
|
|
|
|
namespace v8 {
|
|
|
|
class Isolate;
|
|
class Script;
|
|
class Module;
|
|
|
|
namespace internal {
|
|
|
|
class BytecodeArray;
|
|
class SourcePositionTableIterator;
|
|
|
|
namespace interpreter {
|
|
|
|
class BytecodeArrayIterator;
|
|
|
|
class BytecodeExpectationsPrinter final {
|
|
public:
|
|
explicit BytecodeExpectationsPrinter(v8::Isolate* i)
|
|
: isolate_(i),
|
|
module_(false),
|
|
wrap_(true),
|
|
top_level_(false),
|
|
print_callee_(false),
|
|
test_function_name_(kDefaultTopFunctionName) {}
|
|
|
|
void PrintExpectation(std::ostream* stream, const std::string& snippet) const;
|
|
|
|
void set_module(bool module) { module_ = module; }
|
|
bool module() const { return module_; }
|
|
|
|
void set_wrap(bool wrap) { wrap_ = wrap; }
|
|
bool wrap() const { return wrap_; }
|
|
|
|
void set_top_level(bool top_level) { top_level_ = top_level; }
|
|
bool top_level() const { return top_level_; }
|
|
|
|
void set_print_callee(bool print_callee) { print_callee_ = print_callee; }
|
|
bool print_callee() { return print_callee_; }
|
|
|
|
void set_test_function_name(const std::string& test_function_name) {
|
|
test_function_name_ = test_function_name;
|
|
}
|
|
std::string test_function_name() const { return test_function_name_; }
|
|
|
|
private:
|
|
void PrintEscapedString(std::ostream* stream,
|
|
const std::string& string) const;
|
|
void PrintBytecodeOperand(std::ostream* stream,
|
|
const BytecodeArrayIterator& bytecode_iterator,
|
|
const Bytecode& bytecode, int op_index,
|
|
int parameter_count) const;
|
|
void PrintBytecode(std::ostream* stream,
|
|
const BytecodeArrayIterator& bytecode_iterator,
|
|
int parameter_count) const;
|
|
void PrintSourcePosition(std::ostream* stream,
|
|
SourcePositionTableIterator* source_iterator,
|
|
int bytecode_offset) const;
|
|
void PrintV8String(std::ostream* stream, i::String string) const;
|
|
void PrintConstant(std::ostream* stream, i::Handle<i::Object> constant) const;
|
|
void PrintFrameSize(std::ostream* stream,
|
|
i::Handle<i::BytecodeArray> bytecode_array) const;
|
|
void PrintBytecodeSequence(std::ostream* stream,
|
|
i::Handle<i::BytecodeArray> bytecode_array) const;
|
|
void PrintConstantPool(std::ostream* stream,
|
|
i::FixedArray constant_pool) const;
|
|
void PrintCodeSnippet(std::ostream* stream, const std::string& body) const;
|
|
void PrintBytecodeArray(std::ostream* stream,
|
|
i::Handle<i::BytecodeArray> bytecode_array) const;
|
|
void PrintHandlers(std::ostream* stream,
|
|
i::Handle<i::BytecodeArray> bytecode_array) const;
|
|
|
|
v8::Local<v8::String> V8StringFromUTF8(const char* data) const;
|
|
std::string WrapCodeInFunction(const char* function_name,
|
|
const std::string& function_body) const;
|
|
|
|
v8::Local<v8::Script> CompileScript(const char* program) const;
|
|
v8::Local<v8::Module> CompileModule(const char* program) const;
|
|
void Run(v8::Local<v8::Script> script) const;
|
|
i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal(
|
|
const char* global_name) const;
|
|
i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForModule(
|
|
v8::Local<v8::Module> module) const;
|
|
i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript(
|
|
v8::Local<v8::Script> script) const;
|
|
i::Handle<i::BytecodeArray> GetBytecodeArrayOfCallee(
|
|
const char* source_code) const;
|
|
|
|
i::Isolate* i_isolate() const {
|
|
return reinterpret_cast<i::Isolate*>(isolate_);
|
|
}
|
|
|
|
v8::Isolate* isolate_;
|
|
bool module_;
|
|
bool wrap_;
|
|
bool top_level_;
|
|
bool print_callee_;
|
|
std::string test_function_name_;
|
|
|
|
static const char* const kDefaultTopFunctionName;
|
|
static const char* const kIndent;
|
|
};
|
|
|
|
} // namespace interpreter
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // TEST_CCTEST_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_
|