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

Side by Side Diff: src/transitions.cc

Issue 661133002: TransitionArray now uses <is_data_property, name, attributes> tuple as a key, which allows to have … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/objects.h" 7 #include "src/objects.h"
8 #include "src/transitions-inl.h" 8 #include "src/transitions-inl.h"
9 #include "src/utils.h" 9 #include "src/utils.h"
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 Handle<Name> name, 89 Handle<Name> name,
90 Handle<Map> target, 90 Handle<Map> target,
91 SimpleTransitionFlag flag) { 91 SimpleTransitionFlag flag) {
92 if (!map->HasTransitionArray()) { 92 if (!map->HasTransitionArray()) {
93 return TransitionArray::NewWith(map, name, target, flag); 93 return TransitionArray::NewWith(map, name, target, flag);
94 } 94 }
95 95
96 int number_of_transitions = map->transitions()->number_of_transitions(); 96 int number_of_transitions = map->transitions()->number_of_transitions();
97 int new_size = number_of_transitions; 97 int new_size = number_of_transitions;
98 98
99 int insertion_index = map->transitions()->Search(*name); 99 bool is_special_transition = IsSpecialTransition(*name);
100 PropertyDetails details = is_special_transition
101 ? PropertyDetails(NONE, NORMAL, 0)
102 : GetTargetDetails(*name, *target);
103
104 int insertion_index =
105 is_special_transition
106 ? map->transitions()->SearchSpecial(Symbol::cast(*name))
107 : map->transitions()->Search(details.type(), *name,
108 details.attributes());
100 if (insertion_index == kNotFound) ++new_size; 109 if (insertion_index == kNotFound) ++new_size;
101 110
102 Handle<TransitionArray> result = Allocate(map->GetIsolate(), new_size); 111 Handle<TransitionArray> result = Allocate(map->GetIsolate(), new_size);
103 112
104 // The map's transition array may grown smaller during the allocation above as 113 // The map's transition array may grown smaller during the allocation above as
105 // it was weakly traversed, though it is guaranteed not to disappear. Trim the 114 // it was weakly traversed, though it is guaranteed not to disappear. Trim the
106 // result copy if needed, and recompute variables. 115 // result copy if needed, and recompute variables.
107 DCHECK(map->HasTransitionArray()); 116 DCHECK(map->HasTransitionArray());
108 DisallowHeapAllocation no_gc; 117 DisallowHeapAllocation no_gc;
109 TransitionArray* array = map->transitions(); 118 TransitionArray* array = map->transitions();
110 if (array->number_of_transitions() != number_of_transitions) { 119 if (array->number_of_transitions() != number_of_transitions) {
111 DCHECK(array->number_of_transitions() < number_of_transitions); 120 DCHECK(array->number_of_transitions() < number_of_transitions);
112 121
113 number_of_transitions = array->number_of_transitions(); 122 number_of_transitions = array->number_of_transitions();
114 new_size = number_of_transitions; 123 new_size = number_of_transitions;
115 124
116 insertion_index = array->Search(*name); 125 insertion_index =
126 is_special_transition
127 ? map->transitions()->SearchSpecial(Symbol::cast(*name))
128 : map->transitions()->Search(details.type(), *name,
129 details.attributes());
117 if (insertion_index == kNotFound) ++new_size; 130 if (insertion_index == kNotFound) ++new_size;
118 131
119 result->Shrink(ToKeyIndex(new_size)); 132 result->Shrink(ToKeyIndex(new_size));
120 } 133 }
121 134
122 if (array->HasPrototypeTransitions()) { 135 if (array->HasPrototypeTransitions()) {
123 result->SetPrototypeTransitions(array->GetPrototypeTransitions()); 136 result->SetPrototypeTransitions(array->GetPrototypeTransitions());
124 } 137 }
125 138
126 if (insertion_index != kNotFound) { 139 if (insertion_index != kNotFound) {
127 for (int i = 0; i < number_of_transitions; ++i) { 140 for (int i = 0; i < number_of_transitions; ++i) {
128 if (i != insertion_index) { 141 if (i != insertion_index) {
129 result->NoIncrementalWriteBarrierCopyFrom(array, i, i); 142 result->NoIncrementalWriteBarrierCopyFrom(array, i, i);
130 } 143 }
131 } 144 }
145
146 DCHECK_NE(map->instance_descriptors(),
147 array->GetTarget(insertion_index)->instance_descriptors());
132 result->NoIncrementalWriteBarrierSet(insertion_index, *name, *target); 148 result->NoIncrementalWriteBarrierSet(insertion_index, *name, *target);
133 result->set_back_pointer_storage(array->back_pointer_storage()); 149 result->set_back_pointer_storage(array->back_pointer_storage());
134 return result; 150 return result;
135 } 151 }
136 152
137 insertion_index = 0; 153 insertion_index = 0;
138 for (; insertion_index < number_of_transitions; ++insertion_index) { 154 for (; insertion_index < number_of_transitions; ++insertion_index) {
139 if (InsertionPointFound(array->GetKey(insertion_index), *name)) break; 155 if (InsertionPointFound(array->GetKey(insertion_index), *name)) break;
140 result->NoIncrementalWriteBarrierCopyFrom( 156 result->NoIncrementalWriteBarrierCopyFrom(
141 array, insertion_index, insertion_index); 157 array, insertion_index, insertion_index);
142 } 158 }
143 159
144 result->NoIncrementalWriteBarrierSet(insertion_index, *name, *target); 160 result->NoIncrementalWriteBarrierSet(insertion_index, *name, *target);
145 161
146 for (; insertion_index < number_of_transitions; ++insertion_index) { 162 for (; insertion_index < number_of_transitions; ++insertion_index) {
147 result->NoIncrementalWriteBarrierCopyFrom( 163 result->NoIncrementalWriteBarrierCopyFrom(
148 array, insertion_index, insertion_index + 1); 164 array, insertion_index, insertion_index + 1);
149 } 165 }
150 166
151 result->set_back_pointer_storage(array->back_pointer_storage()); 167 result->set_back_pointer_storage(array->back_pointer_storage());
152 return result; 168 return result;
153 } 169 }
154 170
155 171
172 int TransitionArray::SearchNext(int transition, PropertyType type, Name* name,
173 PropertyAttributes attributes) {
174 int nof_transitions = number_of_transitions();
175 bool is_data = type == FIELD || type == CONSTANT;
176 for (;;) {
177 Map* target = GetTarget(transition);
178 PropertyDetails target_details = GetTargetDetails(name, target);
179 bool target_is_data =
180 target_details.type() == FIELD || target_details.type() == CONSTANT;
181
182 if (target_is_data == is_data &&
183 target_details.attributes() == attributes) {
184 return transition;
185 }
186 transition++;
187 if ((transition >= nof_transitions) || !GetKey(transition)->Equals(name)) {
188 break;
189 }
190 }
191 return kNotFound;
192 }
193
194
195 int TransitionArray::Search(PropertyType type, Name* name,
196 PropertyAttributes attributes) {
197 int transition = SearchFirst(name);
198 if (transition == kNotFound) {
199 return kNotFound;
200 }
201 return SearchNext(transition, type, name, attributes);
202 }
156 } } // namespace v8::internal 203 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/transitions.h ('k') | src/transitions-inl.h » ('j') | src/transitions-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698