[torque] put exported classes into a separate header
Bug: v8:7793 TBR: danno@chromium.org Change-Id: If6b1229af2b282bd24bf222b2a06a45cc640c557 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190750 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#67691}
This commit is contained in:
parent
9c546d8fe0
commit
daa6da4e23
2
BUILD.gn
2
BUILD.gn
@ -1223,6 +1223,8 @@ template("run_torque") {
|
||||
"instance-types-tq.h",
|
||||
"internal-class-definitions-tq.h",
|
||||
"internal-class-definitions-tq-inl.h",
|
||||
"exported-class-definitions-tq.h",
|
||||
"exported-class-definitions-tq-inl.h",
|
||||
]
|
||||
|
||||
outputs = []
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include "src/utils/ostreams.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "torque-generated/class-verifiers-tq.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
#include "torque-generated/internal-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "torque-generated/class-definitions-tq-inl.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
#include "torque-generated/internal-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "src/regexp/regexp.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "torque-generated/class-definitions-tq.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
#include "torque-generated/internal-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -5,8 +5,6 @@
|
||||
#ifndef V8_OBJECTS_OBJECTS_BODY_DESCRIPTORS_INL_H_
|
||||
#define V8_OBJECTS_OBJECTS_BODY_DESCRIPTORS_INL_H_
|
||||
|
||||
#include "src/objects/objects-body-descriptors.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/codegen/reloc-info.h"
|
||||
@ -17,14 +15,15 @@
|
||||
#include "src/objects/hash-table.h"
|
||||
#include "src/objects/js-collection.h"
|
||||
#include "src/objects/js-weak-refs.h"
|
||||
#include "src/objects/objects-body-descriptors.h"
|
||||
#include "src/objects/oddball.h"
|
||||
#include "src/objects/ordered-hash-table-inl.h"
|
||||
#include "src/objects/source-text-module.h"
|
||||
#include "src/objects/synthetic-module.h"
|
||||
#include "src/objects/transitions.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
|
||||
#include "torque-generated/class-definitions-tq-inl.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
#include "torque-generated/internal-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -123,8 +123,8 @@
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
#include "torque-generated/class-definitions-tq-inl.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
#include "torque-generated/internal-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -3857,6 +3857,7 @@ void EmitClassDefinitionHeadersIncludes(const std::string& basename,
|
||||
std::stringstream& header,
|
||||
std::stringstream& inline_header) {
|
||||
header << "#include \"src/objects/objects.h\"\n";
|
||||
header << "#include \"src/objects/heap-object.h\"\n";
|
||||
header << "#include \"src/objects/smi.h\"\n";
|
||||
header << "#include \"torque-generated/field-offsets-tq.h\"\n";
|
||||
header << "#include <type_traits>\n\n";
|
||||
@ -3900,14 +3901,19 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
std::stringstream inline_external_header;
|
||||
std::stringstream internal_header;
|
||||
std::stringstream inline_internal_header;
|
||||
std::stringstream exported_header;
|
||||
std::stringstream inline_exported_header;
|
||||
std::stringstream implementation;
|
||||
std::stringstream factory_header;
|
||||
std::stringstream factory_impl;
|
||||
std::string basename = "class-definitions-tq";
|
||||
std::string internal_basename = "internal-" + basename;
|
||||
std::string exported_basename = "exported-" + basename;
|
||||
std::string file_basename = output_directory + "/" + basename;
|
||||
std::string internal_file_basename =
|
||||
output_directory + "/" + internal_basename;
|
||||
std::string exported_file_basename =
|
||||
output_directory + "/" + exported_basename;
|
||||
std::string factory_basename = "factory-tq";
|
||||
std::string factory_file_basename = output_directory + "/" + factory_basename;
|
||||
|
||||
@ -3923,6 +3929,12 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
IncludeGuardScope internal_inline_header_guard(
|
||||
inline_internal_header, internal_basename + "-inl.h");
|
||||
|
||||
IncludeGuardScope exported_header_guard(exported_header,
|
||||
exported_basename + ".h");
|
||||
|
||||
IncludeGuardScope exported_inline_header_guard(
|
||||
inline_exported_header, exported_basename + "-inl.h");
|
||||
|
||||
internal_header << "#include \"torque-generated/class-definitions-tq.h\"\n";
|
||||
internal_header << "#include \"src/objects/fixed-array.h\"\n";
|
||||
inline_internal_header
|
||||
@ -3930,6 +3942,12 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
inline_internal_header
|
||||
<< "#include \"torque-generated/class-definitions-tq-inl.h\"\n";
|
||||
|
||||
exported_header << "#include \"src/objects/fixed-array.h\"\n";
|
||||
exported_header << "#include \"torque-generated/class-definitions-tq.h\"\n";
|
||||
inline_exported_header
|
||||
<< "#include \"torque-generated/exported-class-definitions-tq.h\"\n";
|
||||
inline_exported_header << "#include \"src/objects/fixed-array-inl.h\"\n";
|
||||
|
||||
EmitClassDefinitionHeadersIncludes(basename, external_header,
|
||||
inline_external_header);
|
||||
|
||||
@ -3943,6 +3961,10 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
IncludeObjectMacrosScope internal_inline_header_macros(
|
||||
inline_internal_header);
|
||||
|
||||
IncludeObjectMacrosScope exported_header_macros(exported_header);
|
||||
IncludeObjectMacrosScope exported_inline_header_macros(
|
||||
inline_exported_header);
|
||||
|
||||
NamespaceScope header_namespaces(external_header, {"v8", "internal"});
|
||||
NamespaceScope inline_header_namespaces(inline_external_header,
|
||||
{"v8", "internal"});
|
||||
@ -3950,6 +3972,10 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
{"v8", "internal"});
|
||||
NamespaceScope internal_inline_header_namespaces(inline_internal_header,
|
||||
{"v8", "internal"});
|
||||
NamespaceScope exported_header_namespaces(exported_header,
|
||||
{"v8", "internal"});
|
||||
NamespaceScope exported_inline_header_namespaces(inline_exported_header,
|
||||
{"v8", "internal"});
|
||||
|
||||
EmitClassDefinitionHeadersForwardDeclarations(external_header);
|
||||
EmitClassDefinitionHeadersForwardDeclarations(internal_header);
|
||||
@ -3962,6 +3988,9 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
factory_impl
|
||||
<< "#include "
|
||||
"\"torque-generated/internal-class-definitions-tq-inl.h\"\n\n";
|
||||
factory_impl
|
||||
<< "#include "
|
||||
"\"torque-generated/exported-class-definitions-tq-inl.h\"\n\n";
|
||||
NamespaceScope factory_impl_namespaces(factory_impl, {"v8", "internal"});
|
||||
factory_impl << "\n";
|
||||
|
||||
@ -3989,18 +4018,23 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
implementation
|
||||
<< "#include "
|
||||
"\"torque-generated/internal-class-definitions-tq-inl.h\"\n\n";
|
||||
implementation
|
||||
<< "#include "
|
||||
"\"torque-generated/exported-class-definitions-tq-inl.h\"\n\n";
|
||||
NamespaceScope implementation_namespaces(implementation,
|
||||
{"v8", "internal"});
|
||||
|
||||
std::set<const StructType*, TypeLess> structs_used_in_classes;
|
||||
|
||||
for (const ClassType* type : TypeOracle::GetClasses()) {
|
||||
std::stringstream& header = (type->IsExtern() || type->ShouldExport())
|
||||
? external_header
|
||||
: internal_header;
|
||||
std::stringstream& header =
|
||||
type->IsExtern()
|
||||
? external_header
|
||||
: type->ShouldExport() ? exported_header : internal_header;
|
||||
std::stringstream& inline_header =
|
||||
(type->IsExtern() || type->ShouldExport()) ? inline_external_header
|
||||
: inline_internal_header;
|
||||
type->IsExtern() ? inline_external_header
|
||||
: type->ShouldExport() ? inline_exported_header
|
||||
: inline_internal_header;
|
||||
|
||||
if (type->GenerateCppClassDefinitions()) {
|
||||
CppClassGenerator g(type, header, inline_header, implementation);
|
||||
@ -4096,6 +4130,8 @@ void ImplementationVisitor::GenerateClassDefinitions(
|
||||
WriteFile(file_basename + ".cc", implementation.str());
|
||||
WriteFile(internal_file_basename + ".h", internal_header.str());
|
||||
WriteFile(internal_file_basename + "-inl.h", inline_internal_header.str());
|
||||
WriteFile(exported_file_basename + ".h", exported_header.str());
|
||||
WriteFile(exported_file_basename + "-inl.h", inline_exported_header.str());
|
||||
WriteFile(factory_file_basename + ".inc", factory_header.str());
|
||||
WriteFile(factory_file_basename + ".cc", factory_impl.str());
|
||||
}
|
||||
@ -4147,6 +4183,8 @@ void ImplementationVisitor::GeneratePrintDefinitions(
|
||||
impl << "#include <iosfwd>\n\n";
|
||||
impl << "#include "
|
||||
"\"torque-generated/internal-class-definitions-tq-inl.h\"\n";
|
||||
impl << "#include "
|
||||
"\"torque-generated/exported-class-definitions-tq-inl.h\"\n";
|
||||
impl << "#include \"src/objects/struct-inl.h\"\n\n";
|
||||
impl << "#include \"src/objects/template-objects-inl.h\"\n\n";
|
||||
|
||||
@ -4470,6 +4508,8 @@ void ImplementationVisitor::GenerateClassVerifiers(
|
||||
cc_contents << "#include \"torque-generated/" << file_name << ".h\"\n";
|
||||
cc_contents << "#include "
|
||||
"\"torque-generated/internal-class-definitions-tq-inl.h\"\n";
|
||||
cc_contents << "#include "
|
||||
"\"torque-generated/exported-class-definitions-tq-inl.h\"\n";
|
||||
|
||||
IncludeObjectMacrosScope object_macros(cc_contents);
|
||||
|
||||
@ -4582,6 +4622,8 @@ void ImplementationVisitor::GenerateExportedMacrosAssembler(
|
||||
h_contents << "#include \"torque-generated/csa-types-tq.h\"\n";
|
||||
h_contents
|
||||
<< "#include \"torque-generated/internal-class-definitions-tq.h\"\n";
|
||||
h_contents
|
||||
<< "#include \"torque-generated/exported-class-definitions-tq.h\"\n";
|
||||
cc_contents << "#include \"src/objects/fixed-array-inl.h\"\n";
|
||||
cc_contents << "#include \"src/objects/free-space.h\"\n";
|
||||
cc_contents << "#include \"src/objects/js-regexp-string-iterator.h\"\n";
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "src/strings/char-predicates.h"
|
||||
#include "test/cctest/compiler/code-assembler-tester.h"
|
||||
#include "test/cctest/compiler/function-tester.h"
|
||||
#include "torque-generated/exported-class-definitions-tq-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
Loading…
Reference in New Issue
Block a user