Commit Graph

1059 Commits

Author SHA1 Message Date
Joe Groff
4caeb49449 Missed a heading.
Swift SVN r17733
2014-05-08 23:27:42 +00:00
Joe Groff
fa74bfc367 Add a proposal for the C pointer language model.
Swift SVN r17732
2014-05-08 23:26:26 +00:00
Dave Abrahams
47eea01ab8 [stdlib] Eager non-verbatim bridging
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
2014-05-08 23:02:08 +00:00
Dave Abrahams
dea14570b9 [stdlib] Array doc adjustment
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
2014-05-06 07:52:58 +00:00
Dave Abrahams
555674633a [stdlib] Array bridging specification tweaks
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
2014-05-05 17:52:58 +00:00
Michael Gottesman
1e7d7fb85f Revert "[stdlib] Array bridging specification tweaks"
This reverts commit r17408.

Swift SVN r17417
2014-05-05 04:05:36 +00:00
Dave Abrahams
a86aecd6fe [stdlib] Array bridging specification tweaks
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
2014-05-04 23:16:06 +00:00
Dave Abrahams
dd6b0f7144 [stdlib] More Array doc updates
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
2014-05-04 01:32:54 +00:00
Dave Abrahams
18d12fa234 [stdlib] One more note about Array casting
Swift SVN r17324
2014-05-03 19:51:52 +00:00
Dave Abrahams
5e045b4453 [stdlib] Limit array casts to Array<T>
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
2014-05-03 19:49:53 +00:00
Dave Abrahams
9cf3eefb8c [stdlib] Array bridging doc update
This thing is freakin' complicated!  We're going to have to find a
reasonable subset to implement for WWDC.

Swift SVN r17308
2014-05-03 03:53:55 +00:00
Dave Abrahams
2c0a803afe [docs] Updated information on Array casts
Swift SVN r17303
2014-05-03 02:07:14 +00:00
Dave Abrahams
a3bc9b6cb0 [stdlib] Array doc update
Swift SVN r17302
2014-05-03 02:07:14 +00:00
Dave Abrahams
98274bd5d3 [docs] Update Arrays.rst
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
2014-05-02 16:30:14 +00:00
Ted Kremenek
4e70269c53 More renaming 'unchecked optional' to 'implicitly unwrapped optional'.
Swift SVN r17236
2014-05-02 06:22:01 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
Dave Abrahams
8e2e7e9bfc [stdlib] Hide all BuiltinXXXConvertible's
During String API review we decided these weren't for user consumption.

Swift SVN r17167
2014-05-01 19:35:50 +00:00
Doug Gregor
ca62675c64 Rip out the parsing code for default values in patterns.
This code was already unused.


Swift SVN r17091
2014-04-30 13:59:44 +00:00
Dmitri Hrybenko
853b63e15c Update LangRef with commit message of r17056
Swift SVN r17081
2014-04-30 09:04:41 +00:00
Chris Lattner
a7012f23ef Remove swift::ArrayType. It is dead and vestigial code for supporting fixed size
arrays, which never got baked.  Remove it until we have time to do things right.


Swift SVN r16995
2014-04-28 21:18:27 +00:00
Ted Kremenek
6caf910d32 Implement new syntactic sugar for UncheckedOptional<T>.
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
2014-04-27 21:59:29 +00:00
Chris Lattner
f6bc393b52 this -> self.
Swift SVN r16932
2014-04-27 16:46:07 +00:00
Chris Lattner
88471c3455 update this for attribute and inout syntax change.
Swift SVN r16929
2014-04-27 16:24:26 +00:00
Ted Kremenek
5ad769ec0b Rename the BridgedToObjectiveC protocol to _BridgedToObjectiveC or _BridgedToObjC.
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
2014-04-27 06:07:25 +00:00
Dmitri Hrybenko
304c34ee17 Update LangRef for 'nonmutating'
Swift SVN r16895
2014-04-26 21:24:23 +00:00
Manman Ren
480b41c824 [SIL Vtable emission] use the least derived method in sil_vtable.
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
2014-04-25 23:42:12 +00:00
Dave Abrahams
64c7c5cf34 [docs] Array bridging diagram
Swift SVN r16779
2014-04-24 23:25:10 +00:00
Joe Groff
f29a156e83 IRGen/Runtime: Add value witness slots for array witnesses.
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
2014-04-24 22:25:26 +00:00
Joe Groff
4ea0a2839b SIL.rst: Document unchecked_addr_cast.
Swift SVN r16744
2014-04-24 04:59:56 +00:00
Joe Groff
68f942117a SIL: Squash 'ref_to_native_object' and 'native_object_to_ref' into one 'unchecked_ref_cast' insn.
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
2014-04-24 03:10:53 +00:00
Joe Groff
fe47ddb540 SIL.rst: Note that unchecked_take_enum_data_addr will not actually destroy the enum when applied to the first payloaded case.
At least not in 1.0.

Swift SVN r16735
2014-04-24 02:36:39 +00:00
Joe Groff
5db5acc8fc SIL.rst: Fix up and extend discussion of layout compatible types.
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
2014-04-24 02:36:37 +00:00
Joe Groff
7bc9bf95cf SIL.rst: Add a note about layout compatibility.
Start trying to formalize when reinterpretCast can actually mean something for the optimizer.

Swift SVN r16731
2014-04-24 01:07:34 +00:00
Joe Groff
285ec1e2dd SIL: Add an unchecked_enum_data instruction.
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
2014-04-24 00:41:08 +00:00
Joe Groff
55f6b925de SIL: Rename 'take_enum_data_addr' to 'unchecked_take_enum_data_addr'.
In preparation for adding an 'unchecked_enum_data' equivalent for loadable enums.

Swift SVN r16728
2014-04-24 00:40:47 +00:00
John McCall
b38a63950d Implement @unowned(unsafe).
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
2014-04-23 08:51:23 +00:00
Joe Groff
c56458d173 Quiet doc warnings.
Swift SVN r16631
2014-04-21 23:11:36 +00:00
Joe Groff
c73acc67f2 SIL: Add an "UnownedInnerPointer" result convention.
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
2014-04-21 21:57:13 +00:00
Dave Zarzycki
c48fd6160e Docs: Add notes about subtle runtime differences
This is useful as a reference for WWDC and forward.

Swift SVN r16625
2014-04-21 21:35:31 +00:00
Joe Groff
85ab7ed9e1 Remove mangling and demangling for block shims.
Swift SVN r16488
2014-04-18 02:36:54 +00:00
Joe Groff
eaa6088102 SIL: Remove the now-obsolete bridge_to_block instruction.
Swift SVN r16487
2014-04-18 02:26:10 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
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
2014-04-17 22:05:42 +00:00
Michael Gottesman
7f7e256f73 [SIL.rst] Begin filling out the section in SIL.rst describing the general optimization passes.
Swift SVN r16196
2014-04-11 02:59:38 +00:00
Dave Abrahams
06e720257e [stdlib] Array docs: use normal bullets
The funny bullets used by our stylesheet don't paste well into emails.
Also, clean up an editorial comment

Swift SVN r16185
2014-04-10 23:37:24 +00:00
Dave Abrahams
2da97e2736 [stdlib] Array docs: correctness fix
Optional<T>.map doesn't unwrap inner optionals, so have to rephrase.

Swift SVN r16184
2014-04-10 23:18:26 +00:00
Dave Abrahams
ecda8ab966 [stdlib] Array docs: typo fix
Swift SVN r16182
2014-04-10 23:13:15 +00:00
Dave Abrahams
38d73b2b96 [stdlib] Initial docs for the new Array design
Swift SVN r16181
2014-04-10 23:10:33 +00:00
Dmitri Hrybenko
f90e0c153b Make 'override' a keyword
rdar://16462192

Swift SVN r16115
2014-04-09 14:19:50 +00:00
Dmitri Hrybenko
a8f85d72bc Allow semicolon can be used as a single no-op statement in otherwise empty cases in
switch statements.

rdar://16381532


Swift SVN r16112
2014-04-09 10:40:48 +00:00
Joe Groff
e9d2e122ee SIL.rst: Document copy_block.
Swift SVN r16087
2014-04-09 00:37:24 +00:00