Commit the platform definition and build script work necessary to
cross-compile for arm64_32.
arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
Use the new builtins for COW representation in Array, ContiguousArray and ArraySlice.
The basic idea is to strictly separate code which mutates an array buffer from code which reads from an array.
The concept is explained in more detail in docs/SIL.rst, section "Copy-on-Write Representation".
The main change is to use beginCOWMutation() instead of isUniquelyReferenced() and insert endCOWMutation() at the end of all mutating functions. Also, reading from the array buffer must be done differently, depending on if the buffer is in a mutable or immutable state.
All the required invariants are enforced by runtime checks - but only in an assert-build of the library: a bit in the buffer object side-table indicates if the buffer is mutable or not.
Along with the library changes, also two optimizations needed to be updated: COWArrayOpt and ObjectOutliner.
- Make internal (but @inlinable)
- Limit API to what is actually supported: a single boolean value.
- Rename members:
init(native:,bits:) ⟹ init(native:,isFlagged:)
func isNativeWithClearedSpareBits() ⟹ isUnflaggedNative
var nativeInstance_noSpareBits ⟹ unflaggedNativeInstance
func isUniquelyReferenced_native_noSpareBits() ⟹ isUniquelyReferencedUnflaggedNative()
Previously we had a single mask for all x86-64 targets which included both the top and bottom bits. This accommodated simulators, which use the top bit, while macOS uses the bottom bit, but reserved one bit more than necessary on each. This change breaks out x86-64 simulators from non-simulators and reserves only the one bit used on each.
rdar://problem/34805348 rdar://problem/29765919
* Reduce array abstraction on apple platforms dealing with literals
Part of the ongoing quest to reduce swift array literal abstraction
penalties: make the SIL optimizer able to eliminate bridging overhead
when dealing with array literals.
Introduce a new classify_bridge_object SIL instruction to handle the
logic of extracting platform specific bits from a Builtin.BridgeObject
value that indicate whether it contains a ObjC tagged pointer object,
or a normal ObjC object. This allows the SIL optimizer to eliminate
these, which allows constant folding a ton of code. On the example
added to test/SILOptimizer/static_arrays.swift, this results in 4x
less SIL code, and also leads to a lot more commonality between linux
and apple platform codegen when passing an array literal.
This also introduces a couple of SIL combines for patterns that occur
in the array literal passing case.
Piggybacks some resilience diagnostics onto the availability
checking code.
Public and versioned functions with inlineable bodies can only
reference other public and internal entities, since the SIL code
for the function body is serialized and stored as part of the
module.
This includes @_transparent functions, @_inlineable functions,
accessors for @_inlineable storage, @inline(__always) functions,
and in Swift 4 mode, default argument expressions.
The new checks are a source-breaking change, however we don't
guarantee source compatibility for underscored attributes.
The new ABI and tests for the default argument model will come in
subsequent commits.
This is a staging attribute that will eventually mean "fixed-contents"
for structs and "closed" for enums, as described in
docs/LibraryEvolution.rst.
This is pretty much the minimal set of types that must be fixed-layout,
because SILGen makes assumptions about their lowering.
If desired, some SILGen refactoring can allow some of these to be
resilient. For example, bridging value types could be made to work
with resilient types.
Currently they do nothing but allow stdlib code to use regular (Bool)
types. However, soon the wrappers for the _native variants will
provide point-of-use sanity checking.
These need to be fully generic to support class protocols and
single-payload enums (not just for optional). It also avoids a massive
amount of overloading for all the reference type variations
(AnyObject, Native, Unknown, Bridge) x 2 for optional versions of
each.
Because the wrapper is generic, type checking had to be deferred until
IRGen. Generating code for the wrapper itself will result in an
IRGen-time type error. They need to be transparent anyway for proper
diagnostics, but also must be internal.
Note that the similar external API type checks ok because it
forces conformance to AnyObject.
The sanity checks are disabled because our current facilities for
unsafe type casting are incomplete and unsound. SILCombine can
remove UnsafeMutablePointer and RawPointer casts by assuming layout
compatibility. IRGen will later discover layout incompatibility and
generate a trap.
I'll send out a proposal for improving the casting situation so we can
get the sanity checks back.
Swift SVN r28057
This reverts commit 64e9f11211a19fa603f5bc2d2bea171a9b07d3fa.
I think this is breaking ExistentialCollection test in the
Release + stdlib asserts build.
Swift SVN r27947
The wrappers for the _native variants provide point-of-use sanity checking.
They also allows stdlib code to use regular (Bool) types.
These need to be fully generic to support class protocols. It also
avoids a massive amount of overloading for all the reference type
variations (AnyObject, Native, Unknown, Bridge) x 2 for optional
versions of each.
Because the wrapper is generic, type checking had to be deferred until
IRGen. Generating code for the wrapper itself will result in an
IRGen-time type error. They need to be transparent anyway for proper
diagnostics, but also must be internal.
The external API passes type checks because it forces conformance to AnyObject.
Swift SVN r27930
Fixes <rdar://problem/18151694> Add Builtin.checkUnique to avoid lost Array copies
The isUniquelyReference APIs are now correct in the presence of full
inlining and ARC optimization. The ARC optimizer can't see into the
Builtin, which lowers to a special SIL instruction.
Swift SVN r27929
Changes compared to the original version:
I fixed the 2 bugs and added a test for the so far undetected missing range check bug.
To keep the SIL simple (4 basic blocks for arr[x]) I extracted the slow path for getElement into a
non-inlinable function.
On the other hand I inlined _typeCheck into the slow-path function.
This speeds up NSArray accesses because now only a single objectAtIndex is required for both
type checking and element retrieving.
Update on performance: DeltaBlue is now only 12% better (and not 25%). I suspect this is because
now Arnold's tail duplication cannot detect the ObjC call in the slow path.
Swift SVN r26935
Now that we can check isNative and NoDTC (no deffered type check needed) with a single bit-mask operation,
it makes sense to have a single array property call for it.
I replaced the the semantics call array.props.needsElementTypeCheck with array.props.isNativeNoDTC,
which is the combination of isNative && !needsElementTypeCheck. I kept array.props.isNative, which is not used for now,
but might be useful in the future, e.g. for array operations which don't care about type checks.
The optimized SIL for a class array access arr[i] now contains the minimum of 4 basic blocks.
PerfTests show +25% for DeltaBlue and some improvemements for -Onone.
Swift SVN r26871
The standard library has grown significantly, and we need a new
directory structure that clearly reflects the role of the APIs, and
allows future growth.
See stdlib/{public,internal,private}/README.txt for more information.
Swift SVN r25876