DescriptorArray::IsProperty-related cleanup.

More minor changes related to property predicates:

 * Slightly simplify logic when handling hidden properties.

 * Make IsProperty usage more consistent in RemoveTransitions.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10617 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2012-02-07 08:59:03 +00:00
parent 029aa9ef92
commit 2a02f4838b

View File

@ -3773,12 +3773,14 @@ MaybeObject* JSObject::GetHiddenPropertiesDictionary(bool create_if_absent) {
// code zero) it will always occupy the first entry if present.
DescriptorArray* descriptors = this->map()->instance_descriptors();
if ((descriptors->number_of_descriptors() > 0) &&
(descriptors->GetKey(0) == GetHeap()->hidden_symbol()) &&
descriptors->IsProperty(0)) {
ASSERT(descriptors->GetType(0) == FIELD);
Object* hidden_store =
this->FastPropertyAt(descriptors->GetFieldIndex(0));
return StringDictionary::cast(hidden_store);
(descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
if (descriptors->GetType(0) == FIELD) {
Object* hidden_store =
this->FastPropertyAt(descriptors->GetFieldIndex(0));
return StringDictionary::cast(hidden_store);
} else {
ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
}
}
} else {
PropertyAttributes attributes;
@ -3819,11 +3821,13 @@ MaybeObject* JSObject::SetHiddenPropertiesDictionary(
// code zero) it will always occupy the first entry if present.
DescriptorArray* descriptors = this->map()->instance_descriptors();
if ((descriptors->number_of_descriptors() > 0) &&
(descriptors->GetKey(0) == GetHeap()->hidden_symbol()) &&
descriptors->IsProperty(0)) {
ASSERT(descriptors->GetType(0) == FIELD);
this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary);
return this;
(descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
if (descriptors->GetType(0) == FIELD) {
this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary);
return this;
} else {
ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
}
}
}
MaybeObject* store_result =
@ -5832,14 +5836,14 @@ MaybeObject* DescriptorArray::RemoveTransitions() {
// not be allocated.
// Compute the size of the map transition entries to be removed.
int num_removed = 0;
int new_number_of_descriptors = 0;
for (int i = 0; i < number_of_descriptors(); i++) {
if (!IsProperty(i)) num_removed++;
if (IsProperty(i)) new_number_of_descriptors++;
}
// Allocate the new descriptor array.
DescriptorArray* new_descriptors;
{ MaybeObject* maybe_result = Allocate(number_of_descriptors() - num_removed);
{ MaybeObject* maybe_result = Allocate(new_number_of_descriptors);
if (!maybe_result->To<DescriptorArray>(&new_descriptors)) {
return maybe_result;
}