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

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/+/1776847Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#63556}
parent 2314928b
......@@ -697,6 +697,23 @@ extern class SharedFunctionInfo extends HeapObject {
@if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
}
@abstract
@generateCppClass
extern class UncompiledData extends HeapObject {
inferred_name: String;
start_position: int32;
end_position: int32;
}
@generateCppClass
extern class UncompiledDataWithoutPreparseData extends UncompiledData {
}
@generateCppClass
extern class UncompiledDataWithPreparseData extends UncompiledData {
preparse_data: PreparseData;
}
@generateCppClass
extern class JSBoundFunction extends JSObject {
// The wrapped function object.
......
......@@ -1749,19 +1749,6 @@ void PreparseData::PreparseDataVerify(Isolate* isolate) {
}
}
void UncompiledDataWithPreparseData::UncompiledDataWithPreparseDataVerify(
Isolate* isolate) {
CHECK(IsUncompiledDataWithPreparseData());
VerifyPointer(isolate, inferred_name());
VerifyPointer(isolate, preparse_data());
}
void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataVerify(
Isolate* isolate) {
CHECK(IsUncompiledDataWithoutPreparseData());
VerifyPointer(isolate, inferred_name());
}
USE_TORQUE_VERIFIER(InterpreterData)
#ifdef V8_INTL_SUPPORT
......
......@@ -84,26 +84,9 @@ void PreparseData::set_child(int index, PreparseData value,
CONDITIONAL_WRITE_BARRIER(*this, offset, value, mode);
}
OBJECT_CONSTRUCTORS_IMPL(UncompiledData, HeapObject)
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithoutPreparseData, UncompiledData)
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreparseData, UncompiledData)
CAST_ACCESSOR(UncompiledData)
ACCESSORS(UncompiledData, inferred_name, String, kInferredNameOffset)
INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset)
INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset)
void UncompiledData::clear_padding() {
if (FIELD_SIZE(kOptionalPaddingOffset) == 0) return;
DCHECK_EQ(4, FIELD_SIZE(kOptionalPaddingOffset));
memset(reinterpret_cast<void*>(address() + kOptionalPaddingOffset), 0,
FIELD_SIZE(kOptionalPaddingOffset));
}
CAST_ACCESSOR(UncompiledDataWithoutPreparseData)
CAST_ACCESSOR(UncompiledDataWithPreparseData)
ACCESSORS(UncompiledDataWithPreparseData, preparse_data, PreparseData,
kPreparseDataOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledData)
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithoutPreparseData)
TQ_OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreparseData)
DEF_GETTER(HeapObject, IsUncompiledData, bool) {
return IsUncompiledDataWithoutPreparseData(isolate) ||
......@@ -618,7 +601,7 @@ void SharedFunctionInfo::ClearPreparseData() {
STATIC_ASSERT(UncompiledDataWithoutPreparseData::kSize <
UncompiledDataWithPreparseData::kSize);
STATIC_ASSERT(UncompiledDataWithoutPreparseData::kSize ==
UncompiledData::kSize);
UncompiledData::kHeaderSize);
data.synchronized_set_map(
GetReadOnlyRoots().uncompiled_data_without_preparse_data_map());
......@@ -644,7 +627,6 @@ void UncompiledData::Initialize(
data, data.RawField(UncompiledData::kInferredNameOffset), inferred_name);
data.set_start_position(start_position);
data.set_end_position(end_position);
data.clear_padding();
}
void UncompiledDataWithPreparseData::Initialize(
......
......@@ -100,14 +100,9 @@ class PreparseData : public HeapObject {
// Abstract class representing extra data for an uncompiled function, which is
// not stored in the SharedFunctionInfo.
class UncompiledData : public HeapObject {
class UncompiledData
: public TorqueGeneratedUncompiledData<UncompiledData, HeapObject> {
public:
DECL_ACCESSORS(inferred_name, String)
DECL_INT32_ACCESSORS(start_position)
DECL_INT32_ACCESSORS(end_position)
DECL_CAST(UncompiledData)
inline static void Initialize(
UncompiledData data, String inferred_name, int start_position,
int end_position,
......@@ -115,56 +110,35 @@ class UncompiledData : public HeapObject {
gc_notify_updated_slot =
[](HeapObject object, ObjectSlot slot, HeapObject target) {});
// Layout description.
#define UNCOMPILED_DATA_FIELDS(V) \
V(kStartOfStrongFieldsOffset, 0) \
V(kInferredNameOffset, kTaggedSize) \
V(kEndOfStrongFieldsOffset, 0) \
/* Raw data fields. */ \
V(kStartPositionOffset, kInt32Size) \
V(kEndPositionOffset, kInt32Size) \
V(kOptionalPaddingOffset, POINTER_SIZE_PADDING(kOptionalPaddingOffset)) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, UNCOMPILED_DATA_FIELDS)
#undef UNCOMPILED_DATA_FIELDS
using BodyDescriptor = FixedBodyDescriptor<kStartOfStrongFieldsOffset,
kEndOfStrongFieldsOffset, kSize>;
// Clear uninitialized padding space.
inline void clear_padding();
using BodyDescriptor =
FixedBodyDescriptor<kStartOfStrongFieldsOffset, kEndOfStrongFieldsOffset,
kHeaderSize>;
OBJECT_CONSTRUCTORS(UncompiledData, HeapObject);
TQ_OBJECT_CONSTRUCTORS(UncompiledData)
};
// Class representing data for an uncompiled function that does not have any
// data from the pre-parser, either because it's a leaf function or because the
// pre-parser bailed out.
class UncompiledDataWithoutPreparseData : public UncompiledData {
class UncompiledDataWithoutPreparseData
: public TorqueGeneratedUncompiledDataWithoutPreparseData<
UncompiledDataWithoutPreparseData, UncompiledData> {
public:
DECL_CAST(UncompiledDataWithoutPreparseData)
DECL_PRINTER(UncompiledDataWithoutPreparseData)
DECL_VERIFIER(UncompiledDataWithoutPreparseData)
static const int kSize = UncompiledData::kSize;
// No extra fields compared to UncompiledData.
using BodyDescriptor = UncompiledData::BodyDescriptor;
OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreparseData, UncompiledData);
TQ_OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreparseData)
};
// Class representing data for an uncompiled function that has pre-parsed scope
// data.
class UncompiledDataWithPreparseData : public UncompiledData {
class UncompiledDataWithPreparseData
: public TorqueGeneratedUncompiledDataWithPreparseData<
UncompiledDataWithPreparseData, UncompiledData> {
public:
DECL_ACCESSORS(preparse_data, PreparseData)
DECL_CAST(UncompiledDataWithPreparseData)
DECL_PRINTER(UncompiledDataWithPreparseData)
DECL_VERIFIER(UncompiledDataWithPreparseData)
inline static void Initialize(
UncompiledDataWithPreparseData data, String inferred_name,
......@@ -173,28 +147,12 @@ class UncompiledDataWithPreparseData : public UncompiledData {
gc_notify_updated_slot =
[](HeapObject object, ObjectSlot slot, HeapObject target) {});
// Layout description.
#define UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS(V) \
V(kStartOfStrongFieldsOffset, 0) \
V(kPreparseDataOffset, kTaggedSize) \
V(kEndOfStrongFieldsOffset, 0) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(UncompiledData::kSize,
UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS)
#undef UNCOMPILED_DATA_WITH_PREPARSE_DATA_FIELDS
// Make sure the size is aligned
STATIC_ASSERT(IsAligned(kSize, kTaggedSize));
using BodyDescriptor = SubclassBodyDescriptor<
UncompiledData::BodyDescriptor,
FixedBodyDescriptor<kStartOfStrongFieldsOffset, kEndOfStrongFieldsOffset,
kSize>>;
OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData, UncompiledData);
TQ_OBJECT_CONSTRUCTORS(UncompiledDataWithPreparseData)
};
class InterpreterData : public Struct {
......
......@@ -3316,7 +3316,8 @@ void ImplementationVisitor::GenerateClassDefinitions(
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";
inline_header << "#include \"src/objects/script.h\"\n";
inline_header << "#include \"src/objects/shared-function-info.h\"\n\n";
IncludeObjectMacrosScope inline_header_macros(inline_header);
NamespaceScope inline_header_namespaces(inline_header, {"v8", "internal"});
......
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