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

Side by Side Diff: src/transitions.cc

Issue 1704353002: [runtime] Force internalize names used before lookup in in DescriptorArray and TransitionArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « src/property.h ('k') | src/transitions-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/transitions.h" 5 #include "src/transitions.h"
6 6
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 SLOW_DCHECK(result->IsSortedNoDuplicates()); 154 SLOW_DCHECK(result->IsSortedNoDuplicates());
155 ReplaceTransitions(map, *result); 155 ReplaceTransitions(map, *result);
156 } 156 }
157 157
158 158
159 // static 159 // static
160 Map* TransitionArray::SearchTransition(Map* map, PropertyKind kind, Name* name, 160 Map* TransitionArray::SearchTransition(Map* map, PropertyKind kind, Name* name,
161 PropertyAttributes attributes) { 161 PropertyAttributes attributes) {
162 DCHECK(name->IsUniqueName());
162 Object* raw_transitions = map->raw_transitions(); 163 Object* raw_transitions = map->raw_transitions();
163 if (IsSimpleTransition(raw_transitions)) { 164 if (IsSimpleTransition(raw_transitions)) {
164 Map* target = GetSimpleTransition(raw_transitions); 165 Map* target = GetSimpleTransition(raw_transitions);
165 Name* key = GetSimpleTransitionKey(target); 166 Name* key = GetSimpleTransitionKey(target);
166 if (!key->Equals(name)) return NULL; 167 if (key != name) return nullptr;
167 PropertyDetails details = GetSimpleTargetDetails(target); 168 PropertyDetails details = GetSimpleTargetDetails(target);
168 if (details.attributes() != attributes) return NULL; 169 if (details.attributes() != attributes) return nullptr;
169 if (details.kind() != kind) return NULL; 170 if (details.kind() != kind) return nullptr;
170 return target; 171 return target;
171 } 172 }
172 if (IsFullTransitionArray(raw_transitions)) { 173 if (IsFullTransitionArray(raw_transitions)) {
173 TransitionArray* transitions = TransitionArray::cast(raw_transitions); 174 TransitionArray* transitions = TransitionArray::cast(raw_transitions);
174 int transition = transitions->Search(kind, name, attributes); 175 int transition = transitions->Search(kind, name, attributes);
175 if (transition == kNotFound) return NULL; 176 if (transition == kNotFound) return nullptr;
176 return transitions->GetTarget(transition); 177 return transitions->GetTarget(transition);
177 } 178 }
178 return NULL; 179 return NULL;
179 } 180 }
180 181
181 182
182 // static 183 // static
183 Map* TransitionArray::SearchSpecial(Map* map, Symbol* name) { 184 Map* TransitionArray::SearchSpecial(Map* map, Symbol* name) {
184 Object* raw_transitions = map->raw_transitions(); 185 Object* raw_transitions = map->raw_transitions();
185 if (IsFullTransitionArray(raw_transitions)) { 186 if (IsFullTransitionArray(raw_transitions)) {
186 TransitionArray* transitions = TransitionArray::cast(raw_transitions); 187 TransitionArray* transitions = TransitionArray::cast(raw_transitions);
187 int transition = transitions->SearchSpecial(name); 188 int transition = transitions->SearchSpecial(name);
188 if (transition == kNotFound) return NULL; 189 if (transition == kNotFound) return NULL;
189 return transitions->GetTarget(transition); 190 return transitions->GetTarget(transition);
190 } 191 }
191 return NULL; 192 return NULL;
192 } 193 }
193 194
194 195
195 // static 196 // static
196 Handle<Map> TransitionArray::FindTransitionToField(Handle<Map> map, 197 Handle<Map> TransitionArray::FindTransitionToField(Handle<Map> map,
197 Handle<Name> name) { 198 Handle<Name> name) {
199 DCHECK(name->IsUniqueName());
198 DisallowHeapAllocation no_gc; 200 DisallowHeapAllocation no_gc;
199 Map* target = SearchTransition(*map, kData, *name, NONE); 201 Map* target = SearchTransition(*map, kData, *name, NONE);
200 if (target == NULL) return Handle<Map>::null(); 202 if (target == NULL) return Handle<Map>::null();
201 PropertyDetails details = target->GetLastDescriptorDetails(); 203 PropertyDetails details = target->GetLastDescriptorDetails();
202 DCHECK_EQ(NONE, details.attributes()); 204 DCHECK_EQ(NONE, details.attributes());
203 if (details.type() != DATA) return Handle<Map>::null(); 205 if (details.type() != DATA) return Handle<Map>::null();
204 return Handle<Map>(target); 206 return Handle<Map>(target);
205 } 207 }
206 208
207 209
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 } 540 }
539 if (out_insertion_index != NULL) *out_insertion_index = transition; 541 if (out_insertion_index != NULL) *out_insertion_index = transition;
540 return kNotFound; 542 return kNotFound;
541 } 543 }
542 544
543 545
544 int TransitionArray::Search(PropertyKind kind, Name* name, 546 int TransitionArray::Search(PropertyKind kind, Name* name,
545 PropertyAttributes attributes, 547 PropertyAttributes attributes,
546 int* out_insertion_index) { 548 int* out_insertion_index) {
547 int transition = SearchName(name, out_insertion_index); 549 int transition = SearchName(name, out_insertion_index);
548 if (transition == kNotFound) { 550 if (transition == kNotFound) return kNotFound;
549 return kNotFound;
550 }
551 return SearchDetails(transition, kind, attributes, out_insertion_index); 551 return SearchDetails(transition, kind, attributes, out_insertion_index);
552 } 552 }
553 } // namespace internal 553 } // namespace internal
554 } // namespace v8 554 } // namespace v8
OLDNEW
« no previous file with comments | « src/property.h ('k') | src/transitions-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698