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

Side by Side Diff: src/factory.cc

Issue 8360004: Avoid incremental marking write-barrier when constructing descriptor arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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/heap.cc » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 Handle<DescriptorArray> array, 824 Handle<DescriptorArray> array,
825 Handle<Object> descriptors) { 825 Handle<Object> descriptors) {
826 v8::NeanderArray callbacks(descriptors); 826 v8::NeanderArray callbacks(descriptors);
827 int nof_callbacks = callbacks.length(); 827 int nof_callbacks = callbacks.length();
828 Handle<DescriptorArray> result = 828 Handle<DescriptorArray> result =
829 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks); 829 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks);
830 830
831 // Number of descriptors added to the result so far. 831 // Number of descriptors added to the result so far.
832 int descriptor_count = 0; 832 int descriptor_count = 0;
833 833
834 // Ensure that marking will not progress and change color of objects.
835 DescriptorArray::WhitenessWitness witness(*result);
836
834 // Copy the descriptors from the array. 837 // Copy the descriptors from the array.
835 for (int i = 0; i < array->number_of_descriptors(); i++) { 838 for (int i = 0; i < array->number_of_descriptors(); i++) {
836 if (array->GetType(i) != NULL_DESCRIPTOR) { 839 if (array->GetType(i) != NULL_DESCRIPTOR) {
837 result->CopyFrom(descriptor_count++, *array, i); 840 result->CopyFrom(descriptor_count++, *array, i, witness);
838 } 841 }
839 } 842 }
840 843
841 // Number of duplicates detected. 844 // Number of duplicates detected.
842 int duplicates = 0; 845 int duplicates = 0;
843 846
844 // Fill in new callback descriptors. Process the callbacks from 847 // Fill in new callback descriptors. Process the callbacks from
845 // back to front so that the last callback with a given name takes 848 // back to front so that the last callback with a given name takes
846 // precedence over previously added callbacks with that name. 849 // precedence over previously added callbacks with that name.
847 for (int i = nof_callbacks - 1; i >= 0; i--) { 850 for (int i = nof_callbacks - 1; i >= 0; i--) {
848 Handle<AccessorInfo> entry = 851 Handle<AccessorInfo> entry =
849 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i))); 852 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i)));
850 // Ensure the key is a symbol before writing into the instance descriptor. 853 // Ensure the key is a symbol before writing into the instance descriptor.
851 Handle<String> key = 854 Handle<String> key =
852 SymbolFromString(Handle<String>(String::cast(entry->name()))); 855 SymbolFromString(Handle<String>(String::cast(entry->name())));
853 // Check if a descriptor with this name already exists before writing. 856 // Check if a descriptor with this name already exists before writing.
854 if (result->LinearSearch(*key, descriptor_count) == 857 if (result->LinearSearch(*key, descriptor_count) ==
855 DescriptorArray::kNotFound) { 858 DescriptorArray::kNotFound) {
856 CallbacksDescriptor desc(*key, *entry, entry->property_attributes()); 859 CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
857 result->Set(descriptor_count, &desc); 860 result->Set(descriptor_count, &desc, witness);
858 descriptor_count++; 861 descriptor_count++;
859 } else { 862 } else {
860 duplicates++; 863 duplicates++;
861 } 864 }
862 } 865 }
863 866
864 // If duplicates were detected, allocate a result of the right size 867 // If duplicates were detected, allocate a result of the right size
865 // and transfer the elements. 868 // and transfer the elements.
866 if (duplicates > 0) { 869 if (duplicates > 0) {
867 int number_of_descriptors = result->number_of_descriptors() - duplicates; 870 int number_of_descriptors = result->number_of_descriptors() - duplicates;
868 Handle<DescriptorArray> new_result = 871 Handle<DescriptorArray> new_result =
869 NewDescriptorArray(number_of_descriptors); 872 NewDescriptorArray(number_of_descriptors);
870 for (int i = 0; i < number_of_descriptors; i++) { 873 for (int i = 0; i < number_of_descriptors; i++) {
871 new_result->CopyFrom(i, *result, i); 874 new_result->CopyFrom(i, *result, i, witness);
872 } 875 }
873 result = new_result; 876 result = new_result;
874 } 877 }
875 878
876 // Sort the result before returning. 879 // Sort the result before returning.
877 result->Sort(); 880 result->Sort(witness);
878 return result; 881 return result;
879 } 882 }
880 883
881 884
882 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, 885 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
883 PretenureFlag pretenure) { 886 PretenureFlag pretenure) {
884 CALL_HEAP_FUNCTION( 887 CALL_HEAP_FUNCTION(
885 isolate(), 888 isolate(),
886 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); 889 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
887 } 890 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1350
1348 1351
1349 Handle<Object> Factory::ToBoolean(bool value) { 1352 Handle<Object> Factory::ToBoolean(bool value) {
1350 return Handle<Object>(value 1353 return Handle<Object>(value
1351 ? isolate()->heap()->true_value() 1354 ? isolate()->heap()->true_value()
1352 : isolate()->heap()->false_value()); 1355 : isolate()->heap()->false_value());
1353 } 1356 }
1354 1357
1355 1358
1356 } } // namespace v8::internal 1359 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/heap.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698