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

Side by Side Diff: src/factory.cc

Issue 10444055: Promoting elements transitions to their own field. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: full patch 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ASSERT(0 <= at_least_space_for); 107 ASSERT(0 <= at_least_space_for);
108 CALL_HEAP_FUNCTION(isolate(), 108 CALL_HEAP_FUNCTION(isolate(),
109 ObjectHashTable::Allocate(at_least_space_for), 109 ObjectHashTable::Allocate(at_least_space_for),
110 ObjectHashTable); 110 ObjectHashTable);
111 } 111 }
112 112
113 113
114 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors) { 114 Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors) {
115 ASSERT(0 <= number_of_descriptors); 115 ASSERT(0 <= number_of_descriptors);
116 CALL_HEAP_FUNCTION(isolate(), 116 CALL_HEAP_FUNCTION(isolate(),
117 DescriptorArray::Allocate(number_of_descriptors), 117 DescriptorArray::Allocate(number_of_descriptors, false),
118 DescriptorArray); 118 DescriptorArray);
119 } 119 }
120 120
121 121
122 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( 122 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
123 int deopt_entry_count, 123 int deopt_entry_count,
124 PretenureFlag pretenure) { 124 PretenureFlag pretenure) {
125 ASSERT(deopt_entry_count > 0); 125 ASSERT(deopt_entry_count > 0);
126 CALL_HEAP_FUNCTION(isolate(), 126 CALL_HEAP_FUNCTION(isolate(),
127 DeoptimizationInputData::Allocate(deopt_entry_count, 127 DeoptimizationInputData::Allocate(deopt_entry_count,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 copy->inobject_properties() + extra_inobject_properties; 488 copy->inobject_properties() + extra_inobject_properties;
489 copy->set_inobject_properties(inobject_properties); 489 copy->set_inobject_properties(inobject_properties);
490 copy->set_unused_property_fields(inobject_properties); 490 copy->set_unused_property_fields(inobject_properties);
491 copy->set_instance_size(copy->instance_size() + instance_size_delta); 491 copy->set_instance_size(copy->instance_size() + instance_size_delta);
492 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); 492 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
493 return copy; 493 return copy;
494 } 494 }
495 495
496 496
497 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) { 497 Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) {
498 CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(), Map); 498 CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(false), Map);
499 } 499 }
500 500
501 501
502 Handle<Map> Factory::GetElementsTransitionMap( 502 Handle<Map> Factory::GetElementsTransitionMap(
503 Handle<JSObject> src, 503 Handle<JSObject> src,
504 ElementsKind elements_kind) { 504 ElementsKind elements_kind) {
505 Isolate* i = isolate(); 505 Isolate* i = isolate();
506 CALL_HEAP_FUNCTION(i, 506 CALL_HEAP_FUNCTION(i,
507 src->GetElementsTransitionMap(i, elements_kind), 507 src->GetElementsTransitionMap(i, elements_kind),
508 Map); 508 Map);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 DescriptorArray); 859 DescriptorArray);
860 } 860 }
861 861
862 862
863 Handle<String> Factory::SymbolFromString(Handle<String> value) { 863 Handle<String> Factory::SymbolFromString(Handle<String> value) {
864 CALL_HEAP_FUNCTION(isolate(), 864 CALL_HEAP_FUNCTION(isolate(),
865 isolate()->heap()->LookupSymbol(*value), String); 865 isolate()->heap()->LookupSymbol(*value), String);
866 } 866 }
867 867
868 868
869 static int LinearSearchUnsorted(DescriptorArray* descriptor_array,
870 String* name, int len) {
871 uint32_t hash = name->Hash();
872 for (int number = 0; number < len; number++) {
873 String* entry = descriptor_array->GetKey(number);
874 if (entry->Hash() == hash &&
875 name->Equals(entry) &&
876 !descriptor_array->IsNullDescriptor(number)) {
877 return number;
878 }
879 }
880 return DescriptorArray::kNotFound;
881 }
882
883
869 Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors( 884 Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
870 Handle<DescriptorArray> array, 885 Handle<DescriptorArray> array,
871 Handle<Object> descriptors) { 886 Handle<Object> descriptors) {
872 v8::NeanderArray callbacks(descriptors); 887 v8::NeanderArray callbacks(descriptors);
873 int nof_callbacks = callbacks.length(); 888 int nof_callbacks = callbacks.length();
874 Handle<DescriptorArray> result = 889 Handle<DescriptorArray> result =
875 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks); 890 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks);
876 891
877 // Number of descriptors added to the result so far. 892 // Number of descriptors added to the result so far.
878 int descriptor_count = 0; 893 int descriptor_count = 0;
(...skipping 14 matching lines...) Expand all
893 // Fill in new callback descriptors. Process the callbacks from 908 // Fill in new callback descriptors. Process the callbacks from
894 // back to front so that the last callback with a given name takes 909 // back to front so that the last callback with a given name takes
895 // precedence over previously added callbacks with that name. 910 // precedence over previously added callbacks with that name.
896 for (int i = nof_callbacks - 1; i >= 0; i--) { 911 for (int i = nof_callbacks - 1; i >= 0; i--) {
897 Handle<AccessorInfo> entry = 912 Handle<AccessorInfo> entry =
898 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i))); 913 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i)));
899 // Ensure the key is a symbol before writing into the instance descriptor. 914 // Ensure the key is a symbol before writing into the instance descriptor.
900 Handle<String> key = 915 Handle<String> key =
901 SymbolFromString(Handle<String>(String::cast(entry->name()))); 916 SymbolFromString(Handle<String>(String::cast(entry->name())));
902 // Check if a descriptor with this name already exists before writing. 917 // Check if a descriptor with this name already exists before writing.
903 if (result->LinearSearch(*key, descriptor_count) == 918 if (LinearSearchUnsorted(*result, *key, descriptor_count) ==
danno 2012/06/01 13:49:55 Add a enum { EXPECT_SORTED, EXPECT_UNSORTED } and
Toon Verwaest 2012/06/04 09:17:48 Done.
904 DescriptorArray::kNotFound) { 919 DescriptorArray::kNotFound) {
905 CallbacksDescriptor desc(*key, *entry, entry->property_attributes()); 920 CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
906 result->Set(descriptor_count, &desc, witness); 921 result->Set(descriptor_count, &desc, witness);
907 descriptor_count++; 922 descriptor_count++;
908 } else { 923 } else {
909 duplicates++; 924 duplicates++;
910 } 925 }
911 } 926 }
912 927
913 // If duplicates were detected, allocate a result of the right size 928 // If duplicates were detected, allocate a result of the right size
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1456
1442 1457
1443 Handle<Object> Factory::ToBoolean(bool value) { 1458 Handle<Object> Factory::ToBoolean(bool value) {
1444 return Handle<Object>(value 1459 return Handle<Object>(value
1445 ? isolate()->heap()->true_value() 1460 ? isolate()->heap()->true_value()
1446 : isolate()->heap()->false_value()); 1461 : isolate()->heap()->false_value());
1447 } 1462 }
1448 1463
1449 1464
1450 } } // namespace v8::internal 1465 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/heap.cc » ('j') | src/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698