OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FIELD_INDEX_INL_H_ | 5 #ifndef V8_FIELD_INDEX_INL_H_ |
6 #define V8_FIELD_INDEX_INL_H_ | 6 #define V8_FIELD_INDEX_INL_H_ |
7 | 7 |
8 #include "src/field-index.h" | 8 #include "src/field-index.h" |
9 #include "src/ic/handler-configuration.h" | |
10 | 9 |
11 namespace v8 { | 10 namespace v8 { |
12 namespace internal { | 11 namespace internal { |
13 | 12 |
14 | 13 |
15 inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) { | 14 inline FieldIndex FieldIndex::ForInObjectOffset(int offset, Map* map) { |
16 DCHECK((offset % kPointerSize) == 0); | 15 DCHECK((offset % kPointerSize) == 0); |
17 int index = offset / kPointerSize; | 16 int index = offset / kPointerSize; |
18 DCHECK(map == NULL || | 17 DCHECK(map == NULL || |
19 index < (map->GetInObjectPropertyOffset(0) / kPointerSize + | 18 index < (map->GetInObjectPropertyOffset(0) / kPointerSize + |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 result = -result - 1; | 81 result = -result - 1; |
83 } | 82 } |
84 result <<= 1; | 83 result <<= 1; |
85 return is_double() ? (result | 1) : result; | 84 return is_double() ? (result | 1) : result; |
86 } | 85 } |
87 | 86 |
88 // Takes an offset as computed by GetLoadByFieldOffset and reconstructs a | 87 // Takes an offset as computed by GetLoadByFieldOffset and reconstructs a |
89 // FieldIndex object from it. | 88 // FieldIndex object from it. |
90 // static | 89 // static |
91 inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) { | 90 inline FieldIndex FieldIndex::ForLoadByFieldOffset(Map* map, int offset) { |
92 DCHECK(LoadHandlerTypeBit::decode(offset) == kLoadICHandlerForProperties); | 91 DCHECK(offset & 1); // Property marker (as opposed to element). |
93 bool is_inobject = FieldOffsetIsInobject::decode(offset); | 92 bool is_inobject = FieldOffsetIsInobject::decode(offset); |
94 bool is_double = FieldOffsetIsDouble::decode(offset); | 93 bool is_double = FieldOffsetIsDouble::decode(offset); |
95 int field_index = FieldOffsetOffset::decode(offset) >> kPointerSizeLog2; | 94 int field_index = FieldOffsetOffset::decode(offset) >> kPointerSizeLog2; |
96 int first_inobject_offset = 0; | 95 int first_inobject_offset = 0; |
97 if (is_inobject) { | 96 if (is_inobject) { |
98 first_inobject_offset = | 97 first_inobject_offset = |
99 map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0; | 98 map->IsJSObjectMap() ? map->GetInObjectPropertyOffset(0) : 0; |
100 } else { | 99 } else { |
101 first_inobject_offset = FixedArray::kHeaderSize; | 100 first_inobject_offset = FixedArray::kHeaderSize; |
102 } | 101 } |
103 int inobject_properties = | 102 int inobject_properties = |
104 map->IsJSObjectMap() ? map->GetInObjectProperties() : 0; | 103 map->IsJSObjectMap() ? map->GetInObjectProperties() : 0; |
105 FieldIndex result(is_inobject, field_index, is_double, inobject_properties, | 104 FieldIndex result(is_inobject, field_index, is_double, inobject_properties, |
106 first_inobject_offset); | 105 first_inobject_offset); |
107 DCHECK(result.GetLoadByFieldOffset() == offset); | 106 DCHECK(result.GetLoadByFieldOffset() == offset); |
108 return result; | 107 return result; |
109 } | 108 } |
110 | 109 |
111 // Returns the offset format consumed by TurboFan stubs: | 110 // Returns the offset format consumed by TurboFan stubs: |
112 // (offset << 3) | (is_double << 2) | (is_inobject << 1) | is_property | 111 // (offset << 3) | (is_double << 2) | (is_inobject << 1) | is_property |
113 // Where |offset| is relative to object start or FixedArray start, respectively. | 112 // Where |offset| is relative to object start or FixedArray start, respectively. |
114 inline int FieldIndex::GetLoadByFieldOffset() const { | 113 inline int FieldIndex::GetLoadByFieldOffset() const { |
115 return FieldOffsetIsInobject::encode(is_inobject()) | | 114 return FieldOffsetIsInobject::encode(is_inobject()) | |
116 FieldOffsetIsDouble::encode(is_double()) | | 115 FieldOffsetIsDouble::encode(is_double()) | |
117 FieldOffsetOffset::encode(index() << kPointerSizeLog2) | | 116 FieldOffsetOffset::encode(index() << kPointerSizeLog2) | |
118 LoadHandlerTypeBit::encode(kLoadICHandlerForProperties); | 117 1; // Property marker (as opposed to element). |
119 } | 118 } |
120 | 119 |
121 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { | 120 inline FieldIndex FieldIndex::ForDescriptor(Map* map, int descriptor_index) { |
122 PropertyDetails details = | 121 PropertyDetails details = |
123 map->instance_descriptors()->GetDetails(descriptor_index); | 122 map->instance_descriptors()->GetDetails(descriptor_index); |
124 int field_index = details.field_index(); | 123 int field_index = details.field_index(); |
125 return ForPropertyIndex(map, field_index, | 124 return ForPropertyIndex(map, field_index, |
126 details.representation().IsDouble()); | 125 details.representation().IsDouble()); |
127 } | 126 } |
128 | 127 |
(...skipping 18 matching lines...) Expand all Loading... |
147 } else { | 146 } else { |
148 return property_index(); | 147 return property_index(); |
149 } | 148 } |
150 } | 149 } |
151 | 150 |
152 | 151 |
153 } // namespace internal | 152 } // namespace internal |
154 } // namespace v8 | 153 } // namespace v8 |
155 | 154 |
156 #endif | 155 #endif |
OLD | NEW |