Skip to content

Commit e4e86b5

Browse files
sethbrenithCommit Bot
authored andcommitted
Convert UncompiledData class to Torque
I removed the padding field because I couldn't see a reason why we would want to pad to system pointer size. I'm guessing that the intent was to pad to tagged pointer size, which was once relevant but isn't anymore since one of the int32 fields got removed. Bug: v8:8952 Change-Id: Ic191d783efd8d686f6920e6e7ce2d3dacba883c5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1776847 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Seth Brenith <seth.brenith@microsoft.com> Cr-Commit-Position: refs/heads/master@{#63556}
1 parent 2314928 commit e4e86b5

5 files changed

Lines changed: 37 additions & 92 deletions

File tree

src/builtins/base.tq

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,23 @@ extern class SharedFunctionInfo extends HeapObject {
697697
@if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
698698
}
699699

700+
@abstract
701+
@generateCppClass
702+
extern class UncompiledData extends HeapObject {
703+
inferred_name: String;
704+
start_position: int32;
705+
end_position: int32;
706+
}
707+
708+
@generateCppClass
709+
extern class UncompiledDataWithoutPreparseData extends UncompiledData {
710+
}
711+
712+
@generateCppClass
713+
extern class UncompiledDataWithPreparseData extends UncompiledData {
714+
preparse_data: PreparseData;
715+
}
716+
700717
@generateCppClass
701718
extern class JSBoundFunction extends JSObject {
702719
// The wrapped function object.

src/diagnostics/objects-debug.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,19 +1749,6 @@ void PreparseData::PreparseDataVerify(Isolate* isolate) {
17491749
}
17501750
}
17511751

1752-
void UncompiledDataWithPreparseData::UncompiledDataWithPreparseDataVerify(
1753-
Isolate* isolate) {
1754-
CHECK(IsUncompiledDataWithPreparseData());
1755-
VerifyPointer(isolate, inferred_name());
1756-
VerifyPointer(isolate, preparse_data());
1757-
}
1758-
1759-
void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataVerify(
1760-
Isolate* isolate) {
1761-
CHECK(IsUncompiledDataWithoutPreparseData());
1762-
VerifyPointer(isolate, inferred_name());
1763-
}
1764-
17651752
USE_TORQUE_VERIFIER(InterpreterData)
17661753

17671754
#ifdef V8_INTL_SUPPORT

src/objects/shared-function-info-inl.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,9 @@ void PreparseData::set_child(int index, PreparseData value,
8484
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
8585
}
8686

87-
OBJECT_CONSTRUCTORS_IMPL(UncompiledData, HeapObject)
88-
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithoutPreparseData, UncompiledData)
89-
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreparseData, UncompiledData)
90-
CAST_ACCESSOR(UncompiledData)
91-
ACCESSORS(UncompiledData, inferred_name, String, kInferredNameOffset)
92-
INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset)
93-
INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset)
94-
95-
void UncompiledData::clear_padding() {
96-
if (FIELD_SIZE(kOptionalPaddingOffset) == 0) return;
97-
DCHECK_EQ(4, FIELD_SIZE(kOptionalPaddingOffset));
98-
memset(reinterpret_cast<void*>(address() + kOptionalPaddingOffset), 0,
99-
FIELD_SIZE(kOptionalPaddingOffset));
100-
}
101-
102-
CAST_ACCESSOR(UncompiledDataWithoutPreparseData)
103-
104-
CAST_ACCESSOR(UncompiledDataWithPreparseData)
105-
ACCESSORS(UncompiledDataWithPreparseData, preparse_data, PreparseData,
106-
kPreparseDataOffset)
87+
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledData)
88+
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithoutPreparseData)
89+
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreparseData)
10790

10891
DEF_GETTER(HeapObject, IsUncompiledData, bool) {
10992
return IsUncompiledDataWithoutPreparseData(isolate) ||
@@ -618,7 +601,7 @@ void SharedFunctionInfo::ClearPreparseData() {
618601
STATIC_ASSERT(UncompiledDataWithoutPreparseData::kSize <
619602
UncompiledDataWithPreparseData::kSize);
620603
STATIC_ASSERT(UncompiledDataWithoutPreparseData::kSize ==
621-
UncompiledData::kSize);
604+
UncompiledData::kHeaderSize);
622605
data.synchronized_set_map(
623606
GetReadOnlyRoots().uncompiled_data_without_preparse_data_map());
624607

@@ -644,7 +627,6 @@ void UncompiledData::Initialize(
644627
data, data.RawField(UncompiledData::kInferredNameOffset), inferred_name);
645628
data.set_start_position(start_position);
646629
data.set_end_position(end_position);
647-
data.clear_padding();
648630
}
649631

650632
void UncompiledDataWithPreparseData::Initialize(

src/objects/shared-function-info.h

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -100,71 +100,45 @@ class PreparseData : public HeapObject {
100100

101101
// Abstract class representing extra data for an uncompiled function, which is
102102
// not stored in the SharedFunctionInfo.
103-
class UncompiledData : public HeapObject {
103+
class UncompiledData
104+
: public TorqueGeneratedUncompiledData<UncompiledData, HeapObject> {
104105
public:
105-
DECL_ACCESSORS(inferred_name, String)
106-
DECL_INT32_ACCESSORS(start_position)
107-
DECL_INT32_ACCESSORS(end_position)
108-
109-
DECL_CAST(UncompiledData)
110-
111106
inline static void Initialize(
112107
UncompiledData data, String inferred_name, int start_position,
113108
int end_position,
114109
std::function<void(HeapObject object, ObjectSlot slot, HeapObject target)>
115110
gc_notify_updated_slot =
116111
[](HeapObject object, ObjectSlot slot, HeapObject target) {});
117112

118-
// Layout description.
119-
#define UNCOMPILED_DATA_FIELDS(V) \
120-
V(kStartOfStrongFieldsOffset, 0) \
121-
V(kInferredNameOffset, kTaggedSize) \
122-
V(kEndOfStrongFieldsOffset, 0) \
123-
/* Raw data fields. */ \
124-
V(kStartPositionOffset, kInt32Size) \
125-
V(kEndPositionOffset, kInt32Size) \
126-
V(kOptionalPaddingOffset, POINTER_SIZE_PADDING(kOptionalPaddingOffset)) \
127-
/* Header size. */ \
128-
V(kSize, 0)
129-
130-
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, UNCOMPILED_DATA_FIELDS)
131-
#undef UNCOMPILED_DATA_FIELDS
132-
133-
using BodyDescriptor = FixedBodyDescriptor<kStartOfStrongFieldsOffset,
134-
kEndOfStrongFieldsOffset, kSize>;
135-
136-
// Clear uninitialized padding space.
137-
inline void clear_padding();
113+
using BodyDescriptor =
114+
FixedBodyDescriptor<kStartOfStrongFieldsOffset, kEndOfStrongFieldsOffset,
115+
kHeaderSize>;
138116

139-
OBJECT_CONSTRUCTORS(UncompiledData, HeapObject);
117+
TQ_OBJECT_CONSTRUCTORS(UncompiledData)
140118
};
141119

142120
// Class representing data for an uncompiled function that does not have any
143121
// data from the pre-parser, either because it's a leaf function or because the
144122
// pre-parser bailed out.
145-
class UncompiledDataWithoutPreparseData : public UncompiledData {
123+
class UncompiledDataWithoutPreparseData
124+
: public TorqueGeneratedUncompiledDataWithoutPreparseData<
125+
UncompiledDataWithoutPreparseData, UncompiledData> {
146126
public:
147-
DECL_CAST(UncompiledDataWithoutPreparseData)
148127
DECL_PRINTER(UncompiledDataWithoutPreparseData)
149-
DECL_VERIFIER(UncompiledDataWithoutPreparseData)
150-
151-
static const int kSize = UncompiledData::kSize;
152128

153129
// No extra fields compared to UncompiledData.
154130
using BodyDescriptor = UncompiledData::BodyDescriptor;
155131

156-
OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreparseData, UncompiledData);
132+
TQ_OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreparseData)
157133
};
158134

159135
// Class representing data for an uncompiled function that has pre-parsed scope
160136
// data.
161-
class UncompiledDataWithPreparseData : public UncompiledData {
137+
class UncompiledDataWithPreparseData
138+
: public TorqueGeneratedUncompiledDataWithPreparseData<
139+
UncompiledDataWithPreparseData, UncompiledData> {
162140
public:
163-
DECL_ACCESSORS(preparse_data, PreparseData)
164-
165-
DECL_CAST(UncompiledDataWithPreparseData)
166141
DECL_PRINTER(UncompiledDataWithPreparseData)
167-
DECL_VERIFIER(UncompiledDataWithPreparseData)
168142

169143
inline static void Initialize(
170144
UncompiledDataWithPreparseData data, String inferred_name,
@@ -173,28 +147,12 @@ class UncompiledDataWithPreparseData : public UncompiledData {
173147
gc_notify_updated_slot =
174148
[](HeapObject object, ObjectSlot slot, HeapObject target) {});
175149

176-
// Layout description.
177-
178-
#define UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS(V) \
179-
V(kStartOfStrongFieldsOffset, 0) \
180-
V(kPreparseDataOffset, kTaggedSize) \
181-
V(kEndOfStrongFieldsOffset, 0) \
182-
/* Total size. */ \
183-
V(kSize, 0)
184-
185-
DEFINE_FIELD_OFFSET_CONSTANTS(UncompiledData::kSize,
186-
UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS)
187-
#undef UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS
188-
189-
// Make sure the size is aligned
190-
STATIC_ASSERT(IsAligned(kSize, kTaggedSize));
191-
192150
using BodyDescriptor = SubclassBodyDescriptor<
193151
UncompiledData::BodyDescriptor,
194152
FixedBodyDescriptor<kStartOfStrongFieldsOffset, kEndOfStrongFieldsOffset,
195153
kSize>>;
196154

197-
OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData, UncompiledData);
155+
TQ_OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData)
198156
};
199157

200158
class InterpreterData : public Struct {

src/torque/implementation-visitor.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,8 @@ void ImplementationVisitor::GenerateClassDefinitions(
33163316
inline_header << "#include \"src/objects/js-promise.h\"\n";
33173317
inline_header << "#include \"src/objects/module.h\"\n";
33183318
inline_header << "#include \"src/objects/objects-inl.h\"\n";
3319-
inline_header << "#include \"src/objects/script.h\"\n\n";
3319+
inline_header << "#include \"src/objects/script.h\"\n";
3320+
inline_header << "#include \"src/objects/shared-function-info.h\"\n\n";
33203321
IncludeObjectMacrosScope inline_header_macros(inline_header);
33213322
NamespaceScope inline_header_namespaces(inline_header, {"v8", "internal"});
33223323

0 commit comments

Comments
 (0)