| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
| 10 #include "src/lookup-inl.h" | 10 #include "src/lookup-inl.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 if (IsElement()) { | 115 if (IsElement()) { |
| 116 ElementsKind old_kind = holder_map_->elements_kind(); | 116 ElementsKind old_kind = holder_map_->elements_kind(); |
| 117 holder_map_ = Map::PrepareForDataElement(holder_map_, value); | 117 holder_map_ = Map::PrepareForDataElement(holder_map_, value); |
| 118 ElementsKind new_kind = holder_map_->elements_kind(); | 118 ElementsKind new_kind = holder_map_->elements_kind(); |
| 119 if (new_kind != old_kind) { | 119 if (new_kind != old_kind) { |
| 120 // TODO(verwaest): Handle element migration in MigrateToMap. | 120 // TODO(verwaest): Handle element migration in MigrateToMap. |
| 121 JSObject::UpdateAllocationSite(holder, new_kind); | 121 JSObject::UpdateAllocationSite(holder, new_kind); |
| 122 if (IsFastDoubleElementsKind(old_kind) != | 122 if (IsFastDoubleElementsKind(old_kind) != |
| 123 IsFastDoubleElementsKind(new_kind)) { | 123 IsFastDoubleElementsKind(new_kind)) { |
| 124 Handle<FixedArrayBase> old_elements(holder->elements()); | 124 uint32_t capacity = holder->elements()->length(); |
| 125 int capacity = old_elements->length(); | |
| 126 Handle<FixedArrayBase> new_elements; | |
| 127 if (IsFastDoubleElementsKind(new_kind)) { | |
| 128 new_elements = factory()->NewFixedDoubleArray(capacity); | |
| 129 } else { | |
| 130 new_elements = factory()->NewFixedArray(capacity); | |
| 131 } | |
| 132 | |
| 133 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_kind); | 125 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_kind); |
| 134 accessor->CopyElements(holder, new_elements, old_kind); | 126 accessor->GrowCapacityAndConvert(holder, capacity); |
| 135 | 127 // GrowCapacityAndConvert migrated the object. No reloading of property |
| 136 JSObject::ValidateElements(holder); | |
| 137 JSObject::SetMapAndElements(holder, holder_map_, new_elements); | |
| 138 | |
| 139 if (FLAG_trace_elements_transitions) { | |
| 140 JSObject::PrintElementsTransition( | |
| 141 stdout, holder, old_kind, old_elements, new_kind, new_elements); | |
| 142 } | |
| 143 // SetMapAndElements above migrated the object. No reloading of property | |
| 144 // infomation is necessary for elements. | 128 // infomation is necessary for elements. |
| 145 return; | 129 return; |
| 146 } else if (FLAG_trace_elements_transitions) { | 130 } else if (FLAG_trace_elements_transitions) { |
| 147 Handle<FixedArrayBase> elements(holder->elements()); | 131 Handle<FixedArrayBase> elements(holder->elements()); |
| 148 JSObject::PrintElementsTransition(stdout, holder, old_kind, elements, | 132 JSObject::PrintElementsTransition(stdout, holder, old_kind, elements, |
| 149 new_kind, elements); | 133 new_kind, elements); |
| 150 } | 134 } |
| 151 } | 135 } |
| 152 | 136 |
| 153 // Copy the backing store if it is copy-on-write. | 137 // Copy the backing store if it is copy-on-write. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 case InterceptorState::kSkipNonMasking: | 482 case InterceptorState::kSkipNonMasking: |
| 499 return true; | 483 return true; |
| 500 case InterceptorState::kProcessNonMasking: | 484 case InterceptorState::kProcessNonMasking: |
| 501 return false; | 485 return false; |
| 502 } | 486 } |
| 503 } | 487 } |
| 504 return interceptor_state_ == InterceptorState::kProcessNonMasking; | 488 return interceptor_state_ == InterceptorState::kProcessNonMasking; |
| 505 } | 489 } |
| 506 } // namespace internal | 490 } // namespace internal |
| 507 } // namespace v8 | 491 } // namespace v8 |
| OLD | NEW |