Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: src/factory.cc

Issue 10808011: Let DescriptorArray::Append insert at proper position, avoiding need for resorting. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 495313953eb0916376891f06ad795320794d811e..b0fa5f05454996ddda1d08250e01c5c301e2b0ac 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -892,9 +892,9 @@ Handle<String> Factory::SymbolFromString(Handle<String> value) {
}
-Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
- Handle<DescriptorArray> array,
- Handle<Object> descriptors) {
+void Factory::CopyAppendCallbackDescriptors(Handle<Map> map,
+ Handle<Object> descriptors) {
+ Handle<DescriptorArray> array(map->instance_descriptors());
v8::NeanderArray callbacks(descriptors);
int nof_callbacks = callbacks.length();
int descriptor_count = array->number_of_descriptors();
@@ -922,10 +922,7 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
Handle<String> key =
SymbolFromString(Handle<String>(String::cast(entry->name())));
// Check if a descriptor with this name already exists before writing.
- if (LinearSearch(*result,
- EXPECT_UNSORTED,
- *key,
- result->NumberOfSetDescriptors()) ==
+ if (LinearSearch(*result, *key, result->NumberOfSetDescriptors()) ==
DescriptorArray::kNotFound) {
CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
result->Append(&desc, witness);
@@ -933,8 +930,8 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
}
int new_number_of_descriptors = result->NumberOfSetDescriptors();
- // Return the old descriptor array if there were no new elements.
- if (new_number_of_descriptors == descriptor_count) return array;
+ // Don't replace the descriptor array if there were no new elements.
+ if (new_number_of_descriptors == descriptor_count) return;
// If duplicates were detected, allocate a result of the right size
// and transfer the elements.
@@ -944,12 +941,11 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
for (int i = 0; i < new_number_of_descriptors; i++) {
new_result->CopyFrom(i, *result, i, witness);
}
+ new_result->SetLastAdded(result->LastAdded());
result = new_result;
}
- // Sort the result before returning.
- result->Sort(witness);
- return result;
+ map->set_instance_descriptors(*result);
}
@@ -1337,20 +1333,15 @@ Handle<JSFunction> Factory::CreateApiFunction(
result->shared()->DontAdaptArguments();
// Recursively copy parent templates' accessors, 'data' may be modified.
- Handle<DescriptorArray> array =
- Handle<DescriptorArray>(map->instance_descriptors());
while (true) {
Handle<Object> props = Handle<Object>(obj->property_accessors());
if (!props->IsUndefined()) {
- array = CopyAppendCallbackDescriptors(array, props);
+ CopyAppendCallbackDescriptors(map, props);
}
Handle<Object> parent = Handle<Object>(obj->parent_template());
if (parent->IsUndefined()) break;
obj = Handle<FunctionTemplateInfo>::cast(parent);
}
- if (!array->IsEmpty()) {
- map->set_instance_descriptors(*array);
- }
ASSERT(result->shared()->IsApiFunction());
return result;
« no previous file with comments | « src/factory.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698