[ubsan] Port Struct subclasses, part 4

AsyncGeneratorRequest, DataHandler, LoadHandler, StoreHandler

Bug: v8:3770
Change-Id: I71198f9af116d2ca37bbe47131ae73b6ae643e01
Reviewed-on: https://chromium-review.googlesource.com/c/1377457
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58259}
diff --git a/src/heap/objects-visiting.h b/src/heap/objects-visiting.h
index 42bcb9b..c08a349 100644
--- a/src/heap/objects-visiting.h
+++ b/src/heap/objects-visiting.h
@@ -42,7 +42,7 @@
   V(CodeDataContainer, CodeDataContainer)                                     \
   V(ConsString, ConsString)                                                   \
   V(Context, Context)                                                         \
-  V(DataHandler, DataHandler*)                                                \
+  V(DataHandler, DataHandler)                                                 \
   V(DescriptorArray, DescriptorArray)                                         \
   V(EmbedderDataArray, EmbedderDataArray)                                     \
   V(EphemeronHashTable, EphemeronHashTable)                                   \
diff --git a/src/ic/handler-configuration-inl.h b/src/ic/handler-configuration-inl.h
index 6b7013c..4cecd22 100644
--- a/src/ic/handler-configuration-inl.h
+++ b/src/ic/handler-configuration-inl.h
@@ -10,6 +10,7 @@
 #include "src/field-index-inl.h"
 #include "src/handles-inl.h"
 #include "src/objects-inl.h"
+#include "src/objects/data-handler-inl.h"
 #include "src/objects/smi.h"
 
 // Has to be the last include (doesn't have include guards):
@@ -18,7 +19,9 @@
 namespace v8 {
 namespace internal {
 
-CAST_ACCESSOR(LoadHandler)
+OBJECT_CONSTRUCTORS_IMPL(LoadHandler, DataHandler)
+
+CAST_ACCESSOR2(LoadHandler)
 
 // Decodes kind from Smi-handler.
 LoadHandler::Kind LoadHandler::GetHandlerKind(Smi smi_handler) {
@@ -110,7 +113,9 @@
   return handle(Smi::FromInt(config), isolate);
 }
 
-CAST_ACCESSOR(StoreHandler)
+OBJECT_CONSTRUCTORS_IMPL(StoreHandler, DataHandler)
+
+CAST_ACCESSOR2(StoreHandler)
 
 Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
   int config = KindBits::encode(kGlobalProxy);
diff --git a/src/ic/handler-configuration.h b/src/ic/handler-configuration.h
index edc02f0..a747651 100644
--- a/src/ic/handler-configuration.h
+++ b/src/ic/handler-configuration.h
@@ -26,7 +26,7 @@
 // TODO(ishell): move to load-handler.h
 class LoadHandler final : public DataHandler {
  public:
-  DECL_CAST(LoadHandler)
+  DECL_CAST2(LoadHandler)
 
   DECL_PRINTER(LoadHandler)
   DECL_VERIFIER(LoadHandler)
@@ -179,6 +179,8 @@
 
   // Decodes the KeyedAccessLoadMode from a {handler}.
   static KeyedAccessLoadMode GetKeyedAccessLoadMode(MaybeObject handler);
+
+  OBJECT_CONSTRUCTORS(LoadHandler, DataHandler)
 };
 
 // A set of bit fields representing Smi handlers for stores and a HeapObject
@@ -186,7 +188,7 @@
 // TODO(ishell): move to store-handler.h
 class StoreHandler final : public DataHandler {
  public:
-  DECL_CAST(StoreHandler)
+  DECL_CAST2(StoreHandler)
 
   DECL_PRINTER(StoreHandler)
   DECL_VERIFIER(StoreHandler)
@@ -298,6 +300,8 @@
   static inline Handle<Smi> StoreField(Isolate* isolate, Kind kind,
                                        int descriptor, FieldIndex field_index,
                                        Representation representation);
+
+  OBJECT_CONSTRUCTORS(StoreHandler, DataHandler)
 };
 
 }  // namespace internal
diff --git a/src/objects-inl.h b/src/objects-inl.h
index b5b99b9..adbfc8a 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -383,6 +383,9 @@
     // special cases.
     case ALLOCATION_SITE_TYPE:
       return true;
+    case LOAD_HANDLER_TYPE:
+    case STORE_HANDLER_TYPE:
+      return true;
     default:
       return false;
   }
@@ -455,7 +458,6 @@
 CAST_ACCESSOR2(BigInt)
 CAST_ACCESSOR2(ObjectBoilerplateDescription)
 CAST_ACCESSOR(Cell)
-CAST_ACCESSOR(DataHandler)
 CAST_ACCESSOR2(EphemeronHashTable)
 CAST_ACCESSOR(EnumCache)
 CAST_ACCESSOR(Foreign)
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index f190241..f410c9a 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -1658,7 +1658,7 @@
 
 void AsyncGeneratorRequest::AsyncGeneratorRequestPrint(
     std::ostream& os) {  // NOLINT
-  HeapObject::PrintHeader(os, "AsyncGeneratorRequest");
+  PrintHeader(os, "AsyncGeneratorRequest");
   const char* mode = "Invalid!";
   switch (resume_mode()) {
     case JSGeneratorObject::kNext:
@@ -1837,7 +1837,7 @@
 }
 
 void LoadHandler::LoadHandlerPrint(std::ostream& os) {  // NOLINT
-  HeapObject::PrintHeader(os, "LoadHandler");
+  PrintHeader(os, "LoadHandler");
   // TODO(ishell): implement printing based on handler kind
   os << "\n - handler: " << Brief(smi_handler());
   os << "\n - validity_cell: " << Brief(validity_cell());
@@ -1855,7 +1855,7 @@
 }
 
 void StoreHandler::StoreHandlerPrint(std::ostream& os) {  // NOLINT
-  HeapObject::PrintHeader(os, "StoreHandler");
+  PrintHeader(os, "StoreHandler");
   // TODO(ishell): implement printing based on handler kind
   os << "\n - handler: " << Brief(smi_handler());
   os << "\n - validity_cell: " << Brief(validity_cell());
diff --git a/src/objects/data-handler-inl.h b/src/objects/data-handler-inl.h
index aaec9d3..b6b0d13 100644
--- a/src/objects/data-handler-inl.h
+++ b/src/objects/data-handler-inl.h
@@ -14,6 +14,10 @@
 namespace v8 {
 namespace internal {
 
+OBJECT_CONSTRUCTORS_IMPL(DataHandler, StructPtr)
+
+CAST_ACCESSOR2(DataHandler)
+
 ACCESSORS(DataHandler, smi_handler, Object, kSmiHandlerOffset)
 ACCESSORS(DataHandler, validity_cell, Object, kValidityCellOffset)
 
diff --git a/src/objects/data-handler.h b/src/objects/data-handler.h
index 8f50957..874a17f 100644
--- a/src/objects/data-handler.h
+++ b/src/objects/data-handler.h
@@ -15,7 +15,7 @@
 
 // DataHandler is a base class for load and store handlers that can't be
 // encoded in one Smi. Kind of a handler can be deduced from instance type.
-class DataHandler : public Struct {
+class DataHandler : public StructPtr {
  public:
   // [smi_handler]: A Smi which encodes a handler or Code object (we still
   // use code handlers for accessing lexical environment variables, but soon
@@ -50,11 +50,13 @@
   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, DATA_HANDLER_FIELDS)
 #undef DATA_HANDLER_FIELDS
 
-  DECL_CAST(DataHandler)
+  DECL_CAST2(DataHandler)
 
   DECL_VERIFIER(DataHandler)
 
   class BodyDescriptor;
+
+  OBJECT_CONSTRUCTORS(DataHandler, StructPtr)
 };
 
 }  // namespace internal
diff --git a/src/objects/js-generator-inl.h b/src/objects/js-generator-inl.h
index 9cc5760..e23e373 100644
--- a/src/objects/js-generator-inl.h
+++ b/src/objects/js-generator-inl.h
@@ -19,11 +19,12 @@
 OBJECT_CONSTRUCTORS_IMPL(JSGeneratorObject, JSObject)
 OBJECT_CONSTRUCTORS_IMPL(JSAsyncFunctionObject, JSGeneratorObject)
 OBJECT_CONSTRUCTORS_IMPL(JSAsyncGeneratorObject, JSGeneratorObject)
+OBJECT_CONSTRUCTORS_IMPL(AsyncGeneratorRequest, StructPtr)
 
 CAST_ACCESSOR2(JSAsyncFunctionObject)
 CAST_ACCESSOR2(JSAsyncGeneratorObject)
 CAST_ACCESSOR2(JSGeneratorObject)
-CAST_ACCESSOR(AsyncGeneratorRequest)
+CAST_ACCESSOR2(AsyncGeneratorRequest)
 
 ACCESSORS2(JSGeneratorObject, function, JSFunction, kFunctionOffset)
 ACCESSORS2(JSGeneratorObject, context, Context, kContextOffset)
diff --git a/src/objects/js-generator.h b/src/objects/js-generator.h
index 7267793..1d7f99b 100644
--- a/src/objects/js-generator.h
+++ b/src/objects/js-generator.h
@@ -138,7 +138,7 @@
   OBJECT_CONSTRUCTORS(JSAsyncGeneratorObject, JSGeneratorObject);
 };
 
-class AsyncGeneratorRequest : public Struct {
+class AsyncGeneratorRequest : public StructPtr {
  public:
   // Holds an AsyncGeneratorRequest, or Undefined.
   DECL_ACCESSORS(next, Object)
@@ -159,12 +159,11 @@
                                 ASYNC_GENERATOR_REQUEST_FIELDS)
 #undef ASYNC_GENERATOR_REQUEST_FIELDS
 
-  DECL_CAST(AsyncGeneratorRequest)
+  DECL_CAST2(AsyncGeneratorRequest)
   DECL_PRINTER(AsyncGeneratorRequest)
   DECL_VERIFIER(AsyncGeneratorRequest)
 
- private:
-  DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncGeneratorRequest);
+  OBJECT_CONSTRUCTORS(AsyncGeneratorRequest, StructPtr);
 };
 
 }  // namespace internal