Skip to content

Commit 07fc96c

Browse files
sethbrenithCommit Bot
authored andcommitted
[cleanup][torque] Use @generateCppClass in some simple cases, part 3
Just mechanical conversion to remove boilerplate code. When .tq and .h files didn't agree on what a field is named, I used the name from the .h file. In a couple of cases the generated accessor became slightly more specific (HeapObject instead of Object), and I had to update the code that uses those accessors accordingly. Change-Id: Ie3af1590e3889887b167c9d045b07860b01f7d15 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776479 Reviewed-by: Jakob Gruber <[email protected]> Reviewed-by: Tobias Tebbi <[email protected]> Commit-Queue: Seth Brenith <[email protected]> Cr-Commit-Position: refs/heads/master@{#64142}
1 parent 0cbbb88 commit 07fc96c

19 files changed

Lines changed: 83 additions & 195 deletions

src/builtins/base.tq

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,11 @@ extern class EmbedderDataArray extends HeapObject {
678678

679679
type ScopeInfo extends HeapObject generates 'TNode<ScopeInfo>';
680680

681+
@generateCppClass
681682
extern class PreparseData extends HeapObject {
682683
// TODO(v8:8983): Add declaration for variable-sized region.
683684
data_length: int32;
684-
inner_length: int32;
685+
children_length: int32;
685686
}
686687

687688
extern class InterpreterData extends Struct {
@@ -873,9 +874,12 @@ extern class JSAsyncFromSyncIterator extends JSObject {
873874
next: Object;
874875
}
875876

877+
@generateCppClass
876878
extern class JSStringIterator extends JSObject {
879+
// The [[IteratedString]] inobject property.
877880
string: String;
878-
next_index: Smi;
881+
// The [[StringIteratorNextIndex]] inobject property.
882+
index: Smi;
879883
}
880884

881885
@abstract
@@ -1532,6 +1536,7 @@ extern class AccessorInfo extends Struct {
15321536
data: Object;
15331537
}
15341538

1539+
@generateCppClass
15351540
extern class AccessorPair extends Struct {
15361541
getter: Object;
15371542
setter: Object;
@@ -1541,12 +1546,19 @@ extern class BreakPoint extends Tuple2 {}
15411546
extern class BreakPointInfo extends Tuple2 {}
15421547
type CoverageInfo extends FixedArray;
15431548

1549+
@generateCppClass
15441550
extern class DebugInfo extends Struct {
1545-
shared_function_info: SharedFunctionInfo;
1551+
shared: SharedFunctionInfo;
15461552
debugger_hints: Smi;
1553+
// Script field from shared function info.
15471554
script: Undefined | Script;
1555+
// The original uninstrumented bytecode array for functions with break
1556+
// points - the instrumented bytecode is held in the shared function info.
15481557
original_bytecode_array: Undefined | BytecodeArray;
1558+
// The debug instrumented bytecode array for functions with break points
1559+
// - also pointed to by the shared function info.
15491560
debug_bytecode_array: Undefined | BytecodeArray;
1561+
// Fixed array holding status information for each active break point.
15501562
break_points: FixedArray;
15511563
flags: Smi;
15521564
coverage_info: CoverageInfo | Undefined;
@@ -1566,6 +1578,7 @@ extern class FeedbackVector extends HeapObject {
15661578
padding: uint32;
15671579
}
15681580

1581+
@generateCppClass
15691582
extern class FeedbackCell extends Struct {
15701583
value: Undefined | FeedbackVector | FixedArray;
15711584
interrupt_budget: int32;
@@ -1629,22 +1642,35 @@ extern class JSFinalizationGroup extends JSObject {
16291642
flags: Smi;
16301643
}
16311644

1645+
@generateCppClass
16321646
extern class JSFinalizationGroupCleanupIterator extends JSObject {
16331647
finalization_group: JSFinalizationGroup;
16341648
}
16351649

1650+
@generateCppClass
16361651
extern class WeakCell extends HeapObject {
16371652
finalization_group: Undefined | JSFinalizationGroup;
16381653
target: Undefined | JSReceiver;
16391654
holdings: Object;
1655+
1656+
// For storing doubly linked lists of WeakCells in JSFinalizationGroup's
1657+
// "active_cells" and "cleared_cells" lists.
16401658
prev: Undefined | WeakCell;
16411659
next: Undefined | WeakCell;
1660+
1661+
// For storing doubly linked lists of WeakCells per key in
1662+
// JSFinalizationGroup's key-based hashmap. WeakCell also needs to know its
1663+
// key, so that we can remove the key from the key_map when we remove the last
1664+
// WeakCell associated with it.
16421665
key: Object;
16431666
key_list_prev: Undefined | WeakCell;
16441667
key_list_next: Undefined | WeakCell;
16451668
}
16461669

1647-
extern class JSWeakRef extends JSObject { target: Undefined | JSReceiver; }
1670+
@generateCppClass
1671+
extern class JSWeakRef extends JSObject {
1672+
target: Undefined | JSReceiver;
1673+
}
16481674

16491675
extern class BytecodeArray extends FixedArrayBase {
16501676
// TODO(v8:8983): bytecode array object sizes vary based on their contents.

src/builtins/string-iterator.tq

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace string_iterator {
1111
properties_or_hash: kEmptyFixedArray,
1212
elements: kEmptyFixedArray,
1313
string: string,
14-
next_index: nextIndex
14+
index: nextIndex
1515
};
1616
}
1717

@@ -31,7 +31,7 @@ namespace string_iterator {
3131
kIncompatibleMethodReceiver, 'String Iterator.prototype.next',
3232
receiver);
3333
const string = iterator.string;
34-
const position: intptr = SmiUntag(iterator.next_index);
34+
const position: intptr = SmiUntag(iterator.index);
3535
const length: intptr = string.length_intptr;
3636
if (position >= length) {
3737
return AllocateJSIteratorResult(Undefined, True);
@@ -40,7 +40,7 @@ namespace string_iterator {
4040
const encoding = UTF16;
4141
const ch = string::LoadSurrogatePairAt(string, length, position, encoding);
4242
const value: String = string::StringFromSingleUTF16EncodedCodePoint(ch);
43-
iterator.next_index = SmiTag(position + value.length_intptr);
43+
iterator.index = SmiTag(position + value.length_intptr);
4444
return AllocateJSIteratorResult(value, False);
4545
}
4646
}

src/compiler/access-builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ FieldAccess AccessBuilder::ForJSStringIteratorString() {
800800
// static
801801
FieldAccess AccessBuilder::ForJSStringIteratorIndex() {
802802
FieldAccess access = {kTaggedBase,
803-
JSStringIterator::kNextIndexOffset,
803+
JSStringIterator::kIndexOffset,
804804
Handle<Name>(),
805805
MaybeHandle<Map>(),
806806
TypeCache::Get()->kStringLengthType,

src/debug/debug.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ void Debug::PrepareFunctionForDebugExecution(
11711171
if (debug_info->flags() & DebugInfo::kPreparedForDebugExecution) return;
11721172

11731173
// Make a copy of the bytecode array if available.
1174-
Handle<Object> maybe_original_bytecode_array =
1174+
Handle<HeapObject> maybe_original_bytecode_array =
11751175
isolate_->factory()->undefined_value();
11761176
if (shared->HasBytecodeArray()) {
11771177
Handle<BytecodeArray> original_bytecode_array =

src/diagnostics/objects-debug.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,6 @@ void BytecodeArray::BytecodeArrayVerify(Isolate* isolate) {
513513

514514
USE_TORQUE_VERIFIER(FreeSpace)
515515

516-
USE_TORQUE_VERIFIER(FeedbackCell)
517-
518516
void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) {
519517
TorqueGeneratedClassVerifiers::FeedbackVectorVerify(*this, isolate);
520518
MaybeObject code = optimized_code_weak_or_smi();
@@ -1688,8 +1686,6 @@ void StoreHandler::StoreHandlerVerify(Isolate* isolate) {
16881686

16891687
USE_TORQUE_VERIFIER(AccessorInfo)
16901688

1691-
USE_TORQUE_VERIFIER(AccessorPair)
1692-
16931689
void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
16941690
TorqueGeneratedClassVerifiers::CallHandlerInfoVerify(*this, isolate);
16951691
CHECK(map() == ReadOnlyRoots(isolate).side_effect_call_handler_info_map() ||
@@ -1742,8 +1738,6 @@ void NormalizedMapCache::NormalizedMapCacheVerify(Isolate* isolate) {
17421738
}
17431739
}
17441740

1745-
USE_TORQUE_VERIFIER(DebugInfo)
1746-
17471741
USE_TORQUE_VERIFIER(StackFrameInfo)
17481742

17491743
void PreparseData::PreparseDataVerify(Isolate* isolate) {

src/objects/debug-objects-inl.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,16 @@ namespace internal {
2121
OBJECT_CONSTRUCTORS_IMPL(BreakPoint, Tuple2)
2222
OBJECT_CONSTRUCTORS_IMPL(BreakPointInfo, Tuple2)
2323
OBJECT_CONSTRUCTORS_IMPL(CoverageInfo, FixedArray)
24-
OBJECT_CONSTRUCTORS_IMPL(DebugInfo, Struct)
24+
TQ_OBJECT_CONSTRUCTORS_IMPL(DebugInfo)
2525

2626
NEVER_READ_ONLY_SPACE_IMPL(DebugInfo)
2727

2828
CAST_ACCESSOR(BreakPointInfo)
29-
CAST_ACCESSOR(DebugInfo)
3029
CAST_ACCESSOR(CoverageInfo)
3130
CAST_ACCESSOR(BreakPoint)
3231

33-
SMI_ACCESSORS(DebugInfo, flags, kFlagsOffset)
34-
ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
35-
SMI_ACCESSORS(DebugInfo, debugger_hints, kDebuggerHintsOffset)
36-
ACCESSORS(DebugInfo, script, Object, kScriptOffset)
37-
ACCESSORS(DebugInfo, original_bytecode_array, Object,
38-
kOriginalBytecodeArrayOffset)
39-
ACCESSORS(DebugInfo, debug_bytecode_array, Object, kDebugBytecodeArrayOffset)
40-
ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsOffset)
41-
ACCESSORS(DebugInfo, coverage_info, Object, kCoverageInfoOffset)
32+
TQ_SMI_ACCESSORS(DebugInfo, flags)
33+
TQ_SMI_ACCESSORS(DebugInfo, debugger_hints)
4234

4335
BIT_FIELD_ACCESSORS(DebugInfo, debugger_hints, side_effect_state,
4436
DebugInfo::SideEffectStateBits)

src/objects/debug-objects.h

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BytecodeArray;
2222

2323
// The DebugInfo class holds additional information for a function being
2424
// debugged.
25-
class DebugInfo : public Struct {
25+
class DebugInfo : public TorqueGeneratedDebugInfo<DebugInfo, Struct> {
2626
public:
2727
NEVER_READ_ONLY_SPACE
2828
enum Flag {
@@ -40,15 +40,9 @@ class DebugInfo : public Struct {
4040
// A bitfield that lists uses of the current instance.
4141
DECL_INT_ACCESSORS(flags)
4242

43-
// The shared function info for the source being debugged.
44-
DECL_ACCESSORS(shared, SharedFunctionInfo)
45-
4643
// Bit field containing various information collected for debugging.
4744
DECL_INT_ACCESSORS(debugger_hints)
4845

49-
// Script field from shared function info.
50-
DECL_ACCESSORS(script, Object)
51-
5246
// DebugInfo can be detached from the SharedFunctionInfo iff it is empty.
5347
bool IsEmpty() const;
5448

@@ -85,17 +79,6 @@ class DebugInfo : public Struct {
8579
void ClearBreakAtEntry();
8680
bool BreakAtEntry() const;
8781

88-
// The original uninstrumented bytecode array for functions with break
89-
// points - the instrumented bytecode is held in the shared function info.
90-
DECL_ACCESSORS(original_bytecode_array, Object)
91-
92-
// The debug instrumented bytecode array for functions with break points
93-
// - also pointed to by the shared function info.
94-
DECL_ACCESSORS(debug_bytecode_array, Object)
95-
96-
// Fixed array holding status information for each active break point.
97-
DECL_ACCESSORS(break_points, FixedArray)
98-
9982
// Check if there is a break point at a source position.
10083
bool HasBreakPoint(Isolate* isolate, int source_position);
10184
// Attempt to clear a break point. Return true if successful.
@@ -162,25 +145,17 @@ class DebugInfo : public Struct {
162145

163146
// Clears all fields related to block coverage.
164147
void ClearCoverageInfo(Isolate* isolate);
165-
DECL_ACCESSORS(coverage_info, Object)
166-
167-
DECL_CAST(DebugInfo)
168148

169149
// Dispatched behavior.
170150
DECL_PRINTER(DebugInfo)
171-
DECL_VERIFIER(DebugInfo)
172-
173-
// Layout description.
174-
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
175-
TORQUE_GENERATED_DEBUG_INFO_FIELDS)
176151

177152
static const int kEstimatedNofBreakPointsInFunction = 4;
178153

179154
private:
180155
// Get the break point info object for a source position.
181156
Object GetBreakPointInfo(Isolate* isolate, int source_position);
182157

183-
OBJECT_CONSTRUCTORS(DebugInfo, Struct);
158+
TQ_OBJECT_CONSTRUCTORS(DebugInfo)
184159
};
185160

186161
// The BreakPointInfo class holds information for break points set in a

src/objects/feedback-cell-inl.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
namespace v8 {
1818
namespace internal {
1919

20-
OBJECT_CONSTRUCTORS_IMPL(FeedbackCell, Struct)
21-
22-
CAST_ACCESSOR(FeedbackCell)
23-
24-
ACCESSORS(FeedbackCell, value, HeapObject, kValueOffset)
25-
INT32_ACCESSORS(FeedbackCell, interrupt_budget, kInterruptBudgetOffset)
20+
TQ_OBJECT_CONSTRUCTORS_IMPL(FeedbackCell)
2621

2722
void FeedbackCell::clear_padding() {
2823
if (FeedbackCell::kAlignedSize == FeedbackCell::kUnalignedSize) return;

src/objects/feedback-cell.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace internal {
1818
// number of closures created for a certain function per native
1919
// context. There's at most one FeedbackCell for each function in
2020
// a native context.
21-
class FeedbackCell : public Struct {
21+
class FeedbackCell : public TorqueGeneratedFeedbackCell<FeedbackCell, Struct> {
2222
public:
2323
static int GetInitialInterruptBudget() {
2424
if (FLAG_lazy_feedback_allocation) {
@@ -27,19 +27,8 @@ class FeedbackCell : public Struct {
2727
return FLAG_interrupt_budget;
2828
}
2929

30-
// [value]: value of the cell.
31-
DECL_ACCESSORS(value, HeapObject)
32-
DECL_INT32_ACCESSORS(interrupt_budget)
33-
34-
DECL_CAST(FeedbackCell)
35-
3630
// Dispatched behavior.
3731
DECL_PRINTER(FeedbackCell)
38-
DECL_VERIFIER(FeedbackCell)
39-
40-
// Layout description.
41-
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
42-
TORQUE_GENERATED_FEEDBACK_CELL_FIELDS)
4332

4433
static const int kUnalignedSize = kSize;
4534
static const int kAlignedSize = RoundUp<kObjectAlignment>(int{kSize});
@@ -50,7 +39,7 @@ class FeedbackCell : public Struct {
5039
using BodyDescriptor =
5140
FixedBodyDescriptor<kValueOffset, kInterruptBudgetOffset, kAlignedSize>;
5241

53-
OBJECT_CONSTRUCTORS(FeedbackCell, Struct);
42+
TQ_OBJECT_CONSTRUCTORS(FeedbackCell)
5443
};
5544

5645
} // namespace internal

src/objects/js-objects-inl.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(JSGlobalProxy)
4040
JSIteratorResult::JSIteratorResult(Address ptr) : JSObject(ptr) {}
4141
OBJECT_CONSTRUCTORS_IMPL(JSMessageObject, JSObject)
4242
TQ_OBJECT_CONSTRUCTORS_IMPL(JSPrimitiveWrapper)
43-
OBJECT_CONSTRUCTORS_IMPL(JSStringIterator, JSObject)
43+
TQ_OBJECT_CONSTRUCTORS_IMPL(JSStringIterator)
4444

4545
NEVER_READ_ONLY_SPACE_IMPL(JSReceiver)
4646

@@ -49,7 +49,6 @@ CAST_ACCESSOR(JSGlobalObject)
4949
CAST_ACCESSOR(JSIteratorResult)
5050
CAST_ACCESSOR(JSMessageObject)
5151
CAST_ACCESSOR(JSReceiver)
52-
CAST_ACCESSOR(JSStringIterator)
5352

5453
MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
5554
Handle<JSReceiver> receiver,
@@ -1009,8 +1008,7 @@ inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) {
10091008
ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
10101009
ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
10111010

1012-
ACCESSORS(JSStringIterator, string, String, kStringOffset)
1013-
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
1011+
TQ_SMI_ACCESSORS(JSStringIterator, index)
10141012

10151013
// If the fast-case backing storage takes up much more memory than a dictionary
10161014
// backing storage would, the object should have slow elements.

0 commit comments

Comments
 (0)