Commit a5811358 authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[cleanup][torque] Use @generateCppClass in some simple cases, part 2

This patch is mostly mechanical. A few changes in
implementation-visitor.cc might be worth mentioning:
- Don't generate both field offset macros and class definitions for the
  same class. This was mostly just to keep me from forgetting to remove
  the DEFINE_FIELD_OFFSET_CONSTANTS part when converting classes, but
  also helpfully flagged that FixedArrayBase wasn't using the generated
  class that it requested.
- Generate forward declarations for all tq-defined classes in
  internal-class-definitions-tq.h. This is helpful for making things
  compile when classes have fields of other class types.
- When generating accessors for union types, use the nearest class type
  that contains the entire union rather than plain Object. This is
  important for compile-time type safety. It also required a few minor
  fixes elsewhere (isolate.cc, modules.cc, scope-info.cc,
  source-text-module.cc, and a correction of the field types in
  CallHandlerInfo to match how they're set in api.cc).

Change-Id: I3b9280e30779ce57fb9f3629eecfec898e26d708
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1774976Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#63458}
parent 213504b9
......@@ -84,10 +84,11 @@ void SourceTextModuleDescriptor::AddStarExport(
}
namespace {
Handle<Object> ToStringOrUndefined(Isolate* isolate, const AstRawString* s) {
Handle<HeapObject> ToStringOrUndefined(Isolate* isolate,
const AstRawString* s) {
return (s == nullptr)
? Handle<Object>::cast(isolate->factory()->undefined_value())
: Handle<Object>::cast(s->string());
? Handle<HeapObject>::cast(isolate->factory()->undefined_value())
: Handle<HeapObject>::cast(s->string());
}
} // namespace
......
This diff is collapsed.
......@@ -467,7 +467,7 @@ TNode<JSReceiver> CallOrConstructBuiltinsAssembler::GetCompatibleReceiver(
GotoIfNot(IsFunctionTemplateInfoMap(LoadMap(current)), &holder_next);
TNode<HeapObject> current_rare = LoadObjectField<HeapObject>(
current, FunctionTemplateInfo::kFunctionTemplateRareDataOffset);
current, FunctionTemplateInfo::kRareDataOffset);
GotoIf(IsUndefined(current_rare), &holder_next);
var_template = LoadObjectField<HeapObject>(
current_rare, FunctionTemplateRareData::kParentTemplateOffset);
......
......@@ -696,8 +696,6 @@ void Map::DictionaryMapVerify(Isolate* isolate) {
CHECK_EQ(Map::GetVisitorId(*this), visitor_id());
}
USE_TORQUE_VERIFIER(AliasedArgumentsEntry)
void EmbedderDataArray::EmbedderDataArrayVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::EmbedderDataArrayVerify(*this, isolate);
EmbedderDataSlot start(*this, 0);
......@@ -911,8 +909,6 @@ void SloppyArgumentsElements::SloppyArgumentsElementsVerify(Isolate* isolate,
CHECK_LE(maxMappedIndex, arg_elements.length());
}
USE_TORQUE_VERIFIER(JSGeneratorObject)
void JSAsyncFunctionObject::JSAsyncFunctionObjectVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSAsyncFunctionObjectVerify(*this, isolate);
promise().HeapObjectVerify(isolate);
......@@ -1137,8 +1133,6 @@ void Oddball::OddballVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(Cell)
USE_TORQUE_VERIFIER(PropertyCell)
void CodeDataContainer::CodeDataContainerVerify(Isolate* isolate) {
......@@ -1213,8 +1207,6 @@ void JSArray::JSArrayVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(JSCollection)
void JSSet::JSSetVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSSetVerify(*this, isolate);
CHECK(table().IsOrderedHashSet() || table().IsUndefined(isolate));
......@@ -1227,8 +1219,6 @@ void JSMap::JSMapVerify(Isolate* isolate) {
// TODO(arv): Verify OrderedHashTable too.
}
USE_TORQUE_VERIFIER(JSCollectionIterator)
void JSSetIterator::JSSetIteratorVerify(Isolate* isolate) {
CHECK(IsJSSetIterator());
JSCollectionIteratorVerify(isolate);
......@@ -1326,36 +1316,16 @@ void JSStringIterator::JSStringIteratorVerify(Isolate* isolate) {
CHECK_LE(index(), String::kMaxLength);
}
USE_TORQUE_VERIFIER(JSAsyncFromSyncIterator)
USE_TORQUE_VERIFIER(JSWeakCollection)
void JSWeakSet::JSWeakSetVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSWeakSetVerify(*this, isolate);
CHECK(table().IsEphemeronHashTable() || table().IsUndefined(isolate));
}
USE_TORQUE_VERIFIER(Microtask)
void CallableTask::CallableTaskVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::CallableTaskVerify(*this, isolate);
CHECK(callable().IsCallable());
}
USE_TORQUE_VERIFIER(CallbackTask)
USE_TORQUE_VERIFIER(PromiseReactionJobTask)
USE_TORQUE_VERIFIER(PromiseFulfillReactionJobTask)
USE_TORQUE_VERIFIER(PromiseRejectReactionJobTask)
USE_TORQUE_VERIFIER(PromiseResolveThenableJobTask)
USE_TORQUE_VERIFIER(PromiseCapability)
USE_TORQUE_VERIFIER(PromiseReaction)
void JSPromise::JSPromiseVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSPromiseVerify(*this, isolate);
if (status() == Promise::kPending) {
......@@ -1489,8 +1459,6 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(JSRegExpStringIterator)
void JSProxy::JSProxyVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSProxyVerify(*this, isolate);
CHECK(map().GetConstructor().IsJSFunction());
......@@ -1548,8 +1516,6 @@ void BigInt::BigIntVerify(Isolate* isolate) {
CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n.
}
USE_TORQUE_VERIFIER(JSModuleNamespace)
void SourceTextModuleInfoEntry::SourceTextModuleInfoEntryVerify(
Isolate* isolate) {
TorqueGeneratedClassVerifiers::SourceTextModuleInfoEntryVerify(*this,
......@@ -1634,8 +1600,6 @@ void PrototypeUsers::Verify(WeakArrayList array) {
CHECK_EQ(weak_maps_count + empty_slots_count + 1, array.length());
}
USE_TORQUE_VERIFIER(TemplateObjectDescription)
void EnumCache::EnumCacheVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::EnumCacheVerify(*this, isolate);
Heap* heap = isolate->heap();
......@@ -1645,8 +1609,6 @@ void EnumCache::EnumCacheVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(ClassPositions)
void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionVerify(
Isolate* isolate) {
CHECK(IsObjectBoilerplateDescription());
......@@ -1655,14 +1617,10 @@ void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionVerify(
this->FixedArrayVerify(isolate);
}
USE_TORQUE_VERIFIER(ArrayBoilerplateDescription)
USE_TORQUE_VERIFIER(AsmWasmData)
USE_TORQUE_VERIFIER(WasmDebugInfo)
USE_TORQUE_VERIFIER(WasmExceptionTag)
void WasmInstanceObject::WasmInstanceObjectVerify(Isolate* isolate) {
JSObjectVerify(isolate);
CHECK(IsWasmInstanceObject());
......@@ -1723,8 +1681,6 @@ USE_TORQUE_VERIFIER(AccessorInfo)
USE_TORQUE_VERIFIER(AccessorPair)
USE_TORQUE_VERIFIER(AccessCheckInfo)
void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::CallHandlerInfoVerify(*this, isolate);
CHECK(map() == ReadOnlyRoots(isolate).side_effect_call_handler_info_map() ||
......@@ -1734,22 +1690,12 @@ void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
.next_call_side_effect_free_call_handler_info_map());
}
USE_TORQUE_VERIFIER(InterceptorInfo)
USE_TORQUE_VERIFIER(TemplateInfo)
USE_TORQUE_VERIFIER(FunctionTemplateInfo)
USE_TORQUE_VERIFIER(FunctionTemplateRareData)
USE_TORQUE_VERIFIER(WasmCapiFunctionData)
USE_TORQUE_VERIFIER(WasmJSFunctionData)
USE_TORQUE_VERIFIER(WasmIndirectFunctionTable)
USE_TORQUE_VERIFIER(ObjectTemplateInfo)
void AllocationSite::AllocationSiteVerify(Isolate* isolate) {
CHECK(IsAllocationSite());
CHECK(dependent_code().IsDependentCode());
......@@ -1789,8 +1735,6 @@ void NormalizedMapCache::NormalizedMapCacheVerify(Isolate* isolate) {
USE_TORQUE_VERIFIER(DebugInfo)
USE_TORQUE_VERIFIER(StackTraceFrame)
USE_TORQUE_VERIFIER(StackFrameInfo)
void PreparseData::PreparseDataVerify(Isolate* isolate) {
......
......@@ -865,8 +865,8 @@ void JSRegExp::JSRegExpPrint(std::ostream& os) { // NOLINT
void JSRegExpStringIterator::JSRegExpStringIteratorPrint(
std::ostream& os) { // NOLINT
JSObjectPrintHeader(os, *this, "JSRegExpStringIterator");
os << "\n - regex: " << Brief(iterating_regexp());
os << "\n - string: " << Brief(iterating_string());
os << "\n - regex: " << Brief(iterating_reg_exp());
os << "\n - string: " << Brief(iterated_string());
os << "\n - done: " << done();
os << "\n - global: " << global();
os << "\n - unicode: " << unicode();
......
......@@ -4348,7 +4348,7 @@ void Isolate::SetHostImportModuleDynamicallyCallback(
Handle<JSObject> Isolate::RunHostInitializeImportMetaObjectCallback(
Handle<SourceTextModule> module) {
Handle<Object> host_meta(module->import_meta(), this);
Handle<HeapObject> host_meta(module->import_meta(), this);
if (host_meta->IsTheHole(this)) {
host_meta = factory()->NewJSObjectWithNullProto();
if (host_initialize_import_meta_object_callback_ != nullptr) {
......
......@@ -21,15 +21,13 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(AccessCheckInfo, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(AccessCheckInfo)
OBJECT_CONSTRUCTORS_IMPL(AccessorInfo, Struct)
OBJECT_CONSTRUCTORS_IMPL(InterceptorInfo, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(InterceptorInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(CallHandlerInfo)
CAST_ACCESSOR(AccessorInfo)
CAST_ACCESSOR(AccessCheckInfo)
CAST_ACCESSOR(InterceptorInfo)
ACCESSORS(AccessorInfo, name, Name, kNameOffset)
SMI_ACCESSORS(AccessorInfo, flags, kFlagsOffset)
......@@ -98,21 +96,7 @@ bool AccessorInfo::HasExpectedReceiverType() {
return expected_receiver_type().IsFunctionTemplateInfo();
}
ACCESSORS(AccessCheckInfo, callback, Object, kCallbackOffset)
ACCESSORS(AccessCheckInfo, named_interceptor, Object, kNamedInterceptorOffset)
ACCESSORS(AccessCheckInfo, indexed_interceptor, Object,
kIndexedInterceptorOffset)
ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)
ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)
ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)
ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)
ACCESSORS(InterceptorInfo, descriptor, Object, kDescriptorOffset)
ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)
ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)
ACCESSORS(InterceptorInfo, definer, Object, kDefinerOffset)
ACCESSORS(InterceptorInfo, data, Object, kDataOffset)
SMI_ACCESSORS(InterceptorInfo, flags, kFlagsOffset)
TQ_SMI_ACCESSORS(InterceptorInfo, flags)
BOOL_ACCESSORS(InterceptorInfo, flags, can_intercept_symbols,
kCanInterceptSymbolsBit)
BOOL_ACCESSORS(InterceptorInfo, flags, all_can_read, kAllCanReadBit)
......
......@@ -102,37 +102,20 @@ class AccessorInfo : public Struct {
OBJECT_CONSTRUCTORS(AccessorInfo, Struct);
};
class AccessCheckInfo : public Struct {
class AccessCheckInfo
: public TorqueGeneratedAccessCheckInfo<AccessCheckInfo, Struct> {
public:
DECL_ACCESSORS(callback, Object)
DECL_ACCESSORS(named_interceptor, Object)
DECL_ACCESSORS(indexed_interceptor, Object)
DECL_ACCESSORS(data, Object)
DECL_CAST(AccessCheckInfo)
// Dispatched behavior.
DECL_PRINTER(AccessCheckInfo)
DECL_VERIFIER(AccessCheckInfo)
static AccessCheckInfo Get(Isolate* isolate, Handle<JSObject> receiver);
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_ACCESS_CHECK_INFO_FIELDS)
OBJECT_CONSTRUCTORS(AccessCheckInfo, Struct);
TQ_OBJECT_CONSTRUCTORS(AccessCheckInfo)
};
class InterceptorInfo : public Struct {
class InterceptorInfo
: public TorqueGeneratedInterceptorInfo<InterceptorInfo, Struct> {
public:
DECL_ACCESSORS(getter, Object)
DECL_ACCESSORS(setter, Object)
DECL_ACCESSORS(query, Object)
DECL_ACCESSORS(descriptor, Object)
DECL_ACCESSORS(deleter, Object)
DECL_ACCESSORS(enumerator, Object)
DECL_ACCESSORS(definer, Object)
DECL_ACCESSORS(data, Object)
DECL_BOOLEAN_ACCESSORS(can_intercept_symbols)
DECL_BOOLEAN_ACCESSORS(all_can_read)
DECL_BOOLEAN_ACCESSORS(non_masking)
......@@ -142,14 +125,8 @@ class InterceptorInfo : public Struct {
inline int flags() const;
inline void set_flags(int flags);
DECL_CAST(InterceptorInfo)
// Dispatched behavior.
DECL_PRINTER(InterceptorInfo)
DECL_VERIFIER(InterceptorInfo)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_INTERCEPTOR_INFO_FIELDS)
static const int kCanInterceptSymbolsBit = 0;
static const int kAllCanReadBit = 1;
......@@ -157,7 +134,7 @@ class InterceptorInfo : public Struct {
static const int kNamed = 3;
static const int kHasNoSideEffect = 4;
OBJECT_CONSTRUCTORS(InterceptorInfo, Struct);
TQ_OBJECT_CONSTRUCTORS(InterceptorInfo)
};
class CallHandlerInfo
......
......@@ -19,15 +19,12 @@ namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(SloppyArgumentsElements, FixedArray)
OBJECT_CONSTRUCTORS_IMPL(JSArgumentsObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(AliasedArgumentsEntry, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSArgumentsObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(AliasedArgumentsEntry)
CAST_ACCESSOR(AliasedArgumentsEntry)
CAST_ACCESSOR(SloppyArgumentsElements)
CAST_ACCESSOR(JSArgumentsObject)
SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot,
kAliasedContextSlotOffset)
TQ_SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot)
DEF_GETTER(SloppyArgumentsElements, context, Context) {
return TaggedField<Context>::load(isolate, *this,
......
......@@ -17,11 +17,11 @@ namespace v8 {
namespace internal {
// Superclass for all objects with instance type {JS_ARGUMENTS_TYPE}
class JSArgumentsObject : public JSObject {
class JSArgumentsObject
: public TorqueGeneratedJSArgumentsObject<JSArgumentsObject, JSObject> {
public:
DECL_VERIFIER(JSArgumentsObject)
DECL_CAST(JSArgumentsObject)
OBJECT_CONSTRUCTORS(JSArgumentsObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSArgumentsObject)
};
// Common superclass for JSSloppyArgumentsObject and JSStrictArgumentsObject.
......@@ -125,21 +125,17 @@ class SloppyArgumentsElements : public FixedArray {
// - the parameter map contains no fast alias mapping (i.e. the hole)
// - this struct (in the slow backing store) contains an index into the context
// - all attributes are available as part if the property details
class AliasedArgumentsEntry : public Struct {
class AliasedArgumentsEntry
: public TorqueGeneratedAliasedArgumentsEntry<AliasedArgumentsEntry,
Struct> {
public:
inline int aliased_context_slot() const;
inline void set_aliased_context_slot(int count);
DECL_CAST(AliasedArgumentsEntry)
// Dispatched behavior.
DECL_PRINTER(AliasedArgumentsEntry)
DECL_VERIFIER(AliasedArgumentsEntry)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_ALIASED_ARGUMENTS_ENTRY_FIELDS)
OBJECT_CONSTRUCTORS(AliasedArgumentsEntry, Struct);
TQ_OBJECT_CONSTRUCTORS(AliasedArgumentsEntry)
};
} // namespace internal
......
......@@ -16,11 +16,7 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Cell, HeapObject)
CAST_ACCESSOR(Cell)
ACCESSORS(Cell, value, Object, kValueOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(Cell)
Cell Cell::FromValueAddress(Address value) {
return Cell::cast(HeapObject::FromAddress(value - kValueOffset));
......
......@@ -6,7 +6,7 @@
#define V8_OBJECTS_CELL_H_
#include "src/objects/heap-object.h"
#include "torque-generated/field-offsets-tq.h"
#include "torque-generated/class-definitions-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -14,27 +14,18 @@
namespace v8 {
namespace internal {
class Cell : public HeapObject {
class Cell : public TorqueGeneratedCell<Cell, HeapObject> {
public:
// [value]: value of the cell.
DECL_ACCESSORS(value, Object)
DECL_CAST(Cell)
static inline Cell FromValueAddress(Address value);
inline Address ValueAddress() { return address() + kValueOffset; }
// Dispatched behavior.
DECL_PRINTER(Cell)
DECL_VERIFIER(Cell)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_CELL_FIELDS)
using BodyDescriptor = FixedBodyDescriptor<kValueOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(Cell, HeapObject);
TQ_OBJECT_CONSTRUCTORS(Cell)
};
} // namespace internal
......
......@@ -16,11 +16,9 @@
namespace v8 {
namespace internal {
CAST_ACCESSOR(EmbedderDataArray)
TQ_SMI_ACCESSORS(EmbedderDataArray, length)
SMI_ACCESSORS(EmbedderDataArray, length, kLengthOffset)
OBJECT_CONSTRUCTORS_IMPL(EmbedderDataArray, HeapObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(EmbedderDataArray)
Address EmbedderDataArray::slots_start() {
return FIELD_ADDR(*this, OffsetOfElementAt(0));
......
......@@ -8,7 +8,7 @@
#include "src/common/globals.h"
#include "src/handles/maybe-handles.h"
#include "src/objects/heap-object.h"
#include "torque-generated/field-offsets-tq.h"
#include "torque-generated/class-definitions-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -20,16 +20,13 @@ namespace internal {
// It's basically an "array of EmbedderDataSlots".
// Note, if the pointer compression is enabled the embedder data slot also
// contains a raw data part in addition to tagged part.
class EmbedderDataArray : public HeapObject {
class EmbedderDataArray
: public TorqueGeneratedEmbedderDataArray<EmbedderDataArray, HeapObject> {
public:
// [length]: length of the array in an embedder data slots.
V8_INLINE int length() const;
V8_INLINE void set_length(int value);
DECL_CAST(EmbedderDataArray)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_EMBEDDER_DATA_ARRAY_FIELDS)
// TODO(v8:8989): [torque] Support marker constants.
static const int kHeaderSize = kSize;
......@@ -64,7 +61,7 @@ class EmbedderDataArray : public HeapObject {
private:
STATIC_ASSERT(kHeaderSize == Internals::kFixedArrayHeaderSize);
OBJECT_CONSTRUCTORS(EmbedderDataArray, HeapObject);
TQ_OBJECT_CONSTRUCTORS(EmbedderDataArray)
};
} // namespace internal
......
......@@ -19,17 +19,17 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSCollection, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSMap, JSCollection)
OBJECT_CONSTRUCTORS_IMPL(JSSet, JSCollection)
OBJECT_CONSTRUCTORS_IMPL(JSWeakCollection, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSWeakMap, JSWeakCollection)
OBJECT_CONSTRUCTORS_IMPL(JSWeakSet, JSWeakCollection)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSCollection)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSMap)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSSet)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSWeakCollection)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSWeakMap)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSWeakSet)
// TODO(jkummerow): Move JSCollectionIterator to js-collection.h?
// TODO(jkummerow): Introduce IsJSCollectionIterator() check? Or unchecked
// version of OBJECT_CONSTRUCTORS_IMPL macro?
JSCollectionIterator::JSCollectionIterator(Address ptr) : JSObject(ptr) {}
TQ_OBJECT_CONSTRUCTORS_IMPL(JSCollectionIterator)
template <class Derived, class TableType>
OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIterator(
Address ptr)
......@@ -45,20 +45,8 @@ JSSetIterator::JSSetIterator(Address ptr)
SLOW_DCHECK(IsJSSetIterator());
}
ACCESSORS(JSCollection, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, table, Object, kTableOffset)
ACCESSORS(JSCollectionIterator, index, Object, kIndexOffset)
ACCESSORS(JSWeakCollection, table, Object, kTableOffset)
CAST_ACCESSOR(JSCollection)
CAST_ACCESSOR(JSSet)
CAST_ACCESSOR(JSSetIterator)
CAST_ACCESSOR(JSMap)
CAST_ACCESSOR(JSMapIterator)
CAST_ACCESSOR(JSWeakCollection)
CAST_ACCESSOR(JSWeakMap)
CAST_ACCESSOR(JSWeakSet)
Object JSMapIterator::CurrentValue() {
OrderedHashMap table = OrderedHashMap::cast(this->table());
......
......@@ -16,21 +16,13 @@
namespace v8 {
namespace internal {
class JSCollectionIterator : public JSObject {
class JSCollectionIterator
: public TorqueGeneratedJSCollectionIterator<JSCollectionIterator,
JSObject> {
public:
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
// [index]: The index into the data table.
DECL_ACCESSORS(index, Object)
void JSCollectionIteratorPrint(std::ostream& os, const char* name);
DECL_VERIFIER(JSCollectionIterator)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSCOLLECTION_ITERATOR_FIELDS)
OBJECT_CONSTRUCTORS(JSCollectionIterator, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSCollectionIterator)
};
// OrderedHashTableIterator is an iterator that iterates over the keys and
......
......@@ -17,39 +17,25 @@ namespace internal {
class OrderedHashSet;
class OrderedHashMap;
class JSCollection : public JSObject {
class JSCollection
: public TorqueGeneratedJSCollection<JSCollection, JSObject> {
public:
DECL_CAST(JSCollection)
// [table]: the backing hash table
DECL_ACCESSORS(table, Object)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSCOLLECTION_FIELDS)
static const int kAddFunctionDescriptorIndex = 3;
DECL_VERIFIER(JSCollection)
OBJECT_CONSTRUCTORS(JSCollection, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSCollection)
};
// The JSSet describes EcmaScript Harmony sets
class JSSet : public JSCollection {
class JSSet : public TorqueGeneratedJSSet<JSSet, JSCollection> {
public:
DECL_CAST(JSSet)
static void Initialize(Handle<JSSet> set, Isolate* isolate);
static void Clear(Isolate* isolate, Handle<JSSet> set);
// Dispatched behavior.
DECL_PRINTER(JSSet)
DECL_VERIFIER(JSSet)
DEFINE_FIELD_OFFSET_CONSTANTS(JSCollection::kHeaderSize,
TORQUE_GENERATED_JSWEAK_SET_FIELDS)
OBJECT_CONSTRUCTORS(JSSet, JSCollection);
TQ_OBJECT_CONSTRUCTORS(JSSet)
};
class JSSetIterator
......@@ -66,20 +52,16 @@ class JSSetIterator
};
// The JSMap describes EcmaScript Harmony maps
class JSMap : public JSCollection {
class JSMap : public TorqueGeneratedJSMap<JSMap, JSCollection> {
public:
DECL_CAST(JSMap)
static void Initialize(Handle<JSMap> map, Isolate* isolate);
static void Clear(Isolate* isolate, Handle<JSMap> map);
// Dispatched behavior.
DECL_PRINTER(JSMap)
DECL_VERIFIER(JSMap)
DEFINE_FIELD_OFFSET_CONSTANTS(JSCollection::kHeaderSize,
TORQUE_GENERATED_JSWEAK_MAP_FIELDS)
OBJECT_CONSTRUCTORS(JSMap, JSCollection);
TQ_OBJECT_CONSTRUCTORS(JSMap)
};
class JSMapIterator
......@@ -100,13 +82,9 @@ class JSMapIterator
};
// Base class for both JSWeakMap and JSWeakSet
class JSWeakCollection : public JSObject {
class JSWeakCollection
: public TorqueGeneratedJSWeakCollection<JSWeakCollection, JSObject> {
public:
DECL_CAST(JSWeakCollection)
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
V8_EXPORT_PRIVATE static void Set(Handle<JSWeakCollection> collection,
Handle<Object> key, Handle<Object> value,
......@@ -116,11 +94,6 @@ class JSWeakCollection : public JSObject {
static Handle<JSArray> GetEntries(Handle<JSWeakCollection> holder,
int max_entries);
DECL_VERIFIER(JSWeakCollection)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSWEAK_COLLECTION_FIELDS)
static const int kAddFunctionDescriptorIndex = 3;
// Iterates the function object according to the visiting policy.
......@@ -131,37 +104,29 @@ class JSWeakCollection : public JSObject {
static const int kSizeOfAllWeakCollections = kHeaderSize;
OBJECT_CONSTRUCTORS(JSWeakCollection, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSWeakCollection)
};
// The JSWeakMap describes EcmaScript Harmony weak maps
class JSWeakMap : public JSWeakCollection {
class JSWeakMap : public TorqueGeneratedJSWeakMap<JSWeakMap, JSWeakCollection> {
public:
DECL_CAST(JSWeakMap)
// Dispatched behavior.
DECL_PRINTER(JSWeakMap)
DECL_VERIFIER(JSWeakMap)
DEFINE_FIELD_OFFSET_CONSTANTS(JSWeakCollection::kHeaderSize,
TORQUE_GENERATED_JSWEAK_MAP_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllWeakCollections);
OBJECT_CONSTRUCTORS(JSWeakMap, JSWeakCollection);
TQ_OBJECT_CONSTRUCTORS(JSWeakMap)
};
// The JSWeakSet describes EcmaScript Harmony weak sets
class JSWeakSet : public JSWeakCollection {
class JSWeakSet : public TorqueGeneratedJSWeakSet<JSWeakSet, JSWeakCollection> {
public:
DECL_CAST(JSWeakSet)
// Dispatched behavior.
DECL_PRINTER(JSWeakSet)
DECL_VERIFIER(JSWeakSet)
DEFINE_FIELD_OFFSET_CONSTANTS(JSWeakCollection::kHeaderSize,
TORQUE_GENERATED_JSWEAK_SET_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllWeakCollections);
OBJECT_CONSTRUCTORS(JSWeakSet, JSWeakCollection);
STATIC_ASSERT(kSize == kSizeOfAllWeakCollections);
TQ_OBJECT_CONSTRUCTORS(JSWeakSet)
};
} // namespace internal
......
......@@ -16,29 +16,15 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSGeneratorObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSAsyncFunctionObject, JSGeneratorObject)
OBJECT_CONSTRUCTORS_IMPL(JSAsyncGeneratorObject, JSGeneratorObject)
OBJECT_CONSTRUCTORS_IMPL(AsyncGeneratorRequest, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSGeneratorObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSAsyncFunctionObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSAsyncGeneratorObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(AsyncGeneratorRequest)
CAST_ACCESSOR(JSAsyncFunctionObject)
CAST_ACCESSOR(JSAsyncGeneratorObject)
CAST_ACCESSOR(JSGeneratorObject)
CAST_ACCESSOR(AsyncGeneratorRequest)
TQ_SMI_ACCESSORS(JSGeneratorObject, resume_mode)
TQ_SMI_ACCESSORS(JSGeneratorObject, continuation)
ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
ACCESSORS(JSGeneratorObject, parameters_and_registers, FixedArray,
kParametersAndRegistersOffset)
ACCESSORS(AsyncGeneratorRequest, next, Object, kNextOffset)
SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode, kResumeModeOffset)
ACCESSORS(AsyncGeneratorRequest, value, Object, kValueOffset)
ACCESSORS(AsyncGeneratorRequest, promise, Object, kPromiseOffset)
TQ_SMI_ACCESSORS(AsyncGeneratorRequest, resume_mode)
bool JSGeneratorObject::is_suspended() const {
DCHECK_LT(kGeneratorExecuting, 0);
......@@ -54,10 +40,7 @@ bool JSGeneratorObject::is_executing() const {
return continuation() == kGeneratorExecuting;
}
ACCESSORS(JSAsyncFunctionObject, promise, JSPromise, kPromiseOffset)
ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
SMI_ACCESSORS(JSAsyncGeneratorObject, is_awaiting, kIsAwaitingOffset)
TQ_SMI_ACCESSORS(JSAsyncGeneratorObject, is_awaiting)
} // namespace internal
} // namespace v8
......
......@@ -17,24 +17,9 @@ namespace internal {
// Forward declarations.
class JSPromise;
class JSGeneratorObject : public JSObject {
class JSGeneratorObject
: public TorqueGeneratedJSGeneratorObject<JSGeneratorObject, JSObject> {
public:
// [function]: The function corresponding to this generator object.
DECL_ACCESSORS(function, JSFunction)
// [context]: The context of the suspended computation.
DECL_ACCESSORS(context, Context)
// [receiver]: The receiver of the suspended computation.
DECL_ACCESSORS(receiver, Object)
// [input_or_debug_pos]
// For executing generators: the most recent input value.
// For suspended generators: debug information (bytecode offset).
// There is currently no need to remember the most recent input value for a
// suspended generator.
DECL_ACCESSORS(input_or_debug_pos, Object)
// [resume_mode]: The most recent resume mode.
enum ResumeMode { kNext, kReturn, kThrow };
DECL_INT_ACCESSORS(resume_mode)
......@@ -54,84 +39,50 @@ class JSGeneratorObject : public JSObject {
// is suspended.
int source_position() const;
// [parameters_and_registers]: Saved interpreter register file.
DECL_ACCESSORS(parameters_and_registers, FixedArray)
DECL_CAST(JSGeneratorObject)
// Dispatched behavior.
DECL_PRINTER(JSGeneratorObject)
DECL_VERIFIER(JSGeneratorObject)
// Magic sentinel values for the continuation.
static const int kGeneratorExecuting = -2;
static const int kGeneratorClosed = -1;
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSGENERATOR_OBJECT_FIELDS)
OBJECT_CONSTRUCTORS(JSGeneratorObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSGeneratorObject)
};
class JSAsyncFunctionObject : public JSGeneratorObject {
class JSAsyncFunctionObject
: public TorqueGeneratedJSAsyncFunctionObject<JSAsyncFunctionObject,
JSGeneratorObject> {
public:
DECL_CAST(JSAsyncFunctionObject)
// Dispatched behavior.
DECL_VERIFIER(JSAsyncFunctionObject)
// [promise]: The promise of the async function.
DECL_ACCESSORS(promise, JSPromise)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSGeneratorObject::kSize,
TORQUE_GENERATED_JSASYNC_FUNCTION_OBJECT_FIELDS)
OBJECT_CONSTRUCTORS(JSAsyncFunctionObject, JSGeneratorObject);
TQ_OBJECT_CONSTRUCTORS(JSAsyncFunctionObject)
};
class JSAsyncGeneratorObject : public JSGeneratorObject {
class JSAsyncGeneratorObject
: public TorqueGeneratedJSAsyncGeneratorObject<JSAsyncGeneratorObject,
JSGeneratorObject> {
public:
DECL_CAST(JSAsyncGeneratorObject)
// Dispatched behavior.
DECL_VERIFIER(JSAsyncGeneratorObject)
// [queue]
// Pointer to the head of a singly linked list of AsyncGeneratorRequest, or
// undefined.
DECL_ACCESSORS(queue, HeapObject)
// [is_awaiting]
// Whether or not the generator is currently awaiting.
DECL_INT_ACCESSORS(is_awaiting)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(
JSGeneratorObject::kSize,
TORQUE_GENERATED_JSASYNC_GENERATOR_OBJECT_FIELDS)
#undef JS_ASYNC_GENERATOR_FIELDS
OBJECT_CONSTRUCTORS(JSAsyncGeneratorObject, JSGeneratorObject);
TQ_OBJECT_CONSTRUCTORS(JSAsyncGeneratorObject)
};
class AsyncGeneratorRequest : public Struct {
class AsyncGeneratorRequest
: public TorqueGeneratedAsyncGeneratorRequest<AsyncGeneratorRequest,
Struct> {
public:
// Holds an AsyncGeneratorRequest, or Undefined.
DECL_ACCESSORS(next, Object)
DECL_INT_ACCESSORS(resume_mode)
DECL_ACCESSORS(value, Object)
DECL_ACCESSORS(promise, Object)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_ASYNC_GENERATOR_REQUEST_FIELDS)
DECL_CAST(AsyncGeneratorRequest)
DECL_PRINTER(AsyncGeneratorRequest)
DECL_VERIFIER(AsyncGeneratorRequest)
OBJECT_CONSTRUCTORS(AsyncGeneratorRequest, Struct);
TQ_OBJECT_CONSTRUCTORS(AsyncGeneratorRequest)
};
} // namespace internal
......
......@@ -31,9 +31,9 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSReceiver, HeapObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSAsyncFromSyncIterator, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSBoundFunction, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSDate, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSAsyncFromSyncIterator)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSBoundFunction)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSDate)
OBJECT_CONSTRUCTORS_IMPL(JSFunction, JSObject)
OBJECT_CONSTRUCTORS_IMPL(JSGlobalObject, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSGlobalProxy)
......@@ -44,9 +44,6 @@ OBJECT_CONSTRUCTORS_IMPL(JSStringIterator, JSObject)
NEVER_READ_ONLY_SPACE_IMPL(JSReceiver)
CAST_ACCESSOR(JSAsyncFromSyncIterator)
CAST_ACCESSOR(JSBoundFunction)
CAST_ACCESSOR(JSDate)
CAST_ACCESSOR(JSFunction)
CAST_ACCESSOR(JSGlobalObject)
CAST_ACCESSOR(JSIteratorResult)
......@@ -450,11 +447,6 @@ void JSObject::InitializeBody(Map map, int start_offset,
}
}
ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
kBoundTargetFunctionOffset)
ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
ACCESSORS(JSFunction, raw_feedback_cell, FeedbackCell, kFeedbackCellOffset)
ACCESSORS(JSGlobalObject, native_context, NativeContext, kNativeContextOffset)
......@@ -712,16 +704,6 @@ void JSFunction::ResetIfBytecodeFlushed() {
}
}
ACCESSORS(JSDate, value, Object, kValueOffset)
ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
ACCESSORS(JSDate, year, Object, kYearOffset)
ACCESSORS(JSDate, month, Object, kMonthOffset)
ACCESSORS(JSDate, day, Object, kDayOffset)
ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
ACCESSORS(JSDate, hour, Object, kHourOffset)
ACCESSORS(JSDate, min, Object, kMinOffset)
ACCESSORS(JSDate, sec, Object, kSecOffset)
bool JSMessageObject::DidEnsureSourcePositionsAvailable() const {
return shared_info().IsUndefined();
}
......@@ -1025,10 +1007,6 @@ inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
kSyncIteratorOffset)
ACCESSORS(JSAsyncFromSyncIterator, next, Object, kNextOffset)
ACCESSORS(JSStringIterator, string, String, kStringOffset)
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
......
......@@ -894,19 +894,9 @@ class JSIteratorResult : public JSObject {
};
// JSBoundFunction describes a bound function exotic object.
class JSBoundFunction : public JSObject {
class JSBoundFunction
: public TorqueGeneratedJSBoundFunction<JSBoundFunction, JSObject> {
public:
// [bound_target_function]: The wrapped function object.
DECL_ACCESSORS(bound_target_function, JSReceiver)
// [bound_this]: The value that is always passed as the this value when
// calling the wrapped function.
DECL_ACCESSORS(bound_this, Object)
// [bound_arguments]: A list of values whose elements are used as the first
// arguments to any call to the wrapped function.
DECL_ACCESSORS(bound_arguments, FixedArray)
static MaybeHandle<String> GetName(Isolate* isolate,
Handle<JSBoundFunction> function);
static Maybe<int> GetLength(Isolate* isolate,
......@@ -914,8 +904,6 @@ class JSBoundFunction : public JSObject {
static MaybeHandle<NativeContext> GetFunctionRealm(
Handle<JSBoundFunction> function);
DECL_CAST(JSBoundFunction)
// Dispatched behavior.
DECL_PRINTER(JSBoundFunction)
DECL_VERIFIER(JSBoundFunction)
......@@ -924,11 +912,7 @@ class JSBoundFunction : public JSObject {
// to ES6 section 19.2.3.5 Function.prototype.toString ( ).
static Handle<String> ToString(Handle<JSBoundFunction> function);
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSBOUND_FUNCTION_FIELDS)
OBJECT_CONSTRUCTORS(JSBoundFunction, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSBoundFunction)
};
// JSFunction describes JavaScript functions.
......@@ -1214,34 +1198,11 @@ class JSPrimitiveWrapper
class DateCache;
// Representation for JS date objects.
class JSDate : public JSObject {
class JSDate : public TorqueGeneratedJSDate<JSDate, JSObject> {
public:
static V8_WARN_UNUSED_RESULT MaybeHandle<JSDate> New(
Handle<JSFunction> constructor, Handle<JSReceiver> new_target, double tv);
// If one component is NaN, all of them are, indicating a NaN time value.
// [value]: the time value.
DECL_ACCESSORS(value, Object)
// [year]: caches year. Either undefined, smi, or NaN.
DECL_ACCESSORS(year, Object)
// [month]: caches month. Either undefined, smi, or NaN.
DECL_ACCESSORS(month, Object)
// [day]: caches day. Either undefined, smi, or NaN.
DECL_ACCESSORS(day, Object)
// [weekday]: caches day of week. Either undefined, smi, or NaN.
DECL_ACCESSORS(weekday, Object)
// [hour]: caches hours. Either undefined, smi, or NaN.
DECL_ACCESSORS(hour, Object)
// [min]: caches minutes. Either undefined, smi, or NaN.
DECL_ACCESSORS(min, Object)
// [sec]: caches seconds. Either undefined, smi, or NaN.
DECL_ACCESSORS(sec, Object)
// [cache stamp]: sample of the date cache stamp at the
// moment when chached fields were cached.
DECL_ACCESSORS(cache_stamp, Object)
DECL_CAST(JSDate)
// Returns the time value (UTC) identifying the current time.
static double CurrentTimeValue(Isolate* isolate);
......@@ -1291,9 +1252,6 @@ class JSDate : public JSObject {
kTimezoneOffset
};
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSDATE_FIELDS)
private:
inline Object DoGetField(FieldIndex index);
......@@ -1302,7 +1260,7 @@ class JSDate : public JSObject {
// Computes and caches the cacheable fields of the date.
inline void SetCachedFields(int64_t local_time_ms, DateCache* date_cache);
OBJECT_CONSTRUCTORS(JSDate, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSDate)
};
// Representation of message objects used for error reporting through
......@@ -1397,27 +1355,19 @@ class JSMessageObject : public JSObject {
// An object which wraps an ordinary Iterator and converts it to behave
// according to the Async Iterator protocol.
// (See https://tc39.github.io/proposal-async-iteration/#sec-iteration)
class JSAsyncFromSyncIterator : public JSObject {
class JSAsyncFromSyncIterator
: public TorqueGeneratedJSAsyncFromSyncIterator<JSAsyncFromSyncIterator,
JSObject> {
public:
DECL_CAST(JSAsyncFromSyncIterator)
DECL_PRINTER(JSAsyncFromSyncIterator)
DECL_VERIFIER(JSAsyncFromSyncIterator)
// Async-from-Sync Iterator instances are ordinary objects that inherit
// properties from the %AsyncFromSyncIteratorPrototype% intrinsic object.
// Async-from-Sync Iterator instances are initially created with the internal
// slots listed in Table 4.
// (proposal-async-iteration/#table-async-from-sync-iterator-internal-slots)
DECL_ACCESSORS(sync_iterator, JSReceiver)
// The "next" method is loaded during GetIterator, and is not reloaded for
// subsequent "next" invocations.
DECL_ACCESSORS(next, Object)
DEFINE_FIELD_OFFSET_CONSTANTS(
JSObject::kHeaderSize, TORQUE_GENERATED_JSASYNC_FROM_SYNC_ITERATOR_FIELDS)
OBJECT_CONSTRUCTORS(JSAsyncFromSyncIterator, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSAsyncFromSyncIterator)
};
class JSStringIterator : public JSObject {
......
......@@ -16,11 +16,9 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSPromise, JSObject)
CAST_ACCESSOR(JSPromise)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSPromise)
ACCESSORS(JSPromise, reactions_or_result, Object, kReactionsOrResultOffset)
SMI_ACCESSORS(JSPromise, flags, kFlagsOffset)
TQ_SMI_ACCESSORS(JSPromise, flags)
BOOL_ACCESSORS(JSPromise, flags, has_handler, kHasHandlerBit)
BOOL_ACCESSORS(JSPromise, flags, handled_hint, kHandledHintBit)
......
......@@ -24,12 +24,8 @@ namespace internal {
// We also overlay the result and reactions fields on the JSPromise, since
// the reactions are only necessary for pending promises, whereas the result
// is only meaningful for settled promises.
class JSPromise : public JSObject {
class JSPromise : public TorqueGeneratedJSPromise<JSPromise, JSObject> {
public:
// [reactions_or_result]: Smi 0 terminated list of PromiseReaction objects
// in case the JSPromise was not settled yet, otherwise the result.
DECL_ACCESSORS(reactions_or_result, Object)
// [result]: Checks that the promise is settled and returns the result.
inline Object result() const;
......@@ -62,15 +58,10 @@ class JSPromise : public JSObject {
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> Resolve(
Handle<JSPromise> promise, Handle<Object> resolution);
DECL_CAST(JSPromise)
// Dispatched behavior.
DECL_PRINTER(JSPromise)
DECL_VERIFIER(JSPromise)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSPROMISE_FIELDS)
static const int kSizeWithEmbedderFields =
kSize + v8::Promise::kEmbedderFieldCount * kEmbedderDataSlotSize;
......@@ -94,7 +85,7 @@ class JSPromise : public JSObject {
Handle<Object> argument,
PromiseReaction::Type type);
OBJECT_CONSTRUCTORS(JSPromise, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSPromise)
};
} // namespace internal
......
......@@ -17,13 +17,8 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSRegExp, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSRegExp)
CAST_ACCESSOR(JSRegExp)
ACCESSORS(JSRegExp, data, Object, kDataOffset)
ACCESSORS(JSRegExp, flags, Object, kFlagsOffset)
ACCESSORS(JSRegExp, source, Object, kSourceOffset)
ACCESSORS(JSRegExp, last_index, Object, kLastIndexOffset)
JSRegExp::Type JSRegExp::TypeTag() const {
......
......@@ -15,20 +15,13 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSRegExpStringIterator, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSRegExpStringIterator)
ACCESSORS(JSRegExpStringIterator, iterating_regexp, Object,
kIteratingRegExpOffset)
ACCESSORS(JSRegExpStringIterator, iterating_string, String,
kIteratedStringOffset)
SMI_ACCESSORS(JSRegExpStringIterator, flags, kFlagsOffset)
TQ_SMI_ACCESSORS(JSRegExpStringIterator, flags)
BOOL_ACCESSORS(JSRegExpStringIterator, flags, done, kDoneBit)
BOOL_ACCESSORS(JSRegExpStringIterator, flags, global, kGlobalBit)
BOOL_ACCESSORS(JSRegExpStringIterator, flags, unicode, kUnicodeBit)
CAST_ACCESSOR(JSRegExpStringIterator)
} // namespace internal
} // namespace v8
......
......@@ -13,14 +13,10 @@
namespace v8 {
namespace internal {
class JSRegExpStringIterator : public JSObject {
class JSRegExpStringIterator
: public TorqueGeneratedJSRegExpStringIterator<JSRegExpStringIterator,
JSObject> {
public:
// [regexp]: the [[IteratingRegExp]] internal property.
DECL_ACCESSORS(iterating_regexp, Object)
// [string]: The [[IteratedString]] internal property.
DECL_ACCESSORS(iterating_string, String)
DECL_INT_ACCESSORS(flags)
// [boolean]: The [[Done]] internal property.
......@@ -32,20 +28,13 @@ class JSRegExpStringIterator : public JSObject {
// [boolean]: The [[Unicode]] internal property.
DECL_BOOLEAN_ACCESSORS(unicode)
DECL_CAST(JSRegExpStringIterator)
DECL_PRINTER(JSRegExpStringIterator)
DECL_VERIFIER(JSRegExpStringIterator)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(
JSObject::kHeaderSize,
TORQUE_GENERATED_JSREG_EXP_STRING_ITERATOR_FIELDS)
static const int kDoneBit = 0;
static const int kGlobalBit = 1;
static const int kUnicodeBit = 2;
OBJECT_CONSTRUCTORS(JSRegExpStringIterator, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSRegExpStringIterator)
};
} // namespace internal
......
......@@ -29,7 +29,7 @@ namespace internal {
// used for tracking the last usage (used for regexp code flushing).
// - max number of registers used by irregexp implementations.
// - number of capture registers (output values) of the regexp.
class JSRegExp : public JSObject {
class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
public:
// Meaning of Type:
// NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet.
......@@ -82,10 +82,7 @@ class JSRegExp : public JSObject {
STATIC_ASSERT(static_cast<int>(kDotAll) == v8::RegExp::kDotAll);
STATIC_ASSERT(kFlagCount == v8::RegExp::kFlagCount);
DECL_ACCESSORS(data, Object)
DECL_ACCESSORS(flags, Object)
DECL_ACCESSORS(last_index, Object)
DECL_ACCESSORS(source, Object)
V8_EXPORT_PRIVATE static MaybeHandle<JSRegExp> New(Isolate* isolate,
Handle<String> source,
......@@ -133,15 +130,10 @@ class JSRegExp : public JSObject {
inline bool HasCompiledCode() const;
inline void DiscardCompiledCodeForSerialization();
DECL_CAST(JSRegExp)
// Dispatched behavior.
DECL_PRINTER(JSRegExp)
DECL_VERIFIER(JSRegExp)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSREG_EXP_FIELDS)
/* This is already an in-object field. */
// TODO(v8:8944): improve handling of in-object fields
static constexpr int kLastIndexOffset = kSize;
......@@ -203,7 +195,7 @@ class JSRegExp : public JSObject {
// The uninitialized value for a regexp code object.
static const int kUninitializedValue = -1;
OBJECT_CONSTRUCTORS(JSRegExp, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSRegExp)
};
DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags)
......
......@@ -124,14 +124,9 @@ ACCESSORS(ClassBoilerplate, instance_computed_properties, FixedArray,
// ArrayBoilerplateDescription
//
OBJECT_CONSTRUCTORS_IMPL(ArrayBoilerplateDescription, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(ArrayBoilerplateDescription)
CAST_ACCESSOR(ArrayBoilerplateDescription)
SMI_ACCESSORS(ArrayBoilerplateDescription, flags, kFlagsOffset)
ACCESSORS(ArrayBoilerplateDescription, constant_elements, FixedArrayBase,
kConstantElementsOffset)
TQ_SMI_ACCESSORS(ArrayBoilerplateDescription, flags)
ElementsKind ArrayBoilerplateDescription::elements_kind() const {
return static_cast<ElementsKind>(flags());
......
......@@ -55,29 +55,22 @@ class ObjectBoilerplateDescription : public FixedArray {
OBJECT_CONSTRUCTORS(ObjectBoilerplateDescription, FixedArray);
};
class ArrayBoilerplateDescription : public Struct {
class ArrayBoilerplateDescription
: public TorqueGeneratedArrayBoilerplateDescription<
ArrayBoilerplateDescription, Struct> {
public:
// store constant_elements of a fixed array
DECL_ACCESSORS(constant_elements, FixedArrayBase)
inline ElementsKind elements_kind() const;
inline void set_elements_kind(ElementsKind kind);
inline bool is_empty() const;
DECL_CAST(ArrayBoilerplateDescription)
// Dispatched behavior.
DECL_PRINTER(ArrayBoilerplateDescription)
DECL_VERIFIER(ArrayBoilerplateDescription)
void BriefPrintDetails(std::ostream& os);
DEFINE_FIELD_OFFSET_CONSTANTS(
HeapObject::kHeaderSize,
TORQUE_GENERATED_ARRAY_BOILERPLATE_DESCRIPTION_FIELDS)
private:
DECL_INT_ACCESSORS(flags)
OBJECT_CONSTRUCTORS(ArrayBoilerplateDescription, Struct);
TQ_OBJECT_CONSTRUCTORS(ArrayBoilerplateDescription)
};
class ClassBoilerplate : public FixedArray {
......
......@@ -18,19 +18,9 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Microtask, Struct)
OBJECT_CONSTRUCTORS_IMPL(CallbackTask, Microtask)
OBJECT_CONSTRUCTORS_IMPL(CallableTask, Microtask)
CAST_ACCESSOR(Microtask)
CAST_ACCESSOR(CallbackTask)
CAST_ACCESSOR(CallableTask)
ACCESSORS(CallableTask, callable, JSReceiver, kCallableOffset)
ACCESSORS(CallableTask, context, Context, kContextOffset)
ACCESSORS(CallbackTask, callback, Foreign, kCallbackOffset)
ACCESSORS(CallbackTask, data, Foreign, kDataOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(Microtask)
TQ_OBJECT_CONSTRUCTORS_IMPL(CallbackTask)
TQ_OBJECT_CONSTRUCTORS_IMPL(CallableTask)
} // namespace internal
} // namespace v8
......
......@@ -17,52 +17,35 @@ namespace internal {
// Abstract base class for all microtasks that can be scheduled on the
// microtask queue. This class merely serves the purpose of a marker
// interface.
class Microtask : public Struct {
class Microtask : public TorqueGeneratedMicrotask<Microtask, Struct> {
public:
// Dispatched behavior.
DECL_CAST(Microtask)
DECL_VERIFIER(Microtask)
OBJECT_CONSTRUCTORS(Microtask, Struct);
TQ_OBJECT_CONSTRUCTORS(Microtask)
};
// A CallbackTask is a special Microtask that allows us to schedule
// C++ microtask callbacks on the microtask queue. This is heavily
// used by Blink for example.
class CallbackTask : public Microtask {
class CallbackTask
: public TorqueGeneratedCallbackTask<CallbackTask, Microtask> {
public:
DECL_ACCESSORS(callback, Foreign)
DECL_ACCESSORS(data, Foreign)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize,
TORQUE_GENERATED_CALLBACK_TASK_FIELDS)
// Dispatched behavior.
DECL_CAST(CallbackTask)
DECL_PRINTER(CallbackTask)
DECL_VERIFIER(CallbackTask)
OBJECT_CONSTRUCTORS(CallbackTask, Microtask);
TQ_OBJECT_CONSTRUCTORS(CallbackTask)
};
// A CallableTask is a special (internal) Microtask that allows us to
// schedule arbitrary callables on the microtask queue. We use this
// for various tests of the microtask queue.
class CallableTask : public Microtask {
class CallableTask
: public TorqueGeneratedCallableTask<CallableTask, Microtask> {
public:
DECL_ACCESSORS(callable, JSReceiver)
DECL_ACCESSORS(context, Context)
DEFINE_FIELD_OFFSET_CONSTANTS(Microtask::kHeaderSize,
TORQUE_GENERATED_CALLABLE_TASK_FIELDS)
// Dispatched behavior.
DECL_CAST(CallableTask)
DECL_PRINTER(CallableTask)
DECL_VERIFIER(CallableTask)
void BriefPrintDetails(std::ostream& os);
OBJECT_CONSTRUCTORS(CallableTask, Microtask);
TQ_OBJECT_CONSTRUCTORS(CallableTask)
};
} // namespace internal
......
......@@ -20,37 +20,24 @@ namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Module, HeapObject)
OBJECT_CONSTRUCTORS_IMPL(SourceTextModule, Module)
OBJECT_CONSTRUCTORS_IMPL(SourceTextModuleInfoEntry, Struct)
OBJECT_CONSTRUCTORS_IMPL(SyntheticModule, Module)
OBJECT_CONSTRUCTORS_IMPL(JSModuleNamespace, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(SourceTextModule)
TQ_OBJECT_CONSTRUCTORS_IMPL(SourceTextModuleInfoEntry)
TQ_OBJECT_CONSTRUCTORS_IMPL(SyntheticModule)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSModuleNamespace)
NEVER_READ_ONLY_SPACE_IMPL(Module)
NEVER_READ_ONLY_SPACE_IMPL(SourceTextModule)
NEVER_READ_ONLY_SPACE_IMPL(SyntheticModule)
CAST_ACCESSOR(Module)
CAST_ACCESSOR(SourceTextModule)
CAST_ACCESSOR(SyntheticModule)
ACCESSORS(Module, exports, ObjectHashTable, kExportsOffset)
ACCESSORS(Module, module_namespace, HeapObject, kModuleNamespaceOffset)
ACCESSORS(Module, exception, Object, kExceptionOffset)
SMI_ACCESSORS(Module, status, kStatusOffset)
SMI_ACCESSORS(Module, hash, kHashOffset)
ACCESSORS(SourceTextModule, code, Object, kCodeOffset)
ACCESSORS(SourceTextModule, regular_exports, FixedArray, kRegularExportsOffset)
ACCESSORS(SourceTextModule, regular_imports, FixedArray, kRegularImportsOffset)
ACCESSORS(SourceTextModule, requested_modules, FixedArray,
kRequestedModulesOffset)
ACCESSORS(SourceTextModule, script, Script, kScriptOffset)
ACCESSORS(SourceTextModule, import_meta, Object, kImportMetaOffset)
SMI_ACCESSORS(SourceTextModule, dfs_index, kDfsIndexOffset)
SMI_ACCESSORS(SourceTextModule, dfs_ancestor_index, kDfsAncestorIndexOffset)
ACCESSORS(SyntheticModule, name, String, kNameOffset)
ACCESSORS(SyntheticModule, export_names, FixedArray, kExportNamesOffset)
ACCESSORS(SyntheticModule, evaluation_steps, Foreign, kEvaluationStepsOffset)
TQ_SMI_ACCESSORS(SourceTextModule, dfs_index)
TQ_SMI_ACCESSORS(SourceTextModule, dfs_ancestor_index)
SourceTextModuleInfo SourceTextModule::info() const {
return (status() >= kEvaluating)
......@@ -58,17 +45,10 @@ SourceTextModuleInfo SourceTextModule::info() const {
: GetSharedFunctionInfo().scope_info().ModuleDescriptorInfo();
}
CAST_ACCESSOR(JSModuleNamespace)
ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
CAST_ACCESSOR(SourceTextModuleInfoEntry)
ACCESSORS(SourceTextModuleInfoEntry, export_name, Object, kExportNameOffset)
ACCESSORS(SourceTextModuleInfoEntry, local_name, Object, kLocalNameOffset)
ACCESSORS(SourceTextModuleInfoEntry, import_name, Object, kImportNameOffset)
SMI_ACCESSORS(SourceTextModuleInfoEntry, module_request, kModuleRequestOffset)
SMI_ACCESSORS(SourceTextModuleInfoEntry, cell_index, kCellIndexOffset)
SMI_ACCESSORS(SourceTextModuleInfoEntry, beg_pos, kBegPosOffset)
SMI_ACCESSORS(SourceTextModuleInfoEntry, end_pos, kEndPosOffset)
TQ_SMI_ACCESSORS(SourceTextModuleInfoEntry, module_request)
TQ_SMI_ACCESSORS(SourceTextModuleInfoEntry, cell_index)
TQ_SMI_ACCESSORS(SourceTextModuleInfoEntry, beg_pos)
TQ_SMI_ACCESSORS(SourceTextModuleInfoEntry, end_pos)
OBJECT_CONSTRUCTORS_IMPL(SourceTextModuleInfo, FixedArray)
CAST_ACCESSOR(SourceTextModuleInfo)
......
......@@ -136,14 +136,10 @@ class Module : public HeapObject {
// When importing a module namespace (import * as foo from "bar"), a
// JSModuleNamespace object (representing module "bar") is created and bound to
// the declared variable (foo). A module can have at most one namespace object.
class JSModuleNamespace : public JSObject {
class JSModuleNamespace
: public TorqueGeneratedJSModuleNamespace<JSModuleNamespace, JSObject> {
public:
DECL_CAST(JSModuleNamespace)
DECL_PRINTER(JSModuleNamespace)
DECL_VERIFIER(JSModuleNamespace)
// The actual module whose namespace is being represented.
DECL_ACCESSORS(module, Module)
// Retrieve the value exported by [module] under the given [name]. If there is
// no such export, return Just(undefined). If the export is uninitialized,
......@@ -163,16 +159,12 @@ class JSModuleNamespace : public JSObject {
kInObjectFieldCount,
};
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSMODULE_NAMESPACE_FIELDS)
// We need to include in-object fields
// TODO(v8:8944): improve handling of in-object fields
static constexpr int kSize =
kHeaderSize + (kTaggedSize * kInObjectFieldCount);
OBJECT_CONSTRUCTORS(JSModuleNamespace, JSObject);
TQ_OBJECT_CONSTRUCTORS(JSModuleNamespace)
};
} // namespace internal
......
......@@ -16,41 +16,12 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(PromiseReactionJobTask, Microtask)
OBJECT_CONSTRUCTORS_IMPL(PromiseFulfillReactionJobTask, PromiseReactionJobTask)
OBJECT_CONSTRUCTORS_IMPL(PromiseRejectReactionJobTask, PromiseReactionJobTask)
OBJECT_CONSTRUCTORS_IMPL(PromiseResolveThenableJobTask, Microtask)
OBJECT_CONSTRUCTORS_IMPL(PromiseCapability, Struct)
OBJECT_CONSTRUCTORS_IMPL(PromiseReaction, Struct)
CAST_ACCESSOR(PromiseCapability)
CAST_ACCESSOR(PromiseReaction)
CAST_ACCESSOR(PromiseReactionJobTask)
CAST_ACCESSOR(PromiseFulfillReactionJobTask)
CAST_ACCESSOR(PromiseRejectReactionJobTask)
CAST_ACCESSOR(PromiseResolveThenableJobTask)
ACCESSORS(PromiseReaction, next, Object, kNextOffset)
ACCESSORS(PromiseReaction, reject_handler, HeapObject, kRejectHandlerOffset)
ACCESSORS(PromiseReaction, fulfill_handler, HeapObject, kFulfillHandlerOffset)
ACCESSORS(PromiseReaction, promise_or_capability, HeapObject,
kPromiseOrCapabilityOffset)
ACCESSORS(PromiseResolveThenableJobTask, context, Context, kContextOffset)
ACCESSORS(PromiseResolveThenableJobTask, promise_to_resolve, JSPromise,
kPromiseToResolveOffset)
ACCESSORS(PromiseResolveThenableJobTask, then, JSReceiver, kThenOffset)
ACCESSORS(PromiseResolveThenableJobTask, thenable, JSReceiver, kThenableOffset)
ACCESSORS(PromiseReactionJobTask, context, Context, kContextOffset)
ACCESSORS(PromiseReactionJobTask, argument, Object, kArgumentOffset)
ACCESSORS(PromiseReactionJobTask, handler, HeapObject, kHandlerOffset)
ACCESSORS(PromiseReactionJobTask, promise_or_capability, HeapObject,
kPromiseOrCapabilityOffset)
ACCESSORS(PromiseCapability, promise, HeapObject, kPromiseOffset)
ACCESSORS(PromiseCapability, resolve, Object, kResolveOffset)
ACCESSORS(PromiseCapability, reject, Object, kRejectOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseReactionJobTask)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseFulfillReactionJobTask)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseRejectReactionJobTask)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseResolveThenableJobTask)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseCapability)
TQ_OBJECT_CONSTRUCTORS_IMPL(PromiseReaction)
} // namespace internal
} // namespace v8
......
......@@ -24,93 +24,59 @@ class JSPromise;
//
// classes, which are used to represent either reactions, and we distinguish
// them by their instance types.
class PromiseReactionJobTask : public Microtask {
class PromiseReactionJobTask
: public TorqueGeneratedPromiseReactionJobTask<PromiseReactionJobTask,
Microtask> {
public:
DECL_ACCESSORS(argument, Object)
DECL_ACCESSORS(context, Context)
DECL_ACCESSORS(handler, HeapObject)
// [promise_or_capability]: Either a JSPromise (in case of native promises),
// a PromiseCapability (general case), or undefined (in case of await).
DECL_ACCESSORS(promise_or_capability, HeapObject)
DEFINE_FIELD_OFFSET_CONSTANTS(
Microtask::kHeaderSize, TORQUE_GENERATED_PROMISE_REACTION_JOB_TASK_FIELDS)
// Dispatched behavior.
DECL_CAST(PromiseReactionJobTask)
DECL_VERIFIER(PromiseReactionJobTask)
static const int kSizeOfAllPromiseReactionJobTasks = kHeaderSize;
OBJECT_CONSTRUCTORS(PromiseReactionJobTask, Microtask);
TQ_OBJECT_CONSTRUCTORS(PromiseReactionJobTask)
};
// Struct to hold state required for a PromiseReactionJob of type "Fulfill".
class PromiseFulfillReactionJobTask : public PromiseReactionJobTask {
class PromiseFulfillReactionJobTask
: public TorqueGeneratedPromiseFulfillReactionJobTask<
PromiseFulfillReactionJobTask, PromiseReactionJobTask> {
public:
// Dispatched behavior.
DECL_CAST(PromiseFulfillReactionJobTask)
DECL_PRINTER(PromiseFulfillReactionJobTask)
DECL_VERIFIER(PromiseFulfillReactionJobTask)
DEFINE_FIELD_OFFSET_CONSTANTS(
PromiseReactionJobTask::kHeaderSize,
TORQUE_GENERATED_PROMISE_FULFILL_REACTION_JOB_TASK_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllPromiseReactionJobTasks);
OBJECT_CONSTRUCTORS(PromiseFulfillReactionJobTask, PromiseReactionJobTask);
TQ_OBJECT_CONSTRUCTORS(PromiseFulfillReactionJobTask)
};
// Struct to hold state required for a PromiseReactionJob of type "Reject".
class PromiseRejectReactionJobTask : public PromiseReactionJobTask {
class PromiseRejectReactionJobTask
: public TorqueGeneratedPromiseRejectReactionJobTask<
PromiseRejectReactionJobTask, PromiseReactionJobTask> {
public:
// Dispatched behavior.
DECL_CAST(PromiseRejectReactionJobTask)
DECL_PRINTER(PromiseRejectReactionJobTask)
DECL_VERIFIER(PromiseRejectReactionJobTask)
DEFINE_FIELD_OFFSET_CONSTANTS(
PromiseReactionJobTask::kHeaderSize,
TORQUE_GENERATED_PROMISE_REJECT_REACTION_JOB_TASK_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllPromiseReactionJobTasks);
OBJECT_CONSTRUCTORS(PromiseRejectReactionJobTask, PromiseReactionJobTask);
TQ_OBJECT_CONSTRUCTORS(PromiseRejectReactionJobTask)
};
// A container struct to hold state required for PromiseResolveThenableJob.
class PromiseResolveThenableJobTask : public Microtask {
class PromiseResolveThenableJobTask
: public TorqueGeneratedPromiseResolveThenableJobTask<
PromiseResolveThenableJobTask, Microtask> {
public:
DECL_ACCESSORS(context, Context)
DECL_ACCESSORS(promise_to_resolve, JSPromise)
DECL_ACCESSORS(then, JSReceiver)
DECL_ACCESSORS(thenable, JSReceiver)
DEFINE_FIELD_OFFSET_CONSTANTS(
Microtask::kHeaderSize,
TORQUE_GENERATED_PROMISE_RESOLVE_THENABLE_JOB_TASK_FIELDS)
// Dispatched behavior.
DECL_CAST(PromiseResolveThenableJobTask)
DECL_PRINTER(PromiseResolveThenableJobTask)
DECL_VERIFIER(PromiseResolveThenableJobTask)
OBJECT_CONSTRUCTORS(PromiseResolveThenableJobTask, Microtask);
TQ_OBJECT_CONSTRUCTORS(PromiseResolveThenableJobTask)
};
// Struct to hold the state of a PromiseCapability.
class PromiseCapability : public Struct {
class PromiseCapability
: public TorqueGeneratedPromiseCapability<PromiseCapability, Struct> {
public:
DECL_ACCESSORS(promise, HeapObject)
DECL_ACCESSORS(resolve, Object)
DECL_ACCESSORS(reject, Object)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_PROMISE_CAPABILITY_FIELDS)
// Dispatched behavior.
DECL_CAST(PromiseCapability)
DECL_PRINTER(PromiseCapability)
DECL_VERIFIER(PromiseCapability)
OBJECT_CONSTRUCTORS(PromiseCapability, Struct);
TQ_OBJECT_CONSTRUCTORS(PromiseCapability)
};
// A representation of promise reaction. This differs from the specification
......@@ -130,26 +96,15 @@ class PromiseCapability : public Struct {
// Smi 0. On the JSPromise instance they are linked in reverse order,
// and are turned into the proper order again when scheduling them on
// the microtask queue.
class PromiseReaction : public Struct {
class PromiseReaction
: public TorqueGeneratedPromiseReaction<PromiseReaction, Struct> {
public:
enum Type { kFulfill, kReject };
DECL_ACCESSORS(next, Object)
DECL_ACCESSORS(reject_handler, HeapObject)
DECL_ACCESSORS(fulfill_handler, HeapObject)
// [promise_or_capability]: Either a JSPromise (in case of native promises),
// a PromiseCapability (general case), or undefined (in case of await).
DECL_ACCESSORS(promise_or_capability, HeapObject)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_PROMISE_REACTION_FIELDS)
// Dispatched behavior.
DECL_CAST(PromiseReaction)
DECL_PRINTER(PromiseReaction)
DECL_VERIFIER(PromiseReaction)
OBJECT_CONSTRUCTORS(PromiseReaction, Struct);
TQ_OBJECT_CONSTRUCTORS(PromiseReaction)
};
} // namespace internal
......
......@@ -879,9 +879,9 @@ std::ostream& operator<<(std::ostream& os,
}
Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
Isolate* isolate, Handle<Object> export_name, Handle<Object> local_name,
Handle<Object> import_name, int module_request, int cell_index, int beg_pos,
int end_pos) {
Isolate* isolate, Handle<HeapObject> export_name,
Handle<HeapObject> local_name, Handle<HeapObject> import_name,
int module_request, int cell_index, int beg_pos, int end_pos) {
Handle<SourceTextModuleInfoEntry> result =
Handle<SourceTextModuleInfoEntry>::cast(isolate->factory()->NewStruct(
SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, AllocationType::kOld));
......
......@@ -380,7 +380,7 @@ bool SourceTextModule::RunInitializationCode(Isolate* isolate,
return false;
}
DCHECK_EQ(*function, Handle<JSGeneratorObject>::cast(generator)->function());
module->set_code(*generator);
module->set_code(JSGeneratorObject::cast(*generator));
return true;
}
......
......@@ -17,43 +17,17 @@ class UnorderedModuleSet;
// The runtime representation of an ECMAScript Source Text Module Record.
// https://tc39.github.io/ecma262/#sec-source-text-module-records
class SourceTextModule : public Module {
class SourceTextModule
: public TorqueGeneratedSourceTextModule<SourceTextModule, Module> {
public:
NEVER_READ_ONLY_SPACE
DECL_CAST(SourceTextModule)
DECL_VERIFIER(SourceTextModule)
DECL_PRINTER(SourceTextModule)
// The code representing this module, or an abstraction thereof.
// This is either a SharedFunctionInfo, a JSFunction, a JSGeneratorObject, or
// a SourceTextModuleInfo, depending on the state (status) the module is in.
// See SourceTextModule::SourceTextModuleVerify() for the precise invariant.
DECL_ACCESSORS(code, Object)
// Arrays of cells corresponding to regular exports and regular imports.
// A cell's position in the array is determined by the cell index of the
// associated module entry (which coincides with the variable index of the
// associated variable).
DECL_ACCESSORS(regular_exports, FixedArray)
DECL_ACCESSORS(regular_imports, FixedArray)
// The shared function info in case {status} is not kEvaluating, kEvaluated or
// kErrored.
SharedFunctionInfo GetSharedFunctionInfo() const;
// Modules imported or re-exported by this module.
// Corresponds 1-to-1 to the module specifier strings in
// SourceTextModuleInfo::module_requests.
DECL_ACCESSORS(requested_modules, FixedArray)
// [script]: Script from which the module originates.
DECL_ACCESSORS(script, Script)
// The value of import.meta inside of this module.
// Lazily initialized on first access. It's the hole before first access and
// a JSObject afterwards.
DECL_ACCESSORS(import_meta, Object)
// Get the SourceTextModuleInfo associated with the code.
inline SourceTextModuleInfo info() const;
......@@ -72,10 +46,6 @@ class SourceTextModule : public Module {
static Handle<JSModuleNamespace> GetModuleNamespace(
Isolate* isolate, Handle<SourceTextModule> module, int module_request);
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(Module::kHeaderSize,
TORQUE_GENERATED_SOURCE_TEXT_MODULE_FIELDS)
using BodyDescriptor =
SubclassBodyDescriptor<Module::BodyDescriptor,
FixedBodyDescriptor<kCodeOffset, kSize, kSize>>;
......@@ -135,7 +105,7 @@ class SourceTextModule : public Module {
static void Reset(Isolate* isolate, Handle<SourceTextModule> module);
OBJECT_CONSTRUCTORS(SourceTextModule, Module);
TQ_OBJECT_CONSTRUCTORS(SourceTextModule)
};
// SourceTextModuleInfo is to SourceTextModuleDescriptor what ScopeInfo is to
......@@ -186,30 +156,24 @@ class SourceTextModuleInfo : public FixedArray {
OBJECT_CONSTRUCTORS(SourceTextModuleInfo, FixedArray);
};
class SourceTextModuleInfoEntry : public Struct {
class SourceTextModuleInfoEntry
: public TorqueGeneratedSourceTextModuleInfoEntry<SourceTextModuleInfoEntry,
Struct> {
public:
DECL_CAST(SourceTextModuleInfoEntry)
DECL_PRINTER(SourceTextModuleInfoEntry)
DECL_VERIFIER(SourceTextModuleInfoEntry)
DECL_ACCESSORS(export_name, Object)
DECL_ACCESSORS(local_name, Object)
DECL_ACCESSORS(import_name, Object)
DECL_INT_ACCESSORS(module_request)
DECL_INT_ACCESSORS(cell_index)
DECL_INT_ACCESSORS(beg_pos)
DECL_INT_ACCESSORS(end_pos)
static Handle<SourceTextModuleInfoEntry> New(
Isolate* isolate, Handle<Object> export_name, Handle<Object> local_name,
Handle<Object> import_name, int module_request, int cell_index,
int beg_pos, int end_pos);
DEFINE_FIELD_OFFSET_CONSTANTS(
Struct::kHeaderSize,
TORQUE_GENERATED_SOURCE_TEXT_MODULE_INFO_ENTRY_FIELDS)
Isolate* isolate, Handle<HeapObject> export_name,
Handle<HeapObject> local_name, Handle<HeapObject> import_name,
int module_request, int cell_index, int beg_pos, int end_pos);
OBJECT_CONSTRUCTORS(SourceTextModuleInfoEntry, Struct);
TQ_OBJECT_CONSTRUCTORS(SourceTextModuleInfoEntry)
};
} // namespace internal
......
......@@ -49,14 +49,11 @@ BOOL_ACCESSORS(StackFrameInfo, flag, is_toplevel, kIsToplevelBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_async, kIsAsyncBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_promise_all, kIsPromiseAllBit)
OBJECT_CONSTRUCTORS_IMPL(StackTraceFrame, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(StackTraceFrame)
NEVER_READ_ONLY_SPACE_IMPL(StackTraceFrame)
CAST_ACCESSOR(StackTraceFrame)
ACCESSORS(StackTraceFrame, frame_array, Object, kFrameArrayOffset)
SMI_ACCESSORS(StackTraceFrame, frame_index, kFrameIndexOffset)
ACCESSORS(StackTraceFrame, frame_info, Object, kFrameInfoOffset)
SMI_ACCESSORS(StackTraceFrame, id, kIdOffset)
TQ_SMI_ACCESSORS(StackTraceFrame, frame_index)
TQ_SMI_ACCESSORS(StackTraceFrame, id)
} // namespace internal
} // namespace v8
......
......@@ -71,22 +71,15 @@ class StackFrameInfo : public Struct {
// The first time any of the Get* or Is* methods is called, a
// StackFrameInfo object is allocated and all necessary information
// retrieved.
class StackTraceFrame : public Struct {
class StackTraceFrame
: public TorqueGeneratedStackTraceFrame<StackTraceFrame, Struct> {
public:
NEVER_READ_ONLY_SPACE
DECL_ACCESSORS(frame_array, Object)
DECL_INT_ACCESSORS(frame_index)
DECL_ACCESSORS(frame_info, Object)
DECL_INT_ACCESSORS(id)
DECL_CAST(StackTraceFrame)
// Dispatched behavior.
DECL_PRINTER(StackTraceFrame)
DECL_VERIFIER(StackTraceFrame)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_STACK_TRACE_FRAME_FIELDS)
static int GetLineNumber(Handle<StackTraceFrame> frame);
static int GetOneBasedLineNumber(Handle<StackTraceFrame> frame);
......@@ -116,10 +109,10 @@ class StackTraceFrame : public Struct {
static bool IsPromiseAll(Handle<StackTraceFrame> frame);
private:
OBJECT_CONSTRUCTORS(StackTraceFrame, Struct);
static Handle<StackFrameInfo> GetFrameInfo(Handle<StackTraceFrame> frame);
static void InitializeFrameInfo(Handle<StackTraceFrame> frame);
TQ_OBJECT_CONSTRUCTORS(StackTraceFrame)
};
// Small helper that retrieves the FrameArray from a stack-trace
......
......@@ -24,10 +24,9 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2)
TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple3)
OBJECT_CONSTRUCTORS_IMPL(AccessorPair, Struct)
OBJECT_CONSTRUCTORS_IMPL(ClassPositions, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(ClassPositions)
CAST_ACCESSOR(AccessorPair)
CAST_ACCESSOR(ClassPositions)
void Struct::InitializeBody(int object_size) {
Object value = GetReadOnlyRoots().undefined_value();
......@@ -39,8 +38,8 @@ void Struct::InitializeBody(int object_size) {
ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
SMI_ACCESSORS(ClassPositions, start, kStartOffset)
SMI_ACCESSORS(ClassPositions, end, kEndOffset)
TQ_SMI_ACCESSORS(ClassPositions, start)
TQ_SMI_ACCESSORS(ClassPositions, end)
Object AccessorPair::get(AccessorComponent component) {
return component == ACCESSOR_GETTER ? getter() : setter();
......
......@@ -80,22 +80,17 @@ class AccessorPair : public Struct {
OBJECT_CONSTRUCTORS(AccessorPair, Struct);
};
class ClassPositions : public Struct {
class ClassPositions
: public TorqueGeneratedClassPositions<ClassPositions, Struct> {
public:
DECL_INT_ACCESSORS(start)
DECL_INT_ACCESSORS(end)
DECL_CAST(ClassPositions)
// Dispatched behavior.
DECL_PRINTER(ClassPositions)
DECL_VERIFIER(ClassPositions)
void BriefPrintDetails(std::ostream& os);
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_CLASS_POSITIONS_FIELDS)
OBJECT_CONSTRUCTORS(ClassPositions, Struct);
TQ_OBJECT_CONSTRUCTORS(ClassPositions)
};
} // namespace internal
......
......@@ -17,26 +17,17 @@ namespace internal {
// instantiated by an embedder with embedder-defined exports and evaluation
// steps.
// https://heycam.github.io/webidl/#synthetic-module-records
class SyntheticModule : public Module {
class SyntheticModule
: public TorqueGeneratedSyntheticModule<SyntheticModule, Module> {
public:
NEVER_READ_ONLY_SPACE
DECL_CAST(SyntheticModule)
DECL_VERIFIER(SyntheticModule)
DECL_PRINTER(SyntheticModule)
// The list of all names exported by this module
DECL_ACCESSORS(name, String)
DECL_ACCESSORS(export_names, FixedArray)
DECL_ACCESSORS(evaluation_steps, Foreign)
static void SetExport(Isolate* isolate, Handle<SyntheticModule> module,
Handle<String> export_name,
Handle<Object> export_value);
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(Module::kHeaderSize,
TORQUE_GENERATED_SYNTHETIC_MODULE_FIELDS)
using BodyDescriptor = SubclassBodyDescriptor<
Module::BodyDescriptor,
FixedBodyDescriptor<kExportNamesOffset, kSize, kSize>>;
......@@ -58,7 +49,7 @@ class SyntheticModule : public Module {
static V8_WARN_UNUSED_RESULT MaybeHandle<Object> Evaluate(
Isolate* isolate, Handle<SyntheticModule> module);
OBJECT_CONSTRUCTORS(SyntheticModule, Module);
TQ_OBJECT_CONSTRUCTORS(SyntheticModule)
};
} // namespace internal
......
......@@ -15,16 +15,11 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(TemplateObjectDescription, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(TemplateObjectDescription)
OBJECT_CONSTRUCTORS_IMPL(CachedTemplateObject, Tuple3)
CAST_ACCESSOR(TemplateObjectDescription)
CAST_ACCESSOR(CachedTemplateObject)
ACCESSORS(TemplateObjectDescription, raw_strings, FixedArray, kRawStringsOffset)
ACCESSORS(TemplateObjectDescription, cooked_strings, FixedArray,
kCookedStringsOffset)
SMI_ACCESSORS(CachedTemplateObject, slot_id, kSlotIdOffset)
ACCESSORS(CachedTemplateObject, template_object, JSArray, kTemplateObjectOffset)
ACCESSORS(CachedTemplateObject, next, HeapObject, kNextOffset)
......
......@@ -39,25 +39,16 @@ class CachedTemplateObject final : public Tuple3 {
// TemplateObjectDescription is a tuple of raw strings and cooked strings for
// tagged template literals. Used to communicate with the runtime for template
// object creation within the {Runtime_GetTemplateObject} method.
class TemplateObjectDescription final : public Struct {
class TemplateObjectDescription final
: public TorqueGeneratedTemplateObjectDescription<TemplateObjectDescription,
Struct> {
public:
DECL_ACCESSORS(raw_strings, FixedArray)
DECL_ACCESSORS(cooked_strings, FixedArray)
DECL_CAST(TemplateObjectDescription)
static Handle<JSArray> GetTemplateObject(
Isolate* isolate, Handle<NativeContext> native_context,
Handle<TemplateObjectDescription> description,
Handle<SharedFunctionInfo> shared_info, int slot_id);
DECL_PRINTER(TemplateObjectDescription)
DECL_VERIFIER(TemplateObjectDescription)
DEFINE_FIELD_OFFSET_CONSTANTS(
Struct::kHeaderSize, TORQUE_GENERATED_TEMPLATE_OBJECT_DESCRIPTION_FIELDS)
OBJECT_CONSTRUCTORS(TemplateObjectDescription, Struct);
TQ_OBJECT_CONSTRUCTORS(TemplateObjectDescription)
};
} // namespace internal
......
......@@ -17,29 +17,16 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(TemplateInfo, Struct)
OBJECT_CONSTRUCTORS_IMPL(FunctionTemplateInfo, TemplateInfo)
OBJECT_CONSTRUCTORS_IMPL(ObjectTemplateInfo, TemplateInfo)
OBJECT_CONSTRUCTORS_IMPL(FunctionTemplateRareData, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(TemplateInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(FunctionTemplateInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(ObjectTemplateInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(FunctionTemplateRareData)
NEVER_READ_ONLY_SPACE_IMPL(TemplateInfo)
ACCESSORS(TemplateInfo, tag, Object, kTagOffset)
ACCESSORS(TemplateInfo, serial_number, Object, kSerialNumberOffset)
SMI_ACCESSORS(TemplateInfo, number_of_properties, kNumberOfPropertiesOffset)
ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)
ACCESSORS(TemplateInfo, property_accessors, Object, kPropertyAccessorsOffset)
ACCESSORS(FunctionTemplateInfo, call_code, Object, kCallCodeOffset)
ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)
ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)
ACCESSORS(FunctionTemplateInfo, shared_function_info, Object,
kSharedFunctionInfoOffset)
ACCESSORS(FunctionTemplateInfo, rare_data, HeapObject,
kFunctionTemplateRareDataOffset)
ACCESSORS(FunctionTemplateInfo, cached_property_name, Object,
kCachedPropertyNameOffset)
SMI_ACCESSORS(FunctionTemplateInfo, length, kLengthOffset)
TQ_SMI_ACCESSORS(TemplateInfo, number_of_properties)
TQ_SMI_ACCESSORS(FunctionTemplateInfo, length)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check,
kNeedsAccessCheckBit)
......@@ -50,7 +37,7 @@ BOOL_ACCESSORS(FunctionTemplateInfo, flag, remove_prototype,
BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache, kDoNotCacheBit)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
kAcceptAnyReceiver)
SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset)
TQ_SMI_ACCESSORS(FunctionTemplateInfo, flag)
// static
FunctionTemplateRareData FunctionTemplateInfo::EnsureFunctionTemplateRareData(
......@@ -88,31 +75,6 @@ RARE_ACCESSORS(instance_call_handler, InstanceCallHandler, Object)
RARE_ACCESSORS(access_check_info, AccessCheckInfo, Object)
#undef RARE_ACCESSORS
ACCESSORS(FunctionTemplateRareData, prototype_template, Object,
kPrototypeTemplateOffset)
ACCESSORS(FunctionTemplateRareData, prototype_provider_template, Object,
kPrototypeProviderTemplateOffset)
ACCESSORS(FunctionTemplateRareData, parent_template, Object,
kParentTemplateOffset)
ACCESSORS(FunctionTemplateRareData, named_property_handler, Object,
kNamedPropertyHandlerOffset)
ACCESSORS(FunctionTemplateRareData, indexed_property_handler, Object,
kIndexedPropertyHandlerOffset)
ACCESSORS(FunctionTemplateRareData, instance_template, Object,
kInstanceTemplateOffset)
ACCESSORS(FunctionTemplateRareData, instance_call_handler, Object,
kInstanceCallHandlerOffset)
ACCESSORS(FunctionTemplateRareData, access_check_info, Object,
kAccessCheckInfoOffset)
ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset)
CAST_ACCESSOR(TemplateInfo)
CAST_ACCESSOR(FunctionTemplateInfo)
CAST_ACCESSOR(FunctionTemplateRareData)
CAST_ACCESSOR(ObjectTemplateInfo)
bool FunctionTemplateInfo::instantiated() {
return shared_function_info().IsSharedFunctionInfo();
}
......
......@@ -13,21 +13,10 @@
namespace v8 {
namespace internal {
class TemplateInfo : public Struct {
class TemplateInfo : public TorqueGeneratedTemplateInfo<TemplateInfo, Struct> {
public:
NEVER_READ_ONLY_SPACE
DECL_ACCESSORS(tag, Object)
DECL_ACCESSORS(serial_number, Object)
DECL_INT_ACCESSORS(number_of_properties)
DECL_ACCESSORS(property_list, Object)
DECL_ACCESSORS(property_accessors, Object)
DECL_VERIFIER(TemplateInfo)
DECL_CAST(TemplateInfo)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_TEMPLATE_INFO_FIELDS)
static const int kFastTemplateInstantiationsCacheSize = 1 * KB;
......@@ -36,55 +25,25 @@ class TemplateInfo : public Struct {
// instead of caching them.
static const int kSlowTemplateInstantiationsCacheSize = 1 * MB;
OBJECT_CONSTRUCTORS(TemplateInfo, Struct);
TQ_OBJECT_CONSTRUCTORS(TemplateInfo)
};
// Contains data members that are rarely set on a FunctionTemplateInfo.
class FunctionTemplateRareData : public Struct {
class FunctionTemplateRareData
: public TorqueGeneratedFunctionTemplateRareData<FunctionTemplateRareData,
Struct> {
public:
// See DECL_RARE_ACCESSORS in FunctionTemplateInfo.
DECL_ACCESSORS(prototype_template, Object)
DECL_ACCESSORS(prototype_provider_template, Object)
DECL_ACCESSORS(parent_template, Object)
DECL_ACCESSORS(named_property_handler, Object)
DECL_ACCESSORS(indexed_property_handler, Object)
DECL_ACCESSORS(instance_template, Object)
DECL_ACCESSORS(instance_call_handler, Object)
DECL_ACCESSORS(access_check_info, Object)
DECL_CAST(FunctionTemplateRareData)
// Dispatched behavior.
DECL_PRINTER(FunctionTemplateRareData)
DECL_VERIFIER(FunctionTemplateRareData)
DEFINE_FIELD_OFFSET_CONSTANTS(
HeapObject::kHeaderSize,
TORQUE_GENERATED_FUNCTION_TEMPLATE_RARE_DATA_FIELDS)
OBJECT_CONSTRUCTORS(FunctionTemplateRareData, Struct);
TQ_OBJECT_CONSTRUCTORS(FunctionTemplateRareData)
};
// See the api-exposed FunctionTemplate for more information.
class FunctionTemplateInfo : public TemplateInfo {
class FunctionTemplateInfo
: public TorqueGeneratedFunctionTemplateInfo<FunctionTemplateInfo,
TemplateInfo> {
public:
// Handler invoked when calling an instance of this FunctionTemplateInfo.
// Either CallInfoHandler or Undefined.
DECL_ACCESSORS(call_code, Object)
DECL_ACCESSORS(class_name, Object)
// If the signature is a FunctionTemplateInfo it is used to check whether the
// receiver calling the associated JSFunction is a compatible receiver, i.e.
// it is an instance of the signature FunctionTemplateInfo or any of the
// receiver's prototypes are.
DECL_ACCESSORS(signature, Object)
// If any of the setters below declared by DECL_RARE_ACCESSORS are used then
// a FunctionTemplateRareData will be stored here. Until then this contains
// undefined.
DECL_ACCESSORS(rare_data, HeapObject)
#define DECL_RARE_ACCESSORS(Name, CamelName, Type) \
DECL_GETTER(Get##CamelName, Type) \
static inline void Set##CamelName( \
......@@ -125,19 +84,12 @@ class FunctionTemplateInfo : public TemplateInfo {
DECL_RARE_ACCESSORS(access_check_info, AccessCheckInfo, Object)
#undef DECL_RARE_ACCESSORS
DECL_ACCESSORS(shared_function_info, Object)
// Internal field to store a flag bitfield.
DECL_INT_ACCESSORS(flag)
// "length" property of the final JSFunction.
DECL_INT_ACCESSORS(length)
// Either the_hole or a private symbol. Used to cache the result on
// the receiver under the the cached_property_name when this
// FunctionTemplateInfo is used as a getter.
DECL_ACCESSORS(cached_property_name, Object)
// Begin flag bits ---------------------
DECL_BOOLEAN_ACCESSORS(undetectable)
......@@ -160,17 +112,11 @@ class FunctionTemplateInfo : public TemplateInfo {
DECL_BOOLEAN_ACCESSORS(accept_any_receiver)
// End flag bits ---------------------
DECL_CAST(FunctionTemplateInfo)
// Dispatched behavior.
DECL_PRINTER(FunctionTemplateInfo)
DECL_VERIFIER(FunctionTemplateInfo)
static const int kInvalidSerialNumber = 0;
DEFINE_FIELD_OFFSET_CONSTANTS(TemplateInfo::kHeaderSize,
TORQUE_GENERATED_FUNCTION_TEMPLATE_INFO_FIELDS)
static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
Isolate* isolate, Handle<FunctionTemplateInfo> info,
MaybeHandle<Name> maybe_name);
......@@ -202,25 +148,18 @@ class FunctionTemplateInfo : public TemplateInfo {
static FunctionTemplateRareData AllocateFunctionTemplateRareData(
Isolate* isolate, Handle<FunctionTemplateInfo> function_template_info);
OBJECT_CONSTRUCTORS(FunctionTemplateInfo, TemplateInfo);
TQ_OBJECT_CONSTRUCTORS(FunctionTemplateInfo)
};
class ObjectTemplateInfo : public TemplateInfo {
class ObjectTemplateInfo
: public TorqueGeneratedObjectTemplateInfo<ObjectTemplateInfo,
TemplateInfo> {
public:
DECL_ACCESSORS(constructor, Object)
DECL_ACCESSORS(data, Object)
DECL_INT_ACCESSORS(embedder_field_count)
DECL_BOOLEAN_ACCESSORS(immutable_proto)
DECL_CAST(ObjectTemplateInfo)
// Dispatched behavior.
DECL_PRINTER(ObjectTemplateInfo)
DECL_VERIFIER(ObjectTemplateInfo)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(TemplateInfo::kHeaderSize,
TORQUE_GENERATED_OBJECT_TEMPLATE_INFO_FIELDS)
// Starting from given object template's constructor walk up the inheritance
// chain till a function template that has an instance template is found.
......@@ -230,7 +169,7 @@ class ObjectTemplateInfo : public TemplateInfo {
using IsImmutablePrototype = BitField<bool, 0, 1>;
using EmbedderFieldCount = IsImmutablePrototype::Next<int, 29>;
OBJECT_CONSTRUCTORS(ObjectTemplateInfo, TemplateInfo);
TQ_OBJECT_CONSTRUCTORS(ObjectTemplateInfo)
};
} // namespace internal
......
......@@ -2943,6 +2943,7 @@ void ImplementationVisitor::GenerateClassFieldOffsets(
// TODO(danno): Remove this once all classes use ClassFieldOffsetGenerator
// to generate field offsets without the use of macros.
if (!type->GenerateCppClassDefinitions()) {
MacroFieldOffsetsGenerator g(header, type);
for (auto f : type->fields()) {
CurrentSourcePosition::Scope scope(f.pos);
......@@ -2952,6 +2953,7 @@ void ImplementationVisitor::GenerateClassFieldOffsets(
header << "\n";
}
}
}
const std::string output_header_path = output_directory + "/" + file_name;
WriteFile(output_header_path, header.str());
}
......@@ -3028,8 +3030,6 @@ class CppClassGenerator {
};
void CppClassGenerator::GenerateClass() {
hdr_ << "class " << name_ << ";\n\n";
hdr_ << template_decl() << "\n";
hdr_ << "class " << gen_name_ << " : public P {\n";
hdr_ << " static_assert(std::is_same<" << name_ << ", D>::value,\n"
......@@ -3201,9 +3201,9 @@ void CppClassGenerator::GenerateFieldAccessorForObject(const Field& f) {
DCHECK(field_type->IsSubtypeOf(TypeOracle::GetObjectType()));
const std::string& name = f.name_and_type.name;
const std::string offset = "k" + CamelifyString(name) + "Offset";
const ClassType* class_type = ClassType::DynamicCast(field_type);
base::Optional<const ClassType*> class_type = field_type->ClassSupertype();
std::string type = class_type ? class_type->name() : "Object";
std::string type = class_type ? (*class_type)->name() : "Object";
// Generate declarations in header.
if (!class_type && field_type != TypeOracle::GetObjectType()) {
......@@ -3275,20 +3275,42 @@ void ImplementationVisitor::GenerateClassDefinitions(
IncludeGuardScope inline_header_guard(inline_header, basename + "-inl.h");
inline_header << "#include \"torque-generated/class-definitions-tq.h\"\n\n";
inline_header << "#include \"src/objects/objects-inl.h\"\n\n";
inline_header << "#include \"src/objects/js-promise.h\"\n";
inline_header << "#include \"src/objects/module.h\"\n";
inline_header << "#include \"src/objects/objects-inl.h\"\n";
inline_header << "#include \"src/objects/script.h\"\n\n";
IncludeObjectMacrosScope inline_header_macros(inline_header);
NamespaceScope inline_header_namespaces(inline_header, {"v8", "internal"});
implementation
<< "#include \"torque-generated/class-definitions-tq.h\"\n\n";
implementation << "#include \"torque-generated/class-verifiers-tq.h\"\n\n";
implementation << "#include \"src/objects/struct-inl.h\"\n\n";
implementation << "#include \"src/objects/arguments-inl.h\"\n";
implementation << "#include \"src/objects/js-collection-inl.h\"\n";
implementation << "#include \"src/objects/embedder-data-array-inl.h\"\n";
implementation << "#include \"src/objects/js-generator-inl.h\"\n";
implementation << "#include \"src/objects/js-regexp-inl.h\"\n";
implementation
<< "#include \"src/objects/js-regexp-string-iterator-inl.h\"\n";
implementation << "#include \"src/objects/literal-objects-inl.h\"\n";
implementation << "#include \"src/objects/microtask-inl.h\"\n";
implementation << "#include \"src/objects/module-inl.h\"\n";
implementation << "#include \"src/objects/promise-inl.h\"\n";
implementation << "#include \"src/objects/stack-frame-info-inl.h\"\n";
implementation << "#include \"src/objects/struct-inl.h\"\n";
implementation << "#include \"src/objects/template-objects-inl.h\"\n\n";
implementation
<< "#include "
"\"torque-generated/internal-class-definitions-tq-inl.h\"\n\n";
NamespaceScope implementation_namespaces(implementation,
{"v8", "internal"});
// Generate forward declarations for every class.
for (const TypeAlias* alias : GlobalContext::GetClasses()) {
const ClassType* type = ClassType::DynamicCast(alias->type());
header << "class " << type->name() << ";\n";
}
for (const TypeAlias* alias : GlobalContext::GetClasses()) {
const ClassType* type = ClassType::DynamicCast(alias->type());
if (type->GenerateCppClassDefinitions()) {
......
......@@ -28,7 +28,7 @@ namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(WasmExceptionObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(WasmExceptionTag, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExceptionTag)
OBJECT_CONSTRUCTORS_IMPL(WasmExportedFunctionData, Struct)
OBJECT_CONSTRUCTORS_IMPL(WasmDebugInfo, Struct)
OBJECT_CONSTRUCTORS_IMPL(WasmGlobalObject, JSObject)
......@@ -42,7 +42,6 @@ NEVER_READ_ONLY_SPACE_IMPL(WasmDebugInfo)
CAST_ACCESSOR(WasmDebugInfo)
CAST_ACCESSOR(WasmExceptionObject)
CAST_ACCESSOR(WasmExceptionTag)
CAST_ACCESSOR(WasmExportedFunctionData)
CAST_ACCESSOR(WasmGlobalObject)
CAST_ACCESSOR(WasmInstanceObject)
......@@ -403,7 +402,7 @@ wasm::ValueType WasmTableObject::type() {
bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; }
// WasmExceptionTag
SMI_ACCESSORS(WasmExceptionTag, index, kIndexOffset)
TQ_SMI_ACCESSORS(WasmExceptionTag, index)
// AsmWasmData
ACCESSORS(AsmWasmData, managed_native_module, Managed<wasm::NativeModule>,
......
......@@ -921,7 +921,8 @@ class WasmDebugInfo : public Struct {
// header. They are referenced by the following fields:
// - {WasmExceptionObject::exception_tag} : The tag of the exception object.
// - {WasmInstanceObject::exceptions_table}: List of tags used by an instance.
class WasmExceptionTag : public Struct {
class WasmExceptionTag
: public TorqueGeneratedWasmExceptionTag<WasmExceptionTag, Struct> {
public:
V8_EXPORT_PRIVATE static Handle<WasmExceptionTag> New(Isolate* isolate,
int index);
......@@ -931,14 +932,9 @@ class WasmExceptionTag : public Struct {
// least one field, hence this also serves as a padding field for now.
DECL_INT_ACCESSORS(index)
DECL_CAST(WasmExceptionTag)
DECL_PRINTER(WasmExceptionTag)
DECL_VERIFIER(WasmExceptionTag)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_WASM_EXCEPTION_TAG_FIELDS)
OBJECT_CONSTRUCTORS(WasmExceptionTag, Struct);
TQ_OBJECT_CONSTRUCTORS(WasmExceptionTag)
};
class AsmWasmData : public Struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment