Commit 24d40afb authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[runtime] Cleanup SharedFunctionInfo fields definitions (9).

Introduce DEFINE_FIELD_OFFSET_CONSTANTS macro for defining a contiguous
sequence of field offsets.
In addition, this CL turns last two Smi fields to int fields.

Bug: v8:6470
Change-Id: I12a6ad8d7b444772dbc01bba6734080f1d5eccdc
Reviewed-on: https://chromium-review.googlesource.com/532913Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45917}
parent cbaae3b6
......@@ -22,10 +22,6 @@ ACCESSORS(SharedFunctionInfo, raw_name, Object, kNameOffset)
ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata,
kFeedbackMetadataOffset)
SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset)
#if V8_SFI_HAS_UNIQUE_ID
SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset)
#endif
ACCESSORS(SharedFunctionInfo, instance_class_name, Object,
kInstanceClassNameOffset)
ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
......@@ -40,6 +36,10 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, start_position_and_type,
BIT_FIELD_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
SharedFunctionInfo::IsTopLevelBit)
INT_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset)
#if V8_SFI_HAS_UNIQUE_ID
INT_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset)
#endif
INT_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
INT_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
kFormalParameterCountOffset)
......
......@@ -434,61 +434,53 @@ class SharedFunctionInfo : public HeapObject {
// Constants.
static const int kDontAdaptArgumentsSentinel = -1;
// Layout description.
// Pointer fields.
static const int kCodeOffset = HeapObject::kHeaderSize;
static const int kNameOffset = kCodeOffset + kPointerSize;
static const int kScopeInfoOffset = kNameOffset + kPointerSize;
static const int kOuterScopeInfoOffset = kScopeInfoOffset + kPointerSize;
static const int kConstructStubOffset = kOuterScopeInfoOffset + kPointerSize;
static const int kInstanceClassNameOffset =
kConstructStubOffset + kPointerSize;
static const int kFunctionDataOffset =
kInstanceClassNameOffset + kPointerSize;
static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize;
static const int kFeedbackMetadataOffset =
kFunctionIdentifierOffset + kPointerSize;
static const int kFunctionLiteralIdOffset =
kFeedbackMetadataOffset + kPointerSize;
#if V8_SFI_HAS_UNIQUE_ID
static const int kUniqueIdOffset = kFunctionLiteralIdOffset + kPointerSize;
static const int kLastPointerFieldOffset = kUniqueIdOffset;
static const int kUniqueIdFieldSize = kInt32Size;
#else
// Just to not break the postmortrem support with conditional offsets
static const int kUniqueIdOffset = kFunctionLiteralIdOffset;
static const int kLastPointerFieldOffset = kFunctionLiteralIdOffset;
static const int kUniqueIdFieldSize = 0;
#endif
// Raw data fields.
static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize;
static const int kFormalParameterCountOffset = kLengthOffset + kIntSize;
static const int kExpectedNofPropertiesOffset =
kFormalParameterCountOffset + kIntSize;
// TODO(ishell): Drop this unused field.
static const int kNumLiteralsOffset = kExpectedNofPropertiesOffset + kIntSize;
static const int kStartPositionAndTypeOffset = kNumLiteralsOffset + kIntSize;
static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
static const int kCompilerHintsOffset =
kFunctionTokenPositionOffset + kIntSize;
static const int kOptCountAndBailoutReasonOffset =
kCompilerHintsOffset + kIntSize;
static const int kCountersOffset = kOptCountAndBailoutReasonOffset + kIntSize;
static const int kAstNodeCountOffset = kCountersOffset + kIntSize;
static const int kProfilerTicksOffset = kAstNodeCountOffset + kIntSize;
// Total size.
static const int kSize = kProfilerTicksOffset + kIntSize;
// Layout description.
#define SHARED_FUNCTION_INFO_FIELDS(V) \
/* Pointer fields. */ \
V(kCodeOffset, kPointerSize) \
V(kNameOffset, kPointerSize) \
V(kScopeInfoOffset, kPointerSize) \
V(kOuterScopeInfoOffset, kPointerSize) \
V(kConstructStubOffset, kPointerSize) \
V(kInstanceClassNameOffset, kPointerSize) \
V(kFunctionDataOffset, kPointerSize) \
V(kScriptOffset, kPointerSize) \
V(kDebugInfoOffset, kPointerSize) \
V(kFunctionIdentifierOffset, kPointerSize) \
V(kFeedbackMetadataOffset, kPointerSize) \
V(kEndOfPointerFieldsOffset, 0) \
/* Raw data fields. */ \
V(kFunctionLiteralIdOffset, kInt32Size) \
V(kUniqueIdOffset, kUniqueIdFieldSize) \
V(kLengthOffset, kInt32Size) \
V(kFormalParameterCountOffset, kInt32Size) \
V(kExpectedNofPropertiesOffset, kInt32Size) \
V(kStartPositionAndTypeOffset, kInt32Size) \
V(kEndPositionOffset, kInt32Size) \
V(kFunctionTokenPositionOffset, kInt32Size) \
V(kCompilerHintsOffset, kInt32Size) \
V(kOptCountAndBailoutReasonOffset, kInt32Size) \
V(kCountersOffset, kInt32Size) \
V(kAstNodeCountOffset, kInt32Size) \
V(kProfilerTicksOffset, kInt32Size) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
SHARED_FUNCTION_INFO_FIELDS)
static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize);
typedef FixedBodyDescriptor<kCodeOffset,
kLastPointerFieldOffset + kPointerSize, kSize>
typedef FixedBodyDescriptor<kCodeOffset, kEndOfPointerFieldsOffset, kSize>
BodyDescriptor;
typedef FixedBodyDescriptor<kNameOffset,
kLastPointerFieldOffset + kPointerSize, kSize>
typedef FixedBodyDescriptor<kNameOffset, kEndOfPointerFieldsOffset, kSize>
BodyDescriptorWeakCode;
// Bit fields in |start_position_and_type|.
......
......@@ -344,7 +344,7 @@ class BitField64 : public BitFieldBase<T, shift, size, uint64_t> { };
#define DEFINE_BIT_FIELD_RANGE_TYPE(Name, Type, Size, _) \
k##Name##Start, k##Name##End = k##Name##Start + Size - 1,
#define DEFINE_BIT_RANGESS(LIST_MACRO) \
#define DEFINE_BIT_RANGES(LIST_MACRO) \
struct LIST_MACRO##_Ranges { \
enum { LIST_MACRO(DEFINE_BIT_FIELD_RANGE_TYPE, _) }; \
};
......@@ -356,11 +356,11 @@ class BitField64 : public BitFieldBase<T, shift, size, uint64_t> { };
typedef BitField64<Type, RangesName::k##Name##Start, Size> Name;
#define DEFINE_BIT_FIELDS(LIST_MACRO) \
DEFINE_BIT_RANGESS(LIST_MACRO) \
DEFINE_BIT_RANGES(LIST_MACRO) \
LIST_MACRO(DEFINE_BIT_FIELD_TYPE, LIST_MACRO##_Ranges)
#define DEFINE_BIT_FIELDS_64(LIST_MACRO) \
DEFINE_BIT_RANGESS(LIST_MACRO) \
DEFINE_BIT_RANGES(LIST_MACRO) \
LIST_MACRO(DEFINE_BIT_FIELD_64_TYPE, LIST_MACRO##_Ranges)
// ----------------------------------------------------------------------------
......@@ -402,6 +402,26 @@ class BitSetComputer {
static int shift(int item) { return (item % kItemsPerWord) * kBitsPerItem; }
};
// Helper macros for defining a contiguous sequence of field offset constants.
// Example: (backslashes at the ends of respective lines of this multi-line
// macro definition are omitted here to please the compiler)
//
// #define MAP_FIELDS(V)
// V(kField1Offset, kPointerSize)
// V(kField2Offset, kIntSize)
// V(kField3Offset, kIntSize)
// V(kField4Offset, kPointerSize)
// V(kSize, 0)
//
// DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
//
#define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + Size - 1,
#define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO) \
enum { \
LIST_MACRO##_StartOffset = StartOffset - 1, \
LIST_MACRO(DEFINE_ONE_FIELD_OFFSET) \
};
// ----------------------------------------------------------------------------
// Hash function.
......
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