Revision: 10617
Author: [email protected]
Date: Tue Feb 7 00:59:03 2012
Log: 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
http://code.google.com/p/v8/source/detail?r=10617
Modified:
/branches/bleeding_edge/src/objects.cc
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Feb 6 05:54:46 2012
+++ /branches/bleeding_edge/src/objects.cc Tue Feb 7 00:59:03 2012
@@ -3773,12 +3773,14 @@
// 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 @@
// 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 @@
// 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;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev