| 216 | void *builtin_das_aligned_alloc16(uint64_t size); |
| 217 | |
| 218 | __forceinline void array_grow ( Context & context, Array & arr, uint32_t stride, LineInfo * at ) { |
| 219 | if ( arr.isLocked() ) context.throw_error_at(at, "can't resize locked array"); |
| 220 | uint64_t newSize = arr.size + 1; |
| 221 | // Keep the int64 surface contract (long_length returns int64) — refuse to grow past INT64_MAX. |
| 222 | if ( newSize > uint64_t(INT64_MAX) ) { |
| 223 | context.throw_error_at(at, "array_grow: newSize exceeds INT64_MAX [newSize=%llu]", (unsigned long long)newSize); |
| 224 | } |
| 225 | if ( newSize > arr.capacity ) { |
| 226 | uint64_t newCapacity = uint64_t(1) << (64 - das_clz64(das::max(newSize, uint64_t(2)) - 1)); |
| 227 | newCapacity = das::max(newCapacity, uint64_t(16)); |
| 228 | // The pow2 round-up overflows past INT64_MAX when newSize > 2^62; clamp so the |
| 229 | // resulting capacity stays representable in the int64 long_capacity() surface. |
| 230 | if ( newCapacity > uint64_t(INT64_MAX) ) newCapacity = uint64_t(INT64_MAX); |
| 231 | array_reserve(context, arr, newCapacity, stride, at); |
| 232 | } |
| 233 | arr.size = newSize; |
| 234 | } |
| 235 | |
| 236 | __forceinline int64_t builtin_array_push ( Array & pArray, int64_t index, int stride, Context * context, LineInfoArg * at ) { |
| 237 | uint64_t idx = pArray.size; |
no test coverage detected