Commit b489d666 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Append to descriptors over map.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12141 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e469cc44
This diff is collapsed.
...@@ -912,6 +912,8 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map, ...@@ -912,6 +912,8 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map,
} }
} }
map->set_instance_descriptors(*result);
// Fill in new callback descriptors. Process the callbacks from // Fill in new callback descriptors. Process the callbacks from
// back to front so that the last callback with a given name takes // back to front so that the last callback with a given name takes
// precedence over previously added callbacks with that name. // precedence over previously added callbacks with that name.
...@@ -925,13 +927,16 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map, ...@@ -925,13 +927,16 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map,
if (LinearSearch(*result, *key, result->NumberOfSetDescriptors()) == if (LinearSearch(*result, *key, result->NumberOfSetDescriptors()) ==
DescriptorArray::kNotFound) { DescriptorArray::kNotFound) {
CallbacksDescriptor desc(*key, *entry, entry->property_attributes()); CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
result->Append(&desc, witness); map->AppendDescriptor(&desc, witness);
} }
} }
int new_number_of_descriptors = result->NumberOfSetDescriptors(); int new_number_of_descriptors = result->NumberOfSetDescriptors();
// Don't replace the descriptor array if there were no new elements. // Reinstall the original descriptor array if no new elements were added.
if (new_number_of_descriptors == descriptor_count) return; if (new_number_of_descriptors == descriptor_count) {
map->set_instance_descriptors(*array);
return;
}
// If duplicates were detected, allocate a result of the right size // If duplicates were detected, allocate a result of the right size
// and transfer the elements. // and transfer the elements.
...@@ -942,10 +947,8 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map, ...@@ -942,10 +947,8 @@ void Factory::CopyAppendCallbackDescriptors(Handle<Map> map,
new_result->CopyFrom(i, *result, i, witness); new_result->CopyFrom(i, *result, i, witness);
} }
new_result->SetLastAdded(result->LastAdded()); new_result->SetLastAdded(result->LastAdded());
result = new_result; map->set_instance_descriptors(*new_result);
} }
map->set_instance_descriptors(*result);
} }
......
...@@ -2110,9 +2110,10 @@ void DescriptorArray::Set(int descriptor_number, ...@@ -2110,9 +2110,10 @@ void DescriptorArray::Set(int descriptor_number,
} }
void DescriptorArray::Append(Descriptor* desc, int DescriptorArray::Append(Descriptor* desc,
const WhitenessWitness& witness) { const WhitenessWitness& witness,
int descriptor_number = NumberOfSetDescriptors(); int number_of_set_descriptors) {
int descriptor_number = number_of_set_descriptors;
int enumeration_index = descriptor_number + 1; int enumeration_index = descriptor_number + 1;
desc->SetEnumerationIndex(enumeration_index); desc->SetEnumerationIndex(enumeration_index);
...@@ -2128,7 +2129,7 @@ void DescriptorArray::Append(Descriptor* desc, ...@@ -2128,7 +2129,7 @@ void DescriptorArray::Append(Descriptor* desc,
} }
Set(descriptor_number, desc, witness); Set(descriptor_number, desc, witness);
SetLastAdded(descriptor_number); return descriptor_number;
} }
...@@ -3554,6 +3555,14 @@ void Map::ClearDescriptorArray(Heap* heap, WriteBarrierMode mode) { ...@@ -3554,6 +3555,14 @@ void Map::ClearDescriptorArray(Heap* heap, WriteBarrierMode mode) {
} }
void Map::AppendDescriptor(Descriptor* desc,
const DescriptorArray::WhitenessWitness& witness) {
DescriptorArray* descriptors = instance_descriptors();
int set_descriptors = descriptors->NumberOfSetDescriptors();
int new_last_added = descriptors->Append(desc, witness, set_descriptors);
descriptors->SetLastAdded(new_last_added);
}
Object* Map::GetBackPointer() { Object* Map::GetBackPointer() {
Object* object = READ_FIELD(this, kInstanceDescriptorsOrBackPointerOffset); Object* object = READ_FIELD(this, kInstanceDescriptorsOrBackPointerOffset);
......
...@@ -2544,8 +2544,9 @@ class DescriptorArray: public FixedArray { ...@@ -2544,8 +2544,9 @@ class DescriptorArray: public FixedArray {
// Append automatically sets the enumeration index. This should only be used // Append automatically sets the enumeration index. This should only be used
// to add descriptors in bulk at the end, followed by sorting the descriptor // to add descriptors in bulk at the end, followed by sorting the descriptor
// array. // array.
inline void Append(Descriptor* desc, inline int Append(Descriptor* desc,
const WhitenessWitness&); const WhitenessWitness&,
int number_of_set_descriptors);
// Transfer a complete descriptor from the src descriptor array to this // Transfer a complete descriptor from the src descriptor array to this
// descriptor array. // descriptor array.
...@@ -4925,6 +4926,9 @@ class Map: public HeapObject { ...@@ -4925,6 +4926,9 @@ class Map: public HeapObject {
MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
NormalizedMapSharingMode sharing); NormalizedMapSharingMode sharing);
inline void AppendDescriptor(Descriptor* desc,
const DescriptorArray::WhitenessWitness&);
// Returns a copy of the map, with all transitions dropped from the // Returns a copy of the map, with all transitions dropped from the
// instance descriptors. // instance descriptors.
MUST_USE_RESULT MaybeObject* Copy(DescriptorArray::SharedMode shared_mode); MUST_USE_RESULT MaybeObject* Copy(DescriptorArray::SharedMode shared_mode);
......
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