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/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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if (t->length() <= kFirstIndex) return 0; | 384 if (t->length() <= kFirstIndex) return 0; |
385 return (t->length() - kFirstIndex) / kTransitionSize; | 385 return (t->length() - kFirstIndex) / kTransitionSize; |
386 } | 386 } |
387 | 387 |
388 | 388 |
389 // Private static helper functions. | 389 // Private static helper functions. |
390 | 390 |
391 Handle<TransitionArray> TransitionArray::Allocate(Isolate* isolate, | 391 Handle<TransitionArray> TransitionArray::Allocate(Isolate* isolate, |
392 int number_of_transitions, | 392 int number_of_transitions, |
393 int slack) { | 393 int slack) { |
394 Handle<FixedArray> array = isolate->factory()->NewFixedArray( | 394 Handle<FixedArray> array = isolate->factory()->NewTransitionArray( |
395 LengthFor(number_of_transitions + slack), TENURED); | 395 LengthFor(number_of_transitions + slack)); |
| 396 array->set(kNextLinkIndex, isolate->heap()->undefined_value()); |
396 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); | 397 array->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); |
397 array->set(kTransitionLengthIndex, Smi::FromInt(number_of_transitions)); | 398 array->set(kTransitionLengthIndex, Smi::FromInt(number_of_transitions)); |
398 return Handle<TransitionArray>::cast(array); | 399 return Handle<TransitionArray>::cast(array); |
399 } | 400 } |
400 | 401 |
401 | 402 |
402 static void ZapTransitionArray(TransitionArray* transitions) { | 403 // static |
403 MemsetPointer(transitions->data_start(), | 404 void TransitionArray::ZapTransitionArray(TransitionArray* transitions) { |
| 405 // Do not zap the next link that is used by GC. |
| 406 STATIC_ASSERT(kNextLinkIndex + 1 == kPrototypeTransitionsIndex); |
| 407 MemsetPointer(transitions->data_start() + kPrototypeTransitionsIndex, |
404 transitions->GetHeap()->the_hole_value(), | 408 transitions->GetHeap()->the_hole_value(), |
405 transitions->length()); | 409 transitions->length() - kPrototypeTransitionsIndex); |
| 410 transitions->SetNumberOfTransitions(0); |
406 } | 411 } |
407 | 412 |
408 | 413 |
409 void TransitionArray::ReplaceTransitions(Handle<Map> map, | 414 void TransitionArray::ReplaceTransitions(Handle<Map> map, |
410 Object* new_transitions) { | 415 Object* new_transitions) { |
411 Object* raw_transitions = map->raw_transitions(); | 416 Object* raw_transitions = map->raw_transitions(); |
412 if (IsFullTransitionArray(raw_transitions)) { | 417 if (IsFullTransitionArray(raw_transitions)) { |
413 TransitionArray* old_transitions = TransitionArray::cast(raw_transitions); | 418 TransitionArray* old_transitions = TransitionArray::cast(raw_transitions); |
414 #ifdef DEBUG | 419 #ifdef DEBUG |
415 CheckNewTransitionsAreConsistent(map, old_transitions, new_transitions); | 420 CheckNewTransitionsAreConsistent(map, old_transitions, new_transitions); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 PropertyAttributes attributes, | 545 PropertyAttributes attributes, |
541 int* out_insertion_index) { | 546 int* out_insertion_index) { |
542 int transition = SearchName(name, out_insertion_index); | 547 int transition = SearchName(name, out_insertion_index); |
543 if (transition == kNotFound) { | 548 if (transition == kNotFound) { |
544 return kNotFound; | 549 return kNotFound; |
545 } | 550 } |
546 return SearchDetails(transition, kind, attributes, out_insertion_index); | 551 return SearchDetails(transition, kind, attributes, out_insertion_index); |
547 } | 552 } |
548 } // namespace internal | 553 } // namespace internal |
549 } // namespace v8 | 554 } // namespace v8 |
OLD | NEW |