| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 int number_of_transitions = map->transitions()->number_of_transitions(); | 125 int number_of_transitions = map->transitions()->number_of_transitions(); |
| 126 int new_size = number_of_transitions; | 126 int new_size = number_of_transitions; |
| 127 | 127 |
| 128 int insertion_index = map->transitions()->Search(*name); | 128 int insertion_index = map->transitions()->Search(*name); |
| 129 if (insertion_index == kNotFound) ++new_size; | 129 if (insertion_index == kNotFound) ++new_size; |
| 130 | 130 |
| 131 Handle<TransitionArray> result = | 131 Handle<TransitionArray> result = |
| 132 map->GetIsolate()->factory()->NewTransitionArray(new_size); | 132 map->GetIsolate()->factory()->NewTransitionArray(new_size); |
| 133 | 133 |
| 134 // The map's transition array may have disappeared or grown smaller during | 134 // The map's transition array may grown smaller during the allocation above as |
| 135 // the allocation above as it was weakly traversed. Trim the result copy if | 135 // it was weakly traversed, though it is guaranteed not to disappear. Trim the |
| 136 // needed, and recompute variables. | 136 // result copy if needed, and recompute variables. |
| 137 ASSERT(map->HasTransitionArray()); |
| 137 DisallowHeapAllocation no_gc; | 138 DisallowHeapAllocation no_gc; |
| 138 if (!map->HasTransitionArray()) { | |
| 139 if (flag == SIMPLE_TRANSITION) { | |
| 140 ASSERT(result->length() >= kSimpleTransitionSize); | |
| 141 result->Shrink(kSimpleTransitionSize); | |
| 142 result->set(kSimpleTransitionTarget, *target); | |
| 143 } else { | |
| 144 ASSERT(result->length() >= ToKeyIndex(1)); | |
| 145 result->Shrink(ToKeyIndex(1)); | |
| 146 result->set(kPrototypeTransitionsIndex, Smi::FromInt(0)); | |
| 147 result->NoIncrementalWriteBarrierSet(0, *name, *target); | |
| 148 } | |
| 149 result->set_back_pointer_storage(map->GetBackPointer()); | |
| 150 | |
| 151 return result; | |
| 152 } | |
| 153 | |
| 154 TransitionArray* array = map->transitions(); | 139 TransitionArray* array = map->transitions(); |
| 155 if (array->number_of_transitions() != number_of_transitions) { | 140 if (array->number_of_transitions() != number_of_transitions) { |
| 156 ASSERT(array->number_of_transitions() < number_of_transitions); | 141 ASSERT(array->number_of_transitions() < number_of_transitions); |
| 157 | 142 |
| 158 number_of_transitions = array->number_of_transitions(); | 143 number_of_transitions = array->number_of_transitions(); |
| 159 new_size = number_of_transitions; | 144 new_size = number_of_transitions; |
| 160 | 145 |
| 161 insertion_index = array->Search(*name); | 146 insertion_index = array->Search(*name); |
| 162 if (insertion_index == kNotFound) ++new_size; | 147 if (insertion_index == kNotFound) ++new_size; |
| 163 | 148 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 192 result->NoIncrementalWriteBarrierCopyFrom( | 177 result->NoIncrementalWriteBarrierCopyFrom( |
| 193 array, insertion_index, insertion_index + 1); | 178 array, insertion_index, insertion_index + 1); |
| 194 } | 179 } |
| 195 | 180 |
| 196 result->set_back_pointer_storage(array->back_pointer_storage()); | 181 result->set_back_pointer_storage(array->back_pointer_storage()); |
| 197 return result; | 182 return result; |
| 198 } | 183 } |
| 199 | 184 |
| 200 | 185 |
| 201 } } // namespace v8::internal | 186 } } // namespace v8::internal |
| OLD | NEW |