| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 result = Allocate(isolate, 1); | 57 result = Allocate(isolate, 1); |
| 58 result->NoIncrementalWriteBarrierSet(0, *name, *target); | 58 result->NoIncrementalWriteBarrierSet(0, *name, *target); |
| 59 } | 59 } |
| 60 result->set_back_pointer_storage(map->GetBackPointer()); | 60 result->set_back_pointer_storage(map->GetBackPointer()); |
| 61 return result; | 61 return result; |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 Handle<TransitionArray> TransitionArray::ExtendToFullTransitionArray( | 65 Handle<TransitionArray> TransitionArray::ExtendToFullTransitionArray( |
| 66 Handle<Map> containing_map) { | 66 Handle<Map> containing_map) { |
| 67 ASSERT(!containing_map->transitions()->IsFullTransitionArray()); | 67 DCHECK(!containing_map->transitions()->IsFullTransitionArray()); |
| 68 int nof = containing_map->transitions()->number_of_transitions(); | 68 int nof = containing_map->transitions()->number_of_transitions(); |
| 69 | 69 |
| 70 // A transition array may shrink during GC. | 70 // A transition array may shrink during GC. |
| 71 Handle<TransitionArray> result = Allocate(containing_map->GetIsolate(), nof); | 71 Handle<TransitionArray> result = Allocate(containing_map->GetIsolate(), nof); |
| 72 DisallowHeapAllocation no_gc; | 72 DisallowHeapAllocation no_gc; |
| 73 int new_nof = containing_map->transitions()->number_of_transitions(); | 73 int new_nof = containing_map->transitions()->number_of_transitions(); |
| 74 if (new_nof != nof) { | 74 if (new_nof != nof) { |
| 75 ASSERT(new_nof == 0); | 75 DCHECK(new_nof == 0); |
| 76 result->Shrink(ToKeyIndex(0)); | 76 result->Shrink(ToKeyIndex(0)); |
| 77 } else if (nof == 1) { | 77 } else if (nof == 1) { |
| 78 result->NoIncrementalWriteBarrierCopyFrom( | 78 result->NoIncrementalWriteBarrierCopyFrom( |
| 79 containing_map->transitions(), kSimpleTransitionIndex, 0); | 79 containing_map->transitions(), kSimpleTransitionIndex, 0); |
| 80 } | 80 } |
| 81 | 81 |
| 82 result->set_back_pointer_storage( | 82 result->set_back_pointer_storage( |
| 83 containing_map->transitions()->back_pointer_storage()); | 83 containing_map->transitions()->back_pointer_storage()); |
| 84 return result; | 84 return result; |
| 85 } | 85 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 int insertion_index = map->transitions()->Search(*name); |
| 100 if (insertion_index == kNotFound) ++new_size; | 100 if (insertion_index == kNotFound) ++new_size; |
| 101 | 101 |
| 102 Handle<TransitionArray> result = Allocate(map->GetIsolate(), new_size); | 102 Handle<TransitionArray> result = Allocate(map->GetIsolate(), new_size); |
| 103 | 103 |
| 104 // The map's transition array may grown smaller during the allocation above as | 104 // 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 | 105 // it was weakly traversed, though it is guaranteed not to disappear. Trim the |
| 106 // result copy if needed, and recompute variables. | 106 // result copy if needed, and recompute variables. |
| 107 ASSERT(map->HasTransitionArray()); | 107 DCHECK(map->HasTransitionArray()); |
| 108 DisallowHeapAllocation no_gc; | 108 DisallowHeapAllocation no_gc; |
| 109 TransitionArray* array = map->transitions(); | 109 TransitionArray* array = map->transitions(); |
| 110 if (array->number_of_transitions() != number_of_transitions) { | 110 if (array->number_of_transitions() != number_of_transitions) { |
| 111 ASSERT(array->number_of_transitions() < number_of_transitions); | 111 DCHECK(array->number_of_transitions() < number_of_transitions); |
| 112 | 112 |
| 113 number_of_transitions = array->number_of_transitions(); | 113 number_of_transitions = array->number_of_transitions(); |
| 114 new_size = number_of_transitions; | 114 new_size = number_of_transitions; |
| 115 | 115 |
| 116 insertion_index = array->Search(*name); | 116 insertion_index = array->Search(*name); |
| 117 if (insertion_index == kNotFound) ++new_size; | 117 if (insertion_index == kNotFound) ++new_size; |
| 118 | 118 |
| 119 result->Shrink(ToKeyIndex(new_size)); | 119 result->Shrink(ToKeyIndex(new_size)); |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 147 result->NoIncrementalWriteBarrierCopyFrom( | 147 result->NoIncrementalWriteBarrierCopyFrom( |
| 148 array, insertion_index, insertion_index + 1); | 148 array, insertion_index, insertion_index + 1); |
| 149 } | 149 } |
| 150 | 150 |
| 151 result->set_back_pointer_storage(array->back_pointer_storage()); | 151 result->set_back_pointer_storage(array->back_pointer_storage()); |
| 152 return result; | 152 return result; |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 } } // namespace v8::internal | 156 } } // namespace v8::internal |
| OLD | NEW |