if (details.type() != FIELD) {
indices = Handle<FixedArray>();
} else {
- int field_index = Descriptor::IndexFromValue(descs->GetValue(i));
+ int field_index = descs->GetFieldIndex(i);
if (field_index >= map->inobject_properties()) {
field_index = -(field_index - map->inobject_properties() + 1);
}
if (!name->IsString()) continue;
Handle<String> key = Handle<String>::cast(name);
PropertyDetails details = map->instance_descriptors()->GetDetails(i);
- if (details.IsDontEnum() || details.IsDeleted()) continue;
+ if (details.IsDontEnum()) continue;
Handle<Object> property;
if (details.type() == FIELD && *map == object->map()) {
property = Handle<Object>(
Smi* PropertyDetails::AsSmi() {
- return Smi::FromInt(value_);
+ // Ensure the upper 2 bits have the same value by sign extending it. This is
+ // necessary to be able to use the 31st bit of the property details.
+ int value = value_ << 1;
+ return Smi::FromInt(value >> 1);
}
int DescriptorArray::GetFieldIndex(int descriptor_number) {
- return Descriptor::IndexFromValue(GetValue(descriptor_number));
+ return GetDetails(descriptor_number).field_index();
}
if (details.type() != next_details.type()) break;
if (details.attributes() != next_details.attributes()) break;
if (!details.representation().Equals(next_details.representation())) break;
- ASSERT(!details.IsDeleted());
- ASSERT(!next_details.IsDeleted());
current = next;
}
PropertyDetails(PropertyAttributes attributes,
PropertyType type,
- Representation representation) {
+ Representation representation,
+ int field_index = 0) {
value_ = TypeField::encode(type)
| AttributesField::encode(attributes)
- | RepresentationField::encode(EncodeRepresentation(representation));
+ | RepresentationField::encode(EncodeRepresentation(representation))
+ | FieldIndexField::encode(field_index);
}
int pointer() { return DescriptorPointer::decode(value_); }
return DecodeRepresentation(RepresentationField::decode(value_));
}
+ int field_index() {
+ return FieldIndexField::decode(value_);
+ }
+
inline PropertyDetails AsDeleted();
static bool IsValidIndex(int index) {
// constants can be embedded in generated code.
class TypeField: public BitField<PropertyType, 0, 3> {};
class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
+
+ // Bit fields for normalized objects.
class DeletedField: public BitField<uint32_t, 6, 1> {};
class DictionaryStorageField: public BitField<uint32_t, 7, 24> {};
- class DescriptorPointer: public BitField<uint32_t, 7, 11> {};
- class RepresentationField: public BitField<uint32_t, 18, 3> {};
+
+ // Bit fields for fast objects.
+ class DescriptorPointer: public BitField<uint32_t, 6, 11> {};
+ class RepresentationField: public BitField<uint32_t, 17, 3> {};
+ class FieldIndexField: public BitField<uint32_t, 20, 11> {};
static const int kInitialIndex = 1;
class Descriptor BASE_EMBEDDED {
public:
- static int IndexFromValue(Object* value) {
- return Smi::cast(value)->value();
- }
-
MUST_USE_RESULT MaybeObject* KeyToUniqueName() {
if (!key_->IsUniqueName()) {
MaybeObject* maybe_result = HEAP->InternalizeString(String::cast(key_));
Object* value,
PropertyAttributes attributes,
PropertyType type,
- Representation representation)
+ Representation representation,
+ int field_index = 0)
: key_(key),
value_(value),
- details_(attributes, type, representation) { }
+ details_(attributes, type, representation, field_index) { }
friend class DescriptorArray;
};
int field_index,
PropertyAttributes attributes,
Representation representation)
- : Descriptor(key, Smi::FromInt(field_index), attributes,
- FIELD, representation) {}
+ : Descriptor(key, Smi::FromInt(0), attributes,
+ FIELD, representation, field_index) {}
};
bool IsDontDelete() { return details_.IsDontDelete(); }
bool IsDontEnum() { return details_.IsDontEnum(); }
- bool IsDeleted() { return details_.IsDeleted(); }
bool IsFound() { return lookup_type_ != NOT_FOUND; }
bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; }
bool IsHandler() { return lookup_type_ == HANDLER_TYPE; }
PropertyIndex GetFieldIndex() {
ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
ASSERT(IsField());
- return PropertyIndex::NewFieldIndex(
- Descriptor::IndexFromValue(GetValue()));
+ return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map()));
}
int GetLocalFieldIndexFromMap(Map* map) {
ASSERT(IsField());
- return Descriptor::IndexFromValue(GetValueFromMap(map)) -
- map->inobject_properties();
+ return GetFieldIndexFromMap(map) - map->inobject_properties();
}
int GetDictionaryEntry() {
return map->instance_descriptors()->GetValue(number_);
}
+ int GetFieldIndexFromMap(Map* map) const {
+ ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
+ ASSERT(number_ < map->NumberOfOwnDescriptors());
+ return map->instance_descriptors()->GetFieldIndex(number_);
+ }
+
void Iterate(ObjectVisitor* visitor);
private: