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
parent 029aa9ef
...@@ -3773,12 +3773,14 @@ MaybeObject* JSObject::GetHiddenPropertiesDictionary(bool create_if_absent) { ...@@ -3773,12 +3773,14 @@ MaybeObject* JSObject::GetHiddenPropertiesDictionary(bool create_if_absent) {
// code zero) it will always occupy the first entry if present. // code zero) it will always occupy the first entry if present.
DescriptorArray* descriptors = this->map()->instance_descriptors(); DescriptorArray* descriptors = this->map()->instance_descriptors();
if ((descriptors->number_of_descriptors() > 0) && if ((descriptors->number_of_descriptors() > 0) &&
(descriptors->GetKey(0) == GetHeap()->hidden_symbol()) && (descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
descriptors->IsProperty(0)) { if (descriptors->GetType(0) == FIELD) {
ASSERT(descriptors->GetType(0) == FIELD); Object* hidden_store =
Object* hidden_store = this->FastPropertyAt(descriptors->GetFieldIndex(0));
this->FastPropertyAt(descriptors->GetFieldIndex(0)); return StringDictionary::cast(hidden_store);
return StringDictionary::cast(hidden_store); } else {
ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
}
} }
} else { } else {
PropertyAttributes attributes; PropertyAttributes attributes;
...@@ -3819,11 +3821,13 @@ MaybeObject* JSObject::SetHiddenPropertiesDictionary( ...@@ -3819,11 +3821,13 @@ MaybeObject* JSObject::SetHiddenPropertiesDictionary(
// code zero) it will always occupy the first entry if present. // code zero) it will always occupy the first entry if present.
DescriptorArray* descriptors = this->map()->instance_descriptors(); DescriptorArray* descriptors = this->map()->instance_descriptors();
if ((descriptors->number_of_descriptors() > 0) && if ((descriptors->number_of_descriptors() > 0) &&
(descriptors->GetKey(0) == GetHeap()->hidden_symbol()) && (descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
descriptors->IsProperty(0)) { if (descriptors->GetType(0) == FIELD) {
ASSERT(descriptors->GetType(0) == FIELD); this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary);
this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary); return this;
return this; } else {
ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
}
} }
} }
MaybeObject* store_result = MaybeObject* store_result =
...@@ -5832,14 +5836,14 @@ MaybeObject* DescriptorArray::RemoveTransitions() { ...@@ -5832,14 +5836,14 @@ MaybeObject* DescriptorArray::RemoveTransitions() {
// not be allocated. // not be allocated.
// Compute the size of the map transition entries to be removed. // 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++) { 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. // Allocate the new descriptor array.
DescriptorArray* new_descriptors; 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)) { if (!maybe_result->To<DescriptorArray>(&new_descriptors)) {
return maybe_result; return maybe_result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment