Reviewers: Jakob,
Message:
PTAL
Description:
Move field index into property details, freeing up the value slot of fields.
BUG=
Please review this at https://codereview.chromium.org/15941016/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/handles.cc
M src/json-stringifier.h
M src/objects-inl.h
M src/objects.cc
M src/property-details.h
M src/property.h
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index
7a8d5c90bc5fa97ac289a600ebe0cfc68b243906..8b3a2db9d315f54dd55ce5681fd7be830062bfcf
100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -802,7 +802,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject>
object,
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);
}
Index: src/json-stringifier.h
diff --git a/src/json-stringifier.h b/src/json-stringifier.h
index
f548a2e7f9e446199a3162539b3ed6c99a738466..e4a978dcee341a1cf0331d927ecd1d97d9f19bfa
100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -640,7 +640,7 @@ BasicJsonStringifier::Result
BasicJsonStringifier::SerializeJSObject(
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>(
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
d0958eef29a0faa736980f8b8bd23887da101375..3d64383c46097e9200c3e65251005f7efb6df00b
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -58,7 +58,10 @@ PropertyDetails::PropertyDetails(Smi* smi) {
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);
}
@@ -2327,7 +2330,7 @@ PropertyType DescriptorArray::GetType(int
descriptor_number) {
int DescriptorArray::GetFieldIndex(int descriptor_number) {
- return Descriptor::IndexFromValue(GetValue(descriptor_number));
+ return GetDetails(descriptor_number).field_index();
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
e83a32d059d19ee30bbf1a0e4fa27b21ec739452..53aa6e60e456f266a4567884035c52d45f2923c3
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2497,8 +2497,6 @@ Map* Map::FindLastMatchMap(int verbatim,
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;
}
Index: src/property-details.h
diff --git a/src/property-details.h b/src/property-details.h
index
3bb1f3368e9efdda6cdef3a6b95e9b003a5e4254..9f8b8431fd1570d46a2d4330ada0e6c4155cd87f
100644
--- a/src/property-details.h
+++ b/src/property-details.h
@@ -169,10 +169,12 @@ class PropertyDetails BASE_EMBEDDED {
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_); }
@@ -214,6 +216,10 @@ class PropertyDetails BASE_EMBEDDED {
return DecodeRepresentation(RepresentationField::decode(value_));
}
+ int field_index() {
+ return FieldIndexField::decode(value_);
+ }
+
inline PropertyDetails AsDeleted();
static bool IsValidIndex(int index) {
@@ -231,8 +237,9 @@ class PropertyDetails BASE_EMBEDDED {
class AttributesField: public BitField<PropertyAttributes, 3,
3> {};
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> {};
+ 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;
Index: src/property.h
diff --git a/src/property.h b/src/property.h
index
606f111525fb566056443bc80cc4de1a1ef79ca7..124775faec753abdb4ff680fb054565422b06544
100644
--- a/src/property.h
+++ b/src/property.h
@@ -44,10 +44,6 @@ namespace internal {
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_));
@@ -89,10 +85,11 @@ class Descriptor BASE_EMBEDDED {
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;
};
@@ -104,8 +101,8 @@ class FieldDescriptor: public Descriptor {
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) {}
};
@@ -311,7 +308,6 @@ class LookupResult BASE_EMBEDDED {
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; }
@@ -417,14 +413,12 @@ class LookupResult BASE_EMBEDDED {
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() {
@@ -466,6 +460,12 @@ class LookupResult BASE_EMBEDDED {
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:
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.