Skip to content

Commit c00bb6d

Browse files
isheludkoCommit Bot
authored andcommitted
[runtime] Prepare Map fields definition for extending instance type field.
Bug: v8:5799 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I2c412f40aba6135dd0dafc7daa57420071ffee1c Reviewed-on: https://chromium-review.googlesource.com/768414 Commit-Queue: Igor Sheludko <[email protected]> Reviewed-by: Camillo Bruni <[email protected]> Cr-Commit-Position: refs/heads/master@{#49361}
1 parent 9d023c6 commit c00bb6d

4 files changed

Lines changed: 28 additions & 42 deletions

File tree

include/v8.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9084,8 +9084,7 @@ class Internals {
90849084
// These values match non-compiler-dependent values defined within
90859085
// the implementation of v8.
90869086
static const int kHeapObjectMapOffset = 0;
9087-
static const int kMapInstanceTypeAndBitFieldOffset =
9088-
1 * kApiPointerSize + kApiIntSize;
9087+
static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
90899088
static const int kStringResourceOffset = 3 * kApiPointerSize;
90909089

90919090
static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double);
@@ -9163,9 +9162,7 @@ class Internals {
91639162
V8_INLINE static int GetInstanceType(const internal::Object* obj) {
91649163
typedef internal::Object O;
91659164
O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
9166-
// Map::InstanceType is defined so that it will always be loaded into
9167-
// the LS 8 bits of one 16-bit word, regardless of endianess.
9168-
return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
9165+
return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
91699166
}
91709167

91719168
V8_INLINE static int GetOddballKind(const internal::Object* obj) {

src/objects/map.h

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ typedef std::vector<Handle<Map>> MapHandles;
8686
// +---------------+---------------------------------------------+
8787
// | TaggedPointer | map - Always a pointer to the MetaMap root |
8888
// +---------------+---------------------------------------------+
89-
// | Int | instance_sizes (the first int field) |
89+
// | Int | The first int field |
9090
// `---+----------+---------------------------------------------+
9191
// | Byte | [instance_size] |
9292
// +----------+---------------------------------------------+
@@ -102,10 +102,14 @@ typedef std::vector<Handle<Map>> MapHandles;
102102
// +----------+---------------------------------------------+
103103
// | Byte | [visitor_id] |
104104
// +----+----------+---------------------------------------------+
105-
// | Int | instance_attributes (second int field) |
105+
// | Int | The second int field |
106106
// `---+----------+---------------------------------------------+
107-
// | Word16 | [instance_type] in low byte |
108-
// | | [bit_field] in high byte |
107+
// | Byte | [instance_type] |
108+
// +----------+---------------------------------------------+
109+
// | Byte | [unused_property_fields] number of unused |
110+
// | | property fields in JSObject (for fast-mode) |
111+
// +----------+---------------------------------------------+
112+
// | Byte | [bit_field] |
109113
// | | - has_non_instance_prototype (bit 0) |
110114
// | | - is_callable (bit 1) |
111115
// | | - has_named_interceptor (bit 2) |
@@ -119,11 +123,8 @@ typedef std::vector<Handle<Map>> MapHandles;
119123
// | | - is_extensible (bit 0) |
120124
// | | - is_prototype_map (bit 2) |
121125
// | | - elements_kind (bits 3..7) |
122-
// +----------+---------------------------------------------+
123-
// | Byte | [unused_property_fields] number of unused |
124-
// | | property fields in JSObject (for fast-mode) |
125126
// +----+----------+---------------------------------------------+
126-
// | Word | [bit_field3] |
127+
// | Int | [bit_field3] |
127128
// | | - number_of_own_descriptors (bit 0..19) |
128129
// | | - is_dictionary_map (bit 20) |
129130
// | | - owns_descriptors (bit 21) |
@@ -136,9 +137,10 @@ typedef std::vector<Handle<Map>> MapHandles;
136137
// | | - may_have_interesting_symbols (bit 28) |
137138
// | | - construction_counter (bit 29..31) |
138139
// | | |
139-
// | | On systems with 64bit pointer types, there |
140+
// +*************************************************************+
141+
// | Int | On systems with 64bit pointer types, there |
140142
// | | is an unused 32bits after bit_field3 |
141-
// +---------------+---------------------------------------------+
143+
// +*************************************************************+
142144
// | TaggedPointer | [prototype] |
143145
// +---------------+---------------------------------------------+
144146
// | TaggedPointer | [constructor_or_backpointer] |
@@ -733,15 +735,21 @@ class Map : public HeapObject {
733735
V(kInObjectPropertiesOrConstructorFunctionIndexOffset, kUInt8Size) \
734736
V(kUsedInstanceSizeInWordsOffset, kUInt8Size) \
735737
V(kVisitorIdOffset, kUInt8Size) \
736-
V(kInstanceAttributesOffset, kInt32Size) \
737-
V(kBitField3Offset, kPointerSize) \
738+
V(kInstanceTypeOffset, kUInt8Size) \
739+
/* TODO(ulan): Free this byte after unused_property_fields are */ \
740+
/* computed using the used_instance_size_in_words() byte. */ \
741+
V(kUnusedPropertyFieldsOffset, kUInt8Size) \
742+
V(kBitFieldOffset, kUInt8Size) \
743+
V(kBitField2Offset, kUInt8Size) \
744+
V(kBitField3Offset, kUInt32Size) \
745+
V(k64BitArchPaddingOffset, kPointerSize == kUInt32Size ? 0 : kUInt32Size) \
738746
/* Pointer fields. */ \
739747
V(kPointerFieldsBeginOffset, 0) \
740748
V(kPrototypeOffset, kPointerSize) \
741749
V(kConstructorOrBackPointerOffset, kPointerSize) \
742750
V(kTransitionsOrPrototypeInfoOffset, kPointerSize) \
743751
V(kDescriptorsOffset, kPointerSize) \
744-
V(kLayoutDescriptorOffset, (FLAG_unbox_double_fields ? kPointerSize : 0)) \
752+
V(kLayoutDescriptorOffset, FLAG_unbox_double_fields ? kPointerSize : 0) \
745753
V(kDependentCodeOffset, kPointerSize) \
746754
V(kWeakCellCacheOffset, kPointerSize) \
747755
V(kPointerFieldsEndOffset, 0) \
@@ -751,26 +759,7 @@ class Map : public HeapObject {
751759
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
752760
#undef MAP_FIELDS
753761

754-
// Byte offsets within kInstanceAttributesOffset attributes.
755-
#if V8_TARGET_LITTLE_ENDIAN
756-
// Order instance type and bit field together such that they can be loaded
757-
// together as a 16-bit word with instance type in the lower 8 bits regardless
758-
// of endianess. Also provide endian-independent offset to that 16-bit word.
759-
static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0;
760-
static const int kBitFieldOffset = kInstanceAttributesOffset + 1;
761-
#else
762-
static const int kBitFieldOffset = kInstanceAttributesOffset + 0;
763-
static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1;
764-
#endif
765-
static const int kInstanceTypeAndBitFieldOffset =
766-
kInstanceAttributesOffset + 0;
767-
static const int kBitField2Offset = kInstanceAttributesOffset + 2;
768-
// TODO(ulan): Free this byte after unused_property_fields are computed using
769-
// the used_instance_size_in_words() byte.
770-
static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3;
771-
772-
STATIC_ASSERT(kInstanceTypeAndBitFieldOffset ==
773-
Internals::kMapInstanceTypeAndBitFieldOffset);
762+
STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
774763

775764
// Bit positions for bit field.
776765
static const int kHasNonInstancePrototype = 0;

src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class BitSetComputer {
455455
//
456456
// DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
457457
//
458-
#define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + Size - 1,
458+
#define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + (Size)-1,
459459

460460
#define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO) \
461461
enum { \

tools/gen-postmortem-metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@
247247
'JSArrayBuffer, backing_store, Object, kBackingStoreOffset',
248248
'JSArrayBufferView, byte_offset, Object, kByteOffsetOffset',
249249
'JSTypedArray, length, Object, kLengthOffset',
250-
'Map, instance_attributes, int, kInstanceAttributesOffset',
251-
'Map, inobject_properties_or_constructor_function_index, int, kInObjectPropertiesOrConstructorFunctionIndexOffset',
252-
'Map, instance_size, int, kInstanceSizeOffset',
250+
'Map, instance_size, char, kInstanceSizeOffset',
251+
'Map, inobject_properties_or_constructor_function_index, char, kInObjectPropertiesOrConstructorFunctionIndexOffset',
252+
'Map, instance_type, char, kInstanceTypeOffset',
253253
'Map, bit_field, char, kBitFieldOffset',
254254
'Map, bit_field2, char, kBitField2Offset',
255255
'Map, bit_field3, int, kBitField3Offset',

0 commit comments

Comments
 (0)