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

Side by Side Diff: src/factory.cc

Issue 149458: Remove the descriptor stream abstractions.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/bootstrapper.cc ('k') | src/handles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 Handle<Object> descriptors) { 563 Handle<Object> descriptors) {
564 v8::NeanderArray callbacks(descriptors); 564 v8::NeanderArray callbacks(descriptors);
565 int nof_callbacks = callbacks.length(); 565 int nof_callbacks = callbacks.length();
566 Handle<DescriptorArray> result = 566 Handle<DescriptorArray> result =
567 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks); 567 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks);
568 568
569 // Number of descriptors added to the result so far. 569 // Number of descriptors added to the result so far.
570 int descriptor_count = 0; 570 int descriptor_count = 0;
571 571
572 // Copy the descriptors from the array. 572 // Copy the descriptors from the array.
573 { 573 for (int i = 0; i < array->number_of_descriptors(); i++) {
574 DescriptorWriter w(*result); 574 if (array->GetType(i) != NULL_DESCRIPTOR) {
575 for (DescriptorReader r(*array); !r.eos(); r.advance()) { 575 result->SetFrom(descriptor_count++, *array, i);
iposva 2009/07/10 16:36:15 This would probably be more readable if SetFrom wa
Mads Ager (chromium) 2009/07/10 19:21:08 I agree. Thanks.
576 if (!r.IsNullDescriptor()) {
577 w.WriteFrom(&r);
578 }
579 descriptor_count++;
580 } 576 }
581 } 577 }
582 578
583 // Number of duplicates detected. 579 // Number of duplicates detected.
584 int duplicates = 0; 580 int duplicates = 0;
585 581
586 // Fill in new callback descriptors. Process the callbacks from 582 // Fill in new callback descriptors. Process the callbacks from
587 // back to front so that the last callback with a given name takes 583 // back to front so that the last callback with a given name takes
588 // precedence over previously added callbacks with that name. 584 // precedence over previously added callbacks with that name.
589 for (int i = nof_callbacks - 1; i >= 0; i--) { 585 for (int i = nof_callbacks - 1; i >= 0; i--) {
590 Handle<AccessorInfo> entry = 586 Handle<AccessorInfo> entry =
591 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i))); 587 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i)));
592 // Ensure the key is a symbol before writing into the instance descriptor. 588 // Ensure the key is a symbol before writing into the instance descriptor.
593 Handle<String> key = 589 Handle<String> key =
594 SymbolFromString(Handle<String>(String::cast(entry->name()))); 590 SymbolFromString(Handle<String>(String::cast(entry->name())));
595 // Check if a descriptor with this name already exists before writing. 591 // Check if a descriptor with this name already exists before writing.
596 if (result->LinearSearch(*key, descriptor_count) == 592 if (result->LinearSearch(*key, descriptor_count) ==
597 DescriptorArray::kNotFound) { 593 DescriptorArray::kNotFound) {
598 CallbacksDescriptor desc(*key, *entry, entry->property_attributes()); 594 CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
599 // We do not use a DescriptorWriter because SymbolFromString can 595 // We do not use a DescriptorWriter because SymbolFromString can
iposva 2009/07/10 16:36:15 The DescriptorWriter comment is now outdated here.
Mads Ager (chromium) 2009/07/10 19:21:08 Whoops, done.
600 // allocate. A DescriptorWriter holds a raw pointer and is 596 // allocate. A DescriptorWriter holds a raw pointer and is
601 // therefore not GC safe. 597 // therefore not GC safe.
602 result->Set(descriptor_count, &desc); 598 result->Set(descriptor_count, &desc);
603 descriptor_count++; 599 descriptor_count++;
604 } else { 600 } else {
605 duplicates++; 601 duplicates++;
606 } 602 }
607 } 603 }
608 604
609 // If duplicates were detected, allocate a result of the right size 605 // If duplicates were detected, allocate a result of the right size
610 // and transfer the elements. 606 // and transfer the elements.
611 if (duplicates > 0) { 607 if (duplicates > 0) {
608 int number_of_descriptors = result->number_of_descriptors() - duplicates;
612 Handle<DescriptorArray> new_result = 609 Handle<DescriptorArray> new_result =
613 NewDescriptorArray(result->number_of_descriptors() - duplicates); 610 NewDescriptorArray(number_of_descriptors);
614 DescriptorWriter w(*new_result); 611 for (int i = 0; i < number_of_descriptors; i++) {
615 DescriptorReader r(*result); 612 new_result->SetFrom(i, *result, i);
616 while (!w.eos()) {
617 w.WriteFrom(&r);
618 r.advance();
619 } 613 }
620 result = new_result; 614 result = new_result;
621 } 615 }
622 616
623 // Sort the result before returning. 617 // Sort the result before returning.
624 result->Sort(); 618 result->Sort();
625 return result; 619 return result;
626 } 620 }
627 621
628 622
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 Execution::ConfigureInstance(instance, 918 Execution::ConfigureInstance(instance,
925 instance_template, 919 instance_template,
926 pending_exception); 920 pending_exception);
927 } else { 921 } else {
928 *pending_exception = false; 922 *pending_exception = false;
929 } 923 }
930 } 924 }
931 925
932 926
933 } } // namespace v8::internal 927 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698