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