OLD | NEW |
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 Handle<WeakCell> target_cell = Map::WeakCellForMap(target_map); | 248 Handle<WeakCell> target_cell = Map::WeakCellForMap(target_map); |
249 | 249 |
250 Handle<FixedArray> cache(GetPrototypeTransitions(*map)); | 250 Handle<FixedArray> cache(GetPrototypeTransitions(*map)); |
251 int capacity = cache->length() - header; | 251 int capacity = cache->length() - header; |
252 int transitions = NumberOfPrototypeTransitions(*cache) + 1; | 252 int transitions = NumberOfPrototypeTransitions(*cache) + 1; |
253 | 253 |
254 if (transitions > capacity) { | 254 if (transitions > capacity) { |
255 // Grow array by factor 2 up to MaxCachedPrototypeTransitions. | 255 // Grow array by factor 2 up to MaxCachedPrototypeTransitions. |
256 int new_capacity = Min(kMaxCachedPrototypeTransitions, transitions * 2); | 256 int new_capacity = Min(kMaxCachedPrototypeTransitions, transitions * 2); |
257 if (new_capacity == capacity) return; | 257 if (new_capacity == capacity) return; |
| 258 int grow_by = new_capacity - capacity; |
258 | 259 |
259 cache = FixedArray::CopySize(cache, header + new_capacity); | 260 Isolate* isolate = map->GetIsolate(); |
| 261 cache = isolate->factory()->CopyFixedArrayAndGrow(cache, grow_by); |
260 if (capacity < 0) { | 262 if (capacity < 0) { |
261 // There was no prototype transitions array before, so the size | 263 // There was no prototype transitions array before, so the size |
262 // couldn't be copied. Initialize it explicitly. | 264 // couldn't be copied. Initialize it explicitly. |
263 SetNumberOfPrototypeTransitions(*cache, 0); | 265 SetNumberOfPrototypeTransitions(*cache, 0); |
264 } | 266 } |
265 | 267 |
266 SetPrototypeTransitions(map, cache); | 268 SetPrototypeTransitions(map, cache); |
267 } | 269 } |
268 | 270 |
269 // Reload number of transitions as GC might shrink them. | 271 // Reload number of transitions as GC might shrink them. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 PropertyAttributes attributes, | 516 PropertyAttributes attributes, |
515 int* out_insertion_index) { | 517 int* out_insertion_index) { |
516 int transition = SearchName(name, out_insertion_index); | 518 int transition = SearchName(name, out_insertion_index); |
517 if (transition == kNotFound) { | 519 if (transition == kNotFound) { |
518 return kNotFound; | 520 return kNotFound; |
519 } | 521 } |
520 return SearchDetails(transition, kind, attributes, out_insertion_index); | 522 return SearchDetails(transition, kind, attributes, out_insertion_index); |
521 } | 523 } |
522 } // namespace internal | 524 } // namespace internal |
523 } // namespace v8 | 525 } // namespace v8 |
OLD | NEW |