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

Unified Diff: src/factory.cc

Issue 10575032: In-place shrinking of descriptor arrays with non-live transitions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 8 years, 6 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/bootstrapper.cc ('k') | src/ic.cc » ('j') | src/ic.cc » ('J')
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 682125e3af5f90ae53d284f4cad85f36238cb015..92b6b6e0176de87bcaf4beab7d266d93ea2d852d 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -939,25 +939,18 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
Handle<Object> descriptors) {
v8::NeanderArray callbacks(descriptors);
int nof_callbacks = callbacks.length();
+ int descriptor_count = array->number_of_descriptors();
Handle<DescriptorArray> result =
- NewDescriptorArray(array->number_of_descriptors() + nof_callbacks);
-
- // Number of descriptors added to the result so far.
- int descriptor_count = 0;
+ NewDescriptorArray(descriptor_count + nof_callbacks);
// Ensure that marking will not progress and change color of objects.
DescriptorArray::WhitenessWitness witness(*result);
// Copy the descriptors from the array.
- for (int i = 0; i < array->number_of_descriptors(); i++) {
- if (!array->IsNullDescriptor(i)) {
- DescriptorArray::CopyFrom(result, descriptor_count++, array, i, witness);
- }
+ for (int i = 0; i < descriptor_count; i++) {
+ DescriptorArray::CopyFrom(result, i, array, i, witness);
}
- // Number of duplicates detected.
- int duplicates = 0;
-
// 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.
@@ -973,18 +966,14 @@ Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
result->Set(descriptor_count, &desc, witness);
descriptor_count++;
- } else {
- duplicates++;
}
}
// If duplicates were detected, allocate a result of the right size
// and transfer the elements.
- if (duplicates > 0) {
- int number_of_descriptors = result->number_of_descriptors() - duplicates;
- Handle<DescriptorArray> new_result =
- NewDescriptorArray(number_of_descriptors);
- for (int i = 0; i < number_of_descriptors; i++) {
+ if (descriptor_count < result->length()) {
+ Handle<DescriptorArray> new_result = NewDescriptorArray(descriptor_count);
+ for (int i = 0; i < descriptor_count; i++) {
DescriptorArray::CopyFrom(new_result, i, result, i, witness);
}
result = new_result;
« no previous file with comments | « src/bootstrapper.cc ('k') | src/ic.cc » ('j') | src/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698