The allocator's crimes include:
* It uses OS SPI that must not be used by non-OS apps.
* It does not play well with memory debugging tools like Instruments.
* It does not return memory to the OS in response to memory pressure.
* It is less tested than we would like because many configurations
inadvertently turn it off (such as running from Xcode).
* Its per-thread magazine implementation does not actually work.
* Its "try alloc" flag is incompletely implemented and never used.
* Its "zero fill" flag is unimplemented and inconsistently used.
Swift SVN r20757
We were rounding the size up to the alignment when allocating a new object (swift_allocObject) but not when directly allocating memory for a non-object (swift_slowAlloc). The deallocation code wasn’t rounding the size up to the alignment at all. Overall, this meant that we would get the wrong index into the allocation cache when deallocating an object whose size got rounded in a way that affects the index.
Fixes <rdar://problem/17542859>, where println(5) would fail on the 32-bit iOS simulator when building the runtime without NDEBUG (so we get extra checking) and the standard library is built without optimization (which keeps a certain 33-byte allocation on the heap). The Interpreter/SDK/objc_cast.swift test triggers this when built under those conditions.
Swift SVN r19499
This double checks:
<rdar://problem/16979846> Array backing store is leaking
<rdar://problem/16989632> Array backing store sizing is still buggy
Swift SVN r18554
not an alignment value.
Assert that various entrypoints get an alignment mask.
Get everything uniformly passing an assertion about
dealloating an object with the correct allocation
size; don't actually enable the assertion yet, though.
rdar://16989632
Swift SVN r18550
I personally like ~(cast)0, but (cast)-1 felt more consistent with LLVM
style; and the waffling before finishing my coffee this morning made the
code wrong. Whoops.
Swift SVN r18221
Huge allocation leaks are detected correctly.
Tiny allocation leaks are problematic, both false positive and false negative.
For example:
leaks Report Version: 2.0
Process 73345: 4980 nodes malloced for 1677 KB
Process 73345: 1 leak for 1048576 total leaked bytes.
Leak: 0x10aed0000 size=1048576 zone: SwiftZone_0x10adc35d8
Swift SVN r18007
We need a custom but simple map table for two reasons:
1) To precisely control our allocations to avoid reentrancy via Instruments.
2) To prepare for out-of-process introspection via Mach VM calls.
This fixes: <rdar://problem/16718231> Swift allocator must not call malloc nor global operator new
Swift SVN r17769
Rather than go through reentrant and problematic contortions to make Swift
work with the existing Instruments hooks, they agreed to just patch some
globals that we provide to get their logic to be activated.
Swift SVN r17144
All of the malloc zone APIs are clumsy object-oriented design in C, but that
does not mean we should be too. This should clarify the design more too.
Swift SVN r15690