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