Commit 334b94e1 authored by Seth Brenith's avatar Seth Brenith Committed by V8 LUCI CQ

[cleanup] Use @generateCppClass on more classes

Most Torque-defined extern classes already use @generateCppClass. As
Nico pointed out in [1], it would be nice to convert the remaining
classes and remove this option. This change converts most of those
remaining classes. I know that the future of Torque-defined classes is a
subject of some debate right now, but I think that it's worth doing a
few mechanical changes to reduce the existing variety of options.

Changes that don't exactly follow the usual pattern:
1. BigIntBase, MutableBigInt: we can define these without a body, and
   then Torque treats them as "really external" rather than "kind of
   external, but with some Torque-generated parts".
2. RegExpMatchInfo: moved its inline functions into a separate file,
   which the generated -tq.cc file requires.

[1] https://docs.google.com/document/d/1q_gZLnXd4bGnCx3IUfbln46K3bSs9UHBGasy9McQtHI/edit#

Bug: v8:8952
Change-Id: I84c7958a295caa0bab847683c05022e18c921cad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3027742Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#75817}
parent 0f987f48
......@@ -214,7 +214,7 @@ extern class GlobalDictionary extends HashTable;
extern class SimpleNumberDictionary extends HashTable;
extern class EphemeronHashTable extends HashTable;
type ObjectHashTable extends HashTable
generates 'TNode<ObjectHashTable>';
generates 'TNode<ObjectHashTable>' constexpr 'ObjectHashTable';
extern class NumberDictionary extends HashTable;
type RawPtr generates 'TNode<RawPtrT>' constexpr 'Address';
......
......@@ -289,6 +289,10 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
StoreHandler::cast(*this).StoreHandlerVerify(isolate);
break;
case BIG_INT_BASE_TYPE:
BigIntBase::cast(*this).BigIntBaseVerify(isolate);
break;
case JS_PROMISE_CONSTRUCTOR_TYPE:
case JS_REG_EXP_CONSTRUCTOR_TYPE:
case JS_ARRAY_CONSTRUCTOR_TYPE:
......@@ -330,15 +334,7 @@ void BytecodeArray::BytecodeArrayVerify(Isolate* isolate) {
// - Jumps must go to new instructions starts.
// - No Illegal bytecodes.
// - No consecutive sequences of prefix Wide / ExtraWide.
CHECK(IsBytecodeArray(isolate));
CHECK(constant_pool(isolate).IsFixedArray(isolate));
VerifyHeapPointer(isolate, constant_pool(isolate));
{
Object table = source_position_table(isolate, kAcquireLoad);
CHECK(table.IsUndefined(isolate) || table.IsException(isolate) ||
table.IsByteArray(isolate));
}
CHECK(handler_table(isolate).IsByteArray(isolate));
TorqueGeneratedClassVerifiers::BytecodeArrayVerify(*this, isolate);
for (int i = 0; i < constant_pool(isolate).length(); ++i) {
// No ThinStrings in the constant pool.
CHECK(!constant_pool(isolate).get(isolate, i).IsThinString(isolate));
......@@ -1490,7 +1486,6 @@ void AsyncGeneratorRequest::AsyncGeneratorRequestVerify(Isolate* isolate) {
}
void BigIntBase::BigIntBaseVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::BigIntBaseVerify(*this, isolate);
CHECK_GE(length(), 0);
CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n.
}
......@@ -1751,8 +1746,6 @@ void PreparseData::PreparseDataVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(InterpreterData)
void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::StackFrameInfoVerify(*this, isolate);
#if V8_ENABLE_WEBASSEMBLY
......
......@@ -231,6 +231,9 @@ void HeapObject::HeapObjectPrint(std::ostream& os) {
case FEEDBACK_METADATA_TYPE:
FeedbackMetadata::cast(*this).FeedbackMetadataPrint(os);
break;
case BIG_INT_BASE_TYPE:
BigIntBase::cast(*this).BigIntBasePrint(os);
break;
case JS_PROMISE_CONSTRUCTOR_TYPE:
case JS_REG_EXP_CONSTRUCTOR_TYPE:
case JS_ARRAY_CONSTRUCTOR_TYPE:
......
......@@ -5,15 +5,14 @@
// TODO(nicohartmann): Discuss whether types used by multiple builtins should be
// in global namespace
extern class BigIntBase extends PrimitiveHeapObject
generates 'TNode<BigInt>' {}
generates 'TNode<BigInt>';
type BigInt extends BigIntBase;
@noVerifier
@hasSameInstanceTypeAsParent
@doNotGenerateCast
extern class MutableBigInt extends BigIntBase generates 'TNode<BigInt>' {
}
extern class MutableBigInt extends BigIntBase generates 'TNode<BigInt>';
Convert<BigInt, MutableBigInt>(i: MutableBigInt): BigInt {
assert(bigint::IsCanonicalized(i));
......
......@@ -31,8 +31,10 @@
namespace v8 {
namespace internal {
#include "torque-generated/src/objects/code-tq-inl.inc"
OBJECT_CONSTRUCTORS_IMPL(DeoptimizationData, FixedArray)
OBJECT_CONSTRUCTORS_IMPL(BytecodeArray, FixedArrayBase)
TQ_OBJECT_CONSTRUCTORS_IMPL(BytecodeArray)
OBJECT_CONSTRUCTORS_IMPL(AbstractCode, HeapObject)
OBJECT_CONSTRUCTORS_IMPL(DependentCode, WeakFixedArray)
OBJECT_CONSTRUCTORS_IMPL(CodeDataContainer, HeapObject)
......@@ -40,7 +42,6 @@ OBJECT_CONSTRUCTORS_IMPL(CodeDataContainer, HeapObject)
NEVER_READ_ONLY_SPACE_IMPL(AbstractCode)
CAST_ACCESSOR(AbstractCode)
CAST_ACCESSOR(BytecodeArray)
CAST_ACCESSOR(Code)
CAST_ACCESSOR(CodeDataContainer)
CAST_ACCESSOR(DependentCode)
......@@ -943,11 +944,6 @@ int32_t BytecodeArray::parameter_count() const {
return ReadField<int32_t>(kParameterSizeOffset) >> kSystemPointerSizeLog2;
}
ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
ACCESSORS(BytecodeArray, handler_table, ByteArray, kHandlerTableOffset)
RELEASE_ACQUIRE_ACCESSORS(BytecodeArray, source_position_table, Object,
kSourcePositionTableOffset)
void BytecodeArray::clear_padding() {
int data_size = kHeaderSize + length();
memset(reinterpret_cast<void*>(address() + data_size), 0,
......
......@@ -32,6 +32,8 @@ namespace interpreter {
class Register;
} // namespace interpreter
#include "torque-generated/src/objects/code-tq.inc"
// CodeDataContainer is a container for all mutable fields associated with its
// referencing {Code} object. Since {Code} objects reside on write-protected
// pages within the heap, its header fields need to be immutable. There always
......@@ -828,7 +830,8 @@ class DependentCode : public WeakFixedArray {
};
// BytecodeArray represents a sequence of interpreter bytecodes.
class BytecodeArray : public FixedArrayBase {
class BytecodeArray
: public TorqueGeneratedBytecodeArray<BytecodeArray, FixedArrayBase> {
public:
enum Age {
kNoAgeBytecodeAge = 0,
......@@ -881,21 +884,6 @@ class BytecodeArray : public FixedArrayBase {
inline Age bytecode_age() const;
inline void set_bytecode_age(Age age);
// Accessors for the constant pool.
DECL_ACCESSORS(constant_pool, FixedArray)
// Accessors for handler table containing offsets of exception handlers.
DECL_ACCESSORS(handler_table, ByteArray)
// Accessors for source position table. Can contain:
// * undefined (initial value)
// * empty_byte_array (for bytecode generated for functions that will never
// have source positions, e.g. native functions).
// * ByteArray (when source positions have been collected for the bytecode)
// * exception (when an error occurred while explicitly collecting source
// positions for pre-existing bytecode).
DECL_RELEASE_ACQUIRE_ACCESSORS(source_position_table, Object)
inline bool HasSourcePositionTable() const;
inline bool DidSourcePositionGenerationFail() const;
......@@ -909,8 +897,6 @@ class BytecodeArray : public FixedArrayBase {
// as it would if no attempt was ever made to collect source positions.
inline void SetSourcePositionsFailedToCollect();
DECL_CAST(BytecodeArray)
// Dispatched behavior.
inline int BytecodeArraySize();
......@@ -935,10 +921,6 @@ class BytecodeArray : public FixedArrayBase {
// is deterministic.
inline void clear_padding();
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(FixedArrayBase::kHeaderSize,
TORQUE_GENERATED_BYTECODE_ARRAY_FIELDS)
// InterpreterEntryTrampoline expects these fields to be next to each other
// and writes a 16-bit value to reset them.
STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset ==
......@@ -951,7 +933,11 @@ class BytecodeArray : public FixedArrayBase {
class BodyDescriptor;
OBJECT_CONSTRUCTORS(BytecodeArray, FixedArrayBase);
private:
// Hide accessors inherited from generated class. Use parameter_count instead.
DECL_INT_ACCESSORS(parameter_size)
TQ_OBJECT_CONSTRUCTORS(BytecodeArray)
};
// DeoptimizationData is a fixed array used to hold the deoptimization data for
......
......@@ -4,10 +4,21 @@
type DependentCode extends WeakFixedArray;
@generateCppClass
extern class BytecodeArray extends FixedArrayBase {
// TODO(v8:8983): bytecode array object sizes vary based on their contents.
constant_pool: FixedArray;
// The handler table contains offsets of exception handlers.
handler_table: ByteArray;
// Source position table. Can contain:
// * undefined (initial value)
// * empty_byte_array (for bytecode generated for functions that will never
// have source positions, e.g. native functions).
// * ByteArray (when source positions have been collected for the bytecode)
// * exception (when an error occurred while explicitly collecting source
// positions for pre-existing bytecode).
@cppAcquireLoad
@cppReleaseStore
source_position_table: Undefined|ByteArray|Exception;
frame_size: int32;
parameter_size: int32;
......
......@@ -16,12 +16,7 @@ namespace internal {
#include "torque-generated/src/objects/data-handler-tq-inl.inc"
OBJECT_CONSTRUCTORS_IMPL(DataHandler, Struct)
CAST_ACCESSOR(DataHandler)
ACCESSORS(DataHandler, smi_handler, Object, kSmiHandlerOffset)
ACCESSORS(DataHandler, validity_cell, Object, kValidityCellOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(DataHandler)
int DataHandler::data_field_count() const {
return (map().instance_size() - kSizeWithData0) / kTaggedSize;
......
......@@ -18,17 +18,8 @@ namespace internal {
// 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 TorqueGeneratedDataHandler<DataHandler, Struct> {
public:
// [smi_handler]: A Smi which encodes a handler or Code object (we still
// use code handlers for accessing lexical environment variables, but soon
// only smi handlers will remain). See LoadHandler and StoreHandler for
// details about encoding.
DECL_ACCESSORS(smi_handler, Object)
// [validity_cell]: A validity Cell that guards prototype chain modifications.
DECL_ACCESSORS(validity_cell, Object)
// Returns number of optional data fields available in the object.
inline int data_field_count() const;
......@@ -38,21 +29,16 @@ class DataHandler : public Struct {
DECL_ACCESSORS(data2, MaybeObject)
DECL_ACCESSORS(data3, MaybeObject)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_DATA_HANDLER_FIELDS)
static const int kSizeWithData0 = kData1Offset;
static const int kSizeWithData1 = kData2Offset;
static const int kSizeWithData2 = kData3Offset;
static const int kSizeWithData3 = kHeaderSize;
DECL_CAST(DataHandler)
DECL_VERIFIER(DataHandler)
class BodyDescriptor;
OBJECT_CONSTRUCTORS(DataHandler, Struct);
TQ_OBJECT_CONSTRUCTORS(DataHandler)
};
} // namespace internal
......
......@@ -3,9 +3,16 @@
// found in the LICENSE file.
@abstract
@generateCppClass
extern class DataHandler extends Struct {
// [smi_handler]: A Smi which encodes a handler or Code object (we still
// use code handlers for accessing lexical environment variables, but soon
// only smi handlers will remain). See LoadHandler and StoreHandler for
// details about encoding.
@if(V8_EXTERNAL_CODE_SPACE) smi_handler: Smi|CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) smi_handler: Smi|Code;
// [validity_cell]: A validity Cell that guards prototype chain modifications.
validity_cell: Smi|Cell;
// Space for the following fields may or may not be allocated.
......
......@@ -33,8 +33,7 @@ namespace internal {
#include "torque-generated/src/objects/map-tq-inl.inc"
OBJECT_CONSTRUCTORS_IMPL(Map, HeapObject)
CAST_ACCESSOR(Map)
TQ_OBJECT_CONSTRUCTORS_IMPL(Map)
ACCESSORS(Map, instance_descriptors, DescriptorArray,
kInstanceDescriptorsOffset)
......
......@@ -188,7 +188,7 @@ using MapHandles = std::vector<Handle<Map>>;
// | | [raw_transitions] |
// +---------------+-------------------------------------------------+
class Map : public HeapObject {
class Map : public TorqueGeneratedMap<Map, HeapObject> {
public:
// Instance size.
// Size in bytes or kVariableSizeSentinel if instances do not have
......@@ -750,8 +750,6 @@ class Map : public HeapObject {
// Returns the number of enumerable properties.
int NumberOfEnumerableProperties() const;
DECL_CAST(Map)
static inline int SlackForArraySize(int old_size, int size_limit);
V8_EXPORT_PRIVATE static void EnsureDescriptorSlack(Isolate* isolate,
......@@ -811,9 +809,6 @@ class Map : public HeapObject {
static const int kMaxPreAllocatedPropertyFields = 255;
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_MAP_FIELDS)
STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
class BodyDescriptor;
......@@ -923,6 +918,10 @@ class Map : public HeapObject {
// Use the high-level instance_descriptors/SetInstanceDescriptors instead.
DECL_RELEASE_SETTER(instance_descriptors, DescriptorArray)
// Hide inherited accessors from the generated superclass.
DECL_ACCESSORS(constructor_or_back_pointer_or_native_context, Object)
DECL_ACCESSORS(transitions_or_prototype_info, Object)
static const int kFastPropertiesSoftLimit = 12;
static const int kMaxFastProperties = 128;
......@@ -930,7 +929,7 @@ class Map : public HeapObject {
template <typename ConcreteVisitor, typename MarkingState>
friend class MarkingVisitorBase;
OBJECT_CONSTRUCTORS(Map, HeapObject);
TQ_OBJECT_CONSTRUCTORS(Map)
};
// The cache for maps used by normalized (dictionary mode) objects.
......
......@@ -34,6 +34,7 @@ bitfield struct MapBitFields3 extends uint32 {
construction_counter: int32: 3 bit;
}
@generateCppClass
extern class Map extends HeapObject {
macro PrototypeInfo(): PrototypeInfo labels HasNoPrototypeInfo {
typeswitch (this.transitions_or_prototype_info) {
......
......@@ -20,7 +20,7 @@ namespace internal {
#include "torque-generated/src/objects/module-tq-inl.inc"
OBJECT_CONSTRUCTORS_IMPL(Module, HeapObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(Module)
TQ_OBJECT_CONSTRUCTORS_IMPL(JSModuleNamespace)
NEVER_READ_ONLY_SPACE_IMPL(Module)
......@@ -28,14 +28,6 @@ NEVER_READ_ONLY_SPACE_IMPL(ModuleRequest)
NEVER_READ_ONLY_SPACE_IMPL(SourceTextModule)
NEVER_READ_ONLY_SPACE_IMPL(SyntheticModule)
CAST_ACCESSOR(Module)
ACCESSORS(Module, exports, ObjectHashTable, kExportsOffset)
ACCESSORS(Module, module_namespace, HeapObject, kModuleNamespaceOffset)
ACCESSORS(Module, exception, Object, kExceptionOffset)
ACCESSORS(Module, top_level_capability, HeapObject, kTopLevelCapabilityOffset)
SMI_ACCESSORS(Module, status, kStatusOffset)
SMI_ACCESSORS(Module, hash, kHashOffset)
BOOL_ACCESSORS(SourceTextModule, flags, async, AsyncBit::kShift)
BIT_FIELD_ACCESSORS(SourceTextModule, flags, async_evaluating_ordinal,
SourceTextModule::AsyncEvaluatingOrdinalBits)
......
......@@ -32,21 +32,12 @@ class Zone;
// Module is the base class for ECMAScript module types, roughly corresponding
// to Abstract Module Record.
// https://tc39.github.io/ecma262/#sec-abstract-module-records
class Module : public HeapObject {
class Module : public TorqueGeneratedModule<Module, HeapObject> {
public:
NEVER_READ_ONLY_SPACE
DECL_CAST(Module)
DECL_VERIFIER(Module)
DECL_PRINTER(Module)
// The complete export table, mapping an export name to its cell.
DECL_ACCESSORS(exports, ObjectHashTable)
// Hash for this object (a random non-zero Smi).
DECL_INT_ACCESSORS(hash)
// Status.
DECL_INT_ACCESSORS(status)
enum Status {
// Order matters!
kUninstantiated,
......@@ -58,16 +49,8 @@ class Module : public HeapObject {
kErrored
};
// The namespace object (or undefined).
DECL_ACCESSORS(module_namespace, HeapObject)
// The exception in the case {status} is kErrored.
Object GetException();
DECL_ACCESSORS(exception, Object)
// The top level promise capability of this module. Will only be defined
// for cycle roots.
DECL_ACCESSORS(top_level_capability, HeapObject)
// Returns if this module or any transitively requested module is [[Async]],
// i.e. has a top-level await.
......@@ -101,10 +84,6 @@ class Module : public HeapObject {
static Handle<JSModuleNamespace> GetModuleNamespace(Isolate* isolate,
Handle<Module> module);
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_MODULE_FIELDS)
using BodyDescriptor =
FixedBodyDescriptor<kExportsOffset, kHeaderSize, kHeaderSize>;
......@@ -155,7 +134,7 @@ class Module : public HeapObject {
static void RecordError(Isolate* isolate, Handle<Module> module,
Handle<Object> error);
OBJECT_CONSTRUCTORS(Module, HeapObject);
TQ_OBJECT_CONSTRUCTORS(Module)
};
// When importing a module namespace (import * as foo from "bar"), a
......
......@@ -3,12 +3,18 @@
// found in the LICENSE file.
@abstract
@generateCppClass
extern class Module extends HeapObject {
// The complete export table, mapping an export name to its cell.
exports: ObjectHashTable;
// Hash for this object (a random non-zero Smi).
hash: Smi;
status: Smi;
module_namespace: JSModuleNamespace|Undefined;
// The exception in the case {status} is kErrored.
exception: Object;
// The top level promise capability of this module. Will only be defined
// for cycle roots.
top_level_capability: JSPromise|Undefined;
}
......
......@@ -34,7 +34,7 @@
#include "src/objects/oddball-inl.h"
#include "src/objects/property-details.h"
#include "src/objects/property.h"
#include "src/objects/regexp-match-info.h"
#include "src/objects/regexp-match-info-inl.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/slots-inl.h"
#include "src/objects/smi-inl.h"
......@@ -439,7 +439,6 @@ bool Object::IsMinusZero() const {
i::IsMinusZero(HeapNumber::cast(*this).value());
}
OBJECT_CONSTRUCTORS_IMPL(RegExpMatchInfo, FixedArray)
OBJECT_CONSTRUCTORS_IMPL(BigIntBase, PrimitiveHeapObject)
OBJECT_CONSTRUCTORS_IMPL(BigInt, BigIntBase)
OBJECT_CONSTRUCTORS_IMPL(FreshlyAllocatedBigInt, BigIntBase)
......@@ -449,7 +448,6 @@ OBJECT_CONSTRUCTORS_IMPL(FreshlyAllocatedBigInt, BigIntBase)
CAST_ACCESSOR(BigIntBase)
CAST_ACCESSOR(BigInt)
CAST_ACCESSOR(RegExpMatchInfo)
bool Object::HasValidElements() {
// Dictionary is covered under FixedArray. ByteArray is used
......@@ -870,48 +868,6 @@ bool Object::ToIntegerIndex(size_t* index) const {
return false;
}
int RegExpMatchInfo::NumberOfCaptureRegisters() {
DCHECK_GE(length(), kLastMatchOverhead);
Object obj = get(kNumberOfCapturesIndex);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kNumberOfCapturesIndex, Smi::FromInt(value));
}
String RegExpMatchInfo::LastSubject() {
DCHECK_GE(length(), kLastMatchOverhead);
return String::cast(get(kLastSubjectIndex));
}
void RegExpMatchInfo::SetLastSubject(String value, WriteBarrierMode mode) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastSubjectIndex, value, mode);
}
Object RegExpMatchInfo::LastInput() {
DCHECK_GE(length(), kLastMatchOverhead);
return get(kLastInputIndex);
}
void RegExpMatchInfo::SetLastInput(Object value, WriteBarrierMode mode) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastInputIndex, value, mode);
}
int RegExpMatchInfo::Capture(int i) {
DCHECK_LT(i, NumberOfCaptureRegisters());
Object obj = get(kFirstCaptureIndex + i);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetCapture(int i, int value) {
DCHECK_LT(i, NumberOfCaptureRegisters());
set(kFirstCaptureIndex + i, Smi::FromInt(value));
}
WriteBarrierMode HeapObject::GetWriteBarrierMode(
const DisallowGarbageCollection& promise) {
return GetWriteBarrierModeForObject(*this, &promise);
......
......@@ -18,8 +18,9 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObject)
CAST_ACCESSOR(PropertyArray)
#include "torque-generated/src/objects/property-array-tq-inl.inc"
TQ_OBJECT_CONSTRUCTORS_IMPL(PropertyArray)
SMI_ACCESSORS(PropertyArray, length_and_hash, kLengthAndHashOffset)
RELEASE_ACQUIRE_SMI_ACCESSORS(PropertyArray, length_and_hash,
......
......@@ -14,7 +14,10 @@
namespace v8 {
namespace internal {
class PropertyArray : public HeapObject {
#include "torque-generated/src/objects/property-array-tq.inc"
class PropertyArray
: public TorqueGeneratedPropertyArray<PropertyArray, HeapObject> {
public:
// [length]: length of the array.
inline int length() const;
......@@ -47,13 +50,9 @@ class PropertyArray : public HeapObject {
}
static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); }
DECL_CAST(PropertyArray)
DECL_PRINTER(PropertyArray)
DECL_VERIFIER(PropertyArray)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_PROPERTY_ARRAY_FIELDS)
// Garbage collection support.
using BodyDescriptor = FlexibleBodyDescriptor<kHeaderSize>;
......@@ -70,7 +69,7 @@ class PropertyArray : public HeapObject {
DECL_RELEASE_ACQUIRE_INT_ACCESSORS(length_and_hash)
OBJECT_CONSTRUCTORS(PropertyArray, HeapObject);
TQ_OBJECT_CONSTRUCTORS(PropertyArray)
};
} // namespace internal
......
......@@ -2,4 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern class PropertyArray extends HeapObject { length_and_hash: Smi; }
@generateCppClass
extern class PropertyArray extends HeapObject {
length_and_hash: Smi;
}
......@@ -16,9 +16,9 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(PropertyCell, HeapObject)
#include "torque-generated/src/objects/property-cell-tq-inl.inc"
CAST_ACCESSOR(PropertyCell)
TQ_OBJECT_CONSTRUCTORS_IMPL(PropertyCell)
ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(PropertyCell, name, Name, kNameOffset)
......
......@@ -14,7 +14,10 @@
namespace v8 {
namespace internal {
class PropertyCell : public HeapObject {
#include "torque-generated/src/objects/property-cell-tq.inc"
class PropertyCell
: public TorqueGeneratedPropertyCell<PropertyCell, HeapObject> {
public:
// [name]: the name of the global property.
DECL_GETTER(name, Name)
......@@ -65,16 +68,12 @@ class PropertyCell : public HeapObject {
// approximation with false positives.
static bool CheckDataIsCompatible(PropertyDetails details, Object value);
DECL_CAST(PropertyCell)
DECL_PRINTER(PropertyCell)
DECL_VERIFIER(PropertyCell)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_PROPERTY_CELL_FIELDS)
using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>;
OBJECT_CONSTRUCTORS(PropertyCell, HeapObject);
TQ_OBJECT_CONSTRUCTORS(PropertyCell)
private:
friend class Factory;
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
extern class PropertyCell extends HeapObject {
name: AnyName;
property_details_raw: Smi;
......
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_
#define V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_
#include "src/objects/fixed-array-inl.h"
#include "src/objects/regexp-match-info.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
#include "torque-generated/src/objects/regexp-match-info-tq-inl.inc"
TQ_OBJECT_CONSTRUCTORS_IMPL(RegExpMatchInfo)
int RegExpMatchInfo::NumberOfCaptureRegisters() {
DCHECK_GE(length(), kLastMatchOverhead);
Object obj = get(kNumberOfCapturesIndex);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kNumberOfCapturesIndex, Smi::FromInt(value));
}
String RegExpMatchInfo::LastSubject() {
DCHECK_GE(length(), kLastMatchOverhead);
return String::cast(get(kLastSubjectIndex));
}
void RegExpMatchInfo::SetLastSubject(String value, WriteBarrierMode mode) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastSubjectIndex, value, mode);
}
Object RegExpMatchInfo::LastInput() {
DCHECK_GE(length(), kLastMatchOverhead);
return get(kLastInputIndex);
}
void RegExpMatchInfo::SetLastInput(Object value, WriteBarrierMode mode) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastInputIndex, value, mode);
}
int RegExpMatchInfo::Capture(int i) {
DCHECK_LT(i, NumberOfCaptureRegisters());
Object obj = get(kFirstCaptureIndex + i);
return Smi::ToInt(obj);
}
void RegExpMatchInfo::SetCapture(int i, int value) {
DCHECK_LT(i, NumberOfCaptureRegisters());
set(kFirstCaptureIndex + i, Smi::FromInt(value));
}
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_REGEXP_MATCH_INFO_INL_H_
......@@ -27,7 +27,8 @@ class String;
// that there are at least two capture indices. The array also contains
// the subject string for the last successful match.
// After creation the result must be treated as a FixedArray in all regards.
class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
class RegExpMatchInfo
: public TorqueGeneratedRegExpMatchInfo<RegExpMatchInfo, FixedArray> {
public:
// Returns the number of captures, which is defined as the length of the
// matchIndices objects of the last match. matchIndices contains two indices
......@@ -57,21 +58,16 @@ class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
static Handle<RegExpMatchInfo> ReserveCaptures(
Isolate* isolate, Handle<RegExpMatchInfo> match_info, int capture_count);
DECL_CAST(RegExpMatchInfo)
static const int kNumberOfCapturesIndex = 0;
static const int kLastSubjectIndex = 1;
static const int kLastInputIndex = 2;
static const int kFirstCaptureIndex = 3;
static const int kLastMatchOverhead = kFirstCaptureIndex;
DEFINE_FIELD_OFFSET_CONSTANTS(FixedArray::kHeaderSize,
TORQUE_GENERATED_REG_EXP_MATCH_INFO_FIELDS)
// Every match info is guaranteed to have enough space to store two captures.
static const int kInitialCaptureIndices = 2;
OBJECT_CONSTRUCTORS(RegExpMatchInfo, FixedArray);
TQ_OBJECT_CONSTRUCTORS(RegExpMatchInfo)
};
} // namespace internal
......
......@@ -4,6 +4,7 @@
@hasSameInstanceTypeAsParent
@doNotGenerateCast
@generateCppClass
extern class RegExpMatchInfo extends FixedArray {
macro GetStartOfCapture(implicit context: Context)(captureIndex:
constexpr int31): Smi {
......
......@@ -94,10 +94,8 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreparseData)
TQ_OBJECT_CONSTRUCTORS_IMPL(BaselineData)
OBJECT_CONSTRUCTORS_IMPL(InterpreterData, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(InterpreterData)
CAST_ACCESSOR(InterpreterData)
ACCESSORS(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
ACCESSORS(InterpreterData, raw_interpreter_trampoline, CodeT,
kInterpreterTrampolineOffset)
......
......@@ -141,22 +141,17 @@ class UncompiledDataWithPreparseData
TQ_OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData)
};
class InterpreterData : public Struct {
class InterpreterData
: public TorqueGeneratedInterpreterData<InterpreterData, Struct> {
public:
DECL_ACCESSORS(bytecode_array, BytecodeArray)
DECL_ACCESSORS(interpreter_trampoline, Code)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_INTERPRETER_DATA_FIELDS)
DECL_CAST(InterpreterData)
DECL_PRINTER(InterpreterData)
DECL_VERIFIER(InterpreterData)
private:
DECL_ACCESSORS(raw_interpreter_trampoline, CodeT)
OBJECT_CONSTRUCTORS(InterpreterData, Struct);
TQ_OBJECT_CONSTRUCTORS(InterpreterData)
};
class BaselineData : public TorqueGeneratedBaselineData<BaselineData, Struct> {
......
......@@ -9,6 +9,7 @@ extern class PreparseData extends HeapObject {
children_length: int32;
}
@generateCppClass
extern class InterpreterData extends Struct {
bytecode_array: BytecodeArray;
@if(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: CodeDataContainer;
......
......@@ -109,13 +109,9 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(InternalizedString)
TQ_OBJECT_CONSTRUCTORS_IMPL(ConsString)
TQ_OBJECT_CONSTRUCTORS_IMPL(ThinString)
TQ_OBJECT_CONSTRUCTORS_IMPL(SlicedString)
OBJECT_CONSTRUCTORS_IMPL(ExternalString, String)
OBJECT_CONSTRUCTORS_IMPL(ExternalOneByteString, ExternalString)
OBJECT_CONSTRUCTORS_IMPL(ExternalTwoByteString, ExternalString)
CAST_ACCESSOR(ExternalOneByteString)
CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalTwoByteString)
TQ_OBJECT_CONSTRUCTORS_IMPL(ExternalString)
TQ_OBJECT_CONSTRUCTORS_IMPL(ExternalOneByteString)
TQ_OBJECT_CONSTRUCTORS_IMPL(ExternalTwoByteString)
StringShape::StringShape(const String str)
: type_(str.map(kAcquireLoad).instance_type()) {
......
......@@ -820,14 +820,11 @@ class SlicedString : public TorqueGeneratedSlicedString<SlicedString, String> {
//
// The API expects that all ExternalStrings are created through the
// API. Therefore, ExternalStrings should not be used internally.
class ExternalString : public String {
class ExternalString
: public TorqueGeneratedExternalString<ExternalString, String> {
public:
DECL_CAST(ExternalString)
DECL_VERIFIER(ExternalString)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_EXTERNAL_STRING_FIELDS)
// Size of uncached external strings.
static const int kUncachedSize =
kResourceOffset + FIELD_SIZE(kResourceOffset);
......@@ -851,12 +848,19 @@ class ExternalString : public String {
STATIC_ASSERT(kResourceOffset == Internals::kStringResourceOffset);
static const int kSizeOfAllExternalStrings = kHeaderSize;
OBJECT_CONSTRUCTORS(ExternalString, String);
private:
// Hide generated accessors.
DECL_ACCESSORS(resource, void*)
DECL_ACCESSORS(resource_data, void*)
TQ_OBJECT_CONSTRUCTORS(ExternalString)
};
// The ExternalOneByteString class is an external string backed by an
// one-byte string.
class ExternalOneByteString : public ExternalString {
class ExternalOneByteString
: public TorqueGeneratedExternalOneByteString<ExternalOneByteString,
ExternalString> {
public:
static const bool kHasOneByteEncoding = true;
......@@ -884,17 +888,11 @@ class ExternalOneByteString : public ExternalString {
inline uint8_t Get(int index,
const SharedStringAccessGuardIfNeeded& access_guard) const;
DECL_CAST(ExternalOneByteString)
class BodyDescriptor;
DEFINE_FIELD_OFFSET_CONSTANTS(
ExternalString::kHeaderSize,
TORQUE_GENERATED_EXTERNAL_ONE_BYTE_STRING_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllExternalStrings);
OBJECT_CONSTRUCTORS(ExternalOneByteString, ExternalString);
TQ_OBJECT_CONSTRUCTORS(ExternalOneByteString)
private:
// The underlying resource as a non-const pointer.
......@@ -903,7 +901,9 @@ class ExternalOneByteString : public ExternalString {
// The ExternalTwoByteString class is an external string backed by a UTF-16
// encoded string.
class ExternalTwoByteString : public ExternalString {
class ExternalTwoByteString
: public TorqueGeneratedExternalTwoByteString<ExternalTwoByteString,
ExternalString> {
public:
static const bool kHasOneByteEncoding = false;
......@@ -934,17 +934,11 @@ class ExternalTwoByteString : public ExternalString {
// For regexp code.
inline const uint16_t* ExternalTwoByteStringGetData(unsigned start);
DECL_CAST(ExternalTwoByteString)
class BodyDescriptor;
DEFINE_FIELD_OFFSET_CONSTANTS(
ExternalString::kHeaderSize,
TORQUE_GENERATED_EXTERNAL_TWO_BYTE_STRING_FIELDS)
STATIC_ASSERT(kSize == kSizeOfAllExternalStrings);
OBJECT_CONSTRUCTORS(ExternalTwoByteString, ExternalString);
TQ_OBJECT_CONSTRUCTORS(ExternalTwoByteString)
private:
// The underlying resource as a non-const pointer.
......
......@@ -50,6 +50,7 @@ extern class ConsString extends String {
@abstract
@doNotGenerateCast
@generateCppClass
extern class ExternalString extends String {
resource: ExternalPointer;
// WARNING: This field is missing for uncached external strings.
......@@ -71,6 +72,7 @@ extern macro ExternalTwoByteStringGetChars(ExternalTwoByteString):
RawPtr<char16>;
@doNotGenerateCast
@generateCppClass
extern class ExternalOneByteString extends ExternalString {
macro GetChars(): RawPtr<char8> {
if (this.StringInstanceType().is_uncached) {
......@@ -82,6 +84,7 @@ extern class ExternalOneByteString extends ExternalString {
}
@doNotGenerateCast
@generateCppClass
extern class ExternalTwoByteString extends ExternalString {
macro GetChars(): RawPtr<char16> {
if (this.StringInstanceType().is_uncached) {
......
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