[torque] make C++ includes explicit

Bug: v8:7793
Change-Id: I12aae5d61a21f3e6e010e07622fe0d01a5ba03eb
Reviewed-on: https://chromium-review.googlesource.com/c/1344118
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Daniel Clifford <danno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58052}
This commit is contained in:
Tobias Tebbi 2018-12-05 17:34:57 +01:00 committed by Commit Bot
parent 7de6d2c196
commit 82cf1cf2e4
17 changed files with 64 additions and 46 deletions

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-array-gen.h'
namespace array {
// Naming convention from elements.cc. We have a similar intent but implement
// fastpaths using generics instead of using a class hierarchy for elements

View File

@ -2,6 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-utils-gen.h'
#include 'src/builtins/builtins.h'
#include 'src/code-factory.h'
#include 'src/elements-kind.h'
#include 'src/heap/factory-inl.h'
#include 'src/objects.h'
#include 'src/objects/arguments.h'
#include 'src/objects/bigint.h'
type Arguments constexpr 'CodeStubArguments*';
type void;
type never;

View File

@ -17,6 +17,9 @@
namespace v8 {
namespace internal {
using compiler::Node;
template <class T>
using TNode = compiler::TNode<T>;
template <class T>
using TVariable = compiler::TypedCodeAssemblerVariable<T>;

View File

@ -10,18 +10,14 @@
namespace v8 {
namespace internal {
using compiler::Node;
template <class T>
using TNode = compiler::TNode<T>;
void BranchIfIterableWithOriginalKeyOrValueMapIterator(
compiler::CodeAssemblerState* state, TNode<Object> iterable,
TNode<Context> context, compiler::CodeAssemblerLabel* if_true,
compiler::CodeAssemblerState* state, compiler::TNode<Object> iterable,
compiler::TNode<Context> context, compiler::CodeAssemblerLabel* if_true,
compiler::CodeAssemblerLabel* if_false);
void BranchIfIterableWithOriginalValueSetIterator(
compiler::CodeAssemblerState* state, TNode<Object> iterable,
TNode<Context> context, compiler::CodeAssemblerLabel* if_true,
compiler::CodeAssemblerState* state, compiler::TNode<Object> iterable,
compiler::TNode<Context> context, compiler::CodeAssemblerLabel* if_true,
compiler::CodeAssemblerLabel* if_false);
} // namespace internal

View File

@ -1,22 +0,0 @@
// Copyright 2018 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 V8_BUILTINS_BUILTINS_TEST_GEN_H_
#define V8_BUILTINS_BUILTINS_TEST_GEN_H_
#include "src/code-stub-assembler.h"
namespace v8 {
namespace internal {
class TestBuiltinsAssembler : public CodeStubAssembler {
public:
explicit TestBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
};
} // namespace internal
} // namespace v8
#endif // V8_BUILTINS_BUILTINS_TEST_GEN_H_

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-collections-gen.h'
namespace collections {
macro LoadKeyValuePairNoSideEffects(implicit context: Context)(o: Object):
KeyValuePair

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-data-view-gen.h'
namespace data_view {
extern operator '.buffer'
macro LoadJSArrayBufferViewBuffer(JSArrayBufferView): JSArrayBuffer;

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-iterator-gen.h'
namespace iterator {
// Returned from IteratorBuiltinsAssembler::GetIterator().
struct IteratorRecord {

View File

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array {
extern runtime TypedArraySortFast(Context, Object): JSTypedArray;
extern macro TypedArrayBuiltinsAssembler::ValidateTypedArray(

View File

@ -65,7 +65,8 @@ namespace torque {
V(ExternConstDeclaration) \
V(StructDeclaration) \
V(NamespaceDeclaration) \
V(ConstDeclaration)
V(ConstDeclaration) \
V(CppIncludeDeclaration)
#define AST_CALLABLE_NODE_KIND_LIST(V) \
V(TorqueMacroDeclaration) \
@ -825,6 +826,13 @@ struct StructDeclaration : Declaration {
std::vector<NameAndTypeExpression> fields;
};
struct CppIncludeDeclaration : Declaration {
DEFINE_AST_NODE_LEAF_BOILERPLATE(CppIncludeDeclaration)
CppIncludeDeclaration(SourcePosition pos, std::string include_path)
: Declaration(kKind, pos), include_path(std::move(include_path)) {}
std::string include_path;
};
#define ENUM_ITEM(name) \
case AstNode::Kind::k##name: \
return std::is_base_of<T, name>::value; \

View File

@ -680,8 +680,8 @@ void CSAGenerator::EmitCSAValue(VisitResult result,
out << "}";
} else {
DCHECK_EQ(1, result.stack_range().Size());
out << "TNode<" << result.type()->GetGeneratedTNodeTypeName() << ">{"
<< values.Peek(result.stack_range().begin()) << "}";
out << "compiler::TNode<" << result.type()->GetGeneratedTNodeTypeName()
<< ">{" << values.Peek(result.stack_range().begin()) << "}";
}
}

View File

@ -20,6 +20,7 @@ namespace internal {
namespace torque {
class Scope;
class Namespace;
DECLARE_CONTEXTUAL_VARIABLE(CurrentScope, Scope*);

View File

@ -237,6 +237,10 @@ void DeclarationVisitor::Visit(StructDeclaration* decl) {
Declarations::DeclareStruct(decl->name, fields);
}
void DeclarationVisitor::Visit(CppIncludeDeclaration* decl) {
GlobalContext::AddCppInclude(decl->include_path);
}
void DeclarationVisitor::Visit(TypeDeclaration* decl) {
std::string generates = decl->generates ? *decl->generates : std::string("");
if (decl->generates) {

View File

@ -81,6 +81,7 @@ class DeclarationVisitor : public FileVisitor {
void Visit(SpecializationDeclaration* decl);
void Visit(ExternConstDeclaration* decl);
void Visit(StructDeclaration* decl);
void Visit(CppIncludeDeclaration* decl);
Signature MakeSpecializedSignature(const SpecializationKey& key);
Callable* SpecializeImplicit(const SpecializationKey& key);

View File

@ -44,6 +44,13 @@ class GlobalContext : public ContextualClass<GlobalContext> {
return result;
}
static void AddCppInclude(std::string include_path) {
Get().cpp_includes_.push_back(std::move(include_path));
}
static const std::vector<std::string>& CppIncludes() {
return Get().cpp_includes_;
}
static void SetVerbose() { Get().verbose_ = true; }
static bool verbose() { return Get().verbose_; }
static Ast* ast() { return &Get().ast_; }
@ -53,6 +60,7 @@ class GlobalContext : public ContextualClass<GlobalContext> {
Namespace* default_namespace_;
Ast ast_;
std::vector<std::unique_ptr<Declarable>> declarables_;
std::vector<std::string> cpp_includes_;
};
template <class T>

View File

@ -49,22 +49,13 @@ void ImplementationVisitor::BeginNamespaceFile(Namespace* nspace) {
std::ostream& source = nspace->source_stream();
std::ostream& header = nspace->header_stream();
source << "#include \"src/objects/arguments.h\"\n";
source << "#include \"src/builtins/builtins-utils-gen.h\"\n";
source << "#include \"src/builtins/builtins.h\"\n";
source << "#include \"src/code-factory.h\"\n";
source << "#include \"src/elements-kind.h\"\n";
source << "#include \"src/heap/factory-inl.h\"\n";
source << "#include \"src/objects.h\"\n";
source << "#include \"src/objects/bigint.h\"\n";
for (const std::string& include_path : GlobalContext::CppIncludes()) {
source << "#include " << StringLiteralQuote(include_path) << "\n";
}
for (Namespace* n : GlobalContext::Get().GetNamespaces()) {
source << "#include \"torque-generated/builtins-" +
DashifyString(n->name()) + "-from-dsl-gen.h\"\n";
if (n != GlobalContext::GetDefaultNamespace()) {
source << "#include \"src/builtins/builtins-" + DashifyString(n->name()) +
"-gen.h\"\n";
}
}
source << "\n";

View File

@ -553,6 +553,14 @@ base::Optional<ParseResult> MakeStructDeclaration(
return ParseResult{result};
}
base::Optional<ParseResult> MakeCppIncludeDeclaration(
ParseResultIterator* child_results) {
auto include_path = child_results->NextAs<std::string>();
Declaration* result =
MakeNode<CppIncludeDeclaration>(std::move(include_path));
return ParseResult{result};
}
base::Optional<ParseResult> MakeExternalBuiltin(
ParseResultIterator* child_results) {
auto transitioning = child_results->NextAs<bool>();
@ -1524,7 +1532,8 @@ struct TorqueGrammar : Grammar {
Rule({Token("struct"), &identifier, Token("{"),
List<NameAndTypeExpression>(Sequence({&nameAndType, Token(";")})),
Token("}")},
MakeStructDeclaration)};
MakeStructDeclaration),
Rule({Token("#include"), &externalString}, MakeCppIncludeDeclaration)};
// Result: Declaration*
Symbol namespaceDeclaration = {