Loading...
--- dyld/dyld-1340/common/Array.h
+++ dyld/dyld-1162/common/Array.h
@@ -25,8 +25,6 @@
#define Array_h
#include <algorithm>
-#include <span>
-
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
@@ -36,9 +34,7 @@
#if !TARGET_OS_EXCLAVEKIT
#include <mach/mach.h>
#endif
-
#include "Allocator.h"
-#include "StringUtils.h"
namespace dyld3 {
@@ -70,10 +66,8 @@
void pop_back() { assert(_usedCount > 0); _usedCount--; }
T* begin() { return &_elements[0]; }
T* end() { return &_elements[_usedCount]; }
- T* data() { return &_elements[0]; }
const T* begin() const { return &_elements[0]; }
const T* end() const { return &_elements[_usedCount]; }
- const T* data() const { return &_elements[0]; }
const Array<T> subArray(uint64_t start, uint64_t size) const { assert(start+size <= _usedCount);
return Array<T>(&_elements[start], size, size); }
bool contains(const T& targ) const { for (const T& a : *this) { if ( a == targ ) return true; } return false; }
@@ -141,12 +135,6 @@
this->_usedCount = n;
}
- T& operator[](uint64_t idx) {
- if ( idx >= this->_usedCount )
- resize(idx + 1);
- return this->_elements[idx];
- }
-
protected:
void growTo(uint64_t n);
void verifySpace(uint64_t n) { if (this->_usedCount+n > this->_allocCount) growTo(this->_usedCount + n); }
@@ -171,26 +159,18 @@
// MAXCOUNT is not specified, keep doubling size
_overflowBufferSize = round_page(std::max(this->_allocCount * 2, n) * sizeof(T));
}
-#if !DYLD_FEATURE_EMBEDDED_PAGE_ALLOCATOR
+#if !TARGET_OS_EXCLAVEKIT
int kr = ::vm_allocate(mach_task_self(), (vm_address_t*)&_overflowBuffer, (vm_size_t)_overflowBufferSize, VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_DYLD));
#else
_overflowBuffer = lsl::MemoryManager::allocate_pages(_overflowBufferSize);
int kr = 0;
#endif
if (kr != 0) {
-#if !TARGET_OS_EXCLAVEKIT
+#if BUILDING_LIBDYLD && !TARGET_OS_EXCLAVEKIT
+ //FIXME We should figure out a way to do this in dyld
char crashString[256];
-#if BUILDING_DYLD
- // snprintf in dyld uses _simple_salloc, which calls vm_allocate
- strlcpy(crashString, "OverflowSafeArray failed to allocate 0x", sizeof(crashString));
- appendHexToString(crashString, (uint64_t)_overflowBufferSize, sizeof(crashString));
- strlcat(crashString, " bytes, vm_allocate returned: 0x", sizeof(crashString));
- appendHexToString(crashString, kr, sizeof(crashString));
- strlcat(crashString, "\n", sizeof(crashString));
-#else
snprintf(crashString, sizeof(crashString), "OverflowSafeArray failed to allocate %llu bytes, vm_allocate returned: %d\n",
(uint64_t)_overflowBufferSize, kr);
-#endif
CRSetCrashLogMessage(crashString);
#endif
assert(0);
@@ -211,7 +191,7 @@
this->_allocCount = _overflowBufferSize / sizeof(T);
if ( oldBuffer != 0 )
-#if !DYLD_FEATURE_EMBEDDED_PAGE_ALLOCATOR
+#if !TARGET_OS_EXCLAVEKIT
::vm_deallocate(mach_task_self(), (vm_address_t)oldBuffer, (vm_size_t)oldBufferSize);
#else
lsl::MemoryManager::deallocate_pages(oldBuffer, oldBufferSize);
@@ -235,7 +215,7 @@
clear();
if ( _overflowBuffer != 0 )
-#if !DYLD_FEATURE_EMBEDDED_PAGE_ALLOCATOR
+#if !TARGET_OS_EXCLAVEKIT
::vm_deallocate(mach_task_self(), (vm_address_t)_overflowBuffer, (vm_size_t)_overflowBufferSize);
#else
lsl::MemoryManager::deallocate_pages(_overflowBuffer, _overflowBufferSize);
@@ -250,7 +230,7 @@
// Free our buffer if we have one
if ( _overflowBuffer != 0 )
-#if !DYLD_FEATURE_EMBEDDED_PAGE_ALLOCATOR
+#if !TARGET_OS_EXCLAVEKIT
vm_deallocate(mach_task_self(), (vm_address_t)_overflowBuffer, (vm_size_t)_overflowBufferSize);
#else
lsl::MemoryManager::deallocate_pages(_overflowBuffer, _overflowBufferSize);