Permalink
Browse files

Free up 11 bits in fast-mode PropertyDetails by removing the enumerat…

…ion-index.

The descriptors are nowadays ordered in order of addition, so that info was
duplicated.

Review URL: https://chromiumcodereview.appspot.com/14622005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@14571 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information...
verwaest@chromium.org
verwaest@chromium.org committed May 7, 2013
1 parent d61ad0c commit 34d4209389de3309046715f763897a2bf35a392d
View
@@ -2409,7 +2409,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
if (from->HasFastProperties()) {
Handle<DescriptorArray> descs =
Handle<DescriptorArray>(from->map()->instance_descriptors());
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
+ for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) {
PropertyDetails details = descs->GetDetails(i);
switch (details.type()) {
case FIELD: {
@@ -2443,10 +2443,8 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
// Add to dictionary.
Handle<Name> key = Handle<Name>(descs->GetKey(i));
Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate());
- PropertyDetails d = PropertyDetails(details.attributes(),
- CALLBACKS,
- Representation::Tagged(),
- details.descriptor_index());
+ PropertyDetails d = PropertyDetails(
+ details.attributes(), CALLBACKS, i + 1);
JSObject::SetNormalizedProperty(to, key, callbacks, d);
break;
}
@@ -1309,8 +1309,7 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) {
if (js_obj->HasFastProperties()) {
DescriptorArray* descs = js_obj->map()->instance_descriptors();
int real_size = js_obj->map()->NumberOfOwnDescriptors();
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
- if (descs->GetDetails(i).descriptor_index() > real_size) continue;
+ for (int i = 0; i < real_size; i++) {
switch (descs->GetType(i)) {
case FIELD: {
int index = descs->GetFieldIndex(i);
View
@@ -4160,7 +4160,7 @@ MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) {
ASSERT(name->IsInternalizedString());
// TODO(verwaest): Since we cannot update the boilerplate's map yet,
// initialize to the worst case.
- FieldDescriptor field(name, i, NONE, Representation::Tagged(), i + 1);
+ FieldDescriptor field(name, i, NONE, Representation::Tagged());
descriptors->Set(i, &field, witness);
}
descriptors->Sort();
@@ -4589,13 +4589,10 @@ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
// The global object might be created from an object template with accessors.
// Fill these accessors into the dictionary.
DescriptorArray* descs = map->instance_descriptors();
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
+ for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
PropertyDetails details = descs->GetDetails(i);
ASSERT(details.type() == CALLBACKS); // Only accessors are expected.
- PropertyDetails d = PropertyDetails(details.attributes(),
- CALLBACKS,
- Representation::None(),
- details.descriptor_index());
+ PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1);
Object* value = descs->GetCallbacksObject(i);
MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value);
if (!maybe_value->ToObject(&value)) return maybe_value;
View
@@ -323,10 +323,6 @@ void Map::MapVerify() {
instance_size() < HEAP->Capacity()));
VerifyHeapPointer(prototype());
VerifyHeapPointer(instance_descriptors());
- DescriptorArray* descriptors = instance_descriptors();
- for (int i = 0; i < NumberOfOwnDescriptors(); ++i) {
- CHECK_EQ(i, descriptors->GetDetails(i).descriptor_index() - 1);
- }
SLOW_ASSERT(instance_descriptors()->IsSortedNoDuplicates());
if (HasTransitionArray()) {
SLOW_ASSERT(transitions()->IsSortedNoDuplicates());
View
@@ -58,10 +58,7 @@ PropertyDetails::PropertyDetails(Smi* smi) {
Smi* PropertyDetails::AsSmi() {
- // 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);
+ return Smi::FromInt(value_);
}
@@ -2347,9 +2344,6 @@ void DescriptorArray::Set(int descriptor_number,
const WhitenessWitness&) {
// Range check.
ASSERT(descriptor_number < number_of_descriptors());
- ASSERT(desc->GetDetails().descriptor_index() <=
- number_of_descriptors());
- ASSERT(desc->GetDetails().descriptor_index() > 0);
ASSERT(!desc->GetDetails().representation().IsNone());
NoIncrementalWriteBarrierSet(this,
@@ -2367,9 +2361,6 @@ void DescriptorArray::Set(int descriptor_number,
void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
// Range check.
ASSERT(descriptor_number < number_of_descriptors());
- ASSERT(desc->GetDetails().descriptor_index() <=
- number_of_descriptors());
- ASSERT(desc->GetDetails().descriptor_index() > 0);
ASSERT(!desc->GetDetails().representation().IsNone());
set(ToKeyIndex(descriptor_number), desc->GetKey());
@@ -2381,9 +2372,7 @@ void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
void DescriptorArray::Append(Descriptor* desc,
const WhitenessWitness& witness) {
int descriptor_number = number_of_descriptors();
- int enumeration_index = descriptor_number + 1;
SetNumberOfDescriptors(descriptor_number + 1);
- desc->SetEnumerationIndex(enumeration_index);
Set(descriptor_number, desc, witness);
uint32_t hash = desc->GetKey()->Hash();
@@ -2402,9 +2391,7 @@ void DescriptorArray::Append(Descriptor* desc,
void DescriptorArray::Append(Descriptor* desc) {
int descriptor_number = number_of_descriptors();
- int enumeration_index = descriptor_number + 1;
SetNumberOfDescriptors(descriptor_number + 1);
- desc->SetEnumerationIndex(enumeration_index);
Set(descriptor_number, desc);
uint32_t hash = desc->GetKey()->Hash();
@@ -4152,23 +4139,6 @@ static MaybeObject* EnsureHasTransitionArray(Map* map) {
void Map::InitializeDescriptors(DescriptorArray* descriptors) {
int len = descriptors->number_of_descriptors();
-#ifdef DEBUG
- ASSERT(len <= DescriptorArray::kMaxNumberOfDescriptors);
-
- bool used_indices[DescriptorArray::kMaxNumberOfDescriptors];
- for (int i = 0; i < len; ++i) used_indices[i] = false;
-
- // Ensure that all enumeration indexes between 1 and length occur uniquely in
- // the descriptor array.
- for (int i = 0; i < len; ++i) {
- int enum_index = descriptors->GetDetails(i).descriptor_index() -
- PropertyDetails::kInitialIndex;
- ASSERT(0 <= enum_index && enum_index < len);
- ASSERT(!used_indices[enum_index]);
- used_indices[enum_index] = true;
- }
-#endif
-
set_instance_descriptors(descriptors);
SetNumberOfOwnDescriptors(len);
}
Oops, something went wrong.

0 comments on commit 34d4209

Please sign in to comment.