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

Side by Side Diff: src/heap.cc

Issue 10816005: Swapped transition array and descriptor array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments, and updated additional code comments. Created 8 years, 4 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 3693 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 // from the function's context, since the function can be from a 3704 // from the function's context, since the function can be from a
3705 // different context. 3705 // different context.
3706 JSFunction* object_function = 3706 JSFunction* object_function =
3707 function->context()->global_context()->object_function(); 3707 function->context()->global_context()->object_function();
3708 3708
3709 // Each function prototype gets a copy of the object function map. 3709 // Each function prototype gets a copy of the object function map.
3710 // This avoid unwanted sharing of maps between prototypes of different 3710 // This avoid unwanted sharing of maps between prototypes of different
3711 // constructors. 3711 // constructors.
3712 Map* new_map; 3712 Map* new_map;
3713 ASSERT(object_function->has_initial_map()); 3713 ASSERT(object_function->has_initial_map());
3714 MaybeObject* maybe_map = 3714 MaybeObject* maybe_map = object_function->initial_map()->Copy();
3715 object_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED);
3716 if (!maybe_map->To(&new_map)) return maybe_map; 3715 if (!maybe_map->To(&new_map)) return maybe_map;
3717 3716
3718 Object* prototype; 3717 Object* prototype;
3719 MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map); 3718 MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map);
3720 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; 3719 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
3721 3720
3722 // When creating the prototype for the function we must set its 3721 // When creating the prototype for the function we must set its
3723 // constructor to the function. 3722 // constructor to the function.
3724 MaybeObject* maybe_failure = 3723 MaybeObject* maybe_failure =
3725 JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes( 3724 JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3849 // the inline_new flag so we only change the map if we generate a 3848 // the inline_new flag so we only change the map if we generate a
3850 // specialized construct stub. 3849 // specialized construct stub.
3851 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields); 3850 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
3852 if (fun->shared()->CanGenerateInlineConstructor(prototype)) { 3851 if (fun->shared()->CanGenerateInlineConstructor(prototype)) {
3853 int count = fun->shared()->this_property_assignments_count(); 3852 int count = fun->shared()->this_property_assignments_count();
3854 if (count > in_object_properties) { 3853 if (count > in_object_properties) {
3855 // Inline constructor can only handle inobject properties. 3854 // Inline constructor can only handle inobject properties.
3856 fun->shared()->ForbidInlineConstructor(); 3855 fun->shared()->ForbidInlineConstructor();
3857 } else { 3856 } else {
3858 DescriptorArray* descriptors; 3857 DescriptorArray* descriptors;
3859 MaybeObject* maybe_descriptors = 3858 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(count);
3860 DescriptorArray::Allocate(count, DescriptorArray::MAY_BE_SHARED);
3861 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors; 3859 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors;
3862 3860
3863 DescriptorArray::WhitenessWitness witness(descriptors); 3861 DescriptorArray::WhitenessWitness witness(descriptors);
3864 for (int i = 0; i < count; i++) { 3862 for (int i = 0; i < count; i++) {
3865 String* name = fun->shared()->GetThisPropertyAssignmentName(i); 3863 String* name = fun->shared()->GetThisPropertyAssignmentName(i);
3866 ASSERT(name->IsSymbol()); 3864 ASSERT(name->IsSymbol());
3867 FieldDescriptor field(name, i, NONE, i + 1); 3865 FieldDescriptor field(name, i, NONE, i + 1);
3868 descriptors->Set(i, &field, witness); 3866 descriptors->Set(i, &field, witness);
3869 } 3867 }
3870 descriptors->Sort(witness); 3868 descriptors->Sort(witness);
3871 3869
3872 // The descriptors may contain duplicates because the compiler does not 3870 // The descriptors may contain duplicates because the compiler does not
3873 // guarantee the uniqueness of property names (it would have required 3871 // guarantee the uniqueness of property names (it would have required
3874 // quadratic time). Once the descriptors are sorted we can check for 3872 // quadratic time). Once the descriptors are sorted we can check for
3875 // duplicates in linear time. 3873 // duplicates in linear time.
3876 if (HasDuplicates(descriptors)) { 3874 if (HasDuplicates(descriptors)) {
3877 fun->shared()->ForbidInlineConstructor(); 3875 fun->shared()->ForbidInlineConstructor();
3878 } else { 3876 } else {
3879 map->InitializeDescriptors(descriptors); 3877 MaybeObject* maybe_failure = map->InitializeDescriptors(descriptors);
3878 if (maybe_failure->IsFailure()) return maybe_failure;
3880 map->set_pre_allocated_property_fields(count); 3879 map->set_pre_allocated_property_fields(count);
3881 map->set_unused_property_fields(in_object_properties - count); 3880 map->set_unused_property_fields(in_object_properties - count);
3882 } 3881 }
3883 } 3882 }
3884 } 3883 }
3885 3884
3886 fun->shared()->StartInobjectSlackTracking(map); 3885 fun->shared()->StartInobjectSlackTracking(map);
3887 3886
3888 return map; 3887 return map;
3889 } 3888 }
(...skipping 3339 matching lines...) Expand 10 before | Expand all | Expand 10 after
7229 static_cast<int>(object_sizes_last_time_[index])); 7228 static_cast<int>(object_sizes_last_time_[index]));
7230 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7229 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7231 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7230 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7232 7231
7233 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7232 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7234 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7233 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7235 ClearObjectStats(); 7234 ClearObjectStats();
7236 } 7235 }
7237 7236
7238 } } // namespace v8::internal 7237 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.cc ('K') | « src/factory.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698