summaryrefslogtreecommitdiff
path: root/deps/v8/src/torque/class-debug-reader-generator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/torque/class-debug-reader-generator.cc')
-rw-r--r--deps/v8/src/torque/class-debug-reader-generator.cc54
1 files changed, 38 insertions, 16 deletions
diff --git a/deps/v8/src/torque/class-debug-reader-generator.cc b/deps/v8/src/torque/class-debug-reader-generator.cc
index 6abdffcc91..fca2409959 100644
--- a/deps/v8/src/torque/class-debug-reader-generator.cc
+++ b/deps/v8/src/torque/class-debug-reader-generator.cc
@@ -10,12 +10,20 @@ namespace v8 {
namespace internal {
namespace torque {
+const char* tq_object_override_decls =
+ R"( std::vector<std::unique_ptr<ObjectProperty>> GetProperties(
+ d::MemoryAccessor accessor) const override;
+ const char* GetName() const override;
+ void Visit(TqObjectVisitor* visitor) const override;
+ bool IsSuperclassOf(const TqObject* other) const override;
+)";
+
namespace {
void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
std::ostream& cc_contents, std::ostream& visitor,
std::unordered_set<const ClassType*>* done) {
// Make sure each class only gets generated once.
- if (!type.IsExtern() || !done->insert(&type).second) return;
+ if (!done->insert(&type).second) return;
const ClassType* super_type = type.GetSuperClass();
// We must emit the classes in dependency order. If the super class hasn't
@@ -25,6 +33,10 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
done);
}
+ // Classes with undefined layout don't grant any particular value here and may
+ // not correspond with actual C++ classes, so skip them.
+ if (type.HasUndefinedLayout()) return;
+
const std::string name = type.name();
const std::string super_name =
super_type == nullptr ? "Object" : super_type->name();
@@ -32,10 +44,7 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
h_contents << " public:\n";
h_contents << " inline Tq" << name << "(uintptr_t address) : Tq"
<< super_name << "(address) {}\n";
- h_contents << " std::vector<std::unique_ptr<ObjectProperty>> "
- "GetProperties(d::MemoryAccessor accessor) const override;\n";
- h_contents << " const char* GetName() const override;\n";
- h_contents << " void Visit(TqObjectVisitor* visitor) const override;\n";
+ h_contents << tq_object_override_decls;
cc_contents << "\nconst char* Tq" << name << "::GetName() const {\n";
cc_contents << " return \"v8::internal::" << name << "\";\n";
@@ -46,6 +55,13 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
cc_contents << " visitor->Visit" << name << "(this);\n";
cc_contents << "}\n";
+ cc_contents << "\nbool Tq" << name
+ << "::IsSuperclassOf(const TqObject* other) const {\n";
+ cc_contents
+ << " return GetName() != other->GetName() && dynamic_cast<const Tq"
+ << name << "*>(other) != nullptr;\n";
+ cc_contents << "}\n";
+
visitor << " virtual void Visit" << name << "(const Tq" << name
<< "* object) {\n";
visitor << " Visit" << super_name << "(object);\n";
@@ -71,9 +87,10 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
if (is_field_tagged) {
field_value_type = "uintptr_t";
field_value_type_compressed = "i::Tagged_t";
- field_cc_type = "v8::internal::" + (field_class_type.has_value()
- ? (*field_class_type)->name()
- : "Object");
+ field_cc_type = "v8::internal::" +
+ (field_class_type.has_value()
+ ? (*field_class_type)->GetGeneratedTNodeTypeName()
+ : "Object");
field_cc_type_compressed =
COMPRESS_POINTERS_BOOL ? "v8::internal::TaggedValue" : field_cc_type;
} else {
@@ -107,7 +124,7 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
std::string index_param;
std::string index_offset;
if (field.index) {
- const Type* index_type = (*field.index)->name_and_type.type;
+ const Type* index_type = field.index->type;
std::string index_type_name;
std::string index_value;
if (index_type == TypeOracle::GetSmiType()) {
@@ -129,18 +146,17 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
}
get_props_impl << " Value<" << index_type_name
<< "> indexed_field_count = Get"
- << CamelifyString((*field.index)->name_and_type.name)
+ << CamelifyString(field.index->name)
<< "Value(accessor);\n";
indexed_field_info =
", " + index_value + ", GetArrayKind(indexed_field_count.validity)";
index_param = ", size_t offset";
index_offset = " + offset * sizeof(value)";
}
- get_props_impl
- << " result.push_back(v8::base::make_unique<ObjectProperty>(\""
- << field_name << "\", \"" << field_cc_type_compressed << "\", \""
- << field_cc_type << "\", " << address_getter << "()"
- << indexed_field_info << "));\n";
+ get_props_impl << " result.push_back(std::make_unique<ObjectProperty>(\""
+ << field_name << "\", \"" << field_cc_type_compressed
+ << "\", \"" << field_cc_type << "\", " << address_getter
+ << "()" << indexed_field_info << "));\n";
h_contents << " uintptr_t " << address_getter << "() const;\n";
h_contents << " Value<" << field_value_type << "> " << field_getter
@@ -158,7 +174,8 @@ void GenerateClassDebugReader(const ClassType& type, std::ostream& h_contents,
<< address_getter << "()" << index_offset
<< ", reinterpret_cast<uint8_t*>(&value), sizeof(value));\n";
cc_contents << " return {validity, "
- << (is_field_tagged ? "Decompress(value, address_)" : "value")
+ << (is_field_tagged ? "EnsureDecompressed(value, address_)"
+ : "value")
<< "};\n";
cc_contents << "}\n";
}
@@ -192,6 +209,11 @@ void ImplementationVisitor::GenerateClassDebugReaders(
h_contents
<< "\n#include \"tools/debug_helper/debug-helper-internal.h\"\n\n";
+ h_contents << "// Unset a windgi.h macro that causes conflicts.\n";
+ h_contents << "#ifdef GetBValue\n";
+ h_contents << "#undef GetBValue\n";
+ h_contents << "#endif\n\n";
+
cc_contents << "#include \"torque-generated/" << file_name << ".h\"\n";
cc_contents << "#include \"include/v8-internal.h\"\n\n";
cc_contents << "namespace i = v8::internal;\n\n";