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

Side by Side Diff: src/objects.cc

Issue 239203002: Move CopyReplaceDescriptors to private (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 5738 matching lines...) Expand 10 before | Expand all | Expand 10 after
5749 int transition_index = old_map->SearchTransition( 5749 int transition_index = old_map->SearchTransition(
5750 isolate->heap()->frozen_symbol()); 5750 isolate->heap()->frozen_symbol());
5751 if (transition_index != TransitionArray::kNotFound) { 5751 if (transition_index != TransitionArray::kNotFound) {
5752 Handle<Map> transition_map(old_map->GetTransition(transition_index)); 5752 Handle<Map> transition_map(old_map->GetTransition(transition_index));
5753 ASSERT(transition_map->has_dictionary_elements()); 5753 ASSERT(transition_map->has_dictionary_elements());
5754 ASSERT(transition_map->is_frozen()); 5754 ASSERT(transition_map->is_frozen());
5755 ASSERT(!transition_map->is_extensible()); 5755 ASSERT(!transition_map->is_extensible());
5756 JSObject::MigrateToMap(object, transition_map); 5756 JSObject::MigrateToMap(object, transition_map);
5757 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) { 5757 } else if (object->HasFastProperties() && old_map->CanHaveMoreTransitions()) {
5758 // Create a new descriptor array with fully-frozen properties 5758 // Create a new descriptor array with fully-frozen properties
5759 int num_descriptors = old_map->NumberOfOwnDescriptors(); 5759 Handle<Map> new_map = Map::CopyForFreeze(old_map);
5760 Handle<DescriptorArray> new_descriptors =
5761 DescriptorArray::CopyUpToAddAttributes(
5762 handle(old_map->instance_descriptors()), num_descriptors, FROZEN);
5763 Handle<Map> new_map = Map::CopyReplaceDescriptors(
5764 old_map, new_descriptors, INSERT_TRANSITION,
5765 isolate->factory()->frozen_symbol());
5766 new_map->freeze();
5767 new_map->set_is_extensible(false);
5768 new_map->set_elements_kind(DICTIONARY_ELEMENTS);
5769 JSObject::MigrateToMap(object, new_map); 5760 JSObject::MigrateToMap(object, new_map);
5770 } else { 5761 } else {
5771 // Slow path: need to normalize properties for safety 5762 // Slow path: need to normalize properties for safety
5772 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); 5763 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0);
5773 5764
5774 // Create a new map, since other objects with this map may be extensible. 5765 // Create a new map, since other objects with this map may be extensible.
5775 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. 5766 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps.
5776 Handle<Map> new_map = Map::Copy(handle(object->map())); 5767 Handle<Map> new_map = Map::Copy(handle(object->map()));
5777 new_map->freeze(); 5768 new_map->freeze();
5778 new_map->set_is_extensible(false); 5769 new_map->set_is_extensible(false);
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
6960 map->set_transitions(*transitions); 6951 map->set_transitions(*transitions);
6961 map->set_owns_descriptors(false); 6952 map->set_owns_descriptors(false);
6962 6953
6963 return result; 6954 return result;
6964 } 6955 }
6965 6956
6966 6957
6967 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, 6958 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
6968 Handle<DescriptorArray> descriptors, 6959 Handle<DescriptorArray> descriptors,
6969 TransitionFlag flag, 6960 TransitionFlag flag,
6970 SimpleTransitionFlag simple_flag) { 6961 MaybeHandle<Name> maybe_name,
6971 return CopyReplaceDescriptors(
6972 map, descriptors, flag, Handle<Name>::null(), simple_flag);
6973 }
6974
6975
6976 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map,
6977 Handle<DescriptorArray> descriptors,
6978 TransitionFlag flag,
6979 Handle<Name> name,
6980 SimpleTransitionFlag simple_flag) { 6962 SimpleTransitionFlag simple_flag) {
6981 ASSERT(descriptors->IsSortedNoDuplicates()); 6963 ASSERT(descriptors->IsSortedNoDuplicates());
6982 6964
6983 Handle<Map> result = CopyDropDescriptors(map); 6965 Handle<Map> result = CopyDropDescriptors(map);
6984 result->InitializeDescriptors(*descriptors); 6966 result->InitializeDescriptors(*descriptors);
6985 6967
6986 if (flag == INSERT_TRANSITION && map->CanHaveMoreTransitions()) { 6968 if (flag == INSERT_TRANSITION && map->CanHaveMoreTransitions()) {
6969 Handle<Name> name;
6970 CHECK(maybe_name.ToHandle(&name));
6987 Handle<TransitionArray> transitions = TransitionArray::CopyInsert( 6971 Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
6988 map, name, result, simple_flag); 6972 map, name, result, simple_flag);
6989 map->set_transitions(*transitions); 6973 map->set_transitions(*transitions);
6990 result->SetBackPointer(*map); 6974 result->SetBackPointer(*map);
6991 } else { 6975 } else {
6992 int length = descriptors->number_of_descriptors(); 6976 int length = descriptors->number_of_descriptors();
6993 for (int i = 0; i < length; i++) { 6977 for (int i = 0; i < length; i++) {
6994 descriptors->SetRepresentation(i, Representation::Tagged()); 6978 descriptors->SetRepresentation(i, Representation::Tagged());
6995 if (descriptors->GetDetails(i).type() == FIELD) { 6979 if (descriptors->GetDetails(i).type() == FIELD) {
6996 descriptors->SetValue(i, HeapType::Any()); 6980 descriptors->SetValue(i, HeapType::Any());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
7113 new_map->SetBackPointer(*map); 7097 new_map->SetBackPointer(*map);
7114 return new_map; 7098 return new_map;
7115 } 7099 }
7116 7100
7117 7101
7118 Handle<Map> Map::Copy(Handle<Map> map) { 7102 Handle<Map> Map::Copy(Handle<Map> map) {
7119 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 7103 Handle<DescriptorArray> descriptors(map->instance_descriptors());
7120 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); 7104 int number_of_own_descriptors = map->NumberOfOwnDescriptors();
7121 Handle<DescriptorArray> new_descriptors = 7105 Handle<DescriptorArray> new_descriptors =
7122 DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors); 7106 DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors);
7123 return CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION); 7107 return CopyReplaceDescriptors(
7108 map, new_descriptors, OMIT_TRANSITION, MaybeHandle<Name>());
7124 } 7109 }
7125 7110
7126 7111
7127 Handle<Map> Map::Create(Handle<JSFunction> constructor, 7112 Handle<Map> Map::Create(Handle<JSFunction> constructor,
7128 int extra_inobject_properties) { 7113 int extra_inobject_properties) {
7129 Handle<Map> copy = Copy(handle(constructor->initial_map())); 7114 Handle<Map> copy = Copy(handle(constructor->initial_map()));
7130 7115
7131 // Check that we do not overflow the instance size when adding the 7116 // Check that we do not overflow the instance size when adding the
7132 // extra inobject properties. 7117 // extra inobject properties.
7133 int instance_size_delta = extra_inobject_properties * kPointerSize; 7118 int instance_size_delta = extra_inobject_properties * kPointerSize;
(...skipping 12 matching lines...) Expand all
7146 int inobject_properties = 7131 int inobject_properties =
7147 copy->inobject_properties() + extra_inobject_properties; 7132 copy->inobject_properties() + extra_inobject_properties;
7148 copy->set_inobject_properties(inobject_properties); 7133 copy->set_inobject_properties(inobject_properties);
7149 copy->set_unused_property_fields(inobject_properties); 7134 copy->set_unused_property_fields(inobject_properties);
7150 copy->set_instance_size(copy->instance_size() + instance_size_delta); 7135 copy->set_instance_size(copy->instance_size() + instance_size_delta);
7151 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy)); 7136 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
7152 return copy; 7137 return copy;
7153 } 7138 }
7154 7139
7155 7140
7141 Handle<Map> Map::CopyForFreeze(Handle<Map> map) {
7142 int num_descriptors = map->NumberOfOwnDescriptors();
7143 Isolate* isolate = map->GetIsolate();
7144 Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes(
7145 handle(map->instance_descriptors(), isolate), num_descriptors, FROZEN);
7146 Handle<Map> new_map = Map::CopyReplaceDescriptors(
7147 map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol());
7148 new_map->freeze();
7149 new_map->set_is_extensible(false);
7150 new_map->set_elements_kind(DICTIONARY_ELEMENTS);
7151 return new_map;
7152 }
7153
7154
7156 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map, 7155 Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
7157 Descriptor* descriptor, 7156 Descriptor* descriptor,
7158 TransitionFlag flag) { 7157 TransitionFlag flag) {
7159 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 7158 Handle<DescriptorArray> descriptors(map->instance_descriptors());
7160 7159
7161 // Ensure the key is unique. 7160 // Ensure the key is unique.
7162 descriptor->KeyToUniqueName(); 7161 descriptor->KeyToUniqueName();
7163 7162
7164 if (flag == INSERT_TRANSITION && 7163 if (flag == INSERT_TRANSITION &&
7165 map->owns_descriptors() && 7164 map->owns_descriptors() &&
(...skipping 9422 matching lines...) Expand 10 before | Expand all | Expand 10 after
16588 #define ERROR_MESSAGES_TEXTS(C, T) T, 16587 #define ERROR_MESSAGES_TEXTS(C, T) T,
16589 static const char* error_messages_[] = { 16588 static const char* error_messages_[] = {
16590 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16589 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16591 }; 16590 };
16592 #undef ERROR_MESSAGES_TEXTS 16591 #undef ERROR_MESSAGES_TEXTS
16593 return error_messages_[reason]; 16592 return error_messages_[reason];
16594 } 16593 }
16595 16594
16596 16595
16597 } } // namespace v8::internal 16596 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698