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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 8113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8124 } | 8124 } |
8125 | 8125 |
8126 | 8126 |
8127 void JSArray::set_length(Smi* length) { | 8127 void JSArray::set_length(Smi* length) { |
8128 // Don't need a write barrier for a Smi. | 8128 // Don't need a write barrier for a Smi. |
8129 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); | 8129 set_length(static_cast<Object*>(length), SKIP_WRITE_BARRIER); |
8130 } | 8130 } |
8131 | 8131 |
8132 | 8132 |
8133 bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) { | 8133 bool JSArray::SetLengthWouldNormalize(Heap* heap, uint32_t new_length) { |
| 8134 // This constant is somewhat arbitrary. Any large enough value would work. |
| 8135 const uint32_t kMaxFastArrayLength = 32 * 1024 * 1024; |
8134 // If the new array won't fit in a some non-trivial fraction of the max old | 8136 // If the new array won't fit in a some non-trivial fraction of the max old |
8135 // space size, then force it to go dictionary mode. | 8137 // space size, then force it to go dictionary mode. |
8136 uint32_t max_fast_array_size = | 8138 uint32_t heap_based_upper_bound = |
8137 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); | 8139 static_cast<uint32_t>((heap->MaxOldGenerationSize() / kDoubleSize) / 4); |
8138 return new_length >= max_fast_array_size; | 8140 return new_length >= Min(kMaxFastArrayLength, heap_based_upper_bound); |
8139 } | 8141 } |
8140 | 8142 |
8141 | 8143 |
8142 bool JSArray::AllowsSetLength() { | 8144 bool JSArray::AllowsSetLength() { |
8143 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); | 8145 bool result = elements()->IsFixedArray() || elements()->IsFixedDoubleArray(); |
8144 DCHECK(result == !HasFixedTypedArrayElements()); | 8146 DCHECK(result == !HasFixedTypedArrayElements()); |
8145 return result; | 8147 return result; |
8146 } | 8148 } |
8147 | 8149 |
8148 | 8150 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8442 #undef WRITE_INT64_FIELD | 8444 #undef WRITE_INT64_FIELD |
8443 #undef READ_BYTE_FIELD | 8445 #undef READ_BYTE_FIELD |
8444 #undef WRITE_BYTE_FIELD | 8446 #undef WRITE_BYTE_FIELD |
8445 #undef NOBARRIER_READ_BYTE_FIELD | 8447 #undef NOBARRIER_READ_BYTE_FIELD |
8446 #undef NOBARRIER_WRITE_BYTE_FIELD | 8448 #undef NOBARRIER_WRITE_BYTE_FIELD |
8447 | 8449 |
8448 } // namespace internal | 8450 } // namespace internal |
8449 } // namespace v8 | 8451 } // namespace v8 |
8450 | 8452 |
8451 #endif // V8_OBJECTS_INL_H_ | 8453 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |