[torque] Remove objects.h include from class-verifiers

and replace it with forward declarations of all occuring classes.

R=tebbi@chromium.org

Bug: v8:7793
Change-Id: I337b069ef10d52e7e42332c977284b4d2ae8fafb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1609836
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61479}
diff --git a/src/torque/implementation-visitor.cc b/src/torque/implementation-visitor.cc
index 26d2842..c235dd2 100644
--- a/src/torque/implementation-visitor.cc
+++ b/src/torque/implementation-visitor.cc
@@ -3050,7 +3050,7 @@
   h_contents << enabled_check;
   cc_contents << enabled_check;
 
-  h_contents << "\n#include \"src/objects.h\"\n";
+  cc_contents << "\n#include \"src/objects.h\"\n";
 
   for (const std::string& include_path : GlobalContext::CppIncludes()) {
     cc_contents << "#include " << StringLiteralQuote(include_path) << "\n";
@@ -3067,9 +3067,17 @@
   h_contents << namespaces;
   cc_contents << namespaces;
 
+  // Generate forward declarations to avoid including any headers.
+  h_contents << "class Isolate;\n";
+  for (auto i : GlobalContext::GetClasses()) {
+    ClassType* type = i.second;
+    if (!type->IsExtern() || !type->ShouldGenerateVerify()) continue;
+    h_contents << "class " << type->name() << ";\n";
+  }
+
   const char* verifier_class = "ClassVerifiersFromDSL";
 
-  h_contents << "class " << verifier_class << "{\n";
+  h_contents << "class " << verifier_class << " {\n";
   h_contents << " public:\n";
 
   for (auto i : GlobalContext::GetClasses()) {