Commit c00bb6da authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[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 <ishell@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49361}
parent 9d023c63
...@@ -9084,8 +9084,7 @@ class Internals { ...@@ -9084,8 +9084,7 @@ class Internals {
// These values match non-compiler-dependent values defined within // These values match non-compiler-dependent values defined within
// the implementation of v8. // the implementation of v8.
static const int kHeapObjectMapOffset = 0; static const int kHeapObjectMapOffset = 0;
static const int kMapInstanceTypeAndBitFieldOffset = static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
1 * kApiPointerSize + kApiIntSize;
static const int kStringResourceOffset = 3 * kApiPointerSize; static const int kStringResourceOffset = 3 * kApiPointerSize;
static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double); static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double);
...@@ -9163,9 +9162,7 @@ class Internals { ...@@ -9163,9 +9162,7 @@ class Internals {
V8_INLINE static int GetInstanceType(const internal::Object* obj) { V8_INLINE static int GetInstanceType(const internal::Object* obj) {
typedef internal::Object O; typedef internal::Object O;
O* map = ReadField<O*>(obj, kHeapObjectMapOffset); O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
// Map::InstanceType is defined so that it will always be loaded into return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
// the LS 8 bits of one 16-bit word, regardless of endianess.
return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
} }
V8_INLINE static int GetOddballKind(const internal::Object* obj) { V8_INLINE static int GetOddballKind(const internal::Object* obj) {
......
...@@ -86,7 +86,7 @@ typedef std::vector<Handle<Map>> MapHandles; ...@@ -86,7 +86,7 @@ typedef std::vector<Handle<Map>> MapHandles;
// +---------------+---------------------------------------------+ // +---------------+---------------------------------------------+
// | TaggedPointer | map - Always a pointer to the MetaMap root | // | TaggedPointer | map - Always a pointer to the MetaMap root |
// +---------------+---------------------------------------------+ // +---------------+---------------------------------------------+
// | Int | instance_sizes (the first int field) | // | Int | The first int field |
// `---+----------+---------------------------------------------+ // `---+----------+---------------------------------------------+
// | Byte | [instance_size] | // | Byte | [instance_size] |
// +----------+---------------------------------------------+ // +----------+---------------------------------------------+
...@@ -102,10 +102,14 @@ typedef std::vector<Handle<Map>> MapHandles; ...@@ -102,10 +102,14 @@ typedef std::vector<Handle<Map>> MapHandles;
// +----------+---------------------------------------------+ // +----------+---------------------------------------------+
// | Byte | [visitor_id] | // | Byte | [visitor_id] |
// +----+----------+---------------------------------------------+ // +----+----------+---------------------------------------------+
// | Int | instance_attributes (second int field) | // | Int | The second int field |
// `---+----------+---------------------------------------------+ // `---+----------+---------------------------------------------+
// | Word16 | [instance_type] in low byte | // | Byte | [instance_type] |
// | | [bit_field] in high byte | // +----------+---------------------------------------------+
// | Byte | [unused_property_fields] number of unused |
// | | property fields in JSObject (for fast-mode) |
// +----------+---------------------------------------------+
// | Byte | [bit_field] |
// | | - has_non_instance_prototype (bit 0) | // | | - has_non_instance_prototype (bit 0) |
// | | - is_callable (bit 1) | // | | - is_callable (bit 1) |
// | | - has_named_interceptor (bit 2) | // | | - has_named_interceptor (bit 2) |
...@@ -119,11 +123,8 @@ typedef std::vector<Handle<Map>> MapHandles; ...@@ -119,11 +123,8 @@ typedef std::vector<Handle<Map>> MapHandles;
// | | - is_extensible (bit 0) | // | | - is_extensible (bit 0) |
// | | - is_prototype_map (bit 2) | // | | - is_prototype_map (bit 2) |
// | | - elements_kind (bits 3..7) | // | | - elements_kind (bits 3..7) |
// +----------+---------------------------------------------+
// | Byte | [unused_property_fields] number of unused |
// | | property fields in JSObject (for fast-mode) |
// +----+----------+---------------------------------------------+ // +----+----------+---------------------------------------------+
// | Word | [bit_field3] | // | Int | [bit_field3] |
// | | - number_of_own_descriptors (bit 0..19) | // | | - number_of_own_descriptors (bit 0..19) |
// | | - is_dictionary_map (bit 20) | // | | - is_dictionary_map (bit 20) |
// | | - owns_descriptors (bit 21) | // | | - owns_descriptors (bit 21) |
...@@ -136,9 +137,10 @@ typedef std::vector<Handle<Map>> MapHandles; ...@@ -136,9 +137,10 @@ typedef std::vector<Handle<Map>> MapHandles;
// | | - may_have_interesting_symbols (bit 28) | // | | - may_have_interesting_symbols (bit 28) |
// | | - construction_counter (bit 29..31) | // | | - construction_counter (bit 29..31) |
// | | | // | | |
// | | On systems with 64bit pointer types, there | // +*************************************************************+
// | Int | On systems with 64bit pointer types, there |
// | | is an unused 32bits after bit_field3 | // | | is an unused 32bits after bit_field3 |
// +---------------+---------------------------------------------+ // +*************************************************************+
// | TaggedPointer | [prototype] | // | TaggedPointer | [prototype] |
// +---------------+---------------------------------------------+ // +---------------+---------------------------------------------+
// | TaggedPointer | [constructor_or_backpointer] | // | TaggedPointer | [constructor_or_backpointer] |
...@@ -733,15 +735,21 @@ class Map : public HeapObject { ...@@ -733,15 +735,21 @@ class Map : public HeapObject {
V(kInObjectPropertiesOrConstructorFunctionIndexOffset, kUInt8Size) \ V(kInObjectPropertiesOrConstructorFunctionIndexOffset, kUInt8Size) \
V(kUsedInstanceSizeInWordsOffset, kUInt8Size) \ V(kUsedInstanceSizeInWordsOffset, kUInt8Size) \
V(kVisitorIdOffset, kUInt8Size) \ V(kVisitorIdOffset, kUInt8Size) \
V(kInstanceAttributesOffset, kInt32Size) \ V(kInstanceTypeOffset, kUInt8Size) \
V(kBitField3Offset, kPointerSize) \ /* TODO(ulan): Free this byte after unused_property_fields are */ \
/* computed using the used_instance_size_in_words() byte. */ \
V(kUnusedPropertyFieldsOffset, kUInt8Size) \
V(kBitFieldOffset, kUInt8Size) \
V(kBitField2Offset, kUInt8Size) \
V(kBitField3Offset, kUInt32Size) \
V(k64BitArchPaddingOffset, kPointerSize == kUInt32Size ? 0 : kUInt32Size) \
/* Pointer fields. */ \ /* Pointer fields. */ \
V(kPointerFieldsBeginOffset, 0) \ V(kPointerFieldsBeginOffset, 0) \
V(kPrototypeOffset, kPointerSize) \ V(kPrototypeOffset, kPointerSize) \
V(kConstructorOrBackPointerOffset, kPointerSize) \ V(kConstructorOrBackPointerOffset, kPointerSize) \
V(kTransitionsOrPrototypeInfoOffset, kPointerSize) \ V(kTransitionsOrPrototypeInfoOffset, kPointerSize) \
V(kDescriptorsOffset, kPointerSize) \ V(kDescriptorsOffset, kPointerSize) \
V(kLayoutDescriptorOffset, (FLAG_unbox_double_fields ? kPointerSize : 0)) \ V(kLayoutDescriptorOffset, FLAG_unbox_double_fields ? kPointerSize : 0) \
V(kDependentCodeOffset, kPointerSize) \ V(kDependentCodeOffset, kPointerSize) \
V(kWeakCellCacheOffset, kPointerSize) \ V(kWeakCellCacheOffset, kPointerSize) \
V(kPointerFieldsEndOffset, 0) \ V(kPointerFieldsEndOffset, 0) \
...@@ -751,26 +759,7 @@ class Map : public HeapObject { ...@@ -751,26 +759,7 @@ class Map : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS) DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
#undef MAP_FIELDS #undef MAP_FIELDS
// Byte offsets within kInstanceAttributesOffset attributes. STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
#if V8_TARGET_LITTLE_ENDIAN
// Order instance type and bit field together such that they can be loaded
// together as a 16-bit word with instance type in the lower 8 bits regardless
// of endianess. Also provide endian-independent offset to that 16-bit word.
static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0;
static const int kBitFieldOffset = kInstanceAttributesOffset + 1;
#else
static const int kBitFieldOffset = kInstanceAttributesOffset + 0;
static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1;
#endif
static const int kInstanceTypeAndBitFieldOffset =
kInstanceAttributesOffset + 0;
static const int kBitField2Offset = kInstanceAttributesOffset + 2;
// TODO(ulan): Free this byte after unused_property_fields are computed using
// the used_instance_size_in_words() byte.
static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3;
STATIC_ASSERT(kInstanceTypeAndBitFieldOffset ==
Internals::kMapInstanceTypeAndBitFieldOffset);
// Bit positions for bit field. // Bit positions for bit field.
static const int kHasNonInstancePrototype = 0; static const int kHasNonInstancePrototype = 0;
......
...@@ -455,7 +455,7 @@ class BitSetComputer { ...@@ -455,7 +455,7 @@ class BitSetComputer {
// //
// DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS) // DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, MAP_FIELDS)
// //
#define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + Size - 1, #define DEFINE_ONE_FIELD_OFFSET(Name, Size) Name, Name##End = Name + (Size)-1,
#define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO) \ #define DEFINE_FIELD_OFFSET_CONSTANTS(StartOffset, LIST_MACRO) \
enum { \ enum { \
......
...@@ -247,9 +247,9 @@ extras_accessors = [ ...@@ -247,9 +247,9 @@ extras_accessors = [
'JSArrayBuffer, backing_store, Object, kBackingStoreOffset', 'JSArrayBuffer, backing_store, Object, kBackingStoreOffset',
'JSArrayBufferView, byte_offset, Object, kByteOffsetOffset', 'JSArrayBufferView, byte_offset, Object, kByteOffsetOffset',
'JSTypedArray, length, Object, kLengthOffset', 'JSTypedArray, length, Object, kLengthOffset',
'Map, instance_attributes, int, kInstanceAttributesOffset', 'Map, instance_size, char, kInstanceSizeOffset',
'Map, inobject_properties_or_constructor_function_index, int, kInObjectPropertiesOrConstructorFunctionIndexOffset', 'Map, inobject_properties_or_constructor_function_index, char, kInObjectPropertiesOrConstructorFunctionIndexOffset',
'Map, instance_size, int, kInstanceSizeOffset', 'Map, instance_type, char, kInstanceTypeOffset',
'Map, bit_field, char, kBitFieldOffset', 'Map, bit_field, char, kBitFieldOffset',
'Map, bit_field2, char, kBitField2Offset', 'Map, bit_field2, char, kBitField2Offset',
'Map, bit_field3, int, kBitField3Offset', 'Map, bit_field3, int, kBitField3Offset',
......
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