5 #ifndef V8_FIELD_INDEX_INL_H_ 6 #define V8_FIELD_INDEX_INL_H_ 8 #include "src/field-index.h" 9 #include "src/objects-inl.h" 10 #include "src/objects/descriptor-array.h" 15 inline FieldIndex FieldIndex::ForInObjectOffset(
int offset, Encoding encoding) {
16 DCHECK(encoding == kWord32 ? (offset % kInt32Size) == 0
17 : (offset % kPointerSize) == 0);
18 return FieldIndex(
true, offset, encoding, 0, 0);
21 inline FieldIndex FieldIndex::ForPropertyIndex(
const Map map,
23 Representation representation) {
24 DCHECK(map->instance_type() >= FIRST_NONSTRING_TYPE);
25 int inobject_properties = map->GetInObjectProperties();
26 bool is_inobject = property_index < inobject_properties;
27 int first_inobject_offset;
30 first_inobject_offset = map->GetInObjectPropertyOffset(0);
31 offset = map->GetInObjectPropertyOffset(property_index);
33 first_inobject_offset = FixedArray::kHeaderSize;
34 property_index -= inobject_properties;
35 offset = FixedArray::kHeaderSize + property_index * kPointerSize;
37 Encoding encoding = FieldEncoding(representation);
38 return FieldIndex(is_inobject, offset, encoding, inobject_properties,
39 first_inobject_offset);
45 inline int FieldIndex::GetLoadByFieldIndex()
const {
54 result -= JSObject::kHeaderSize / kPointerSize;
56 result -= FixedArray::kHeaderSize / kPointerSize;
60 return is_double() ? (result | 1) : result;
63 inline FieldIndex FieldIndex::ForDescriptor(
const Map map,
64 int descriptor_index) {
65 PropertyDetails details =
66 map->instance_descriptors()->GetDetails(descriptor_index);
67 int field_index = details.field_index();
68 return ForPropertyIndex(map, field_index, details.representation());
74 #endif // V8_FIELD_INDEX_INL_H_