Trying to lazily compute bridge results and cache them isn't going to
work, because there's no place to efficiently invalidate the cache in
cases like this:
func f(a: NSArray) {
for i in 0...a.count {
println(a.objectAtIndex(i)) // Fills up the cache
}
}
var message = ["hello", "world"]
f(message)
message[0] = "goodbye, cruel" // need a cache invalidation or else
f(message) // ...this prints "hello\nworld\n"
Since we need C performance for subscript assignment, we just can't
afford to do anything extra there.
Instead, when the element type isn't "Bridged Verbatim," just eagerly
convert it to an NSArray.
Swift SVN r17722
We were wishfully thinking that we could convert all NSArrays lazily.
However, since non-class/existential types are supposed to have a
statically-knowable efficient representation we need an eager conversion
in those cases.
Swift SVN r17538
Chris suggested that we should lazily typecheck each element when an
NSArray is downcast to Array<T>. That sounded like a good idea, and
along the way we decided to simplify the implementation and spec by not
bending over backwards to allow broken duck-typing to work for pure ObjC
classes.
Swift SVN r17468
Chris suggested that we should lazily typecheck each element when an
NSArray is downcast to Array<T>. That sounded like a good idea, and
along the way we decided to simplify the implementation and spec by not
bending over backwards to allow broken duck-typing to work for pure ObjC
classes.
Swift SVN r17408
There's little point in allowing Array<T> to have both direct and
indirect representations when T can be a class type. Let's drop the
branch cost and generate less code.
Swift SVN r17353
There's no need to support up- or down-casts for NativeArray<T> or
Slice<T>. Slice might turn out to be easy, but we don't have time right
now. Doing it for NativeArray<T> would have efficiency costs that we
don't want to pay.
Swift SVN r17323
This is a partial update. We need to decide how to rework array
up-/down-casting to account for value semantics changes. Will post to
the list.
Swift SVN r17254
This leaves in the existing syntax for @unchecked T?. That will
be addressed in later patches.
There's still a mysterious case where some of the SIL output
includes UncheckedOptional<T> and some places T!.
Moreover, this doesn't handle SourceKit's behavior for printing
for overrides. This just handles parsing the 'T!' syntax.
Swift SVN r16945
For now we're going to keep BridgedToObjectiveC as a private internal
implementation detail. Adding the "_" prefix marks it as internal.
Implements <rdar://problem/16736672>.
Swift SVN r16921
Given base class A and dervied class B, both with member functions f(),
to look for A.f in B's vtable, we should return SILFunction for B.f.
Before this commit, B's vtable will have entry for B.f, A's vtable will
have entry for A.f. When looking for A.f in B's vtable, it returns null.
And devirtualizer will look for A.f in A's vtable and resolve it to
SILFunction for A.f.
When replacing a class_method %1 : $A, #A.f!1 with a function ref to B.f,
we will have type checking issues for the apply instructions. So devirtualizer
will replace the argument of the apply instructions when necessary.
rdar://16681983
Swift SVN r16854
Add value witnesses for destroyArray, initializeArrayWithCopy, and initializeArrayWithTake{FrontToBack,BackToFront}, and fill out the runtime value witness table implementations. Stub out the IRGen ones for now.
Swift SVN r16772
An unsafe cast from a base to a derived class isn't really all that different from one from Builtin.NativeObject to an arbitrary class, so relax this pair of instructions to allow an arbitrary bitcast. This only combines the instructions; it doesn't attempt to simplify any codegen that was emitting round-trip casts before yet.
Swift SVN r16736
Got the sense of 'layout compatible' reversed for enum payloads, and mixed up "commutative" and "transitive". Add rules to cover RawPointer <-> Word, heap object references, and single-field structs.
Swift SVN r16734
This allows the payload for a loadable enum to be unsafely projected without branching, enabling more enum optimizations when switch branches can be culled or when indirect enum code can be promoted.
Swift SVN r16729
This was part of the original weak design that
there was never any particular reason to rush the
implementation for. It's convenient to do this now
so that we can use it to implement Unmanaged<T> for
importing CF types.
Swift SVN r16693
This will represent the return convention of imported __attribute__((objc_returns_inner_pointer)) methods. Leave it unimplemented for now until we can autorelease things sanely.
Swift SVN r16628
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.
Using this mechanism we implement assertions that can be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).
In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.
Example
Assert.swift:
@transparent
func assert<T : LogicValue>(
condition: @auto_closure () -> T, message: StaticString = StaticString(),
// Do not supply these parameters explicitly; they will be filled in
// by the compiler and aren't even present when asserts are disabled
file: StaticString = __FILE__, line: UWord = __LINE__
) {
// Only in debug mode.
if _isDebug() {
assert(condition().getLogicValue(), message, file, line)
}
}
AssertCommon.swift:
@transparent
func _isDebug() -> Bool {
return Int32(Builtin.assert_configuration()) == 0;
}
rdar://16458612
Swift SVN r16472